lago-python-client 1.9.1__tar.gz → 1.11.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 (156) hide show
  1. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/PKG-INFO +1 -1
  2. lago-python-client-1.11.0/lago_python_client/__init__.py +2 -0
  3. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/add_ons/clients.py +9 -3
  4. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/base_client.py +2 -1
  5. lago-python-client-1.11.0/lago_python_client/billable_metrics/clients.py +24 -0
  6. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/client.py +21 -4
  7. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/coupons/clients.py +22 -7
  8. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/credit_notes/clients.py +29 -13
  9. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/customers/clients.py +36 -17
  10. lago-python-client-1.11.0/lago_python_client/events/clients.py +90 -0
  11. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/exceptions.py +2 -1
  12. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/fees/clients.py +8 -3
  13. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/functools_ext.py +10 -5
  14. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/gross_revenues/clients.py +3 -3
  15. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoice_collections/clients.py +3 -3
  16. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoiced_usages/clients.py +3 -3
  17. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoices/clients.py +23 -13
  18. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/mixins.py +55 -16
  19. lago-python-client-1.11.0/lago_python_client/models/__init__.py +86 -0
  20. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/add_on.py +1 -0
  21. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/billable_metric.py +1 -1
  22. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/customer.py +2 -0
  23. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/customer_usage.py +2 -0
  24. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/event.py +2 -0
  25. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/fee.py +5 -1
  26. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/gross_revenue.py +1 -1
  27. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/invoice.py +14 -0
  28. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/invoice_collection.py +1 -1
  29. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/invoiced_usage.py +1 -1
  30. lago-python-client-1.11.0/lago_python_client/models/lifetime_usage.py +21 -0
  31. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/minimum_commitment.py +2 -2
  32. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/mrr.py +1 -1
  33. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/organization.py +2 -0
  34. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/overdue_balance.py +2 -2
  35. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/payment_request.py +8 -0
  36. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/plan.py +15 -2
  37. lago-python-client-1.11.0/lago_python_client/models/usage_threshold.py +39 -0
  38. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/mrrs/clients.py +3 -3
  39. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/organizations/clients.py +2 -2
  40. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/overdue_balances/clients.py +11 -5
  41. lago-python-client-1.11.0/lago_python_client/payment_requests/clients.py +15 -0
  42. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/plans/clients.py +9 -3
  43. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/services/json.py +14 -3
  44. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/services/request.py +16 -8
  45. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/services/response.py +13 -14
  46. lago-python-client-1.11.0/lago_python_client/subscriptions/clients.py +70 -0
  47. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/taxes/clients.py +9 -3
  48. lago-python-client-1.11.0/lago_python_client/version.py +1 -0
  49. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/wallets/clients.py +26 -12
  50. lago-python-client-1.11.0/lago_python_client/webhook_endpoints/clients.py +24 -0
  51. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/webhooks/clients.py +12 -7
  52. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client.egg-info/PKG-INFO +1 -1
  53. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client.egg-info/SOURCES.txt +2 -0
  54. lago-python-client-1.11.0/pyproject.toml +10 -0
  55. lago-python-client-1.11.0/tests/test_add_on_client.py +200 -0
  56. lago-python-client-1.11.0/tests/test_applied_coupon_client.py +136 -0
  57. lago-python-client-1.11.0/tests/test_billable_metric_client.py +206 -0
  58. lago-python-client-1.11.0/tests/test_client.py +13 -0
  59. lago-python-client-1.11.0/tests/test_coupon_client.py +201 -0
  60. lago-python-client-1.11.0/tests/test_credit_note_client.py +194 -0
  61. lago-python-client-1.11.0/tests/test_customer_client.py +234 -0
  62. lago-python-client-1.11.0/tests/test_event_client.py +177 -0
  63. lago-python-client-1.11.0/tests/test_fee_client.py +31 -0
  64. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/test_functools_ext.py +3 -1
  65. lago-python-client-1.11.0/tests/test_gross_revenue_client.py +29 -0
  66. lago-python-client-1.11.0/tests/test_invoice_client.py +257 -0
  67. lago-python-client-1.11.0/tests/test_invoice_collection_client.py +30 -0
  68. lago-python-client-1.11.0/tests/test_invoiced_usage_client.py +29 -0
  69. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/test_json_services.py +4 -3
  70. lago-python-client-1.11.0/tests/test_mrr_client.py +28 -0
  71. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/test_organization_client.py +23 -16
  72. lago-python-client-1.11.0/tests/test_overdue_balance_client.py +29 -0
  73. lago-python-client-1.11.0/tests/test_payment_request_client.py +109 -0
  74. lago-python-client-1.11.0/tests/test_plan_client.py +330 -0
  75. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/test_request_services.py +23 -12
  76. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/test_response_services.py +36 -31
  77. lago-python-client-1.11.0/tests/test_subscription_client.py +276 -0
  78. lago-python-client-1.11.0/tests/test_tax_client.py +194 -0
  79. lago-python-client-1.11.0/tests/test_wallet_client.py +207 -0
  80. lago-python-client-1.11.0/tests/test_wallet_transaction_client.py +70 -0
  81. lago-python-client-1.11.0/tests/test_webhook_client.py +42 -0
  82. lago-python-client-1.11.0/tests/test_webhook_endpoint_client.py +170 -0
  83. lago-python-client-1.9.1/lago_python_client/__init__.py +0 -2
  84. lago-python-client-1.9.1/lago_python_client/billable_metrics/clients.py +0 -26
  85. lago-python-client-1.9.1/lago_python_client/events/clients.py +0 -55
  86. lago-python-client-1.9.1/lago_python_client/models/__init__.py +0 -25
  87. lago-python-client-1.9.1/lago_python_client/payment_requests/clients.py +0 -22
  88. lago-python-client-1.9.1/lago_python_client/subscriptions/clients.py +0 -18
  89. lago-python-client-1.9.1/lago_python_client/version.py +0 -1
  90. lago-python-client-1.9.1/lago_python_client/webhook_endpoints/clients.py +0 -29
  91. lago-python-client-1.9.1/pyproject.toml +0 -6
  92. lago-python-client-1.9.1/tests/test_add_on_client.py +0 -152
  93. lago-python-client-1.9.1/tests/test_applied_coupon_client.py +0 -108
  94. lago-python-client-1.9.1/tests/test_billable_metric_client.py +0 -153
  95. lago-python-client-1.9.1/tests/test_client.py +0 -14
  96. lago-python-client-1.9.1/tests/test_coupon_client.py +0 -152
  97. lago-python-client-1.9.1/tests/test_credit_note_client.py +0 -165
  98. lago-python-client-1.9.1/tests/test_customer_client.py +0 -205
  99. lago-python-client-1.9.1/tests/test_event_client.py +0 -116
  100. lago-python-client-1.9.1/tests/test_fee_client.py +0 -27
  101. lago-python-client-1.9.1/tests/test_gross_revenue_client.py +0 -28
  102. lago-python-client-1.9.1/tests/test_invoice_client.py +0 -195
  103. lago-python-client-1.9.1/tests/test_invoice_collection_client.py +0 -29
  104. lago-python-client-1.9.1/tests/test_invoiced_usage_client.py +0 -28
  105. lago-python-client-1.9.1/tests/test_mrr_client.py +0 -27
  106. lago-python-client-1.9.1/tests/test_overdue_balance_client.py +0 -28
  107. lago-python-client-1.9.1/tests/test_payment_request_client.py +0 -45
  108. lago-python-client-1.9.1/tests/test_plan_client.py +0 -247
  109. lago-python-client-1.9.1/tests/test_subscription_client.py +0 -162
  110. lago-python-client-1.9.1/tests/test_tax_client.py +0 -145
  111. lago-python-client-1.9.1/tests/test_wallet_client.py +0 -158
  112. lago-python-client-1.9.1/tests/test_wallet_transaction_client.py +0 -62
  113. lago-python-client-1.9.1/tests/test_webhook_client.py +0 -33
  114. lago-python-client-1.9.1/tests/test_webhook_endpoint_client.py +0 -127
  115. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/LICENSE +0 -0
  116. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/README.md +0 -0
  117. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/add_ons/__init__.py +0 -0
  118. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/base_model.py +0 -0
  119. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/billable_metrics/__init__.py +0 -0
  120. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/coupons/__init__.py +0 -0
  121. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/credit_notes/__init__.py +0 -0
  122. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/customers/__init__.py +0 -0
  123. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/events/__init__.py +0 -0
  124. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/fees/__init__.py +0 -0
  125. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/gross_revenues/__init__.py +0 -0
  126. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoice_collections/__init__.py +0 -0
  127. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoiced_usages/__init__.py +0 -0
  128. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/invoices/__init__.py +0 -0
  129. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/applied_coupon.py +0 -0
  130. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/charge.py +0 -0
  131. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/coupon.py +0 -0
  132. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/credit.py +0 -0
  133. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/credit_note.py +0 -0
  134. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/invoice_item.py +0 -0
  135. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/subscription.py +0 -0
  136. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/tax.py +0 -0
  137. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/wallet.py +0 -0
  138. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/wallet_transaction.py +0 -0
  139. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/models/webhook_endpoint.py +0 -0
  140. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/mrrs/__init__.py +0 -0
  141. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/organizations/__init__.py +0 -0
  142. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/overdue_balances/__init__.py +0 -0
  143. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/payment_requests/__init__.py +0 -0
  144. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/plans/__init__.py +0 -0
  145. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/py.typed +0 -0
  146. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/services/__init__.py +0 -0
  147. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/subscriptions/__init__.py +0 -0
  148. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/taxes/__init__.py +0 -0
  149. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/wallets/__init__.py +0 -0
  150. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/webhook_endpoints/__init__.py +0 -0
  151. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client/webhooks/__init__.py +0 -0
  152. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client.egg-info/dependency_links.txt +0 -0
  153. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client.egg-info/requires.txt +0 -0
  154. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/lago_python_client.egg-info/top_level.txt +0 -0
  155. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/setup.cfg +0 -0
  156. {lago-python-client-1.9.1 → lago-python-client-1.11.0}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lago-python-client
