python-moloni-fix 0.3.16__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.
- moloni/__init__.py +0 -0
- moloni/__version__.py +1 -0
- moloni/api/__init__.py +701 -0
- moloni/api/bankaccounts_client.py +372 -0
- moloni/api/billsoflading_client.py +693 -0
- moloni/api/companies_client.py +322 -0
- moloni/api/countries_client.py +171 -0
- moloni/api/creditnotes_client.py +615 -0
- moloni/api/currencies_client.py +171 -0
- moloni/api/customeralternateaddresses_client.py +519 -0
- moloni/api/customerreturnnotes_client.py +701 -0
- moloni/api/customers_client.py +1413 -0
- moloni/api/debitnotes_client.py +597 -0
- moloni/api/deductions_client.py +435 -0
- moloni/api/deliverymethods_client.py +431 -0
- moloni/api/deliverynotes_client.py +714 -0
- moloni/api/documentmodels_client.py +171 -0
- moloni/api/documents_client.py +472 -0
- moloni/api/documentsets_client.py +447 -0
- moloni/api/estimates_client.py +663 -0
- moloni/api/fiscalzones_client.py +219 -0
- moloni/api/identificationtemplates_client.py +513 -0
- moloni/api/invoicereceipts_client.py +705 -0
- moloni/api/invoices_client.py +705 -0
- moloni/api/languages_client.py +171 -0
- moloni/api/maturitydates_client.py +441 -0
- moloni/api/measurementunits_client.py +437 -0
- moloni/api/ownassetsmovementguides_client.py +683 -0
- moloni/api/paymentmethods_client.py +429 -0
- moloni/api/productcategories_client.py +400 -0
- moloni/api/products_client.py +1252 -0
- moloni/api/receipts_client.py +591 -0
- moloni/api/salesmen_client.py +580 -0
- moloni/api/simplifiedinvoices_client.py +705 -0
- moloni/api/subscription_client.py +104 -0
- moloni/api/suppliers_client.py +1264 -0
- moloni/api/taxes_client.py +477 -0
- moloni/api/taxexemptions_client.py +171 -0
- moloni/api/users_client.py +104 -0
- moloni/api/vehicles_client.py +435 -0
- moloni/api/warehouses_client.py +506 -0
- moloni/api/waybills_client.py +699 -0
- moloni/base/__init__.py +24 -0
- moloni/base/client.py +164 -0
- moloni/base/config.py +6 -0
- moloni/base/helpers.py +150 -0
- moloni/base/logger_config.py +49 -0
- python_moloni_fix-0.3.16.dist-info/METADATA +231 -0
- python_moloni_fix-0.3.16.dist-info/RECORD +52 -0
- python_moloni_fix-0.3.16.dist-info/WHEEL +5 -0
- python_moloni_fix-0.3.16.dist-info/licenses/LICENSE +21 -0
- python_moloni_fix-0.3.16.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
from pydantic import BaseModel, ValidationError
|
|
2
|
+
from typing import Union, Optional, List, Any
|
|
3
|
+
|
|
4
|
+
from moloni.base.client import MoloniBaseClient
|
|
5
|
+
from moloni.base.helpers import endpoint, fill_query_params, validate_data
|
|
6
|
+
from moloni.base import ApiResponse
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ApiRequestModel(BaseModel):
|
|
10
|
+
_api_client: Any = None
|
|
11
|
+
|
|
12
|
+
def connect(self, *args, **kwargs):
|
|
13
|
+
self._api_client = TaxesClient(*args, **kwargs)
|
|
14
|
+
return self
|
|
15
|
+
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
return self.connect()
|
|
18
|
+
|
|
19
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TaxesCountModifiedSinceModel(ApiRequestModel):
|
|
24
|
+
company_id: Union[str, int]
|
|
25
|
+
lastmodified: Optional[str] = None
|
|
26
|
+
|
|
27
|
+
def request(self) -> ApiResponse:
|
|
28
|
+
"""
|
|
29
|
+
request(self) -> ApiResponse
|
|
30
|
+
|
|
31
|
+
Make an API request using the initialized client.
|
|
32
|
+
|
|
33
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
34
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
35
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
The response from the API.
|
|
39
|
+
|
|
40
|
+
Raises:
|
|
41
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
42
|
+
|
|
43
|
+
Example:
|
|
44
|
+
|
|
45
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
46
|
+
|
|
47
|
+
..code-block:: python
|
|
48
|
+
|
|
49
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
50
|
+
response = api.request()
|
|
51
|
+
|
|
52
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
53
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
if hasattr(self, "_api_client"):
|
|
57
|
+
response = self._api_client.count_modified_since(
|
|
58
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
59
|
+
)
|
|
60
|
+
return response
|
|
61
|
+
else:
|
|
62
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class TaxesDeleteModel(ApiRequestModel):
|
|
66
|
+
company_id: Union[str, int]
|
|
67
|
+
tax_id: Optional[Union[str, int]] = None
|
|
68
|
+
|
|
69
|
+
def request(self) -> ApiResponse:
|
|
70
|
+
"""
|
|
71
|
+
request(self) -> ApiResponse
|
|
72
|
+
|
|
73
|
+
Make an API request using the initialized client.
|
|
74
|
+
|
|
75
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
76
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
77
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
The response from the API.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
|
|
87
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
88
|
+
|
|
89
|
+
..code-block:: python
|
|
90
|
+
|
|
91
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
92
|
+
response = api.request()
|
|
93
|
+
|
|
94
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
95
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
96
|
+
|
|
97
|
+
"""
|
|
98
|
+
if hasattr(self, "_api_client"):
|
|
99
|
+
response = self._api_client.delete(
|
|
100
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
101
|
+
)
|
|
102
|
+
return response
|
|
103
|
+
else:
|
|
104
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class TaxesGetAllModel(ApiRequestModel):
|
|
108
|
+
company_id: Union[str, int]
|
|
109
|
+
|
|
110
|
+
def request(self) -> ApiResponse:
|
|
111
|
+
"""
|
|
112
|
+
request(self) -> ApiResponse
|
|
113
|
+
|
|
114
|
+
Make an API request using the initialized client.
|
|
115
|
+
|
|
116
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
117
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
118
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
The response from the API.
|
|
122
|
+
|
|
123
|
+
Raises:
|
|
124
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
125
|
+
|
|
126
|
+
Example:
|
|
127
|
+
|
|
128
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
129
|
+
|
|
130
|
+
..code-block:: python
|
|
131
|
+
|
|
132
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
133
|
+
response = api.request()
|
|
134
|
+
|
|
135
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
136
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
if hasattr(self, "_api_client"):
|
|
140
|
+
response = self._api_client.get_all(
|
|
141
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
142
|
+
)
|
|
143
|
+
return response
|
|
144
|
+
else:
|
|
145
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class TaxesGetModifiedSinceModel(ApiRequestModel):
|
|
149
|
+
company_id: Union[str, int]
|
|
150
|
+
lastmodified: Optional[str] = None
|
|
151
|
+
|
|
152
|
+
def request(self) -> ApiResponse:
|
|
153
|
+
"""
|
|
154
|
+
request(self) -> ApiResponse
|
|
155
|
+
|
|
156
|
+
Make an API request using the initialized client.
|
|
157
|
+
|
|
158
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
159
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
160
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
The response from the API.
|
|
164
|
+
|
|
165
|
+
Raises:
|
|
166
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
167
|
+
|
|
168
|
+
Example:
|
|
169
|
+
|
|
170
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
171
|
+
|
|
172
|
+
..code-block:: python
|
|
173
|
+
|
|
174
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
175
|
+
response = api.request()
|
|
176
|
+
|
|
177
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
178
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
179
|
+
|
|
180
|
+
"""
|
|
181
|
+
if hasattr(self, "_api_client"):
|
|
182
|
+
response = self._api_client.get_modified_since(
|
|
183
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
184
|
+
)
|
|
185
|
+
return response
|
|
186
|
+
else:
|
|
187
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class TaxesInsertModel(ApiRequestModel):
|
|
191
|
+
company_id: Union[str, int]
|
|
192
|
+
active_by_default: Optional[str] = None
|
|
193
|
+
exemption_reason: Optional[str] = None
|
|
194
|
+
fiscal_zone: Optional[str] = None
|
|
195
|
+
name: Optional[str] = None
|
|
196
|
+
saft_type: Optional[str] = None
|
|
197
|
+
stamp_tax: Optional[str] = None
|
|
198
|
+
type: Optional[str] = None
|
|
199
|
+
value: Optional[str] = None
|
|
200
|
+
vat_type: Optional[str] = None
|
|
201
|
+
|
|
202
|
+
def request(self) -> ApiResponse:
|
|
203
|
+
"""
|
|
204
|
+
request(self) -> ApiResponse
|
|
205
|
+
|
|
206
|
+
Make an API request using the initialized client.
|
|
207
|
+
|
|
208
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
209
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
210
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
The response from the API.
|
|
214
|
+
|
|
215
|
+
Raises:
|
|
216
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
|
|
220
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
221
|
+
|
|
222
|
+
..code-block:: python
|
|
223
|
+
|
|
224
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
225
|
+
response = api.request()
|
|
226
|
+
|
|
227
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
228
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
229
|
+
|
|
230
|
+
"""
|
|
231
|
+
if hasattr(self, "_api_client"):
|
|
232
|
+
response = self._api_client.insert(
|
|
233
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
234
|
+
)
|
|
235
|
+
return response
|
|
236
|
+
else:
|
|
237
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class TaxesUpdateModel(ApiRequestModel):
|
|
241
|
+
company_id: Union[str, int]
|
|
242
|
+
active_by_default: Optional[str] = None
|
|
243
|
+
exemption_reason: Optional[str] = None
|
|
244
|
+
fiscal_zone: Optional[str] = None
|
|
245
|
+
name: Optional[str] = None
|
|
246
|
+
saft_type: Optional[str] = None
|
|
247
|
+
stamp_tax: Optional[str] = None
|
|
248
|
+
tax_id: Optional[Union[str, int]] = None
|
|
249
|
+
type: Optional[str] = None
|
|
250
|
+
value: Optional[str] = None
|
|
251
|
+
vat_type: Optional[str] = None
|
|
252
|
+
|
|
253
|
+
def request(self) -> ApiResponse:
|
|
254
|
+
"""
|
|
255
|
+
request(self) -> ApiResponse
|
|
256
|
+
|
|
257
|
+
Make an API request using the initialized client.
|
|
258
|
+
|
|
259
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
260
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
261
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
262
|
+
|
|
263
|
+
Returns:
|
|
264
|
+
The response from the API.
|
|
265
|
+
|
|
266
|
+
Raises:
|
|
267
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
268
|
+
|
|
269
|
+
Example:
|
|
270
|
+
|
|
271
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
272
|
+
|
|
273
|
+
..code-block:: python
|
|
274
|
+
|
|
275
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
276
|
+
response = api.request()
|
|
277
|
+
|
|
278
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
279
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
280
|
+
|
|
281
|
+
"""
|
|
282
|
+
if hasattr(self, "_api_client"):
|
|
283
|
+
response = self._api_client.update(
|
|
284
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
285
|
+
)
|
|
286
|
+
return response
|
|
287
|
+
else:
|
|
288
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class TaxesClient(MoloniBaseClient):
|
|
292
|
+
|
|
293
|
+
@endpoint("/<version>/taxes/countModifiedSince/", method="post")
|
|
294
|
+
def count_modified_since(
|
|
295
|
+
self, data: Union[TaxesCountModifiedSinceModel, dict], **kwargs
|
|
296
|
+
):
|
|
297
|
+
"""
|
|
298
|
+
count_modified_since(self, data: Union[TaxesCountModifiedSinceModel, dict], **kwargs)
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
|
|
302
|
+
data (Union[TaxesCountModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
|
|
303
|
+
|
|
304
|
+
- company_id (Union[str, int]): company_id of the TaxesCountModifiedSinceModel.
|
|
305
|
+
|
|
306
|
+
- lastmodified (str): lastmodified of the TaxesCountModifiedSinceModel.
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
ApiResponse: The response from the API.
|
|
312
|
+
"""
|
|
313
|
+
|
|
314
|
+
data = validate_data(data, self.validate, TaxesCountModifiedSinceModel)
|
|
315
|
+
|
|
316
|
+
return self._request(
|
|
317
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
@endpoint("/<version>/taxes/delete/", method="post")
|
|
321
|
+
def delete(self, data: Union[TaxesDeleteModel, dict], **kwargs):
|
|
322
|
+
"""
|
|
323
|
+
delete(self, data: Union[TaxesDeleteModel, dict], **kwargs)
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
|
|
327
|
+
data (Union[TaxesDeleteModel, dict]): A model instance or dictionary containing the following fields:
|
|
328
|
+
|
|
329
|
+
- company_id (Union[str, int]): company_id of the TaxesDeleteModel.
|
|
330
|
+
|
|
331
|
+
- tax_id (Union[str, int]): tax_id of the TaxesDeleteModel.
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
ApiResponse: The response from the API.
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
data = validate_data(data, self.validate, TaxesDeleteModel)
|
|
340
|
+
|
|
341
|
+
return self._request(
|
|
342
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
@endpoint("/<version>/taxes/getAll/", method="post")
|
|
346
|
+
def get_all(self, data: Union[TaxesGetAllModel, dict], **kwargs):
|
|
347
|
+
"""
|
|
348
|
+
get_all(self, data: Union[TaxesGetAllModel, dict], **kwargs)
|
|
349
|
+
|
|
350
|
+
Args:
|
|
351
|
+
|
|
352
|
+
data (Union[TaxesGetAllModel, dict]): A model instance or dictionary containing the following fields:
|
|
353
|
+
|
|
354
|
+
- company_id (Union[str, int]): company_id of the TaxesGetAllModel.
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
Returns:
|
|
359
|
+
ApiResponse: The response from the API.
|
|
360
|
+
"""
|
|
361
|
+
|
|
362
|
+
data = validate_data(data, self.validate, TaxesGetAllModel)
|
|
363
|
+
|
|
364
|
+
return self._request(
|
|
365
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
@endpoint("/<version>/taxes/getModifiedSince/", method="post")
|
|
369
|
+
def get_modified_since(
|
|
370
|
+
self, data: Union[TaxesGetModifiedSinceModel, dict], **kwargs
|
|
371
|
+
):
|
|
372
|
+
"""
|
|
373
|
+
get_modified_since(self, data: Union[TaxesGetModifiedSinceModel, dict], **kwargs)
|
|
374
|
+
|
|
375
|
+
Args:
|
|
376
|
+
|
|
377
|
+
data (Union[TaxesGetModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
|
|
378
|
+
|
|
379
|
+
- company_id (Union[str, int]): company_id of the TaxesGetModifiedSinceModel.
|
|
380
|
+
|
|
381
|
+
- lastmodified (str): lastmodified of the TaxesGetModifiedSinceModel.
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
Returns:
|
|
386
|
+
ApiResponse: The response from the API.
|
|
387
|
+
"""
|
|
388
|
+
|
|
389
|
+
data = validate_data(data, self.validate, TaxesGetModifiedSinceModel)
|
|
390
|
+
|
|
391
|
+
return self._request(
|
|
392
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
@endpoint("/<version>/taxes/insert/", method="post")
|
|
396
|
+
def insert(self, data: Union[TaxesInsertModel, dict], **kwargs):
|
|
397
|
+
"""
|
|
398
|
+
insert(self, data: Union[TaxesInsertModel, dict], **kwargs)
|
|
399
|
+
|
|
400
|
+
Args:
|
|
401
|
+
|
|
402
|
+
data (Union[TaxesInsertModel, dict]): A model instance or dictionary containing the following fields:
|
|
403
|
+
|
|
404
|
+
- active_by_default (str): active_by_default of the TaxesInsertModel.
|
|
405
|
+
|
|
406
|
+
- company_id (Union[str, int]): company_id of the TaxesInsertModel.
|
|
407
|
+
|
|
408
|
+
- exemption_reason (str): exemption_reason of the TaxesInsertModel.
|
|
409
|
+
|
|
410
|
+
- fiscal_zone (str): fiscal_zone of the TaxesInsertModel.
|
|
411
|
+
|
|
412
|
+
- name (str): name of the TaxesInsertModel.
|
|
413
|
+
|
|
414
|
+
- saft_type (str): saft_type of the TaxesInsertModel.
|
|
415
|
+
|
|
416
|
+
- stamp_tax (str): stamp_tax of the TaxesInsertModel.
|
|
417
|
+
|
|
418
|
+
- type (str): type of the TaxesInsertModel.
|
|
419
|
+
|
|
420
|
+
- value (str): value of the TaxesInsertModel.
|
|
421
|
+
|
|
422
|
+
- vat_type (str): vat_type of the TaxesInsertModel.
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
Returns:
|
|
427
|
+
ApiResponse: The response from the API.
|
|
428
|
+
"""
|
|
429
|
+
|
|
430
|
+
data = validate_data(data, self.validate, TaxesInsertModel)
|
|
431
|
+
|
|
432
|
+
return self._request(
|
|
433
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
@endpoint("/<version>/taxes/update/", method="post")
|
|
437
|
+
def update(self, data: Union[TaxesUpdateModel, dict], **kwargs):
|
|
438
|
+
"""
|
|
439
|
+
update(self, data: Union[TaxesUpdateModel, dict], **kwargs)
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
|
|
443
|
+
data (Union[TaxesUpdateModel, dict]): A model instance or dictionary containing the following fields:
|
|
444
|
+
|
|
445
|
+
- active_by_default (str): active_by_default of the TaxesUpdateModel.
|
|
446
|
+
|
|
447
|
+
- company_id (Union[str, int]): company_id of the TaxesUpdateModel.
|
|
448
|
+
|
|
449
|
+
- exemption_reason (str): exemption_reason of the TaxesUpdateModel.
|
|
450
|
+
|
|
451
|
+
- fiscal_zone (str): fiscal_zone of the TaxesUpdateModel.
|
|
452
|
+
|
|
453
|
+
- name (str): name of the TaxesUpdateModel.
|
|
454
|
+
|
|
455
|
+
- saft_type (str): saft_type of the TaxesUpdateModel.
|
|
456
|
+
|
|
457
|
+
- stamp_tax (str): stamp_tax of the TaxesUpdateModel.
|
|
458
|
+
|
|
459
|
+
- tax_id (Union[str, int]): tax_id of the TaxesUpdateModel.
|
|
460
|
+
|
|
461
|
+
- type (str): type of the TaxesUpdateModel.
|
|
462
|
+
|
|
463
|
+
- value (str): value of the TaxesUpdateModel.
|
|
464
|
+
|
|
465
|
+
- vat_type (str): vat_type of the TaxesUpdateModel.
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
Returns:
|
|
470
|
+
ApiResponse: The response from the API.
|
|
471
|
+
"""
|
|
472
|
+
|
|
473
|
+
data = validate_data(data, self.validate, TaxesUpdateModel)
|
|
474
|
+
|
|
475
|
+
return self._request(
|
|
476
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
477
|
+
)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
from pydantic import BaseModel, ValidationError
|
|
2
|
+
from typing import Union, Optional, List, Any
|
|
3
|
+
|
|
4
|
+
from moloni.base.client import MoloniBaseClient
|
|
5
|
+
from moloni.base.helpers import endpoint, fill_query_params, validate_data
|
|
6
|
+
from moloni.base import ApiResponse
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ApiRequestModel(BaseModel):
|
|
10
|
+
_api_client: Any = None
|
|
11
|
+
|
|
12
|
+
def connect(self, *args, **kwargs):
|
|
13
|
+
self._api_client = TaxexemptionsClient(*args, **kwargs)
|
|
14
|
+
return self
|
|
15
|
+
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
return self.connect()
|
|
18
|
+
|
|
19
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TaxexemptionsCountModifiedSinceModel(ApiRequestModel):
|
|
24
|
+
lastmodified: Optional[str] = None
|
|
25
|
+
|
|
26
|
+
def request(self) -> ApiResponse:
|
|
27
|
+
"""
|
|
28
|
+
request(self) -> ApiResponse
|
|
29
|
+
|
|
30
|
+
Make an API request using the initialized client.
|
|
31
|
+
|
|
32
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
33
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
34
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
The response from the API.
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
41
|
+
|
|
42
|
+
Example:
|
|
43
|
+
|
|
44
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
45
|
+
|
|
46
|
+
..code-block:: python
|
|
47
|
+
|
|
48
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
49
|
+
response = api.request()
|
|
50
|
+
|
|
51
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
52
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
if hasattr(self, "_api_client"):
|
|
56
|
+
response = self._api_client.count_modified_since(
|
|
57
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
58
|
+
)
|
|
59
|
+
return response
|
|
60
|
+
else:
|
|
61
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TaxexemptionsGetModifiedSinceModel(ApiRequestModel):
|
|
65
|
+
lastmodified: Optional[str] = None
|
|
66
|
+
|
|
67
|
+
def request(self) -> ApiResponse:
|
|
68
|
+
"""
|
|
69
|
+
request(self) -> ApiResponse
|
|
70
|
+
|
|
71
|
+
Make an API request using the initialized client.
|
|
72
|
+
|
|
73
|
+
This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
|
|
74
|
+
If the client is initialized, it will make an API request using the provided method name and the model's data,
|
|
75
|
+
excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
The response from the API.
|
|
79
|
+
|
|
80
|
+
Raises:
|
|
81
|
+
ValueError: If the client is not initialized via the `connect` method.
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
|
|
85
|
+
# Assuming you have a model instance `request_model` and an API client `api_client`
|
|
86
|
+
|
|
87
|
+
..code-block:: python
|
|
88
|
+
|
|
89
|
+
with request_model.connect(auth_config=auth_config) as api:
|
|
90
|
+
response = api.request()
|
|
91
|
+
|
|
92
|
+
# The above example assumes that the `connect` method has been used to initialize the client.
|
|
93
|
+
# The request method then sends the model's data to the API and returns the API's response.
|
|
94
|
+
|
|
95
|
+
"""
|
|
96
|
+
if hasattr(self, "_api_client"):
|
|
97
|
+
response = self._api_client.get_modified_since(
|
|
98
|
+
self.model_dump(exclude={"_api_client"}, exclude_unset=True)
|
|
99
|
+
)
|
|
100
|
+
return response
|
|
101
|
+
else:
|
|
102
|
+
raise ValueError("Client not initialized. Use the 'connect' method.")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class TaxexemptionsClient(MoloniBaseClient):
|
|
106
|
+
|
|
107
|
+
@endpoint("/<version>/taxExemptions/countModifiedSince/", method="post")
|
|
108
|
+
def count_modified_since(
|
|
109
|
+
self, data: Union[TaxexemptionsCountModifiedSinceModel, dict], **kwargs
|
|
110
|
+
):
|
|
111
|
+
"""
|
|
112
|
+
count_modified_since(self, data: Union[TaxexemptionsCountModifiedSinceModel, dict], **kwargs)
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
|
|
116
|
+
data (Union[TaxexemptionsCountModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
|
|
117
|
+
|
|
118
|
+
- lastmodified (str): lastmodified of the TaxexemptionsCountModifiedSinceModel.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
ApiResponse: The response from the API.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
data = validate_data(data, self.validate, TaxexemptionsCountModifiedSinceModel)
|
|
127
|
+
|
|
128
|
+
return self._request(
|
|
129
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
@endpoint("/<version>/taxExemptions/getAll/", method="post")
|
|
133
|
+
def get_all(self, **kwargs):
|
|
134
|
+
"""
|
|
135
|
+
get_all(self, **kwargs)
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
ApiResponse: The response from the API.
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
return self._request(
|
|
145
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**kwargs}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@endpoint("/<version>/taxExemptions/getModifiedSince/", method="post")
|
|
149
|
+
def get_modified_since(
|
|
150
|
+
self, data: Union[TaxexemptionsGetModifiedSinceModel, dict], **kwargs
|
|
151
|
+
):
|
|
152
|
+
"""
|
|
153
|
+
get_modified_since(self, data: Union[TaxexemptionsGetModifiedSinceModel, dict], **kwargs)
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
|
|
157
|
+
data (Union[TaxexemptionsGetModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
|
|
158
|
+
|
|
159
|
+
- lastmodified (str): lastmodified of the TaxexemptionsGetModifiedSinceModel.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
ApiResponse: The response from the API.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
data = validate_data(data, self.validate, TaxexemptionsGetModifiedSinceModel)
|
|
168
|
+
|
|
169
|
+
return self._request(
|
|
170
|
+
fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
|
|
171
|
+
)
|