Skip to content
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

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/bamboohr/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.urls import path

from .views import PostFolder, PostPackage, BambooHrConnection, BambooHrView, BambooHrConfigurationView, \
DisconnectView, SyncEmployeesView
DisconnectView, SyncEmployeesView, BambooHrReadyView

app_name = 'bamboohr'

urlpatterns = [
path('ready/', BambooHrReadyView.as_view(), name='ready'),
path('', BambooHrView.as_view(), name='bamboohr'),
path('packages/', PostPackage.as_view(), name='package'),
path('folder/', PostFolder.as_view(), name='folder'),
Expand Down
30 changes: 30 additions & 0 deletions apps/bamboohr/views.py
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
Expand All @@ -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):
Copy link
Contributor

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


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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix this @Ashutosh619-sudo

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

403 will be good here
cc @ashwin1111

)
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
Expand Down
Loading