lago-python-client 1.10.0__tar.gz → 1.15.0__tar.gz

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 (128) hide show
  1. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/PKG-INFO +17 -2
  2. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/README.md +7 -0
  3. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/base_client.py +2 -1
  4. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/client.py +19 -2
  5. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/events/clients.py +31 -3
  6. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/exceptions.py +2 -1
  7. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoices/clients.py +14 -0
  8. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/__init__.py +2 -0
  9. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/customer.py +10 -2
  10. lago_python_client-1.15.0/lago_python_client/models/error_detail.py +15 -0
  11. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/event.py +2 -0
  12. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/fee.py +4 -0
  13. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/invoice.py +3 -0
  14. lago_python_client-1.15.0/lago_python_client/models/lifetime_usage.py +21 -0
  15. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/organization.py +2 -0
  16. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/payment_request.py +8 -1
  17. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/subscription.py +2 -0
  18. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/payment_requests/clients.py +2 -1
  19. lago_python_client-1.15.0/lago_python_client/subscriptions/clients.py +70 -0
  20. lago_python_client-1.15.0/lago_python_client/version.py +1 -0
  21. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client.egg-info/PKG-INFO +17 -2
  22. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client.egg-info/SOURCES.txt +89 -0
  23. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_event_client.py +22 -3
  24. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_invoice_client.py +13 -0
  25. lago_python_client-1.15.0/tests/test_payment_request_client.py +109 -0
  26. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_subscription_client.py +64 -0
  27. lago-python-client-1.10.0/lago_python_client/subscriptions/clients.py +0 -24
  28. lago-python-client-1.10.0/lago_python_client/version.py +0 -1
  29. lago-python-client-1.10.0/tests/test_payment_request_client.py +0 -57
  30. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/LICENSE +0 -0
  31. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/__init__.py +0 -0
  32. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/add_ons/__init__.py +0 -0
  33. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/add_ons/clients.py +0 -0
  34. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/base_model.py +0 -0
  35. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/billable_metrics/__init__.py +0 -0
  36. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/billable_metrics/clients.py +0 -0
  37. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/coupons/__init__.py +0 -0
  38. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/coupons/clients.py +0 -0
  39. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/credit_notes/__init__.py +0 -0
  40. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/credit_notes/clients.py +0 -0
  41. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/customers/__init__.py +0 -0
  42. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/customers/clients.py +0 -0
  43. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/events/__init__.py +0 -0
  44. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/fees/__init__.py +0 -0
  45. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/fees/clients.py +0 -0
  46. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/functools_ext.py +0 -0
  47. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/gross_revenues/__init__.py +0 -0
  48. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/gross_revenues/clients.py +0 -0
  49. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoice_collections/__init__.py +0 -0
  50. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoice_collections/clients.py +0 -0
  51. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoiced_usages/__init__.py +0 -0
  52. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoiced_usages/clients.py +0 -0
  53. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/invoices/__init__.py +0 -0
  54. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/mixins.py +0 -0
  55. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/add_on.py +0 -0
  56. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/applied_coupon.py +0 -0
  57. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/billable_metric.py +0 -0
  58. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/charge.py +0 -0
  59. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/coupon.py +0 -0
  60. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/credit.py +0 -0
  61. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/credit_note.py +0 -0
  62. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/customer_usage.py +0 -0
  63. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/gross_revenue.py +0 -0
  64. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/invoice_collection.py +0 -0
  65. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/invoice_item.py +0 -0
  66. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/invoiced_usage.py +0 -0
  67. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/minimum_commitment.py +0 -0
  68. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/mrr.py +0 -0
  69. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/overdue_balance.py +0 -0
  70. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/plan.py +0 -0
  71. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/tax.py +0 -0
  72. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/usage_threshold.py +0 -0
  73. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/wallet.py +0 -0
  74. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/wallet_transaction.py +0 -0
  75. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/models/webhook_endpoint.py +0 -0
  76. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/mrrs/__init__.py +0 -0
  77. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/mrrs/clients.py +0 -0
  78. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/organizations/__init__.py +0 -0
  79. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/organizations/clients.py +0 -0
  80. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/overdue_balances/__init__.py +0 -0
  81. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/overdue_balances/clients.py +0 -0
  82. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/payment_requests/__init__.py +0 -0
  83. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/plans/__init__.py +0 -0
  84. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/plans/clients.py +0 -0
  85. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/py.typed +0 -0
  86. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/services/__init__.py +0 -0
  87. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/services/json.py +0 -0
  88. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/services/request.py +0 -0
  89. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/services/response.py +0 -0
  90. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/subscriptions/__init__.py +0 -0
  91. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/taxes/__init__.py +0 -0
  92. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/taxes/clients.py +0 -0
  93. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/wallets/__init__.py +0 -0
  94. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/wallets/clients.py +0 -0
  95. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/webhook_endpoints/__init__.py +0 -0
  96. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/webhook_endpoints/clients.py +0 -0
  97. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/webhooks/__init__.py +0 -0
  98. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client/webhooks/clients.py +0 -0
  99. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client.egg-info/dependency_links.txt +0 -0
  100. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client.egg-info/requires.txt +0 -0
  101. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/lago_python_client.egg-info/top_level.txt +0 -0
  102. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/pyproject.toml +0 -0
  103. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/setup.cfg +0 -0
  104. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/__init__.py +0 -0
  105. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_add_on_client.py +0 -0
  106. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_applied_coupon_client.py +0 -0
  107. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_billable_metric_client.py +0 -0
  108. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_client.py +0 -0
  109. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_coupon_client.py +0 -0
  110. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_credit_note_client.py +0 -0
  111. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_customer_client.py +0 -0
  112. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_fee_client.py +0 -0
  113. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_functools_ext.py +0 -0
  114. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_gross_revenue_client.py +0 -0
  115. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_invoice_collection_client.py +0 -0
  116. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_invoiced_usage_client.py +0 -0
  117. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_json_services.py +0 -0
  118. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_mrr_client.py +0 -0
  119. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_organization_client.py +0 -0
  120. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_overdue_balance_client.py +0 -0
  121. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_plan_client.py +0 -0
  122. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_request_services.py +0 -0
  123. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_response_services.py +0 -0
  124. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_tax_client.py +0 -0
  125. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_wallet_client.py +0 -0
  126. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_wallet_transaction_client.py +0 -0
  127. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_webhook_client.py +0 -0
  128. {lago-python-client-1.10.0 → lago_python_client-1.15.0}/tests/test_webhook_endpoint_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lago-python-client