3
- Version: 1.9.1
3
+ Version: 1.11.0
4
4
  Summary: Lago Python API Client
5
5
  Home-page: https://github.com/getlago/lago-python-client
6
6
  Author: Lovro Colic
@@ -0,0 +1,2 @@
1
+ from lago_python_client.client import Client as Client
2
+ from lago_python_client.version import LAGO_VERSION as LAGO_VERSION
@@ -1,7 +1,13 @@
1
1
  from typing import ClassVar, Type
2
2
 
3
3
  from ..base_client import BaseClient
4
- from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
4
+ from ..mixins import (
5
+ CreateCommandMixin,
6
+ DestroyCommandMixin,
7
+ FindAllCommandMixin,
8
+ FindCommandMixin,
9
+ UpdateCommandMixin,
10
+ )
5
11
  from ..models.add_on import AddOnResponse
6
12
 
7
13
 
@@ -13,6 +19,6 @@ class AddOnClient(
13
19
  UpdateCommandMixin[AddOnResponse],
14
20
  BaseClient,
15
21
  ):
16
- API_RESOURCE: ClassVar[str] = 'add_ons'
22
+ API_RESOURCE: ClassVar[str] = "add_ons"
17
23
  RESPONSE_MODEL: ClassVar[Type[AddOnResponse]] = AddOnResponse
