Created
April 20, 2022 13:52
-
-
Save emihir0/a9dc7134a9e1b1f38d48ccadc0eceb11 to your computer and use it in GitHub Desktop.
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
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