brynq-sdk-factorial 2.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. brynq_sdk_factorial/__init__.py +60 -0
  2. brynq_sdk_factorial/companies.py +76 -0
  3. brynq_sdk_factorial/compensations.py +80 -0
  4. brynq_sdk_factorial/contracts.py +50 -0
  5. brynq_sdk_factorial/costcenter.py +80 -0
  6. brynq_sdk_factorial/custom_fields.py +76 -0
  7. brynq_sdk_factorial/employees.py +57 -0
  8. brynq_sdk_factorial/family_situation.py +50 -0
  9. brynq_sdk_factorial/files.py +22 -0
  10. brynq_sdk_factorial/locations.py +49 -0
  11. brynq_sdk_factorial/payroll.py +54 -0
  12. brynq_sdk_factorial/schemas/attendance_schemas.py +264 -0
  13. brynq_sdk_factorial/schemas/banking_schemas.py +87 -0
  14. brynq_sdk_factorial/schemas/companies_schemas.py +29 -0
  15. brynq_sdk_factorial/schemas/contracts_schemas.py +395 -0
  16. brynq_sdk_factorial/schemas/documents_schemas.py +95 -0
  17. brynq_sdk_factorial/schemas/employee_updates_schemas.py +300 -0
  18. brynq_sdk_factorial/schemas/employees_schemas.py +187 -0
  19. brynq_sdk_factorial/schemas/expenses_schemas.py +144 -0
  20. brynq_sdk_factorial/schemas/family_situation.py +33 -0
  21. brynq_sdk_factorial/schemas/finance_schemas.py +433 -0
  22. brynq_sdk_factorial/schemas/holidays_schemas.py +21 -0
  23. brynq_sdk_factorial/schemas/job_catalog_schemas.py +35 -0
  24. brynq_sdk_factorial/schemas/locations_schemas.py +85 -0
  25. brynq_sdk_factorial/schemas/payroll_employees_schemas.py +33 -0
  26. brynq_sdk_factorial/schemas/payroll_integrations_base_schemas.py +27 -0
  27. brynq_sdk_factorial/schemas/payroll_schemas.py +92 -0
  28. brynq_sdk_factorial/schemas/project_management_schemas.py +192 -0
  29. brynq_sdk_factorial/schemas/shift_management_schemas.py +40 -0
  30. brynq_sdk_factorial/schemas/teams_schemas.py +57 -0
  31. brynq_sdk_factorial/schemas/time_planning_schemas.py +28 -0
  32. brynq_sdk_factorial/schemas/time_settings_schemas.py +29 -0
  33. brynq_sdk_factorial/schemas/timeoff_schemas.py +386 -0
  34. brynq_sdk_factorial/schemas/trainings_schemas.py +215 -0
  35. brynq_sdk_factorial/schemas/work_schedule_schemas.py +82 -0
  36. brynq_sdk_factorial/teams.py +76 -0
  37. brynq_sdk_factorial/workschedules.py +50 -0
  38. brynq_sdk_factorial-2.3.0.dist-info/METADATA +17 -0
  39. brynq_sdk_factorial-2.3.0.dist-info/RECORD +41 -0
  40. brynq_sdk_factorial-2.3.0.dist-info/WHEEL +5 -0
  41. brynq_sdk_factorial-2.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,60 @@