18
- ROOT_NAME: ClassVar[str] = 'add_on'
24
+ ROOT_NAME: ClassVar[str] = "add_on"
@@ -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
@@ -0,0 +1,24 @@
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.billable_metric import BillableMetricResponse
12
+
13
+
14
+ class BillableMetricClient(
15
+ CreateCommandMixin[BillableMetricResponse],
16
+ DestroyCommandMixin[BillableMetricResponse],
17
+ FindAllCommandMixin[BillableMetricResponse],
18
+ FindCommandMixin[BillableMetricResponse],
19
+ UpdateCommandMixin[BillableMetricResponse],
20
+ BaseClient,
21
+ ):
22
+ API_RESOURCE: ClassVar[str] = "billable_metrics"
23
+ RESPONSE_MODEL: ClassVar[Type[BillableMetricResponse]] = BillableMetricResponse
24
+ ROOT_NAME: ClassVar[str] = "billable_metric"
@@ -30,17 +30,34 @@ except ImportError: # Python 3.7
30
30
 
31
31
 
32
32
  class Client:
33
- BASE_URL: Final[str] = 'https://api.getlago.com/'
34
- API_PATH: Final[str] = 'api/v1/'
33
+ BASE_URL: Final[str] = "https://api.getlago.com/"
34
+ BASE_INGEST_URL: Final[str] = "https://ingest.getlago.com/"
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,7 +1,13 @@
1
1
  from typing import ClassVar, Type
