Skip to content

Commit

Permalink
Script to populate the webhook_id in Bamboohr (#141)
Browse files Browse the repository at this point in the history
* Script to populate the webhook_id in Bamboohr

* resolved comment
  • Loading branch information
Ashutosh619-sudo authored Jan 17, 2024
1 parent 2a1740c commit 3999dbb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/python/create-webhook-bamboohr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from apps.bamboohr.models import BambooHr
from bamboosdk.bamboohrsdk import BambooHrSDK
from admin_settings.settings import API_URL

all_bamboohr = BambooHr.objects.filter(api_token__isnull=False, sub_domain__isnull=False)

for bamboohr in all_bamboohr:

try :
bamboohrsdk = BambooHrSDK(api_token=bamboohr.api_token, sub_domain=bamboohr.sub_domain)

webhook_payload = {
'postFields': {
'firstName': 'firstName',
'lastName': 'lastName',
'department': 'department',
'workEmail': 'workEmail',
'status': 'status',
'reportingTo': 'reportingTo'
},
'name': bamboohr.org.name,
'monitorFields': ['firstName', 'lastName', 'department', 'workEmail', 'status', 'reportingTo'],
'url': API_URL + f'/orgs/{bamboohr.org.id}/bamboohr/webhook_callback/',
'format': 'json'
}

response = bamboohrsdk.webhook.post(payload=webhook_payload)
BambooHr.objects.filter(id=bamboohr.id).update(webhook_id=int(response['id']))

except Exception as e:
print(f'For org_id {bamboohr.org.id} error occured', e)

0 comments on commit 3999dbb

Please sign in to comment.