-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ready View for making sure bamboohr Creds are valid #119
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import logging | ||
from bamboosdk.bamboohrsdk import BambooHrSDK | ||
|
||
from rest_framework.response import Response | ||
from rest_framework.views import status | ||
|
@@ -12,9 +13,38 @@ | |
from apps.bamboohr.actions import disconnect_bamboohr, sync_employees | ||
from apps.names import BAMBOO_HR | ||
|
||
from rest_framework.views import APIView | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.level = logging.INFO | ||
|
||
class BambooHrReadyView(generics.ListAPIView): | ||
|
||
def get(self, request, *args, **kwargs): | ||
try: | ||
# bamboohr = BambooHr.objects.get(org_id__in=[kwargs['org_id']]) | ||
bamboohrsdk = BambooHrSDK(api_token='864acbfb14b38f974439af49ec95bc02e52a45b9', sub_domain='baba') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fix this @Ashutosh619-sudo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are |
||
response = bamboohrsdk.time_off.get() | ||
|
||
if response['timeOffTypes']: | ||
return Response( | ||
data = { | ||
'message': 'Ready' | ||
}, | ||
status=status.HTTP_200_OK | ||
) | ||
else: | ||
return Response( | ||
data = { | ||
'message': 'Invalid token' | ||
}, | ||
status=status.HTTP_400_BAD_REQUEST | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 403 will be good here |
||
) | ||
except BambooHr.DoesNotExist: | ||
return Response( | ||
data={'message': 'Bamboo HR Details Not Found'}, | ||
status=status.HTTP_404_NOT_FOUND | ||
) | ||
|
||
class BambooHrView(generics.ListAPIView): | ||
serializer_class = BambooHrSerializer | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change class name similar to url