brynq-sdk-zenegy 1.3.3__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.
- brynq_sdk_zenegy/__init__.py +23 -0
- brynq_sdk_zenegy/absence.py +100 -0
- brynq_sdk_zenegy/companies.py +43 -0
- brynq_sdk_zenegy/cost_center.py +80 -0
- brynq_sdk_zenegy/departments.py +77 -0
- brynq_sdk_zenegy/employee_documents.py +40 -0
- brynq_sdk_zenegy/employees.py +301 -0
- brynq_sdk_zenegy/global_value_sets.py +260 -0
- brynq_sdk_zenegy/global_values.py +265 -0
- brynq_sdk_zenegy/paychecks.py +119 -0
- brynq_sdk_zenegy/payroll.py +117 -0
- brynq_sdk_zenegy/payslips.py +43 -0
- brynq_sdk_zenegy/pensions.py +118 -0
- brynq_sdk_zenegy/schemas/__init__.py +30 -0
- brynq_sdk_zenegy/schemas/absences.py +393 -0
- brynq_sdk_zenegy/schemas/companies.py +42 -0
- brynq_sdk_zenegy/schemas/company_cost_centers.py +48 -0
- brynq_sdk_zenegy/schemas/company_departments.py +147 -0
- brynq_sdk_zenegy/schemas/employee_documents.py +30 -0
- brynq_sdk_zenegy/schemas/employee_pay_checks.py +169 -0
- brynq_sdk_zenegy/schemas/employee_pensions.py +140 -0
- brynq_sdk_zenegy/schemas/employees.py +2372 -0
- brynq_sdk_zenegy/schemas/global_value_sets.py +185 -0
- brynq_sdk_zenegy/schemas/global_values.py +433 -0
- brynq_sdk_zenegy/schemas/payrolls.py +134 -0
- brynq_sdk_zenegy/schemas/payslips.py +32 -0
- brynq_sdk_zenegy/schemas/supplements_and_deductions_rates.py +189 -0
- brynq_sdk_zenegy/supplements_and_deductions_rates.py +71 -0
- brynq_sdk_zenegy/zenegy.py +221 -0
- brynq_sdk_zenegy-1.3.3.dist-info/METADATA +16 -0
- brynq_sdk_zenegy-1.3.3.dist-info/RECORD +33 -0
- brynq_sdk_zenegy-1.3.3.dist-info/WHEEL +5 -0
- brynq_sdk_zenegy-1.3.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from typing import Dict, Any, Optional, Type, List
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
|
|
8
|
+
from .absence import Absences
|
|
9
|
+
from brynq_sdk_brynq import BrynQ
|
|
10
|
+
from brynq_sdk_functions import Functions
|
|
11
|
+
from .companies import Companies
|
|
12
|
+
from .employees import Employees
|
|
13
|
+
from .cost_center import CostCenter
|
|
14
|
+
from .payroll import Payrolls
|
|
15
|
+
from .payslips import Payslips
|
|
16
|
+
from .global_values import GlobalValues
|
|
17
|
+
from .global_value_sets import GlobalValueSets
|
|
18
|
+
from .supplements_and_deductions_rates import SupplementsAndDeductionsRates
|
|
19
|
+
from .departments import CompanyDepartments
|
|
20
|
+
from .employee_documents import EmployeeDocuments
|
|
21
|
+
|
|
22
|
+
class Zenegy(BrynQ):
|
|
23
|
+
"""
|
|
24
|
+
Base class for interacting with the Zenegy API.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
# Default timeout in seconds for all requests
|
|
28
|
+
TIMEOUT = 30
|
|
29
|
+
|
|
30
|
+
def __init__(self, system_type: str,
|
|
31
|
+
debug: bool = False, test_environment: bool = False, test_environment_id: str = None):
|
|
32
|
+
"""
|
|
33
|
+
Initialize the Zenegy API client.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
system_type (str): System type
|
|
37
|
+
test_environment (bool): Test environment flag
|
|
38
|
+
debug (bool): Debug flag
|
|
39
|
+
"""
|
|
40
|
+
super().__init__()
|
|
41
|
+
|
|
42
|
+
if not test_environment and test_environment_id is None:
|
|
43
|
+
self.base_url = "https://api.zenegy.com"
|
|
44
|
+
system = "zenegy"
|
|
45
|
+
elif test_environment_id:
|
|
46
|
+
self.base_url = "https://api-gateway.beta.zalary.com"
|
|
47
|
+
system = "zenegy-development"
|
|
48
|
+
self.data_interface_id = test_environment_id
|
|
49
|
+
self.interfaces._brynq.data_interface_id = test_environment_id
|
|
50
|
+
self.interfaces.credentials._brynq.data_interface_id = test_environment_id
|
|
51
|
+
else:
|
|
52
|
+
raise ValueError("Test environment ID is required, please set up interface for test enviromnent of Zenegy")
|
|
53
|
+
|
|
54
|
+
# Get credentials
|
|
55
|
+
credentials = self.interfaces.credentials.get(
|
|
56
|
+
system=system,
|
|
57
|
+
system_type=system_type,
|
|
58
|
+
test_environment=test_environment,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Get bearer token
|
|
62
|
+
self.token = credentials["data"]["access_token"]
|
|
63
|
+
self.company_uid = credentials["data"]["company_id"]
|
|
64
|
+
|
|
65
|
+
# Initialize session with timeout
|
|
66
|
+
self.session = requests.Session()
|
|
67
|
+
self.session.headers.update({
|
|
68
|
+
"Authorization": f"Bearer {self.token}",
|
|
69
|
+
"Accept": "application/json",
|
|
70
|
+
"Content-Type": "application/json"
|
|
71
|
+
})
|
|
72
|
+
self.session.timeout = self.TIMEOUT
|
|
73
|
+
|
|
74
|
+
# Set debug mode
|
|
75
|
+
self.debug = debug
|
|
76
|
+
|
|
77
|
+
# Initialize entity classes
|
|
78
|
+
self.absences = Absences(self)
|
|
79
|
+
self.companies = Companies(self)
|
|
80
|
+
self.cost_centers = CostCenter(self)
|
|
81
|
+
self.employees = Employees(self)
|
|
82
|
+
self.payrolls = Payrolls(self)
|
|
83
|
+
self.payslips = Payslips(self)
|
|
84
|
+
self.employee_documents = EmployeeDocuments(self)
|
|
85
|
+
self.global_values = GlobalValues(self)
|
|
86
|
+
self.global_value_sets = GlobalValueSets(self)
|
|
87
|
+
self.supplements_and_deduction_rates = SupplementsAndDeductionsRates(self)
|
|
88
|
+
self.departments = CompanyDepartments(self)
|
|
89
|
+
|
|
90
|
+
def get(self, endpoint: str, params: Dict[str, Any] = None):
|
|
91
|
+
"""
|
|
92
|
+
Make a GET request to the API.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
endpoint: API endpoint to call
|
|
96
|
+
params: Query parameters
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Raw API response data
|
|
100
|
+
"""
|
|
101
|
+
try:
|
|
102
|
+
# Make the API request
|
|
103
|
+
response = self.session.get(
|
|
104
|
+
url=f"{self.base_url}/{endpoint}",
|
|
105
|
+
params=params,
|
|
106
|
+
timeout=self.TIMEOUT,
|
|
107
|
+
)
|
|
108
|
+
self.raise_for_status_with_details(response)
|
|
109
|
+
content = response.json()
|
|
110
|
+
|
|
111
|
+
return content
|
|
112
|
+
|
|
113
|
+
except Exception as e:
|
|
114
|
+
raise Exception(f"Failed to retrieve data: {str(e)}") from e
|
|
115
|
+
|
|
116
|
+
def post(self, endpoint: str, json: Optional[Dict[str, Any]] = None) -> requests.Response:
|
|
117
|
+
"""
|
|
118
|
+
Make a POST request using the shared session with timeout.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
endpoint: API endpoint to call
|
|
122
|
+
json: JSON body to send in the request
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
requests.Response: Raw response object
|
|
126
|
+
"""
|
|
127
|
+
try:
|
|
128
|
+
response = self.session.post(
|
|
129
|
+
url=f"{self.base_url}/{endpoint}",
|
|
130
|
+
json=json,
|
|
131
|
+
timeout=self.TIMEOUT,
|
|
132
|
+
)
|
|
133
|
+
self.raise_for_status_with_details(response)
|
|
134
|
+
return response
|
|
135
|
+
except Exception as e:
|
|
136
|
+
raise Exception(f"Failed to POST {endpoint}: {str(e)}") from e
|
|
137
|
+
|
|
138
|
+
def patch(self, endpoint: str, json: Optional[Dict[str, Any]] = None) -> requests.Response:
|
|
139
|
+
"""
|
|
140
|
+
Make a PATCH request using the shared session with timeout.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
endpoint: API endpoint to call
|
|
144
|
+
json: JSON body to send in the request
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
requests.Response: Raw response object
|
|
148
|
+
"""
|
|
149
|
+
try:
|
|
150
|
+
response = self.session.patch(
|
|
151
|
+
url=f"{self.base_url}/{endpoint}",
|
|
152
|
+
json=json,
|
|
153
|
+
timeout=self.TIMEOUT,
|
|
154
|
+
)
|
|
155
|
+
self.raise_for_status_with_details(response)
|
|
156
|
+
return response
|
|
157
|
+
except Exception as e:
|
|
158
|
+
raise Exception(f"Failed to PATCH {endpoint}: {str(e)}") from e
|
|
159
|
+
|
|
160
|
+
def put(self, endpoint: str, json: Optional[Dict[str, Any]] = None) -> requests.Response:
|
|
161
|
+
"""
|
|
162
|
+
Make a PUT request using the shared session with timeout.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
endpoint: API endpoint to call
|
|
166
|
+
json: JSON body to send in the request
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
requests.Response: Raw response object
|
|
170
|
+
"""
|
|
171
|
+
try:
|
|
172
|
+
response = self.session.put(
|
|
173
|
+
url=f"{self.base_url}/{endpoint}",
|
|
174
|
+
json=json,
|
|
175
|
+
timeout=self.TIMEOUT,
|
|
176
|
+
)
|
|
177
|
+
self.raise_for_status_with_details(response)
|
|
178
|
+
return response
|
|
179
|
+
except Exception as e:
|
|
180
|
+
raise Exception(f"Failed to PUT {endpoint}: {str(e)}") from e
|
|
181
|
+
|
|
182
|
+
def delete(self, endpoint: str) -> requests.Response:
|
|
183
|
+
"""
|
|
184
|
+
Make a DELETE request using the shared session with timeout.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
endpoint: API endpoint to call
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
requests.Response: Raw response object
|
|
191
|
+
"""
|
|
192
|
+
try:
|
|
193
|
+
response = self.session.delete(
|
|
194
|
+
url=f"{self.base_url}/{endpoint}",
|
|
195
|
+
timeout=self.TIMEOUT,
|
|
196
|
+
)
|
|
197
|
+
self.raise_for_status_with_details(response)
|
|
198
|
+
return response
|
|
199
|
+
except Exception as e:
|
|
200
|
+
raise Exception(f"Failed to DELETE {endpoint}: {str(e)}") from e
|
|
201
|
+
|
|
202
|
+
def raise_for_status_with_details(self, response: requests.Response) -> None:
|
|
203
|
+
"""
|
|
204
|
+
Raises HTTPError if the response contains an HTTP error status.
|
|
205
|
+
Additionally includes response content (JSON or plain text) in the exception message
|
|
206
|
+
to provide more detailed context.
|
|
207
|
+
"""
|
|
208
|
+
try:
|
|
209
|
+
response.raise_for_status()
|
|
210
|
+
except requests.exceptions.HTTPError as e:
|
|
211
|
+
# Attempt to extract error details from the response
|
|
212
|
+
try:
|
|
213
|
+
error_details = response.json()
|
|
214
|
+
except ValueError:
|
|
215
|
+
# If the response is not JSON, fall back to plain text
|
|
216
|
+
error_details = response.text
|
|
217
|
+
|
|
218
|
+
# Raise a new exception with the detailed message
|
|
219
|
+
raise requests.exceptions.HTTPError(
|
|
220
|
+
f"{str(e)}\nResponse details:\n{error_details}"
|
|
221
|
+
) from e
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: brynq_sdk_zenegy
|
|
3
|
+
Version: 1.3.3
|
|
4
|
+
Summary: Zenegy wrapper from BrynQ
|
|
5
|
+
Author: BrynQ
|
|
6
|
+
Author-email: support@brynq.com
|
|
7
|
+
License: BrynQ License
|
|
8
|
+
Requires-Dist: brynq-sdk-brynq>=3
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: author-email
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: license
|
|
13
|
+
Dynamic: requires-dist
|
|
14
|
+
Dynamic: summary
|
|
15
|
+
|
|
16
|
+
Zenegy wrapper from BrynQ
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
brynq_sdk_zenegy/__init__.py,sha256=oj56tcw0Ia9VaZ1aNChTrk9SqoHt6B3Y-ugrL9zyZ0o,798
|
|
2
|
+
brynq_sdk_zenegy/absence.py,sha256=ZmMy7t1CFmXK3-WfpA6b20XZ2ahwsR2gQeHInOb48Dk,3665
|
|
3
|
+
brynq_sdk_zenegy/companies.py,sha256=DbNx4E-tjqdohbqpPeVrKTWCNCyOa9m7ZIXwuPx4ctU,1271
|
|
4
|
+
brynq_sdk_zenegy/cost_center.py,sha256=zdBSe8KZ683LIeHIXCt5Y9sCY4HcXI_eEcooq3P9jSU,2763
|
|
5
|
+
brynq_sdk_zenegy/departments.py,sha256=o2G59BkLioyo9_FhwppA_1nurzNf30k6XkkTYDLdsa4,2451
|
|
6
|
+
brynq_sdk_zenegy/employee_documents.py,sha256=xYXukrSd6gqI5UbiupGb5_zrKzOsNeh4FbVippdIpw8,1396
|
|
7
|
+
brynq_sdk_zenegy/employees.py,sha256=SYQGWBt3bNTvtByeftrJB0yAaxnzZXqpH2Unt56AsAM,12135
|
|
8
|
+
brynq_sdk_zenegy/global_value_sets.py,sha256=2T63dLUvD4mY7L1coXYQD8UttE4m0gKGolH55r_2mmI,10289
|
|
9
|
+
brynq_sdk_zenegy/global_values.py,sha256=RBv33piYctIu95Z022noDFsMhPjSzsaBbyeaU84V2bw,10598
|
|
10
|
+
brynq_sdk_zenegy/paychecks.py,sha256=9kUuFY3jc8vfyYVxqBXDWSVXD_X-FlW693an-CirlTw,4844
|
|
11
|
+
brynq_sdk_zenegy/payroll.py,sha256=gVLBEaMe2Rq3Vt06Gf2KllnGmwt5glNJFFiSylQ4AMs,4921
|
|
12
|
+
brynq_sdk_zenegy/payslips.py,sha256=n21-6TXU-KrKza6vhglzahb6ThpvL9PW5WJSrn7lsdk,1371
|
|
13
|
+
brynq_sdk_zenegy/pensions.py,sha256=1-IBvs8CzABTCDh_FYjx9nSk4qWQ0e6gXijncWXxgzg,4581
|
|
14
|
+
brynq_sdk_zenegy/supplements_and_deductions_rates.py,sha256=cGVs73SYDFxeIifzvHfKGqzd_SrtxqeG-KFGJdDu2pA,2723
|
|
15
|
+
brynq_sdk_zenegy/zenegy.py,sha256=q92m1Mhd9qRx4qQC2csjm_M5WyYzAI1m2GcQUM2e3-M,7666
|
|
16
|
+
brynq_sdk_zenegy/schemas/__init__.py,sha256=B8EZcXMHd3S4wkOXS-jG9__irnZFeipsY1Va61DH-2w,1782
|
|
17
|
+
brynq_sdk_zenegy/schemas/absences.py,sha256=jsQ4vLCyP6H__Omg7gJJXUPM69LcVxQ4veClJ3FS3yE,22182
|
|
18
|
+
brynq_sdk_zenegy/schemas/companies.py,sha256=VKQgSSMcaNeVkpWj29h3DyVYxARx0WwR4TqmLEPf4h4,2988
|
|
19
|
+
brynq_sdk_zenegy/schemas/company_cost_centers.py,sha256=a-t7RSWWai61B241WrxCBvUmTv7RbBIalqfKLh_57Js,1872
|
|
20
|
+
brynq_sdk_zenegy/schemas/company_departments.py,sha256=CO8lj2ulBxUxQOumEa5jizqjIW9O9zp0qNdDBQyASdU,11364
|
|
21
|
+
brynq_sdk_zenegy/schemas/employee_documents.py,sha256=zIYnZe5Egc2OsepNR2k9sa8_oYbgYlko_uUo9Pj1ac0,1853
|
|
22
|
+
brynq_sdk_zenegy/schemas/employee_pay_checks.py,sha256=EPKeuxk7trFyza4HuHQhqmFFP73-EV8YQYlqTi4fQ0A,20965
|
|
23
|
+
brynq_sdk_zenegy/schemas/employee_pensions.py,sha256=ql9u0ixeY7PJdiuCIeraEuxfUGkWUcQDEFhWMo-xIFA,9190
|
|
24
|
+
brynq_sdk_zenegy/schemas/employees.py,sha256=mpfda-XNeJA_GDvsNZwebktep6qsdokZT136cB-cNow,224459
|
|
25
|
+
brynq_sdk_zenegy/schemas/global_value_sets.py,sha256=T2-wbv1X3cynHagmSm5Txt2Nt8XM9IExpEgZavackQo,12797
|
|
26
|
+
brynq_sdk_zenegy/schemas/global_values.py,sha256=p3O7Wcl7Zs1h5RuHFDqb43wBJKu-IPXy4MSnc5j2pzw,34182
|
|
27
|
+
brynq_sdk_zenegy/schemas/payrolls.py,sha256=lH7wWQ9TlgxNdcv-YVmwTwU1CX0Bnjr7Q3c-PDB-nXA,16481
|
|
28
|
+
brynq_sdk_zenegy/schemas/payslips.py,sha256=oo_synehNZl6BJdW9Ndqa1EL2bay89BHaZiWZiCgMWc,2450
|
|
29
|
+
brynq_sdk_zenegy/schemas/supplements_and_deductions_rates.py,sha256=g4GSI-klmTKrTYcKuktatj3te5xVhUrYxTsrJ-mg6ho,16878
|
|
30
|
+
brynq_sdk_zenegy-1.3.3.dist-info/METADATA,sha256=_K26zjKtbcibwmHCptAeIt8ve9RX2CmYsfr7bq1YEFE,341
|
|
31
|
+
brynq_sdk_zenegy-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
32
|
+
brynq_sdk_zenegy-1.3.3.dist-info/top_level.txt,sha256=quyHxFQMtqHujnE15mGvieYNp-0MR1aLx0ns5VYYWOo,17
|
|
33
|
+
brynq_sdk_zenegy-1.3.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
brynq_sdk_zenegy
|