-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "API view added for refreshing employees from BambooHR (#120)"
This reverts commit 82a01d6.
- Loading branch information
1 parent
a17a0be
commit 96b4105
Showing
9 changed files
with
47 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,13 @@ | ||
|
||
from django.db.models.signals import pre_save, post_save, pre_delete | ||
from django.db.models.signals import pre_save | ||
from django.dispatch import receiver | ||
from admin_settings.settings import API_URL | ||
|
||
from workato import Workato | ||
|
||
from bamboosdk.bamboohrsdk import BambooHrSDK | ||
from apps.bamboohr.models import BambooHrConfiguration, BambooHr | ||
from apps.bamboohr.models import BambooHrConfiguration | ||
from apps.orgs.models import Org | ||
|
||
@receiver(pre_save, sender=BambooHrConfiguration) | ||
def run_pre_save_configuration_triggers(sender, instance: BambooHrConfiguration, **kwargs): | ||
connector = Workato() | ||
org = Org.objects.get(id=instance.org_id) | ||
connector.recipes.post(org.managed_user_id, instance.recipe_id, None, 'stop') | ||
|
||
|
||
@receiver(post_save, sender=BambooHr) | ||
def run_post_save_bamboohr_triggers(sender, instance: BambooHr, **kwargs): | ||
|
||
bamboohrsdk = BambooHrSDK(api_token=instance.api_token, sub_domain=instance.sub_domain) | ||
|
||
webhook_payload = { | ||
'postFields': { | ||
'firstName': 'firstName', | ||
'lastName': 'lastName', | ||
'department': 'department', | ||
'workEmail': 'workEmail', | ||
'status': 'status' | ||
}, | ||
'name': instance.org.name, | ||
'monitorFields': ['firstName', 'lastName', 'department', 'workEmail', 'status'], | ||
'url': API_URL + f'/orgs/{instance.org.id}/bamboohr/webhook_callback/', | ||
'format': 'json' | ||
} | ||
|
||
response = bamboohrsdk.webhook.post(payload=webhook_payload) | ||
BambooHr.objects.filter(id=instance.id).update(webhook_id=int(response['id'])) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters