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,506 @@
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 = WarehousesClient(*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 Suppliers(BaseModel):
24
+ cost_price: Optional[Any] = None
25
+ supplier_id: Optional[Any] = None
26
+
27
+
28
+ class Taxes(BaseModel):
29
+ cumulative: Optional[Any] = None
30
+ order: Optional[Any] = None
31
+ tax_id: Optional[Any] = None
32
+ value: Optional[Any] = None
33
+
34
+
35
+ class Warehouses(BaseModel):
36
+ stock: Optional[Any] = None
37
+ warehouse_id: Optional[Any] = None
38
+
39
+
40
+ class WarehousesCountModifiedSinceModel(ApiRequestModel):
41
+ company_id: Union[str, int]
42
+ lastmodified: Optional[str] = None
43
+
44
+ def request(self) -> ApiResponse:
45
+ """
46
+ request(self) -> ApiResponse
47
+
48
+ Make an API request using the initialized client.
49
+
50
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
51
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
52
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
53
+
54
+ Returns:
55
+ The response from the API.
56
+
57
+ Raises:
58
+ ValueError: If the client is not initialized via the `connect` method.
59
+
60
+ Example:
61
+
62
+ # Assuming you have a model instance `request_model` and an API client `api_client`
63
+
64
+ ..code-block:: python
65
+
66
+ with request_model.connect(auth_config=auth_config) as api:
67
+ response = api.request()
68
+
69
+ # The above example assumes that the `connect` method has been used to initialize the client.
70
+ # The request method then sends the model's data to the API and returns the API's response.
71
+
72
+ """
73
+ if hasattr(self, "_api_client"):
74
+ response = self._api_client.count_modified_since(
75
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
76
+ )
77
+ return response
78
+ else:
79
+ raise ValueError("Client not initialized. Use the 'connect' method.")
80
+
81
+
82
+ class WarehousesDeleteModel(ApiRequestModel):
83
+ company_id: Union[str, int]
84
+ warehouse_id: Optional[Union[str, int]] = None
85
+
86
+ def request(self) -> ApiResponse:
87
+ """
88
+ request(self) -> ApiResponse
89
+
90
+ Make an API request using the initialized client.
91
+
92
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
93
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
94
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
95
+
96
+ Returns:
97
+ The response from the API.
98
+
99
+ Raises:
100
+ ValueError: If the client is not initialized via the `connect` method.
101
+
102
+ Example:
103
+
104
+ # Assuming you have a model instance `request_model` and an API client `api_client`
105
+
106
+ ..code-block:: python
107
+
108
+ with request_model.connect(auth_config=auth_config) as api:
109
+ response = api.request()
110
+
111
+ # The above example assumes that the `connect` method has been used to initialize the client.
112
+ # The request method then sends the model's data to the API and returns the API's response.
113
+
114
+ """
115
+ if hasattr(self, "_api_client"):
116
+ response = self._api_client.delete(
117
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
118
+ )
119
+ return response
120
+ else:
121
+ raise ValueError("Client not initialized. Use the 'connect' method.")
122
+
123
+
124
+ class WarehousesGetAllModel(ApiRequestModel):
125
+ company_id: Union[str, int]
126
+
127
+ def request(self) -> ApiResponse:
128
+ """
129
+ request(self) -> ApiResponse
130
+
131
+ Make an API request using the initialized client.
132
+
133
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
134
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
135
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
136
+
137
+ Returns:
138
+ The response from the API.
139
+
140
+ Raises:
141
+ ValueError: If the client is not initialized via the `connect` method.
142
+
143
+ Example:
144
+
145
+ # Assuming you have a model instance `request_model` and an API client `api_client`
146
+
147
+ ..code-block:: python
148
+
149
+ with request_model.connect(auth_config=auth_config) as api:
150
+ response = api.request()
151
+
152
+ # The above example assumes that the `connect` method has been used to initialize the client.
153
+ # The request method then sends the model's data to the API and returns the API's response.
154
+
155
+ """
156
+ if hasattr(self, "_api_client"):
157
+ response = self._api_client.get_all(
158
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
159
+ )
160
+ return response
161
+ else:
162
+ raise ValueError("Client not initialized. Use the 'connect' method.")
163
+
164
+
165
+ class WarehousesGetModifiedSinceModel(ApiRequestModel):
166
+ company_id: Union[str, int]
167
+ lastmodified: Optional[str] = None
168
+
169
+ def request(self) -> ApiResponse:
170
+ """
171
+ request(self) -> ApiResponse
172
+
173
+ Make an API request using the initialized client.
174
+
175
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
176
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
177
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
178
+
179
+ Returns:
180
+ The response from the API.
181
+
182
+ Raises:
183
+ ValueError: If the client is not initialized via the `connect` method.
184
+
185
+ Example:
186
+
187
+ # Assuming you have a model instance `request_model` and an API client `api_client`
188
+
189
+ ..code-block:: python
190
+
191
+ with request_model.connect(auth_config=auth_config) as api:
192
+ response = api.request()
193
+
194
+ # The above example assumes that the `connect` method has been used to initialize the client.
195
+ # The request method then sends the model's data to the API and returns the API's response.
196
+
197
+ """
198
+ if hasattr(self, "_api_client"):
199
+ response = self._api_client.get_modified_since(
200
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
201
+ )
202
+ return response
203
+ else:
204
+ raise ValueError("Client not initialized. Use the 'connect' method.")
205
+
206
+
207
+ class WarehousesInsertModel(ApiRequestModel):
208
+ company_id: Union[str, int]
209
+ address: Optional[str] = None
210
+ city: Optional[str] = None
211
+ code: Optional[str] = None
212
+ contact_email: Optional[str] = None
213
+ contact_name: Optional[str] = None
214
+ country_id: Optional[Union[str, int]] = None
215
+ fax: Optional[str] = None
216
+ is_default: Optional[bool] = None
217
+ phone: Optional[str] = None
218
+ title: Optional[str] = None
219
+ zip_code: Optional[str] = None
220
+
221
+ def request(self) -> ApiResponse:
222
+ """
223
+ request(self) -> ApiResponse
224
+
225
+ Make an API request using the initialized client.
226
+
227
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
228
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
229
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
230
+
231
+ Returns:
232
+ The response from the API.
233
+
234
+ Raises:
235
+ ValueError: If the client is not initialized via the `connect` method.
236
+
237
+ Example:
238
+
239
+ # Assuming you have a model instance `request_model` and an API client `api_client`
240
+
241
+ ..code-block:: python
242
+
243
+ with request_model.connect(auth_config=auth_config) as api:
244
+ response = api.request()
245
+
246
+ # The above example assumes that the `connect` method has been used to initialize the client.
247
+ # The request method then sends the model's data to the API and returns the API's response.
248
+
249
+ """
250
+ if hasattr(self, "_api_client"):
251
+ response = self._api_client.insert(
252
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
253
+ )
254
+ return response
255
+ else:
256
+ raise ValueError("Client not initialized. Use the 'connect' method.")
257
+
258
+
259
+ class WarehousesUpdateModel(ApiRequestModel):
260
+ company_id: Union[str, int]
261
+ address: Optional[str] = None
262
+ city: Optional[str] = None
263
+ code: Optional[str] = None
264
+ contact_email: Optional[str] = None
265
+ contact_name: Optional[str] = None
266
+ country_id: Optional[Union[str, int]] = None
267
+ fax: Optional[str] = None
268
+ is_default: Optional[bool] = None
269
+ phone: Optional[str] = None
270
+ title: Optional[str] = None
271
+ warehouse_id: Optional[Union[str, int]] = None
272
+ zip_code: Optional[str] = None
273
+
274
+ def request(self) -> ApiResponse:
275
+ """
276
+ request(self) -> ApiResponse
277
+
278
+ Make an API request using the initialized client.
279
+
280
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
281
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
282
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
283
+
284
+ Returns:
285
+ The response from the API.
286
+
287
+ Raises:
288
+ ValueError: If the client is not initialized via the `connect` method.
289
+
290
+ Example:
291
+
292
+ # Assuming you have a model instance `request_model` and an API client `api_client`
293
+
294
+ ..code-block:: python
295
+
296
+ with request_model.connect(auth_config=auth_config) as api:
297
+ response = api.request()
298
+
299
+ # The above example assumes that the `connect` method has been used to initialize the client.
300
+ # The request method then sends the model's data to the API and returns the API's response.
301
+
302
+ """
303
+ if hasattr(self, "_api_client"):
304
+ response = self._api_client.update(
305
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
306
+ )
307
+ return response
308
+ else:
309
+ raise ValueError("Client not initialized. Use the 'connect' method.")
310
+
311
+
312
+ class WarehousesClient(MoloniBaseClient):
313
+
314
+ @endpoint("/<version>/warehouses/countModifiedSince/", method="post")
315
+ def count_modified_since(
316
+ self, data: Union[WarehousesCountModifiedSinceModel, dict], **kwargs
317
+ ):
318
+ """
319
+ count_modified_since(self, data: Union[WarehousesCountModifiedSinceModel, dict], **kwargs)
320
+
321
+ Args:
322
+
323
+ data (Union[WarehousesCountModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
324
+
325
+ - company_id (Union[str, int]): company_id of the WarehousesCountModifiedSinceModel.
326
+
327
+ - lastmodified (str): lastmodified of the WarehousesCountModifiedSinceModel.
328
+
329
+
330
+
331
+ Returns:
332
+ ApiResponse: The response from the API.
333
+ """
334
+
335
+ data = validate_data(data, self.validate, WarehousesCountModifiedSinceModel)
336
+
337
+ return self._request(
338
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
339
+ )
340
+
341
+ @endpoint("/<version>/warehouses/delete/", method="post")
342
+ def delete(self, data: Union[WarehousesDeleteModel, dict], **kwargs):
343
+ """
344
+ delete(self, data: Union[WarehousesDeleteModel, dict], **kwargs)
345
+
346
+ Args:
347
+
348
+ data (Union[WarehousesDeleteModel, dict]): A model instance or dictionary containing the following fields:
349
+
350
+ - company_id (Union[str, int]): company_id of the WarehousesDeleteModel.
351
+
352
+ - warehouse_id (Union[str, int]): warehouse_id of the WarehousesDeleteModel.
353
+
354
+
355
+
356
+ Returns:
357
+ ApiResponse: The response from the API.
358
+ """
359
+
360
+ data = validate_data(data, self.validate, WarehousesDeleteModel)
361
+
362
+ return self._request(
363
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
364
+ )
365
+
366
+ @endpoint("/<version>/warehouses/getAll/", method="post")
367
+ def get_all(self, data: Union[WarehousesGetAllModel, dict], **kwargs):
368
+ """
369
+ get_all(self, data: Union[WarehousesGetAllModel, dict], **kwargs)
370
+
371
+ Args:
372
+
373
+ data (Union[WarehousesGetAllModel, dict]): A model instance or dictionary containing the following fields:
374
+
375
+ - company_id (Union[str, int]): company_id of the WarehousesGetAllModel.
376
+
377
+
378
+
379
+ Returns:
380
+ ApiResponse: The response from the API.
381
+ """
382
+
383
+ data = validate_data(data, self.validate, WarehousesGetAllModel)
384
+
385
+ return self._request(
386
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
387
+ )
388
+
389
+ @endpoint("/<version>/warehouses/getModifiedSince/", method="post")
390
+ def get_modified_since(
391
+ self, data: Union[WarehousesGetModifiedSinceModel, dict], **kwargs
392
+ ):
393
+ """
394
+ get_modified_since(self, data: Union[WarehousesGetModifiedSinceModel, dict], **kwargs)
395
+
396
+ Args:
397
+
398
+ data (Union[WarehousesGetModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
399
+
400
+ - company_id (Union[str, int]): company_id of the WarehousesGetModifiedSinceModel.
401
+
402
+ - lastmodified (str): lastmodified of the WarehousesGetModifiedSinceModel.
403
+
404
+
405
+
406
+ Returns:
407
+ ApiResponse: The response from the API.
408
+ """
409
+
410
+ data = validate_data(data, self.validate, WarehousesGetModifiedSinceModel)
411
+
412
+ return self._request(
413
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
414
+ )
415
+
416
+ @endpoint("/<version>/warehouses/insert/", method="post")
417
+ def insert(self, data: Union[WarehousesInsertModel, dict], **kwargs):
418
+ """
419
+ insert(self, data: Union[WarehousesInsertModel, dict], **kwargs)
420
+
421
+ Args:
422
+
423
+ data (Union[WarehousesInsertModel, dict]): A model instance or dictionary containing the following fields:
424
+
425
+ - address (str): address of the WarehousesInsertModel.
426
+
427
+ - city (str): city of the WarehousesInsertModel.
428
+
429
+ - code (str): code of the WarehousesInsertModel.
430
+
431
+ - company_id (Union[str, int]): company_id of the WarehousesInsertModel.
432
+
433
+ - contact_email (str): contact_email of the WarehousesInsertModel.
434
+
435
+ - contact_name (str): contact_name of the WarehousesInsertModel.
436
+
437
+ - country_id (Union[str, int]): country_id of the WarehousesInsertModel.
438
+
439
+ - fax (str): fax of the WarehousesInsertModel.
440
+
441
+ - is_default (bool): is_default of the WarehousesInsertModel.
442
+
443
+ - phone (str): phone of the WarehousesInsertModel.
444
+
445
+ - title (str): title of the WarehousesInsertModel.
446
+
447
+ - zip_code (str): zip_code of the WarehousesInsertModel.
448
+
449
+
450
+
451
+ Returns:
452
+ ApiResponse: The response from the API.
453
+ """
454
+
455
+ data = validate_data(data, self.validate, WarehousesInsertModel)
456
+
457
+ return self._request(
458
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
459
+ )
460
+
461
+ @endpoint("/<version>/warehouses/update/", method="post")
462
+ def update(self, data: Union[WarehousesUpdateModel, dict], **kwargs):
463
+ """
464
+ update(self, data: Union[WarehousesUpdateModel, dict], **kwargs)
465
+
466
+ Args:
467
+
468
+ data (Union[WarehousesUpdateModel, dict]): A model instance or dictionary containing the following fields:
469
+
470
+ - address (str): address of the WarehousesUpdateModel.
471
+
472
+ - city (str): city of the WarehousesUpdateModel.
473
+
474
+ - code (str): code of the WarehousesUpdateModel.
475
+
476
+ - company_id (Union[str, int]): company_id of the WarehousesUpdateModel.
477
+
478
+ - contact_email (str): contact_email of the WarehousesUpdateModel.
479
+
480
+ - contact_name (str): contact_name of the WarehousesUpdateModel.
481
+
482
+ - country_id (Union[str, int]): country_id of the WarehousesUpdateModel.
483
+
484
+ - fax (str): fax of the WarehousesUpdateModel.
485
+
486
+ - is_default (bool): is_default of the WarehousesUpdateModel.
487
+
488
+ - phone (str): phone of the WarehousesUpdateModel.
489
+
490
+ - title (str): title of the WarehousesUpdateModel.
491
+
492
+ - warehouse_id (Union[str, int]): warehouse_id of the WarehousesUpdateModel.
493
+
494
+ - zip_code (str): zip_code of the WarehousesUpdateModel.
495
+
496
+
497
+
498
+ Returns:
499
+ ApiResponse: The response from the API.
500
+ """
501
+
502
+ data = validate_data(data, self.validate, WarehousesUpdateModel)
503
+
504
+ return self._request(
505
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
506
+ )