1
+ import requests
2
+ from typing import List, Union, Optional, Literal
3
+ from brynq_sdk_brynq import BrynQ
4
+ from .compensations import Compensations
5
+ from .employees import Employees
6
+ from .companies import Companies
7
+ from .contracts import Contracts
8
+ from .files import Files
9
+ from .costcenter import Costcenter
10
+ from .locations import Locations
11
+ from .payroll import Payroll
12
+ from .teams import Teams
13
+ from .workschedules import Workschedules
14
+ from .family_situation import FamilySituation
15
+
16
+ # Set the base class for Factorial. This class will be used to set the credentials and those will be used in all other classes.
17
+ class Factorial(BrynQ):
18
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug: bool = False, demo: bool = False):
19
+ """"
20
+ For the documentation of Factorial, see: https://apidoc.factorialhr.com/docs/authentication-1
21
+ """
22
+ super().__init__()
23
+ self.timeout = 3600
24
+ if demo:
25
+ self.base_url = 'https://api.demo.factorial.dev/api/2025-07-01/'
26
+ self.base_url_v1 = 'https://api.demo.factorial.dev/api/v1/'
27
+ else:
28
+ self.base_url = 'https://api.factorialhr.com/api/2025-07-01/'
29
+ self.base_url_v1 = 'https://api.factorialhr.com/api/v1/'
30
+ headers = self._get_credentials(system_type)
31
+ self.session = requests.Session()
32
+ self.session.headers.update(headers)
33
+ self.employees = Employees(self)
34
+ self.contracts = Contracts(self)
35
+ self.companies = Companies(self)
36
+ self.costcenter = Costcenter(self)
37
+ self.compensations = Compensations(self)
38
+ self.team = Teams(self)
39
+ self.locations = Locations(self)
40
+ self.payroll = Payroll(self)
41
+ self.workschedules = Workschedules(self)
42
+ self.files = Files(self)
43
+ self.family_situation = FamilySituation(self)
44
+ self.debug = debug
45
+
46
+ def _get_credentials(self, system_type):
47
+ """
48
+ Sets the credentials for the SuccessFactors API.
49
+ :param label (str): The label for the system credentials.
50
+ :returns: headers (dict): The headers for the API request, including the access token.
51
+ """
52
+ credentials = self.interfaces.credentials.get(system="factorial", system_type=system_type)
53
+ credentials = credentials.get('data')
54
+
55
+ headers = {
56
+ 'Authorization': f"Bearer {credentials['access_token']}",
57
+ 'Content-Type': 'application/json'
58
+ }
59
+
60
+ return headers
@@ -0,0 +1,76 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Companies:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/companies/legal_entities'
9
+
10
+ def get(self,
11
+ ids: list = None,
12
+ employees_ids: list[int] = None,
13
+ companies_ids: list[int] = None,
14
+ country_ids: list[int] = None) -> pd.DataFrame:
15
+
16
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
17
+ func_params = list(locals().items())
18
+ params = {}
19
+ for param, value in func_params:
20
+ if param != 'self' and value is not None:
21
+ params[param] = value
22
+
23
+ has_next_page = True
24
+ result_data = pd.DataFrame()
25
+ while has_next_page:
26
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
27
+ params=params,
28
+ timeout=self.factorial.timeout)
29
+ response.raise_for_status()
30
+ response_data = response.json()
31
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
32
+ has_next_page = response_data['meta']['has_next_page']
33
+ if has_next_page:
34
+ params['after_id'] = response_data['meta']['end_cursor']
35
+
36
+ return result_data
37
+
38
+ def get_types(self,
39
+ ids: list = None,
40
+ legal_entity_ids: list[int] = None) -> pd.DataFrame:
41
+
42
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
43
+ func_params = locals().items()
44
+ params = {}
45
+ for param, value in func_params:
46
+ if param != 'self' and value is not None:
47
+ params[param] = value
48
+
49
+ has_next_page = True
50
+ result_data = pd.DataFrame()
51
+ while has_next_page:
52
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
53
+ params=params,
54
+ timeout=self.factorial.timeout)
55
+ response.raise_for_status()
56
+ response_data = response.json()
57
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
58
+ has_next_page = response_data['meta']['has_next_page']
59
+ params['after_id'] = response_data['meta']['end_cursor']
60
+
61
+ return result_data
62
+
63
+ def update(self, company_id: str, data: dict) -> requests.Response:
64
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{company_id}',
65
+ json=data,
66
+ timeout=self.factorial.timeout)
67
+ response.raise_for_status()
68
+ return response
69
+
70
+ def delete(self, company_id: str) -> requests.Response:
71
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{company_id}', timeout=self.factorial.timeout)
72
+ response.raise_for_status()
73
+ return response
74
+
75
+ def create(self, data: dict) -> requests.Response:
76
+ raise NotImplementedError
@@ -0,0 +1,80 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Compensations:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/contracts/'
9
+
10
+ def get(self,
11
+ ids: list = None,
12
+ contract_version_id: list[int] = None) -> pd.DataFrame:
13
+
14
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
15
+ func_params = list(locals().items())
16
+ params = {}
17
+ for param, value in func_params:
18
+ if param != 'self' and value is not None:
19
+ params[param] = value
20
+
21
+ has_next_page = True
22
+ result_data = pd.DataFrame()
23
+ while has_next_page:
24
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}compensations',
25
+ params=params,
26
+ timeout=self.factorial.timeout)
27
+ response.raise_for_status()
28
+ response_data = response.json()
29
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
30
+ has_next_page = response_data['meta']['has_next_page']
31
+ if has_next_page:
32
+ params['after_id'] = response_data['meta']['end_cursor']
33
+
34
+ taxonomies = self.get_types()
35
+ if not result_data.empty:
36
+ result_data = pd.merge(result_data, taxonomies, left_on='contracts_taxonomy_id', right_on='id', suffixes=('', '_taxonomy'))
37
+
38
+ return result_data
39
+
40
+ def get_types(self,
41
+ ids: list = None,
42
+ legal_entity_ids: list[int] = None,
43
+ legal_entity_id: int = None) -> pd.DataFrame:
44
+
45
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
46
+ func_params = list(locals().items())
47
+ params = {}
48
+ for param, value in func_params:
49
+ if param != 'self' and value is not None:
50
+ params[param] = value
51
+
52
+ has_next_page = True
53
+ result_data = pd.DataFrame()
54
+ while has_next_page:
55
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}taxonomies',
56
+ params=params,
57
+ timeout=self.factorial.timeout)
58
+ response.raise_for_status()
59
+ response_data = response.json()
60
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
61
+ has_next_page = response_data['meta']['has_next_page']
62
+ if has_next_page:
63
+ params['after_id'] = response_data['meta']['end_cursor']
64
+
65
+ return result_data
66
+
67
+ def update(self, compensation_id: str, data: dict) -> requests.Response:
68
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{compensation_id}',
69
+ json=data,
70
+ timeout=self.factorial.timeout)
71
+ response.raise_for_status()
72
+ return response
73
+
74
+ def delete(self, compensation_id: str) -> requests.Response:
75
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{compensation_id}', timeout=self.factorial.timeout)
76
+ response.raise_for_status()
77
+ return response
78
+
79
+ def create(self, data: dict) -> requests.Response:
80
+ raise NotImplementedError
@@ -0,0 +1,50 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Contracts:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/contracts/contract_versions'
9
+
10
+ def get(self,
11
+ ids: list = None,
12
+ employee_ids: list[int] = None,
13
+ date: str = None) -> pd.DataFrame:
14
+
15
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
16
+ func_params = list(locals().items())
17
+ params = {}
18
+ for param, value in func_params:
19
+ if param != 'self' and value is not None:
20
+ params[param] = value
21
+
22
+ has_next_page = True
23
+ result_data = pd.DataFrame()
24
+ while has_next_page:
25
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
26
+ params=params,
27
+ timeout=self.factorial.timeout)
28
+ response.raise_for_status()
29
+ response_data = response.json()
30
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
31
+ has_next_page = response_data['meta']['has_next_page']
32
+ if has_next_page:
33
+ params['after_id'] = response_data['meta']['end_cursor']
34
+
35
+ return result_data
36
+
37
+ def update(self, contract_id: str, data: dict) -> requests.Response:
38
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{contract_id}',
39
+ json=data,
40
+ timeout=self.factorial.timeout)
41
+ response.raise_for_status()
42
+ return response
43
+
44
+ def delete(self, contract_id: str) -> requests.Response:
45
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{contract_id}', timeout=self.factorial.timeout)
46
+ response.raise_for_status()
47
+ return response
48
+
49
+ def create(self, data: dict) -> requests.Response:
50
+ raise NotImplementedError
@@ -0,0 +1,80 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Costcenter:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/finance/cost_centers'
9
+
10
+ def get(self,
11
+ ids: list = None,
12
+ company_id: int = None,
13
+ legal_entity_ids: list = None,
14
+ include_actives_on_date: str = None,
15
+ search: str = None) -> pd.DataFrame:
16
+
17
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
18
+ func_params = locals().items()
19
+ params = {}
20
+ for param, value in func_params:
21
+ if param != 'self' and value is not None:
22
+ params[param] = value
23
+
24
+ has_next_page = True
25
+ result_data = pd.DataFrame()
26
+ while has_next_page:
27
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
28
+ params=params,
29
+ timeout=self.factorial.timeout)
30
+ response.raise_for_status()
31
+ response_data = response.json()
32
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
33
+ has_next_page = response_data['meta']['has_next_page']
34
+ if has_next_page:
35
+ params['after_id'] = response_data['meta']['end_cursor']
36
+
37
+ return result_data
38
+
39
+ def get_membership(self,
40
+ cost_center_id: int = None,
41
+ employee_id: int = None,
42
+ active_on: str = None,
43
+ company_id: int = None) -> pd.DataFrame:
44
+
45
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
46
+ func_params = list(locals().items())
47
+ params = {}
48
+ for param, value in func_params:
49
+ if param != 'self' and value is not None:
50
+ params[param] = value
51
+
52
+ has_next_page = True
53
+ result_data = pd.DataFrame()
54
+ while has_next_page:
55
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}/resources/finance/cost_center_memberships',
56
+ params=params,
57
+ timeout=self.factorial.timeout)
58
+ response.raise_for_status()
59
+ response_data = response.json()
60
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
61
+ has_next_page = response_data['meta']['has_next_page']
62
+ if has_next_page:
63
+ params['after_id'] = response_data['meta']['end_cursor']
64
+
65
+ return result_data
66
+
67
+ def update(self, costcenter_id: str, data: dict) -> requests.Response:
68
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{costcenter_id}',
69
+ json=data,
70
+ timeout=self.factorial.timeout)
71
+ response.raise_for_status()
72
+ return response
73
+
74
+ def delete(self, costcenter_id: str) -> requests.Response:
75
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{costcenter_id}', timeout=self.factorial.timeout)
76
+ response.raise_for_status()
77
+ return response
78
+
79
+ def create(self, data: dict) -> requests.Response:
80
+ raise NotImplementedError
@@ -0,0 +1,76 @@
1
+ from typing import Literal, List
2
+
3
+ import requests
4
+ import pandas as pd
5
+
6
+
7
+ class CustomFields:
8
+ def __init__(self, factorial):
9
+ self.factorial = factorial
10
+ self.base_endpoint = '/resources/custom_fields/fields'
11
+
12
+ def get(self,
13
+ ids: list = None,
14
+ field_type: str = None,
15
+ label: str = None,
16
+ slug: str = None,
17
+ company_id: int = None
18
+ ) -> pd.DataFrame:
19
+
20
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
21
+ func_params = locals().items()
22
+ params = {}
23
+ for param, value in func_params:
24
+ if param != 'self' and value is not None:
25
+ params[param] = value
26
+
27
+ has_next_page = True
28
+ result_data = pd.DataFrame()
29
+ while has_next_page:
30
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
31
+ params=params,
32
+ timeout=self.factorial.timeout)
33
+ response.raise_for_status()
34
+ response_data = response.json()
35
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
36
+ has_next_page = response_data['meta']['has_next_page']
37
+ params['after_id'] = response_data['meta']['end_cursor']
38
+
39
+ return result_data
40
+
41
+ def update(self, contract_id: str, data: dict) -> requests.Response:
42
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{self.base_endpoint}',
43
+ json=data,
44
+ timeout=self.factorial.timeout)
45
+ response.raise_for_status()
46
+ return response
47
+
48
+ def delete(self, contract_id: str) -> requests.Response:
49
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{self.base_endpoint}', timeout=self.factorial.timeout)
50
+ response.raise_for_status()
51
+ return response
52
+
53
+ def create(self,
54
+ company_id: int,
55
+ editable: Literal['owned', 'reportees', 'teamleader', 'everybody'] = None,
56
+ visible: Literal['owned', 'reportees', 'teamleader', 'everybody'] = None,
57
+ label: str = None,
58
+ field_type: Literal['text', 'long_text', 'date', 'rating', 'checkbox', 'single_choice', 'multiple_choice', 'money', 'cents'] = None,
59
+ min_value: int = None,
60
+ max_value: int = None,
61
+ required: bool = None,
62
+ options: List[str] = None,
63
+ position: int = None
64
+ ) -> requests.Response:
65
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
66
+ func_params = list(locals().items())
67
+ data = {}
68
+ for param, value in func_params:
69
+ if param != 'self' and value is not None:
70
+ data[param] = value
71
+
72
+ response = self.factorial.session.post(url=f'{self.factorial.base_url}{self.base_endpoint}/{self.base_endpoint}',
73
+ data=data,
74
+ timeout=self.factorial.timeout)
75
+ response.raise_for_status()
76
+ return response
@@ -0,0 +1,57 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Employees:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/employees/employees'
9
+
10
+ def get(self,
11
+ only_active: bool = False,
12
+ only_managers: bool = False,
13
+ ids: list = None,
14
+ access_ids: list[int] = None,
15
+ emails: list[str] = None,
16
+ full_text_name: str = None,
17
+ name_starts_with: str = None,
18
+ legal_entity_ids: list[int] = None,
19
+ team_ids: list[int] = None,
20
+ location_ids: list[int] = None) -> pd.DataFrame:
21
+
22
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
23
+ func_params = list(locals().items())
24
+ params = {}
25
+ for param, value in func_params:
26
+ if param != 'self' and value is not None:
27
+ params[param] = value
28
+
29
+ has_next_page = True
30
+ result_data = pd.DataFrame()
31
+ while has_next_page:
32
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
33
+ params=params,
34
+ timeout=self.factorial.timeout)
35
+ response.raise_for_status()
36
+ response_data = response.json()
37
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
38
+ has_next_page = response_data['meta']['has_next_page']
39
+ if has_next_page:
40
+ params['after_id'] = response_data['meta']['end_cursor']
41
+
42
+ return result_data
43
+
44
+ def update(self, employee_id: str, data: dict) -> requests.Response:
45
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{employee_id}',
46
+ json=data,
47
+ timeout=self.factorial.timeout)
48
+ response.raise_for_status()
49
+ return response
50
+
51
+ def delete(self, employee_id: str) -> requests.Response:
52
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{employee_id}', timeout=self.factorial.timeout)
53
+ response.raise_for_status()
54
+ return response
55
+
56
+ def create(self, data: dict) -> requests.Response:
57
+ raise NotImplementedError
@@ -0,0 +1,50 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class FamilySituation:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/payroll/family_situations'
9
+
10
+ def get(self,
11
+ employee_ids: list[int] = None) -> pd.DataFrame:
12
+
13
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
14
+ func_params = list(locals().items())
15
+ params = {}
16
+ for param, value in func_params:
17
+ if param != 'self' and value is not None:
18
+ params[param] = value
19
+
20
+ has_next_page = True
21
+ result_data = pd.DataFrame()
22
+ while has_next_page:
23
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
24
+ params=params,
25
+ timeout=self.factorial.timeout)
26
+ response.raise_for_status()
27
+ response_data = response.json()
28
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
29
+ has_next_page = response_data['meta']['has_next_page']
30
+ if has_next_page:
31
+ params['after_id'] = response_data['meta']['end_cursor']
32
+
33
+ return result_data
34
+
35
+ def create(self, data: dict) -> requests.Response:
36
+ response = self.factorial.session.post(url=f'{self.factorial.base_url}{self.base_endpoint}',
37
+ json=data,
38
+ timeout=self.factorial.timeout)
39
+ response.raise_for_status()
40
+ return response
41
+
42
+ def update(self, family_situation_id: str, data: dict) -> requests.Response:
43
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{family_situation_id}',
44
+ json=data,
45
+ timeout=self.factorial.timeout)
46
+ response.raise_for_status()
47
+ return response
48
+
49
+ def delete(self, family_situation_id: str) -> requests.Response:
50
+ raise NotImplementedError
@@ -0,0 +1,22 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Files:
6
+
7
+ def __init__(self, core):
8
+ self.core = core
9
+ self.base_endpoint = '/core/employees'
10
+
11
+ def get(self) -> pd.DataFrame:
12
+ response = requests.get(f'{self.core.factorial.base_url_v1}{self.base_endpoint}', timeout=self.factorial.timeout)
13
+ response.raise_for_status()
14
+ return pd.DataFrame(response.json())
15
+
16
+ def update(self, employee_id: str, data: dict) -> requests.Response:
17
+ response = requests.put(f'{self.core.factorial.base_url_v1}{self.base_endpoint}/{employee_id}', json=data, timeout=self.factorial.timeout)
18
+ response.raise_for_status()
19
+ return response
20
+
21
+ def create(self, data: dict) -> requests.Response:
22
+ raise NotImplementedError
@@ -0,0 +1,49 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Locations:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/locations/locations'
9
+
10
+ def get(self,
11
+ ids: list = None,
12
+ employee_ids: list[int] = None) -> pd.DataFrame:
13
+
14
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
15
+ func_params = list(locals().items())
16
+ params = {}
17
+ for param, value in func_params:
18
+ if param != 'self' and value is not None:
19
+ params[param] = value
20
+
21
+ has_next_page = True
22
+ result_data = pd.DataFrame()
23
+ while has_next_page:
24
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
25
+ params=params,
26
+ timeout=self.factorial.timeout)
27
+ response.raise_for_status()
28
+ response_data = response.json()
29
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
30
+ has_next_page = response_data['meta']['has_next_page']
31
+ if has_next_page:
32
+ params['after_id'] = response_data['meta']['end_cursor']
33
+
34
+ return result_data
35
+
36
+ def update(self, location_id: str, data: dict) -> requests.Response:
37
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{location_id}',
38
+ json=data,
39
+ timeout=self.factorial.timeout)
40
+ response.raise_for_status()
41
+ return response
42
+
43
+ def delete(self, location_id: str) -> requests.Response:
44
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{location_id}', timeout=self.factorial.timeout)
45
+ response.raise_for_status()
46
+ return response
47
+
48
+ def create(self, data: dict) -> requests.Response:
49
+ raise NotImplementedError
@@ -0,0 +1,54 @@
1
+ import requests
2
+ import pandas as pd
3
+
4
+
5
+ class Payroll:
6
+ def __init__(self, factorial):
7
+ self.factorial = factorial
8
+ self.base_endpoint = '/resources/payroll/supplements'
9
+
10
+ def get(self,
11
+ to_date: str = None, # YYYY-MM-DD
12
+ from_date: str = None, # YYYY-MM-DD
13
+ legal_entity_ids: list = None,
14
+ policy_period_ids: list = None,
15
+ compensation_id: int = None,
16
+ ids: list = None,
17
+ employee_ids: list[int] = None) -> pd.DataFrame:
18
+
19
+ # Use locals() to get all function parameters as a dictionary. Do not move this down since it will include all variables in function scope
20
+ func_params = list(locals().items())
21
+ params = {}
22
+ for param, value in func_params:
23
+ if param != 'self' and value is not None:
24
+ params[param] = value
25
+
26
+ has_next_page = True
27
+ result_data = pd.DataFrame()
28
+ while has_next_page:
29
+ response = self.factorial.session.get(url=f'{self.factorial.base_url}{self.base_endpoint}',
30
+ params=params,
31
+ timeout=self.factorial.timeout)
32
+ response.raise_for_status()
33
+ response_data = response.json()
34
+ result_data = pd.concat([result_data, pd.DataFrame(response_data['data'])])
35
+ has_next_page = response_data['meta']['has_next_page']
36
+ if has_next_page:
37
+ params['after_id'] = response_data['meta']['end_cursor']
38
+
39
+ return result_data
40
+
41
+ def update(self, supplement_id: str, data: dict) -> requests.Response:
42
+ response = self.factorial.session.put(url=f'{self.factorial.base_url}{self.base_endpoint}/{supplement_id}',
43
+ json=data,
44
+ timeout=self.factorial.timeout)
45
+ response.raise_for_status()
46
+ return response
47
+
48
+ def delete(self, supplement_id: str) -> requests.Response:
49
+ response = self.factorial.session.delete(url=f'{self.factorial.base_url}{self.base_endpoint}/{supplement_id}', timeout=self.factorial.timeout)
50
+ response.raise_for_status()
51
+ return response
52
+
53
+ def create(self, data: dict) -> requests.Response:
54
+ raise NotImplementedError