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.
Files changed (52) hide show
  1. moloni/__init__.py +0 -0
  2. moloni/__version__.py +1 -0
  3. moloni/api/__init__.py +701 -0
  4. moloni/api/bankaccounts_client.py +372 -0
  5. moloni/api/billsoflading_client.py +693 -0
  6. moloni/api/companies_client.py +322 -0
  7. moloni/api/countries_client.py +171 -0
  8. moloni/api/creditnotes_client.py +615 -0
  9. moloni/api/currencies_client.py +171 -0
  10. moloni/api/customeralternateaddresses_client.py +519 -0
  11. moloni/api/customerreturnnotes_client.py +701 -0
  12. moloni/api/customers_client.py +1413 -0
  13. moloni/api/debitnotes_client.py +597 -0
  14. moloni/api/deductions_client.py +435 -0
  15. moloni/api/deliverymethods_client.py +431 -0
  16. moloni/api/deliverynotes_client.py +714 -0
  17. moloni/api/documentmodels_client.py +171 -0
  18. moloni/api/documents_client.py +472 -0
  19. moloni/api/documentsets_client.py +447 -0
  20. moloni/api/estimates_client.py +663 -0
  21. moloni/api/fiscalzones_client.py +219 -0
  22. moloni/api/identificationtemplates_client.py +513 -0
  23. moloni/api/invoicereceipts_client.py +705 -0
  24. moloni/api/invoices_client.py +705 -0
  25. moloni/api/languages_client.py +171 -0
  26. moloni/api/maturitydates_client.py +441 -0
  27. moloni/api/measurementunits_client.py +437 -0
  28. moloni/api/ownassetsmovementguides_client.py +683 -0
  29. moloni/api/paymentmethods_client.py +429 -0
  30. moloni/api/productcategories_client.py +400 -0
  31. moloni/api/products_client.py +1252 -0
  32. moloni/api/receipts_client.py +591 -0
  33. moloni/api/salesmen_client.py +580 -0
  34. moloni/api/simplifiedinvoices_client.py +705 -0
  35. moloni/api/subscription_client.py +104 -0
  36. moloni/api/suppliers_client.py +1264 -0
  37. moloni/api/taxes_client.py +477 -0
  38. moloni/api/taxexemptions_client.py +171 -0
  39. moloni/api/users_client.py +104 -0
  40. moloni/api/vehicles_client.py +435 -0
  41. moloni/api/warehouses_client.py +506 -0
  42. moloni/api/waybills_client.py +699 -0
  43. moloni/base/__init__.py +24 -0
  44. moloni/base/client.py +164 -0
  45. moloni/base/config.py +6 -0
  46. moloni/base/helpers.py +150 -0
  47. moloni/base/logger_config.py +49 -0
  48. python_moloni_fix-0.3.16.dist-info/METADATA +231 -0
  49. python_moloni_fix-0.3.16.dist-info/RECORD +52 -0
  50. python_moloni_fix-0.3.16.dist-info/WHEEL +5 -0
  51. python_moloni_fix-0.3.16.dist-info/licenses/LICENSE +21 -0
  52. python_moloni_fix-0.3.16.dist-info/top_level.txt +1 -0
