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,580 @@
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 = SalesmenClient(*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 SalesmenCountModifiedSinceModel(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 SalesmenDeleteModel(ApiRequestModel):
66
+ company_id: Union[str, int]
67
+ salesman_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 SalesmenGetAllModel(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 SalesmenGetModifiedSinceModel(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 SalesmenGetOneModel(ApiRequestModel):
191
+ company_id: Union[str, int]
192
+ salesman_id: Optional[Union[str, int]] = None
193
+
194
+ def request(self) -> ApiResponse:
195
+ """
196
+ request(self) -> ApiResponse
197
+
198
+ Make an API request using the initialized client.
199
+
200
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
201
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
202
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
203
+
204
+ Returns:
205
+ The response from the API.
206
+
207
+ Raises:
208
+ ValueError: If the client is not initialized via the `connect` method.
209
+
210
+ Example:
211
+
212
+ # Assuming you have a model instance `request_model` and an API client `api_client`
213
+
214
+ ..code-block:: python
215
+
216
+ with request_model.connect(auth_config=auth_config) as api:
217
+ response = api.request()
218
+
219
+ # The above example assumes that the `connect` method has been used to initialize the client.
220
+ # The request method then sends the model's data to the API and returns the API's response.
221
+
222
+ """
223
+ if hasattr(self, "_api_client"):
224
+ response = self._api_client.get_one(
225
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
226
+ )
227
+ return response
228
+ else:
229
+ raise ValueError("Client not initialized. Use the 'connect' method.")
230
+
231
+
232
+ class SalesmenInsertModel(ApiRequestModel):
233
+ company_id: Union[str, int]
234
+ address: Optional[str] = None
235
+ base_commission: Optional[str] = None
236
+ city: Optional[str] = None
237
+ country_id: Optional[Union[str, int]] = None
238
+ email: Optional[str] = None
239
+ fax: Optional[str] = None
240
+ language_id: Optional[Union[str, int]] = None
241
+ name: Optional[str] = None
242
+ notes: Optional[str] = None
243
+ number: Optional[str] = None
244
+ phone: Optional[str] = None
245
+ qty_copies_document: Optional[str] = None
246
+ vat: Optional[str] = None
247
+ website: Optional[str] = None
248
+ zip_code: Optional[str] = None
249
+
250
+ def request(self) -> ApiResponse:
251
+ """
252
+ request(self) -> ApiResponse
253
+
254
+ Make an API request using the initialized client.
255
+
256
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
257
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
258
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
259
+
260
+ Returns:
261
+ The response from the API.
262
+
263
+ Raises:
264
+ ValueError: If the client is not initialized via the `connect` method.
265
+
266
+ Example:
267
+
268
+ # Assuming you have a model instance `request_model` and an API client `api_client`
269
+
270
+ ..code-block:: python
271
+
272
+ with request_model.connect(auth_config=auth_config) as api:
273
+ response = api.request()
274
+
275
+ # The above example assumes that the `connect` method has been used to initialize the client.
276
+ # The request method then sends the model's data to the API and returns the API's response.
277
+
278
+ """
279
+ if hasattr(self, "_api_client"):
280
+ response = self._api_client.insert(
281
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
282
+ )
283
+ return response
284
+ else:
285
+ raise ValueError("Client not initialized. Use the 'connect' method.")
286
+
287
+
288
+ class SalesmenUpdateModel(ApiRequestModel):
289
+ company_id: Union[str, int]
290
+ address: Optional[str] = None
291
+ base_commission: Optional[str] = None
292
+ city: Optional[str] = None
293
+ country_id: Optional[Union[str, int]] = None
294
+ email: Optional[str] = None
295
+ fax: Optional[str] = None
296
+ language_id: Optional[Union[str, int]] = None
297
+ name: Optional[str] = None
298
+ notes: Optional[str] = None
299
+ number: Optional[str] = None
300
+ phone: Optional[str] = None
301
+ qty_copies_document: Optional[str] = None
302
+ salesman_id: Optional[Union[str, int]] = None
303
+ vat: Optional[str] = None
304
+ website: Optional[str] = None
305
+ zip_code: Optional[str] = None
306
+
307
+ def request(self) -> ApiResponse:
308
+ """
309
+ request(self) -> ApiResponse
310
+
311
+ Make an API request using the initialized client.
312
+
313
+ This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method).
314
+ If the client is initialized, it will make an API request using the provided method name and the model's data,
315
+ excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`.
316
+
317
+ Returns:
318
+ The response from the API.
319
+
320
+ Raises:
321
+ ValueError: If the client is not initialized via the `connect` method.
322
+
323
+ Example:
324
+
325
+ # Assuming you have a model instance `request_model` and an API client `api_client`
326
+
327
+ ..code-block:: python
328
+
329
+ with request_model.connect(auth_config=auth_config) as api:
330
+ response = api.request()
331
+
332
+ # The above example assumes that the `connect` method has been used to initialize the client.
333
+ # The request method then sends the model's data to the API and returns the API's response.
334
+
335
+ """
336
+ if hasattr(self, "_api_client"):
337
+ response = self._api_client.update(
338
+ self.model_dump(exclude={"_api_client"}, exclude_unset=True)
339
+ )
340
+ return response
341
+ else:
342
+ raise ValueError("Client not initialized. Use the 'connect' method.")
343
+
344
+
345
+ class SalesmenClient(MoloniBaseClient):
346
+
347
+ @endpoint("/<version>/salesmen/countModifiedSince/", method="post")
348
+ def count_modified_since(
349
+ self, data: Union[SalesmenCountModifiedSinceModel, dict], **kwargs
350
+ ):
351
+ """
352
+ count_modified_since(self, data: Union[SalesmenCountModifiedSinceModel, dict], **kwargs)
353
+
354
+ Args:
355
+
356
+ data (Union[SalesmenCountModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
357
+
358
+ - company_id (Union[str, int]): company_id of the SalesmenCountModifiedSinceModel.
359
+
360
+ - lastmodified (str): lastmodified of the SalesmenCountModifiedSinceModel.
361
+
362
+
363
+
364
+ Returns:
365
+ ApiResponse: The response from the API.
366
+ """
367
+
368
+ data = validate_data(data, self.validate, SalesmenCountModifiedSinceModel)
369
+
370
+ return self._request(
371
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
372
+ )
373
+
374
+ @endpoint("/<version>/salesmen/delete/", method="post")
375
+ def delete(self, data: Union[SalesmenDeleteModel, dict], **kwargs):
376
+ """
377
+ delete(self, data: Union[SalesmenDeleteModel, dict], **kwargs)
378
+
379
+ Args:
380
+
381
+ data (Union[SalesmenDeleteModel, dict]): A model instance or dictionary containing the following fields:
382
+
383
+ - company_id (Union[str, int]): company_id of the SalesmenDeleteModel.
384
+
385
+ - salesman_id (Union[str, int]): salesman_id of the SalesmenDeleteModel.
386
+
387
+
388
+
389
+ Returns:
390
+ ApiResponse: The response from the API.
391
+ """
392
+
393
+ data = validate_data(data, self.validate, SalesmenDeleteModel)
394
+
395
+ return self._request(
396
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
397
+ )
398
+
399
+ @endpoint("/<version>/salesmen/getAll/", method="post")
400
+ def get_all(self, data: Union[SalesmenGetAllModel, dict], **kwargs):
401
+ """
402
+ get_all(self, data: Union[SalesmenGetAllModel, dict], **kwargs)
403
+
404
+ Args:
405
+
406
+ data (Union[SalesmenGetAllModel, dict]): A model instance or dictionary containing the following fields:
407
+
408
+ - company_id (Union[str, int]): company_id of the SalesmenGetAllModel.
409
+
410
+
411
+
412
+ Returns:
413
+ ApiResponse: The response from the API.
414
+ """
415
+
416
+ data = validate_data(data, self.validate, SalesmenGetAllModel)
417
+
418
+ return self._request(
419
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
420
+ )
421
+
422
+ @endpoint("/<version>/salesmen/getModifiedSince/", method="post")
423
+ def get_modified_since(
424
+ self, data: Union[SalesmenGetModifiedSinceModel, dict], **kwargs
425
+ ):
426
+ """
427
+ get_modified_since(self, data: Union[SalesmenGetModifiedSinceModel, dict], **kwargs)
428
+
429
+ Args:
430
+
431
+ data (Union[SalesmenGetModifiedSinceModel, dict]): A model instance or dictionary containing the following fields:
432
+
433
+ - company_id (Union[str, int]): company_id of the SalesmenGetModifiedSinceModel.
434
+
435
+ - lastmodified (str): lastmodified of the SalesmenGetModifiedSinceModel.
436
+
437
+
438
+
439
+ Returns:
440
+ ApiResponse: The response from the API.
441
+ """
442
+
443
+ data = validate_data(data, self.validate, SalesmenGetModifiedSinceModel)
444
+
445
+ return self._request(
446
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
447
+ )
448
+
449
+ @endpoint("/<version>/salesmen/getOne/", method="post")
450
+ def get_one(self, data: Union[SalesmenGetOneModel, dict], **kwargs):
451
+ """
452
+ get_one(self, data: Union[SalesmenGetOneModel, dict], **kwargs)
453
+
454
+ Args:
455
+
456
+ data (Union[SalesmenGetOneModel, dict]): A model instance or dictionary containing the following fields:
457
+
458
+ - company_id (Union[str, int]): company_id of the SalesmenGetOneModel.
459
+
460
+ - salesman_id (Union[str, int]): salesman_id of the SalesmenGetOneModel.
461
+
462
+
463
+
464
+ Returns:
465
+ ApiResponse: The response from the API.
466
+ """
467
+
468
+ data = validate_data(data, self.validate, SalesmenGetOneModel)
469
+
470
+ return self._request(
471
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
472
+ )
473
+
474
+ @endpoint("/<version>/salesmen/insert/", method="post")
475
+ def insert(self, data: Union[SalesmenInsertModel, dict], **kwargs):
476
+ """
477
+ insert(self, data: Union[SalesmenInsertModel, dict], **kwargs)
478
+
479
+ Args:
480
+
481
+ data (Union[SalesmenInsertModel, dict]): A model instance or dictionary containing the following fields:
482
+
483
+ - address (str): address of the SalesmenInsertModel.
484
+
485
+ - base_commission (str): base_commission of the SalesmenInsertModel.
486
+
487
+ - city (str): city of the SalesmenInsertModel.
488
+
489
+ - company_id (Union[str, int]): company_id of the SalesmenInsertModel.
490
+
491
+ - country_id (Union[str, int]): country_id of the SalesmenInsertModel.
492
+
493
+ - email (str): email of the SalesmenInsertModel.
494
+
495
+ - fax (str): fax of the SalesmenInsertModel.
496
+
497
+ - language_id (Union[str, int]): language_id of the SalesmenInsertModel.
498
+
499
+ - name (str): name of the SalesmenInsertModel.
500
+
501
+ - notes (str): notes of the SalesmenInsertModel.
502
+
503
+ - number (str): number of the SalesmenInsertModel.
504
+
505
+ - phone (str): phone of the SalesmenInsertModel.
506
+
507
+ - qty_copies_document (str): qty_copies_document of the SalesmenInsertModel.
508
+
509
+ - vat (str): vat of the SalesmenInsertModel.
510
+
511
+ - website (str): website of the SalesmenInsertModel.
512
+
513
+ - zip_code (str): zip_code of the SalesmenInsertModel.
514
+
515
+
516
+
517
+ Returns:
518
+ ApiResponse: The response from the API.
519
+ """
520
+
521
+ data = validate_data(data, self.validate, SalesmenInsertModel)
522
+
523
+ return self._request(
524
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
525
+ )
526
+
527
+ @endpoint("/<version>/salesmen/update/", method="post")
528
+ def update(self, data: Union[SalesmenUpdateModel, dict], **kwargs):
529
+ """
530
+ update(self, data: Union[SalesmenUpdateModel, dict], **kwargs)
531
+
532
+ Args:
533
+
534
+ data (Union[SalesmenUpdateModel, dict]): A model instance or dictionary containing the following fields:
535
+
536
+ - address (str): address of the SalesmenUpdateModel.
537
+
538
+ - base_commission (str): base_commission of the SalesmenUpdateModel.
539
+
540
+ - city (str): city of the SalesmenUpdateModel.
541
+
542
+ - company_id (Union[str, int]): company_id of the SalesmenUpdateModel.
543
+
544
+ - country_id (Union[str, int]): country_id of the SalesmenUpdateModel.
545
+
546
+ - email (str): email of the SalesmenUpdateModel.
547
+
548
+ - fax (str): fax of the SalesmenUpdateModel.
549
+
550
+ - language_id (Union[str, int]): language_id of the SalesmenUpdateModel.
551
+
552
+ - name (str): name of the SalesmenUpdateModel.
553
+
554
+ - notes (str): notes of the SalesmenUpdateModel.
555
+
556
+ - number (str): number of the SalesmenUpdateModel.
557
+
558
+ - phone (str): phone of the SalesmenUpdateModel.
559
+
560
+ - qty_copies_document (str): qty_copies_document of the SalesmenUpdateModel.
561
+
562
+ - salesman_id (Union[str, int]): salesman_id of the SalesmenUpdateModel.
563
+
564
+ - vat (str): vat of the SalesmenUpdateModel.
565
+
566
+ - website (str): website of the SalesmenUpdateModel.
567
+
568
+ - zip_code (str): zip_code of the SalesmenUpdateModel.
569
+
570
+
571
+
572
+ Returns:
573
+ ApiResponse: The response from the API.
574
+ """
575
+
576
+ data = validate_data(data, self.validate, SalesmenUpdateModel)
577
+
578
+ return self._request(
579
+ fill_query_params(kwargs.pop("path"), self.version), data={**data, **kwargs}
580
+ )