2
2
 
3
3
  from ..base_client import BaseClient
4
- from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
4
+ from ..mixins import (
5
+ CreateCommandMixin,
6
+ DestroyCommandMixin,
7
+ FindAllCommandMixin,
8
+ FindCommandMixin,
9
+ UpdateCommandMixin,
10
+ )
5
11
  from ..models.coupon import CouponResponse
6
12
  from ..models.applied_coupon import AppliedCouponResponse
7
13
  from ..services.request import make_headers, make_url, send_delete_request
@@ -16,21 +22,30 @@ class CouponClient(
16
22
  UpdateCommandMixin[CouponResponse],
17
23
  BaseClient,
18
24
  ):
19
- API_RESOURCE: ClassVar[str] = 'coupons'
25
+ API_RESOURCE: ClassVar[str] = "coupons"
20
26
  RESPONSE_MODEL: ClassVar[Type[CouponResponse]] = CouponResponse
21
- ROOT_NAME: ClassVar[str] = 'coupon'
27
+ ROOT_NAME: ClassVar[str] = "coupon"
22
28
 
23
29
 
24
- class AppliedCouponClient(CreateCommandMixin[AppliedCouponResponse], FindAllCommandMixin[AppliedCouponResponse], BaseClient):
25
- API_RESOURCE: ClassVar[str] = 'applied_coupons'
30
+ class AppliedCouponClient(
31
+ CreateCommandMixin[AppliedCouponResponse],
32
+ FindAllCommandMixin[AppliedCouponResponse],
33
+ BaseClient,
34
+ ):
35
+ API_RESOURCE: ClassVar[str] = "applied_coupons"
26
36
  RESPONSE_MODEL: ClassVar[Type[AppliedCouponResponse]] = AppliedCouponResponse
27
- ROOT_NAME: ClassVar[str] = 'applied_coupon'
37
+ ROOT_NAME: ClassVar[str] = "applied_coupon"
28
38
 
29
39
  def destroy(self, external_customer_id: str, applied_coupon_id: str) -> AppliedCouponResponse:
30
40
  api_response: Response = send_delete_request(
31
41
  url=make_url(
32
42
  origin=self.base_url,
33
- path_parts=('customers', external_customer_id, self.API_RESOURCE, applied_coupon_id),
43
+ path_parts=(
44
+ "customers",
45
+ external_customer_id,
46
+ self.API_RESOURCE,
47
+ applied_coupon_id,
48
+ ),
34
49
  ),
35
50
  headers=make_headers(api_key=self.api_key),
36
51
  )
@@ -1,10 +1,24 @@
1
- from typing import ClassVar, Optional, Type, Union
1
+ from typing import ClassVar, Optional, Type
2
2
 
3
3
  from ..base_client import BaseClient
4
- from ..mixins import CreateCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
5
- from ..models.credit_note import CreditNoteResponse, CreditNoteEstimatedResponse, CreditNoteEstimate
4
+ from ..mixins import (
5
+ CreateCommandMixin,
6
+ FindAllCommandMixin,
7
+ FindCommandMixin,
8
+ UpdateCommandMixin,
9
+ )
10
+ from ..models.credit_note import (
11
+ CreditNoteResponse,
12
+ CreditNoteEstimatedResponse,
13
+ CreditNoteEstimate,
14
+ )
6
15
  from ..services.json import to_json
7
- from ..services.request import make_headers, make_url, send_post_request, send_put_request
16
+ from ..services.request import (
17
+ make_headers,
18
+ make_url,
19
+ send_post_request,
20
+ send_put_request,
21
+ )
8
22
  from ..services.response import get_response_data, prepare_object_response, Response