3
- Version: 1.10.0
3
+ Version: 1.15.0
4
4
  Summary: Lago Python API Client
5
5
  Home-page: https://github.com/getlago/lago-python-client
6
6
  Author: Lovro Colic
@@ -19,8 +19,16 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Topic :: Software Development
20
20
  Requires-Python: >3.6
21
21
  Description-Content-Type: text/markdown
22
- Provides-Extra: test
23
22
  License-File: LICENSE
23
+ Requires-Dist: classes~=0.4.1
24
+ Requires-Dist: httpx<1.0.0,>=0.24.0
25
+ Requires-Dist: orjson~=3.8
26
+ Requires-Dist: pydantic<3,>=1.10
27
+ Requires-Dist: typeguard~=3.0.2
28
+ Provides-Extra: test
29
+ Requires-Dist: mypy==0.971; extra == "test"
30
+ Requires-Dist: pytest; extra == "test"
31
+ Requires-Dist: pytest_httpx; extra == "test"
24
32
 
25
33
  # Lago Python Client
26
34
 
@@ -29,6 +37,13 @@ This is a python wrapper for Lago API
29
37
  [![PyPI version](https://badge.fury.io/py/lago-python-client.svg)](https://badge.fury.io/py/lago-python-client)
30
38
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
31
39
 
40
+ ## Current Releases
41
+
42
+ | Project | Release Badge |
43
+ |--------------------|-----------------------------------------------------------------------------------------------------|
44
+ | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
45
+ | **Lago Python Client** | [![Lago Python Client Release](https://img.shields.io/github/v/release/getlago/lago-python-client)](https://github.com/getlago/lago-python-client/releases) |
46
+
32
47
  ## Installation
33
48
 
34
49
  Install the lago-python-client via pip from PyPI:
@@ -5,6 +5,13 @@ This is a python wrapper for Lago API
5
5
  [![PyPI version](https://badge.fury.io/py/lago-python-client.svg)](https://badge.fury.io/py/lago-python-client)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
7
7
 
8
+ ## Current Releases
9
+
10
+ | Project | Release Badge |
11
+ |--------------------|-----------------------------------------------------------------------------------------------------|
12
+ | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
13
+ | **Lago Python Client** | [![Lago Python Client Release](https://img.shields.io/github/v/release/getlago/lago-python-client)](https://github.com/getlago/lago-python-client/releases) |
14
+
8
15
  ## Installation
9
16
 
10
17
  Install the lago-python-client via pip from PyPI:
@@ -7,9 +7,10 @@ from lago_python_client.base_model import BaseModel
7
7
  class BaseClient(ABC):
8
8
  """The base class used for each collection client."""
9
9
 
10
- def __init__(self, base_url: str, api_key: str):
10
+ def __init__(self, base_url: str, api_key: str, base_ingest_url: str = ""):
11
11
  self.base_url = base_url
12
12
  self.api_key = api_key
13
+ self.base_ingest_url = base_ingest_url
13
14
 
14
15
  @property
15
16
  @classmethod
@@ -31,16 +31,33 @@ except ImportError: # Python 3.7
31
31
 
32
32
  class Client:
33
33
  BASE_URL: Final[str] = "https://api.getlago.com/"
34
+ BASE_INGEST_URL: Final[str] = "https://ingest.getlago.com/"
34
35
  API_PATH: Final[str] = "api/v1/"
35
36
 
36
- def __init__(self, api_key: str = "", api_url: str = "") -> None:
37
+ def __init__(
38
+ self, api_key: str = "", api_url: str = "", use_ingest_service: bool = False, ingest_api_url: str = ""
39
+ ) -> None:
37
40
  self.api_key: str = api_key
38
41
  self.api_url: str = api_url
42
+ self.use_ingest_service: bool = use_ingest_service
43
+ self.ingest_api_url: str = ingest_api_url
39
44
 
40
45
  @property
41
46
  def base_api_url(self) -> str:
42
47
  return urljoin(self.api_url if self.api_url else Client.BASE_URL, Client.API_PATH)
43
48
 
49
+ @property
50
+ def base_ingest_api_url(self) -> str:
51
+ if not self.use_ingest_service:
52
+ return self.base_api_url
53
+
54
+ if self.ingest_api_url == "":
55
+ ingest_url = Client.BASE_INGEST_URL
56
+ else:
57
+ ingest_url = self.ingest_api_url
58
+
59
+ return urljoin(ingest_url, Client.API_PATH)
60
+
44
61
  @callable_cached_property
45
62
  def add_ons(self) -> AddOnClient:
46
63
  return AddOnClient(self.base_api_url, self.api_key)
@@ -67,7 +84,7 @@ class Client:
67
84
 
68
85
  @callable_cached_property
69
86
  def events(self) -> EventClient:
70
- return EventClient(self.base_api_url, self.api_key)
87
+ return EventClient(self.base_api_url, self.api_key, self.base_ingest_api_url)
71
88
 
72
89
  @callable_cached_property
73
90
  def fees(self) -> FeeClient:
@@ -1,17 +1,20 @@
1
1
  import sys
2
- from typing import Any, ClassVar, Type
2
+ from typing import Any, ClassVar, Optional, Type
3
+
4
+ import httpx
3
5
 
4
6
  from lago_python_client.base_model import BaseModel
5
7
 
6
8
  from ..base_client import BaseClient
7
9
  from ..fees.clients import FeeClient
8
- from ..mixins import CreateCommandMixin, FindCommandMixin
10
+ from ..mixins import FindCommandMixin
9
11
  from ..models.event import EventResponse
10
12
  from ..models.fee import FeeResponse
11
13
  from ..services.json import to_json
12
14
  from ..services.request import make_headers, make_url, send_post_request
13
15
  from ..services.response import (
14
16
  get_response_data,
17
+ prepare_object_response,
15
18
  prepare_object_list_response,
16
19
  verify_response,
17
20
  Response,
@@ -23,11 +26,36 @@ else:
23
26
  from typing import Mapping
24
27
 
25
28
 
26
- class EventClient(CreateCommandMixin[EventResponse], FindCommandMixin[EventResponse], BaseClient):
29
+ class EventClient(FindCommandMixin[EventResponse], BaseClient):
27
30
  API_RESOURCE: ClassVar[str] = "events"
28
31
  RESPONSE_MODEL: ClassVar[Type[EventResponse]] = EventResponse
29
32
  ROOT_NAME: ClassVar[str] = "event"
30
33
 
34
+ def create(self, input_object: BaseModel, timeout: Optional[httpx.Timeout] = None) -> Optional[EventResponse]:
35
+ api_response: Response = send_post_request(
36
+ url=make_url(
37
+ origin=self.base_ingest_url,
38
+ path_parts=(self.API_RESOURCE,),
39
+ ),
40
+ content=to_json(
41
+ {
42
+ self.ROOT_NAME: input_object.dict(),
43
+ }
44
+ ),
45
+ headers=make_headers(api_key=self.api_key),
46
+ timeout=timeout,
47
+ )
48
+
49
+ # Process response data
50
+ response_data = get_response_data(response=api_response, key=self.ROOT_NAME)
51
+ if not response_data:
52
+ return None
53
+
54
+ return prepare_object_response(
55
+ response_model=self.RESPONSE_MODEL,
56
+ data=response_data,
57
+ )
58
+
31
59
  def batch_create(self, input_object: BaseModel) -> None:
32
60
  api_response: Response = send_post_request(
33
61
  url=make_url(
@@ -24,7 +24,8 @@ class LagoApiError(Exception):
24
24
  self.response = response
25
25
  self.detail = detail
26
26
  self.headers = headers
27
+ super().__init__(self.response)
27
28
 
28
29
  def __repr__(self) -> str:
29
30
  class_name = self.__class__.__name__
30
- return f"{class_name}(status_code={self.status_code!r}, detail={self.detail!r})"
31
+ return f"{class_name}(response={self.response!r}"
@@ -78,6 +78,20 @@ class InvoiceClient(
78
78
  data=get_response_data(response=api_response, key=self.ROOT_NAME),
79
79
  )
80
80
 
81
+ def retry(self, resource_id: str) -> InvoiceResponse:
82
+ api_response: Response = send_post_request(
83
+ url=make_url(
84
+ origin=self.base_url,
85
+ path_parts=(self.API_RESOURCE, resource_id, "retry"),
86
+ ),
87
+ headers=make_headers(api_key=self.api_key),
88
+ )
89
+
90
+ return prepare_object_response(
91
+ response_model=self.RESPONSE_MODEL,
92
+ data=get_response_data(response=api_response, key=self.ROOT_NAME),
93
+ )
94
+
81
95
  def finalize(self, resource_id: str) -> InvoiceResponse:
82
96
  api_response: Response = send_put_request(
83
97
  url=make_url(
@@ -82,3 +82,5 @@ from .usage_threshold import (
82
82
  UsageThresholds as UsageThresholds,
83
83
  UsageThresholdsResponse as UsageThresholdsResponse,
84
84
  )
85
+ from .payment_request import PaymentRequest as PaymentRequest
86
+ from .lifetime_usage import LifetimeUsageResponse as LifetimeUsageResponse
@@ -88,13 +88,17 @@ class Customer(BaseModel):
88
88
  net_payment_term: Optional[int]
89
89
  tax_identification_number: Optional[str]
90
90
  logo_url: Optional[str]
91
- name: str
91
+ name: Optional[str]
92
+ firstname: Optional[str]
93
+ lastname: Optional[str]
94
+ customer_type: Optional[str]
92
95
  phone: Optional[str]
93
96
  state: Optional[str]
94
97
  timezone: Optional[str]
95
98
  url: Optional[str]
96
99
  zipcode: Optional[str]
97
100
  metadata: Optional[MetadataList]
101
+ finalize_zero_amount_invoice: Optional[str]
98
102
  billing_configuration: Optional[CustomerBillingConfiguration]
99
103
  shipping_address: Optional[Address]
100
104
  integration_customers: Optional[IntegrationCustomersList]
@@ -117,7 +121,10 @@ class CustomerResponse(BaseResponseModel):
117
121
  net_payment_term: Optional[int]
118
122
  tax_identification_number: Optional[str]
119
123
  logo_url: Optional[str]
120
- name: str
124
+ name: Optional[str]
125
+ firstname: Optional[str]
126
+ lastname: Optional[str]
127
+ customer_type: Optional[str]
121
128
  phone: Optional[str]
122
129
  state: Optional[str]
123
130
  timezone: Optional[str]
@@ -125,6 +132,7 @@ class CustomerResponse(BaseResponseModel):
125
132
  url: Optional[str]
126
133
  zipcode: Optional[str]
127
134
  metadata: Optional[MetadataResponseList]
135
+ finalize_zero_amount_invoice: Optional[str]
128
136
  billing_configuration: Optional[CustomerBillingConfiguration]
129
137
  shipping_address: Optional[Address]
130
138
  integration_customers: Optional[IntegrationCustomersResponseList]
@@ -0,0 +1,15 @@
1
+ from typing import Any, Dict, List, Optional
2
+
3
+ from lago_python_client.base_model import BaseModel
4
+
5
+ from ..base_model import BaseResponseModel
6
+
7
+
8
+ class ErrorDetailResponse(BaseModel):
9
+ organization_id: str
10
+ error_code: str
11
+ details: Optional[Dict[str, Any]]
12
+
13
+
14
+ class ErrorDetailsResponse(BaseResponseModel):
15
+ __root__: List[ErrorDetailResponse]
@@ -10,6 +10,7 @@ class Event(BaseModel):
10
10
  external_subscription_id: str
11
11
  code: str
12
12
  timestamp: Optional[Union[int, str]]
13
+ precise_total_amount_cents: Optional[str]
13
14
  properties: Optional[Dict[str, Any]]
14
15
 
15
16
 
@@ -25,6 +26,7 @@ class EventResponse(BaseResponseModel):
25
26
  external_subscription_id: str
26
27
  code: str
27
28
  timestamp: str
29
+ precise_total_amount_cents: Optional[str]
28
30
  properties: Optional[Dict[str, Any]]
29
31
  created_at: str
30
32
 
@@ -28,6 +28,7 @@ class FeeAppliedTaxes(BaseResponseModel):
28
28
 
29
29
  class FeeResponse(BaseResponseModel):
30
30
  lago_id: Optional[str]
31
+ lago_charge_id: Optional[str]
31
32
  lago_charge_filter_id: Optional[str]
32
33
  lago_invoice_id: Optional[str]
33
34
  lago_true_up_fee_id: Optional[str]
@@ -40,6 +41,9 @@ class FeeResponse(BaseResponseModel):
40
41
  total_amount_cents: Optional[int]
41
42
  unit_amount_cents: Optional[int] # deprecated
42
43
  precise_unit_amount: Optional[str]
44
+ precise_amount: Optional[str]
45
+ precise_total_amount: Optional[str]
46
+ taxes_precise_amount: Optional[str]
43
47
  total_amount_currency: Optional[str]
44
48
  units: Optional[float]
45
49
  events_count: Optional[int]
@@ -6,6 +6,7 @@ from .credit import CreditsResponse
6
6
  from .customer import CustomerResponse
7
7
  from .fee import FeesResponse
8
8
  from .subscription import SubscriptionsResponse
9
+ from .error_detail import ErrorDetailsResponse
9
10
  from ..base_model import BaseResponseModel
10
11
  from .usage_threshold import UsageThreshold
11
12
 
@@ -47,6 +48,7 @@ class OneOffInvoice(BaseModel):
47
48
  external_customer_id: Optional[str]
48
49
  currency: Optional[str]
49
50
  fees: Optional[InvoiceFeesList]
51
+ error_details: Optional[ErrorDetailsResponse]
50
52
 
51
53
 
52
54
  class InvoiceAppliedTax(BaseResponseModel):
@@ -109,3 +111,4 @@ class InvoiceResponse(BaseResponseModel):
109
111
  metadata: Optional[InvoiceMetadataList]
110
112
  applied_taxes: Optional[InvoiceAppliedTaxes]
111
113
  applied_usage_thresholds: Optional[InvoiceAppliedUsageThresholds]
114
+ error_details: Optional[ErrorDetailsResponse]
@@ -0,0 +1,21 @@
1
+ from typing import Optional, List
2
+
3
+ from ..base_model import BaseResponseModel
4
+
5
+
6
+ class LifetimeUsageThresholdResponse(BaseResponseModel):
7
+ amount_cents: int
8
+ completion_ratio: float
9
+ reached_at: Optional[str]
10
+
11
+
12
+ class LifetimeUsageResponse(BaseResponseModel):
13
+ lago_id: str
14
+ lago_subscription_id: str
15
+ external_subscription_id: str
16
+ external_historical_usage_amount_cents: int
17
+ invoiced_usage_amount_cents: int
18
+ current_usage_amount_cents: int
19
+ from_datetime: Optional[str]
20
+ to_datetime: Optional[str]
21
+ usage_thresholds: Optional[List[LifetimeUsageThresholdResponse]]
@@ -30,6 +30,7 @@ class Organization(BaseModel):
30
30
  tax_identification_number: Optional[str]
31
31
  timezone: Optional[str]
32
32
  email_settings: Optional[List[str]]
33
+ finalize_zero_amount_invoice: Optional[bool]
33
34
  billing_configuration: Optional[OrganizationBillingConfiguration]
34
35
 
35
36
 
@@ -53,4 +54,5 @@ class OrganizationResponse(BaseResponseModel):
53
54
  tax_identification_number: Optional[str]
54
55
  timezone: Optional[str]
55
56
  email_settings: Optional[List[str]]
57
+ finalize_zero_amount_invoice: Optional[bool]
56
58
  billing_configuration: Optional[OrganizationBillingConfiguration]
@@ -1,9 +1,15 @@
1
1
  from typing import List, Optional
2
2
 
3
- from ..base_model import BaseResponseModel
3
+ from ..base_model import BaseModel, BaseResponseModel
4
4
  from .customer import CustomerResponse
5
5
 
6
6
 
7
+ class PaymentRequest(BaseModel):
8
+ email: str
9
+ external_customer_id: str
10
+ lago_invoice_ids: List[str]
11
+
12
+
7
13
  class PaymentRequestInvoiceResponse(BaseResponseModel):
8
14
  lago_id: str
9
15
  sequential_id: Optional[int]
@@ -38,6 +44,7 @@ class PaymentRequestResponse(BaseResponseModel):
38
44
  email: str
39
45
  amount_cents: int
40
46
  amount_currency: str
47
+ payment_status: str
41
48
  created_at: str
42
49
  customer: Optional[CustomerResponse]
43
50
  invoices: Optional[PaymentRequestInvoicesResponse]
@@ -36,6 +36,8 @@ class SubscriptionResponse(BaseResponseModel):
36
36
  previous_plan_code: Optional[str]
37
37
  next_plan_code: Optional[str]
38
38
  downgrade_plan_date: Optional[str]
39
+ current_billing_period_started_at: Optional[str]
40
+ current_billing_period_ending_at: Optional[str]
39
41
 
40
42
 
41
43
  class SubscriptionsResponse(BaseResponseModel):
@@ -1,11 +1,12 @@
1
1
  from typing import ClassVar, Type
2
2
 
3
3
  from ..base_client import BaseClient
4
- from ..mixins import FindAllCommandMixin
4
+ from ..mixins import CreateCommandMixin, FindAllCommandMixin
5
5
  from ..models.payment_request import PaymentRequestResponse
6
6
 
7
7
 
8
8
  class PaymentRequestClient(
9
+ CreateCommandMixin[PaymentRequestResponse],
9
10
  FindAllCommandMixin[PaymentRequestResponse],
10
11
  BaseClient,
11
12
  ):
@@ -0,0 +1,70 @@
1
+ from typing import ClassVar, Type
2
+
3
+ from ..base_client import BaseClient
4
+ from ..mixins import (
5
+ CreateCommandMixin,
6
+ DestroyCommandMixin,
7
+ FindAllCommandMixin,
8
+ FindCommandMixin,
9
+ UpdateCommandMixin,
10
+ )
11
+ from ..models.lifetime_usage import LifetimeUsageResponse
12
+ from ..models.subscription import SubscriptionResponse
13
+ from ..services.request import (
14
+ make_headers,
15
+ make_url,
16
+ send_get_request,
17
+ send_put_request,
18
+ )
19
+ from ..services.response import (
20
+ Response,
21
+ get_response_data,
22
+ prepare_object_response,
23
+ )
24
+ from ..services.json import to_json
25
+
26
+
27
+ class SubscriptionClient(
28
+ CreateCommandMixin[SubscriptionResponse],
29
+ DestroyCommandMixin[SubscriptionResponse],
30
+ FindAllCommandMixin[SubscriptionResponse],
31
+ FindCommandMixin[SubscriptionResponse],
32
+ UpdateCommandMixin[SubscriptionResponse],
33
+ BaseClient,
34
+ ):
35
+ API_RESOURCE: ClassVar[str] = "subscriptions"
36
+ RESPONSE_MODEL: ClassVar[Type[SubscriptionResponse]] = SubscriptionResponse
37
+ ROOT_NAME: ClassVar[str] = "subscription"
38
+
39
+ def lifetime_usage(self, resource_id: str) -> LifetimeUsageResponse:
40
+ api_response: Response = send_get_request(
41
+ url=make_url(
42
+ origin=self.base_url,
43
+ path_parts=(self.API_RESOURCE, resource_id, "lifetime_usage"),
44
+ ),
45
+ headers=make_headers(api_key=self.api_key),
46
+ )
47
+
48
+ return prepare_object_response(
49
+ response_model=LifetimeUsageResponse,
50
+ data=get_response_data(response=api_response, key="lifetime_usage"),
51
+ )
52
+
53
+ def update_lifetime_usage(
54
+ self, resource_id: str, external_historical_usage_amount_cents: int
55
+ ) -> LifetimeUsageResponse:
56
+ api_response: Response = send_put_request(
57
+ url=make_url(
58
+ origin=self.base_url,
59
+ path_parts=(self.API_RESOURCE, resource_id, "lifetime_usage"),
60
+ ),
61
+ content=to_json(
62
+ {"lifetime_usage": {"external_historical_usage_amount_cents": external_historical_usage_amount_cents}}
63
+ ),
64
+ headers=make_headers(api_key=self.api_key),
65
+ )
66
+
67
+ return prepare_object_response(
68
+ response_model=LifetimeUsageResponse,
69
+ data=get_response_data(response=api_response, key="lifetime_usage"),
70
+ )
@@ -0,0 +1 @@
1
+ LAGO_VERSION = "1.15.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lago-python-client
3
- Version: 1.10.0
3
+ Version: 1.15.0
4
4
  Summary: Lago Python API Client
5
5
  Home-page: https://github.com/getlago/lago-python-client
6
6
  Author: Lovro Colic
@@ -19,8 +19,16 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Topic :: Software Development
20
20
  Requires-Python: >3.6
21
21
  Description-Content-Type: text/markdown
22
- Provides-Extra: test
23
22
  License-File: LICENSE
23
+ Requires-Dist: classes~=0.4.1
24
+ Requires-Dist: httpx<1.0.0,>=0.24.0
25
+ Requires-Dist: orjson~=3.8
26
+ Requires-Dist: pydantic<3,>=1.10
27
+ Requires-Dist: typeguard~=3.0.2
28
+ Provides-Extra: test
29
+ Requires-Dist: mypy==0.971; extra == "test"
30
+ Requires-Dist: pytest; extra == "test"
31
+ Requires-Dist: pytest_httpx; extra == "test"
24
32
 
25
33
  # Lago Python Client
26
34
 
@@ -29,6 +37,13 @@ This is a python wrapper for Lago API
29
37
  [![PyPI version](https://badge.fury.io/py/lago-python-client.svg)](https://badge.fury.io/py/lago-python-client)
30
38
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html)
31
39
 
40
+ ## Current Releases
41
+
42
+ | Project | Release Badge |
43
+ |--------------------|-----------------------------------------------------------------------------------------------------|
44
+ | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
45
+ | **Lago Python Client** | [![Lago Python Client Release](https://img.shields.io/github/v/release/getlago/lago-python-client)](https://github.com/getlago/lago-python-client/releases) |
46
+
32
47
  ## Installation
33
48
 
34
49
  Install the lago-python-client via pip from PyPI:
@@ -43,6 +43,7 @@ setup.cfg
43
43
  ./lago_python_client/models/credit_note.py
44
44
  ./lago_python_client/models/customer.py
45
45
  ./lago_python_client/models/customer_usage.py
46
+ ./lago_python_client/models/error_detail.py
46
47
  ./lago_python_client/models/event.py
47
48
  ./lago_python_client/models/fee.py
48
49
  ./lago_python_client/models/gross_revenue.py
@@ -50,6 +51,7 @@ setup.cfg
50
51
  ./lago_python_client/models/invoice_collection.py
51
52
  ./lago_python_client/models/invoice_item.py
52
53
  ./lago_python_client/models/invoiced_usage.py
54
+ ./lago_python_client/models/lifetime_usage.py
53
55
  ./lago_python_client/models/minimum_commitment.py
54
56
  ./lago_python_client/models/mrr.py
55
57
  ./lago_python_client/models/organization.py
@@ -115,11 +117,98 @@ setup.cfg
115
117
  ./tests/test_wallet_transaction_client.py
116
118
  ./tests/test_webhook_client.py
117
119
  ./tests/test_webhook_endpoint_client.py
120
+ lago_python_client/__init__.py
121
+ lago_python_client/base_client.py
122
+ lago_python_client/base_model.py
123
+ lago_python_client/client.py
124
+ lago_python_client/exceptions.py
125
+ lago_python_client/functools_ext.py
126
+ lago_python_client/mixins.py
127
+ lago_python_client/py.typed
128
+ lago_python_client/version.py
118
129
  lago_python_client.egg-info/PKG-INFO
119
130
  lago_python_client.egg-info/SOURCES.txt
120
131
  lago_python_client.egg-info/dependency_links.txt
121
132
  lago_python_client.egg-info/requires.txt
122
133
  lago_python_client.egg-info/top_level.txt
134
+ lago_python_client/add_ons/__init__.py
135
+ lago_python_client/add_ons/clients.py
136
+ lago_python_client/billable_metrics/__init__.py
137
+ lago_python_client/billable_metrics/clients.py
138
+ lago_python_client/coupons/__init__.py
139
+ lago_python_client/coupons/clients.py
140
+ lago_python_client/credit_notes/__init__.py
141
+ lago_python_client/credit_notes/clients.py
142
+ lago_python_client/customers/__init__.py
143
+ lago_python_client/customers/clients.py
144
+ lago_python_client/events/__init__.py
145
+ lago_python_client/events/clients.py
146
+ lago_python_client/fees/__init__.py
147
+ lago_python_client/fees/clients.py
148
+ lago_python_client/gross_revenues/__init__.py
149
+ lago_python_client/gross_revenues/clients.py
150
+ lago_python_client/invoice_collections/__init__.py
151
+ lago_python_client/invoice_collections/clients.py
152
+ lago_python_client/invoiced_usages/__init__.py
153
+ lago_python_client/invoiced_usages/clients.py
154
+ lago_python_client/invoices/__init__.py
155
+ lago_python_client/invoices/clients.py
156
+ lago_python_client/models/__init__.py
157
+ lago_python_client/models/add_on.py
158
+ lago_python_client/models/applied_coupon.py
159
+ lago_python_client/models/billable_metric.py
160
+ lago_python_client/models/charge.py
161
+ lago_python_client/models/coupon.py
162
+ lago_python_client/models/credit.py
163
+ lago_python_client/models/credit_note.py
164
+ lago_python_client/models/customer.py
165
+ lago_python_client/models/customer_usage.py
166
+ lago_python_client/models/error_detail.py
167
+ lago_python_client/models/event.py
168
+ lago_python_client/models/fee.py
169
+ lago_python_client/models/gross_revenue.py
170
+ lago_python_client/models/invoice.py
171
+ lago_python_client/models/invoice_collection.py
172
+ lago_python_client/models/invoice_item.py
173
+ lago_python_client/models/invoiced_usage.py
174
+ lago_python_client/models/lifetime_usage.py
175
+ lago_python_client/models/minimum_commitment.py
176
+ lago_python_client/models/mrr.py
177
+ lago_python_client/models/organization.py
178
+ lago_python_client/models/overdue_balance.py
179
+ lago_python_client/models/payment_request.py
180
+ lago_python_client/models/plan.py
181
+ lago_python_client/models/subscription.py
182
+ lago_python_client/models/tax.py
183
+ lago_python_client/models/usage_threshold.py
184
+ lago_python_client/models/wallet.py
185
+ lago_python_client/models/wallet_transaction.py
186
+ lago_python_client/models/webhook_endpoint.py
187
+ lago_python_client/mrrs/__init__.py
188
+ lago_python_client/mrrs/clients.py
189
+ lago_python_client/organizations/__init__.py
190
+ lago_python_client/organizations/clients.py
191
+ lago_python_client/overdue_balances/__init__.py
192
+ lago_python_client/overdue_balances/clients.py
193
+ lago_python_client/payment_requests/__init__.py
194
+ lago_python_client/payment_requests/clients.py
195
+ lago_python_client/plans/__init__.py
196
+ lago_python_client/plans/clients.py
197
+ lago_python_client/services/__init__.py
198
+ lago_python_client/services/json.py
199
+ lago_python_client/services/request.py
200
+ lago_python_client/services/response.py
201
+ lago_python_client/subscriptions/__init__.py
202
+ lago_python_client/subscriptions/clients.py
203
+ lago_python_client/taxes/__init__.py
204
+ lago_python_client/taxes/clients.py
205
+ lago_python_client/wallets/__init__.py
206
+ lago_python_client/wallets/clients.py
207
+ lago_python_client/webhook_endpoints/__init__.py
208
+ lago_python_client/webhook_endpoints/clients.py
209
+ lago_python_client/webhooks/__init__.py
210
+ lago_python_client/webhooks/clients.py
211
+ tests/__init__.py
123
212
  tests/test_add_on_client.py
124
213
  tests/test_applied_coupon_client.py
125
214
  tests/test_billable_metric_client.py