@@ -0,0 +1,435 @@
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 = DeductionsClient(*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 DeductionsCountModifiedSinceModel(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 DeductionsDeleteModel(ApiRequestModel):
66
+ company_id: Union[str, int]
67
+ deduction_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 DeductionsGetAllModel(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 DeductionsGetModifiedSinceModel(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 DeductionsInsertModel(ApiRequestModel):
191
+ company_id: Union[str, int]
192
+ name: Optional[str] = None
193
+ value: Optional[str] = None
194
+
195
+ def request(self) -> ApiResponse:
196
+ """
197
+ request(self) -> ApiResponse
198
+
199
+ Make an API request using the initialized client.
200
+
201
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
202
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
203
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
204
+
205
+ Returns:
206
+ The response from the API.
207
+
208
+ Raises:
209
+ ValueError: If the client is not initialized via the `connect` method.
210
+
211
+ Example:
212
+
213
+ # Assuming you have a model instance `request_model` and an API client `api_client`
214
+
215
+ ..code-block:: python
216
+
217
+ with request_model.connect(auth_config=auth_config) as api:
218
+ response = api.request()
219
+
220
+ # The above example assumes that the `connect` method has been used to initialize the client.
221
+ # The request method then sends the model's data to the API and returns the API's response.
222
+
223
+ """
224
+ if hasattr(self, "_api_client"):
225
+ response = self._api_client.insert(
226
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
227
+ )
228
+ return response
229
+ else:
230
+ raise ValueError("Client not initialized. Use the 'connect' method.")
231
+
232
+
233
+ class DeductionsUpdateModel(ApiRequestModel):
234
+ company_id: Union[str, int]
235
+ deduction_id: Optional[Union[str, int]] = None
236
+ name: Optional[str] = None
237
+ value: Optional[str] = None
238
+
239
+ def request(self) -> ApiResponse:
240
+ """
241
+ request(self) -> ApiResponse
242
+
243
+ Make an API request using the initialized client.
244
+
245
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
246
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
247
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
248
+
249
+ Returns:
250
+ The response from the API.
251
+
252
+ Raises:
253
+ ValueError: If the client is not initialized via the `connect` method.
254
+
255
+ Example:
256
+
257
+ # Assuming you have a model instance `request_model` and an API client `api_client`
258
+
259
+ ..code-block:: python
260
+
261
+ with request_model.connect(auth_config=auth_config) as api:
262
+ response = api.request()
263
+
264
+ # The above example assumes that the `connect` method has been used to initialize the client.
265
+ # The request method then sends the model's data to the API and returns the API's response.
266
+
267
+ """
268
+ if hasattr(self, "_api_client"):
269
+ response = self._api_client.update(
270
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
271
+ )
272
+ return response
273
+ else:
274
+ raise ValueError("Client not initialized. Use the 'connect' method.")
275
+
276
+
277
+ class DeductionsClient(MoloniBaseClient):
278
+
279
+ @endpoint("/<version>/deductions/countModifiedSince/", method="post")
280
+ def count_modified_since(
281
+ self, data: Union[DeductionsCountModifiedSinceModel, dict], **kwargs
282
+ ):
283
+ """
284
+ count_modified_since(self, data: Union[DeductionsCountModifiedSinceModel, dict], **kwargs)
285
+
286
+ Args:
287
+
288
+ data (Union[DeductionsCountModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
289
+
290
+ - company_id (Union[str, int]): company_id of the DeductionsCountModifiedSinceModel.
291
+
292
+ - lastmodified (str): lastmodified of the DeductionsCountModifiedSinceModel.
293
+
294
+
295
+
296
+ Returns:
297
+ ApiResponse: The response from the API.
298
+ """
299
+
300
+ data = validate_data(data, self.validate, DeductionsCountModifiedSinceModel)
301
+
302
+ return self._request(
303
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
304
+ )
305
+
306
+ @endpoint("/<version>/deductions/delete/", method="post")
307
+ def delete(self, data: Union[DeductionsDeleteModel, dict], **kwargs):
308
+ """
309
+ delete(self, data: Union[DeductionsDeleteModel, dict], **kwargs)
310
+
311
+ Args:
312
+
313
+ data (Union[DeductionsDeleteModel, dict]): A model instance or dictionary containing the following fields:
314
+
315
+ - company_id (Union[str, int]): company_id of the DeductionsDeleteModel.
316
+
317
+ - deduction_id (Union[str, int]): deduction_id of the DeductionsDeleteModel.
318
+
319
+
320
+
321
+ Returns:
322
+ ApiResponse: The response from the API.
323
+ """
324
+
325
+ data = validate_data(data, self.validate, DeductionsDeleteModel)
326
+
327
+ return self._request(
328
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
329
+ )
330
+
331
+ @endpoint("/<version>/deductions/getAll/", method="post")
332
+ def get_all(self, data: Union[DeductionsGetAllModel, dict], **kwargs):
333
+ """
334
+ get_all(self, data: Union[DeductionsGetAllModel, dict], **kwargs)
335
+
336
+ Args:
337
+
338
+ data (Union[DeductionsGetAllModel, dict]): A model instance or dictionary containing the following fields:
339
+
340
+ - company_id (Union[str, int]): company_id of the DeductionsGetAllModel.
341
+
342
+
343
+
344
+ Returns:
345
+ ApiResponse: The response from the API.
346
+ """
347
+
348
+ data = validate_data(data, self.validate, DeductionsGetAllModel)
349
+
350
+ return self._request(
351
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
352
+ )
353
+
354
+ @endpoint("/<version>/deductions/getModifiedSince/", method="post")
355
+ def get_modified_since(
356
+ self, data: Union[DeductionsGetModifiedSinceModel, dict], **kwargs
357
+ ):
358
+ """
359
+ get_modified_since(self, data: Union[DeductionsGetModifiedSinceModel, dict], **kwargs)
360
+
361
+ Args:
362
+
363
+ data (Union[DeductionsGetModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
364
+
365
+ - company_id (Union[str, int]): company_id of the DeductionsGetModifiedSinceModel.
366
+
367
+ - lastmodified (str): lastmodified of the DeductionsGetModifiedSinceModel.
368
+
369
+
370
+
371
+ Returns:
372
+ ApiResponse: The response from the API.
373
+ """
374
+
375
+ data = validate_data(data, self.validate, DeductionsGetModifiedSinceModel)
376
+
377
+ return self._request(
378
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
379
+ )
380
+
381
+ @endpoint("/<version>/deductions/insert/", method="post")
382
+ def insert(self, data: Union[DeductionsInsertModel, dict], **kwargs):
383
+ """
384
+ insert(self, data: Union[DeductionsInsertModel, dict], **kwargs)
385
+
386
+ Args:
387
+
388
+ data (Union[DeductionsInsertModel, dict]): A model instance or dictionary containing the following fields:
389
+
390
+ - company_id (Union[str, int]): company_id of the DeductionsInsertModel.
391
+
392
+ - name (str): name of the DeductionsInsertModel.
393
+
394
+ - value (str): value of the DeductionsInsertModel.
395
+
396
+
397
+
398
+ Returns:
399
+ ApiResponse: The response from the API.
400
+ """
401
+
402
+ data = validate_data(data, self.validate, DeductionsInsertModel)
403
+
404
+ return self._request(
405
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
406
+ )
407
+
408
+ @endpoint("/<version>/deductions/update/", method="post")
409
+ def update(self, data: Union[DeductionsUpdateModel, dict], **kwargs):
410
+ """
411
+ update(self, data: Union[DeductionsUpdateModel, dict], **kwargs)
412
+
413
+ Args:
414
+
415
+ data (Union[DeductionsUpdateModel, dict]): A model instance or dictionary containing the following fields:
416
+
417
+ - company_id (Union[str, int]): company_id of the DeductionsUpdateModel.
418
+
419
+ - deduction_id (Union[str, int]): deduction_id of the DeductionsUpdateModel.
420
+
421
+ - name (str): name of the DeductionsUpdateModel.
422
+
423
+ - value (str): value of the DeductionsUpdateModel.
424
+
425
+
426
+
427
+ Returns:
428
+ ApiResponse: The response from the API.
429
+ """
430
+
431
+ data = validate_data(data, self.validate, DeductionsUpdateModel)
432
+
433
+ return self._request(
434
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
435
+ )