9
23
 
10
24
 
@@ -15,16 +29,16 @@ class CreditNoteClient(
15
29
  UpdateCommandMixin[CreditNoteResponse],
16
30
  BaseClient,
17
31
  ):
18
- API_RESOURCE: ClassVar[str] = 'credit_notes'
19
- ESTIMATE_API_RESOURCE: ClassVar[str] = 'estimated_credit_note'
32
+ API_RESOURCE: ClassVar[str] = "credit_notes"
33
+ ESTIMATE_API_RESOURCE: ClassVar[str] = "estimated_credit_note"
20
34
  RESPONSE_MODEL: ClassVar[Type[CreditNoteResponse]] = CreditNoteResponse
21
- ROOT_NAME: ClassVar[str] = 'credit_note'
35
+ ROOT_NAME: ClassVar[str] = "credit_note"
22
36
 
23
37
  def download(self, resource_id: str) -> Optional[CreditNoteResponse]:
24
38
  api_response: Response = send_post_request(
25
39
  url=make_url(
26
40
  origin=self.base_url,
27
- path_parts=(self.API_RESOURCE, resource_id, 'download'),
41
+ path_parts=(self.API_RESOURCE, resource_id, "download"),
28
42
  ),
29
43
  headers=make_headers(api_key=self.api_key),
30
44
  )
@@ -42,7 +56,7 @@ class CreditNoteClient(
42
56
  api_response: Response = send_put_request(
43
57
  url=make_url(
44
58
  origin=self.base_url,
45
- path_parts=(self.API_RESOURCE, resource_id, 'void'),
59
+ path_parts=(self.API_RESOURCE, resource_id, "void"),
46
60
  ),
47
61
  headers=make_headers(api_key=self.api_key),
48
62
  )
@@ -56,11 +70,13 @@ class CreditNoteClient(
56
70
  api_response: Response = send_post_request(
57
71
  url=make_url(
58
72
  origin=self.base_url,
59
- path_parts=(self.API_RESOURCE, 'estimate'),
73
+ path_parts=(self.API_RESOURCE, "estimate"),
74
+ ),
75
+ content=to_json(
76
+ {
77
+ self.ROOT_NAME: input_object.dict(),
78
+ }
60
79
  ),
61
- content=to_json({
62
- self.ROOT_NAME: input_object.dict(),
63
- }),
64
80
  headers=make_headers(api_key=self.api_key),
65
81
  )
66
82
 
@@ -2,11 +2,26 @@ import sys
2
2
  from typing import Any, Mapping, ClassVar, Type, Union
3
3
 
4
4
  from ..base_client import BaseClient
5
- from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin
5
+ from ..mixins import (
6
+ CreateCommandMixin,
7
+ DestroyCommandMixin,
8
+ FindAllCommandMixin,
9
+ FindCommandMixin,
10
+ )
6
11
  from ..models.customer import CustomerResponse
7
12
  from ..models.customer_usage import CustomerUsageResponse
8
- from ..services.request import make_headers, make_url, send_get_request, send_post_request
9
- from ..services.response import get_response_data, prepare_index_response, prepare_object_response, Response
13
+ from ..services.request import (
14
+ make_headers,
15
+ make_url,
16
+ send_get_request,
17
+ send_post_request,
18
+ )
19
+ from ..services.response import (
20
+ get_response_data,
21
+ prepare_index_response,
22
+ prepare_object_response,
23
+ Response,
24
+ )
10
25
 
11
26
  if sys.version_info >= (3, 9):
12
27
  from collections.abc import Mapping
@@ -21,17 +36,17 @@ class CustomerClient(
21
36
  FindCommandMixin[CustomerResponse],
22
37
  BaseClient,
23
38
  ):
24
- API_RESOURCE: ClassVar[str] = 'customers'
39
+ API_RESOURCE: ClassVar[str] = "customers"
25
40
  RESPONSE_MODEL: ClassVar[Type[CustomerResponse]] = CustomerResponse
26
- ROOT_NAME: ClassVar[str] = 'customer'
41
+ ROOT_NAME: ClassVar[str] = "customer"
27
42
 
28
43
  def current_usage(self, resource_id: str, external_subscription_id: str) -> CustomerUsageResponse:
29
44
  api_response: Response = send_get_request(
30
45
  url=make_url(
31
46
  origin=self.base_url,
32
- path_parts=(self.API_RESOURCE, resource_id, 'current_usage'),
47
+ path_parts=(self.API_RESOURCE, resource_id, "current_usage"),
33
48
  query_pairs={
34
- 'external_subscription_id': external_subscription_id,
49
+ "external_subscription_id": external_subscription_id,
35
50
  },
36
51
  ),
37
52
  headers=make_headers(api_key=self.api_key),
@@ -39,16 +54,21 @@ class CustomerClient(
39
54
 
40
55
  return prepare_object_response(
41
56
  response_model=CustomerUsageResponse,
42
- data=get_response_data(response=api_response, key='customer_usage'),
57
+ data=get_response_data(response=api_response, key="customer_usage"),
43
58
  )
44
59
 
45
- def past_usage(self, resource_id: str, external_subscription_id: str, options: Mapping[str, Union[int, str]] = {}) -> Mapping[str, Any]:
60
+ def past_usage(
61
+ self,
62
+ resource_id: str,
63
+ external_subscription_id: str,
64
+ options: Mapping[str, Union[int, str]] = {},
65
+ ) -> Mapping[str, Any]:
46
66
  api_response: Response = send_get_request(
47
67
  url=make_url(
48
68
  origin=self.base_url,
49
- path_parts=(self.API_RESOURCE, resource_id, 'past_usage'),
69
+ path_parts=(self.API_RESOURCE, resource_id, "past_usage"),
50
70
  query_pairs={
51
- 'external_subscription_id': external_subscription_id,
71
+ "external_subscription_id": external_subscription_id,
52
72
  **options,
53
73
  },
54
74
  ),
@@ -56,32 +76,31 @@ class CustomerClient(
56
76
  )
57
77
 
58
78
  return prepare_index_response(
59
- api_resource='usage_periods',
79
+ api_resource="usage_periods",
60
80
  response_model=CustomerUsageResponse,
61
81
  data=get_response_data(response=api_response),
62
82
  )
63
83
 
64
-
65
84
  def portal_url(self, resource_id: str) -> str:
66
85
  api_response: Response = send_get_request(
67
86
  url=make_url(
68
87
  origin=self.base_url,
69
- path_parts=(self.API_RESOURCE, resource_id, 'portal_url'),
88
+ path_parts=(self.API_RESOURCE, resource_id, "portal_url"),
70
89
  ),
71
90
  headers=make_headers(api_key=self.api_key),
72
91
  )
73
92
 
74
93
  response_data = get_response_data(response=api_response, key=self.ROOT_NAME)
75
- return response_data.get('portal_url', '') if isinstance(response_data, Mapping) else ''
94
+ return response_data.get("portal_url", "") if isinstance(response_data, Mapping) else ""
76
95
 
77
96
  def checkout_url(self, resource_id: str) -> str:
78
97
  api_response: Response = send_post_request(
79
98
  url=make_url(
80
99
  origin=self.base_url,
81
- path_parts=(self.API_RESOURCE, resource_id, 'checkout_url'),
100
+ path_parts=(self.API_RESOURCE, resource_id, "checkout_url"),
82
101
  ),
83
102
  headers=make_headers(api_key=self.api_key),
84
103
  )
85
104
 
86
105
  response_data = get_response_data(response=api_response, key=self.ROOT_NAME)
87
- return response_data.get('checkout_url', '') if isinstance(response_data, Mapping) else ''
106
+ return response_data.get("checkout_url", "") if isinstance(response_data, Mapping) else ""
@@ -0,0 +1,90 @@
1
+ import sys
2
+ from typing import Any, ClassVar, Optional, Type
3
+
4
+ import httpx
5
+
6
+ from lago_python_client.base_model import BaseModel
7
+
8
+ from ..base_client import BaseClient
9
+ from ..fees.clients import FeeClient
10
+ from ..mixins import FindCommandMixin
11
+ from ..models.event import EventResponse
12
+ from ..models.fee import FeeResponse
13
+ from ..services.json import to_json
14
+ from ..services.request import make_headers, make_url, send_post_request
15
+ from ..services.response import (
16
+ get_response_data,
17
+ prepare_object_response,
18
+ prepare_object_list_response,
19
+ verify_response,
20
+ Response,
21
+ )
22
+
23
+ if sys.version_info >= (3, 9):
24
+ from collections.abc import Mapping
25
+ else:
26
+ from typing import Mapping
27
+
28
+
29
+ class EventClient(FindCommandMixin[EventResponse], BaseClient):
30
+ API_RESOURCE: ClassVar[str] = "events"
31
+ RESPONSE_MODEL: ClassVar[Type[EventResponse]] = EventResponse
32
+ ROOT_NAME: ClassVar[str] = "event"
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
+
59
+ def batch_create(self, input_object: BaseModel) -> None:
60
+ api_response: Response = send_post_request(
61
+ url=make_url(
62
+ origin=self.base_url,
63
+ path_parts=(self.API_RESOURCE, "batch"),
64
+ ),
65
+ content=to_json(input_object.dict()),
66
+ headers=make_headers(api_key=self.api_key),
67
+ )
68
+ verify_response(api_response)
69
+
70
+ return None
71
+
72
+ def estimate_fees(self, input_object: BaseModel) -> Mapping[str, Any]:
73
+ api_response: Response = send_post_request(
74
+ url=make_url(
75
+ origin=self.base_url,
76
+ path_parts=(self.API_RESOURCE, "estimate_fees"),
77
+ ),
78
+ content=to_json(
79
+ {
80
+ self.ROOT_NAME: input_object.dict(),
81
+ }
82
+ ),
83
+ headers=make_headers(api_key=self.api_key),
84
+ )
85
+
86
+ return prepare_object_list_response(
87
+ api_resource=FeeClient.API_RESOURCE,
88
+ response_model=FeeResponse,
89
+ data=get_response_data(response=api_response, key="fees"),
90
+ )
@@ -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}"
@@ -1,7 +1,12 @@
1
1
  from typing import ClassVar, Type
2
2
 
3
3
  from ..base_client import BaseClient
4
- from ..mixins import FindCommandMixin, FindAllCommandMixin, UpdateCommandMixin, DestroyCommandMixin
4
+ from ..mixins import (
5
+ FindCommandMixin,
6
+ FindAllCommandMixin,
7
+ UpdateCommandMixin,
8
+ DestroyCommandMixin,
9
+ )
5
10
  from ..models.fee import FeeResponse
6
11
 
7
12
 
@@ -12,6 +17,6 @@ class FeeClient(
12
17
  DestroyCommandMixin[FeeResponse],
13
18
  BaseClient,
14
19
  ):
15
- API_RESOURCE: ClassVar[str] = 'fees'
20
+ API_RESOURCE: ClassVar[str] = "fees"
16
21
  RESPONSE_MODEL: ClassVar[Type[FeeResponse]] = FeeResponse
17
- ROOT_NAME: ClassVar[str] = 'fee'
22
+ ROOT_NAME: ClassVar[str] = "fee"
@@ -1,6 +1,7 @@
1
1
  import sys
2
2
  from typing import Any, TypeVar
3
3
  import warnings
4
+
4
5
  try:
5
6
  from functools import cached_property
6
7
  except ImportError:
@@ -30,11 +31,13 @@ class Proxy(object):
30
31
 
31
32
  def __call__(self) -> Any:
32
33
  warnings.warn(
33
- ''.join((
34
- 'We are going to deprecate callable properties (`client.<your_tag_name>()`) in future. ',
35
- 'Please, remove braces. ',
36
- 'Use `client.<your_tag_name>.<your_operation_name>(...)` instead of `client.<your_tag_name>().<your_operation_name>(...)`',
37
- )),
34
+ "".join(
35
+ (
36
+ "We are going to deprecate callable properties (`client.<your_tag_name>()`) in future. ",
37
+ "Please, remove braces. ",
38
+ "Use `client.<your_tag_name>.<your_operation_name>(...)` instead of `client.<your_tag_name>().<your_operation_name>(...)`",
39
+ )
40
+ ),
38
41
  PendingDeprecationWarning,
39
42
  )
40
43
  return self._obj
@@ -53,8 +56,10 @@ class Proxy(object):
53
56
 
54
57
 
55
58
  if sys.version_info >= (3, 9):
59
+
56
60
  def callable_cached_property(func: Callable[P, T]) -> cached_property[T]:
57
61
  return cached_property(lambda s: Proxy(func(s))) # type: ignore
58
62
  else:
63
+
59
64
  def callable_cached_property(func):
60
65
  return cached_property(lambda s: Proxy(func(s)))
@@ -17,15 +17,15 @@ class GrossRevenueClient(
17
17
  FindAllCommandMixin[GrossRevenueResponse],
18
18
  BaseClient,
19
19
  ):
20
- API_RESOURCE: ClassVar[str] = 'gross_revenues'
20
+ API_RESOURCE: ClassVar[str] = "gross_revenues"
21
21
  RESPONSE_MODEL: ClassVar[Type[GrossRevenueResponse]] = GrossRevenueResponse
22
- ROOT_NAME: ClassVar[str] = 'gross_revenue'
22
+ ROOT_NAME: ClassVar[str] = "gross_revenue"
23
23
 
24
24
  def find_all(self, options: Mapping[str, Union[int, str]] = {}) -> Mapping[str, Any]:
25
25
  api_response: Response = send_get_request(
26
26
  url=make_url(
27
27
  origin=self.base_url,
28
- path_parts=('analytics', 'gross_revenue'),
28
+ path_parts=("analytics", "gross_revenue"),
29
29
  query_pairs=options,
30
30
  ),
31
31
  headers=make_headers(api_key=self.api_key),
@@ -17,15 +17,15 @@ class InvoiceCollectionClient(
17
17
  FindAllCommandMixin[InvoiceCollectionResponse],
18
18
  BaseClient,
19
19
  ):
20
- API_RESOURCE: ClassVar[str] = 'invoice_collections'
20
+ API_RESOURCE: ClassVar[str] = "invoice_collections"
21
21
  RESPONSE_MODEL: ClassVar[Type[InvoiceCollectionResponse]] = InvoiceCollectionResponse
22
- ROOT_NAME: ClassVar[str] = 'invoice_collection'
22
+ ROOT_NAME: ClassVar[str] = "invoice_collection"
23
23
 
24
24
  def find_all(self, options: Mapping[str, Union[int, str]] = {}) -> Mapping[str, Any]:
25
25
  api_response: Response = send_get_request(
26
26
  url=make_url(
27
27
  origin=self.base_url,
28
- path_parts=('analytics', 'invoice_collection'),
28
+ path_parts=("analytics", "invoice_collection"),
29
29
  query_pairs=options,
30
30
  ),
31
31
  headers=make_headers(api_key=self.api_key),
@@ -17,15 +17,15 @@ class InvoicedUsageClient(
17
17
  FindAllCommandMixin[InvoicedUsageResponse],
18
18
  BaseClient,
19
19
  ):
20
- API_RESOURCE: ClassVar[str] = 'invoiced_usages'
20
+ API_RESOURCE: ClassVar[str] = "invoiced_usages"
21
21
  RESPONSE_MODEL: ClassVar[Type[InvoicedUsageResponse]] = InvoicedUsageResponse
22
- ROOT_NAME: ClassVar[str] = 'invoiced_usage'
22
+ ROOT_NAME: ClassVar[str] = "invoiced_usage"
23
23
 
24
24
  def find_all(self, options: Mapping[str, Union[int, str]] = {}) -> Mapping[str, Any]:
25
25
  api_response: Response = send_get_request(
26
26
  url=make_url(
27
27
  origin=self.base_url,
28
- path_parts=('analytics', 'invoiced_usage'),
28
+ path_parts=("analytics", "invoiced_usage"),
29
29
  query_pairs=options,
30
30
  ),
31
31
  headers=make_headers(api_key=self.api_key),