Skip to content

Instantly share code, notes, and snippets.

@emihir0
Created April 20, 2022 13:52
Show Gist options
  • Save emihir0/a9dc7134a9e1b1f38d48ccadc0eceb11 to your computer and use it in GitHub Desktop.
Save emihir0/a9dc7134a9e1b1f38d48ccadc0eceb11 to your computer and use it in GitHub Desktop.
import requests
class GiritonApi:
TOKEN = 'xxx'
URL = 'https://rest.giriton.com/system/api/'
ENDPOINT_EMPLOYEES_LIST = 'hr/usersEmployedOn'
ENDPOINT_EMPLOYEE = 'hr/userEmployedOn'
@property
def headers(self):
return {'Content-Type': 'application/json', 'giriton-TOKEN': self.TOKEN}
def _construct_url(self, endpoint):
return f'{self.URL}{endpoint}'
def get(self, endpoint):
url = self._construct_url(endpoint)
return requests.get(url, headers=self.headers)
def post(self, endpoint, data):
url = self._construct_url(endpoint)
return requests.post(url, json=data, headers=self.headers)
def get_employees_list(self):
response = self.get(self.ENDPOINT_EMPLOYEES_LIST)
return response.json()
def update_employee(self, employee_id, data):
response = self.post(self.ENDPOINT_EMPLOYEE, data={'number': f'{employee_id}', **data})
return response
api = GiritonApi()
api.update_employee(201, data={'presenceCardIds': ['987654321654987', '654321']})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment