lago-python-client 1.18.0__tar.gz → 1.22.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 (131) hide show
  1. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/PKG-INFO +1 -1
  2. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/client.py +5 -0
  3. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/customers/clients.py +9 -5
  4. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoices/clients.py +17 -1
  5. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/__init__.py +7 -1
  6. lago_python_client-1.22.0/lago_python_client/models/billing_period.py +18 -0
  7. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/coupon.py +4 -0
  8. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/invoice.py +15 -2
  9. lago_python_client-1.22.0/lago_python_client/models/payment.py +26 -0
  10. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/subscription.py +4 -0
  11. lago_python_client-1.22.0/lago_python_client/payments/clients.py +16 -0
  12. lago_python_client-1.22.0/lago_python_client/version.py +1 -0
  13. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client.egg-info/PKG-INFO +1 -1
  14. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client.egg-info/SOURCES.txt +10 -0
  15. lago_python_client-1.22.0/tests/__init__.py +0 -0
  16. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_customer_client.py +17 -0
  17. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_invoice_client.py +23 -0
  18. lago_python_client-1.22.0/tests/test_payment_client.py +108 -0
  19. lago_python_client-1.18.0/lago_python_client/version.py +0 -1
  20. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/LICENSE +0 -0
  21. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/README.md +0 -0
  22. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/__init__.py +0 -0
  23. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/add_ons/__init__.py +0 -0
  24. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/add_ons/clients.py +0 -0
  25. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/base_client.py +0 -0
  26. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/base_model.py +0 -0
  27. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/billable_metrics/__init__.py +0 -0
  28. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/billable_metrics/clients.py +0 -0
  29. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/coupons/__init__.py +0 -0
  30. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/coupons/clients.py +0 -0
  31. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/credit_notes/__init__.py +0 -0
  32. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/credit_notes/clients.py +0 -0
  33. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/customers/__init__.py +0 -0
  34. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/events/__init__.py +0 -0
  35. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/events/clients.py +0 -0
  36. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/exceptions.py +0 -0
  37. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/fees/__init__.py +0 -0
  38. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/fees/clients.py +0 -0
  39. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/functools_ext.py +0 -0
  40. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/gross_revenues/__init__.py +0 -0
  41. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/gross_revenues/clients.py +0 -0
  42. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoice_collections/__init__.py +0 -0
  43. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoice_collections/clients.py +0 -0
  44. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoiced_usages/__init__.py +0 -0
  45. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoiced_usages/clients.py +0 -0
  46. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/invoices/__init__.py +0 -0
  47. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/mixins.py +0 -0
  48. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/add_on.py +0 -0
  49. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/applied_coupon.py +0 -0
  50. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/billable_metric.py +0 -0
  51. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/charge.py +0 -0
  52. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/credit.py +0 -0
  53. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/credit_note.py +0 -0
  54. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/customer.py +0 -0
  55. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/customer_usage.py +0 -0
  56. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/error_detail.py +0 -0
  57. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/event.py +0 -0
  58. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/fee.py +0 -0
  59. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/gross_revenue.py +0 -0
  60. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/invoice_collection.py +0 -0
  61. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/invoice_item.py +0 -0
  62. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/invoiced_usage.py +0 -0
  63. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/lifetime_usage.py +0 -0
  64. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/minimum_commitment.py +0 -0
  65. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/mrr.py +0 -0
  66. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/organization.py +0 -0
  67. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/overdue_balance.py +0 -0
  68. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/payment_request.py +0 -0
  69. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/plan.py +0 -0
  70. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/tax.py +0 -0
  71. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/usage_threshold.py +0 -0
  72. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/wallet.py +0 -0
  73. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/wallet_transaction.py +0 -0
  74. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/models/webhook_endpoint.py +0 -0
  75. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/mrrs/__init__.py +0 -0
  76. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/mrrs/clients.py +0 -0
  77. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/organizations/__init__.py +0 -0
  78. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/organizations/clients.py +0 -0
  79. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/overdue_balances/__init__.py +0 -0
  80. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/overdue_balances/clients.py +0 -0
  81. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/payment_requests/__init__.py +0 -0
  82. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/payment_requests/clients.py +0 -0
  83. {lago_python_client-1.18.0/lago_python_client/plans → lago_python_client-1.22.0/lago_python_client/payments}/__init__.py +0 -0
  84. {lago_python_client-1.18.0/lago_python_client/services → lago_python_client-1.22.0/lago_python_client/plans}/__init__.py +0 -0
  85. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/plans/clients.py +0 -0
  86. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/py.typed +0 -0
  87. {lago_python_client-1.18.0/lago_python_client/subscriptions → lago_python_client-1.22.0/lago_python_client/services}/__init__.py +0 -0
  88. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/services/json.py +0 -0
  89. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/services/request.py +0 -0
  90. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/services/response.py +0 -0
  91. {lago_python_client-1.18.0/lago_python_client/taxes → lago_python_client-1.22.0/lago_python_client/subscriptions}/__init__.py +0 -0
  92. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/subscriptions/clients.py +0 -0
  93. {lago_python_client-1.18.0/lago_python_client/wallets → lago_python_client-1.22.0/lago_python_client/taxes}/__init__.py +0 -0
  94. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/taxes/clients.py +0 -0
  95. {lago_python_client-1.18.0/lago_python_client/webhook_endpoints → lago_python_client-1.22.0/lago_python_client/wallets}/__init__.py +0 -0
  96. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/wallets/clients.py +0 -0
  97. {lago_python_client-1.18.0/lago_python_client/webhooks → lago_python_client-1.22.0/lago_python_client/webhook_endpoints}/__init__.py +0 -0
  98. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/webhook_endpoints/clients.py +0 -0
  99. {lago_python_client-1.18.0/tests → lago_python_client-1.22.0/lago_python_client/webhooks}/__init__.py +0 -0
  100. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client/webhooks/clients.py +0 -0
  101. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client.egg-info/dependency_links.txt +0 -0
  102. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client.egg-info/requires.txt +0 -0
  103. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/lago_python_client.egg-info/top_level.txt +0 -0
  104. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/pyproject.toml +0 -0
  105. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/setup.cfg +0 -0
  106. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_add_on_client.py +0 -0
  107. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_applied_coupon_client.py +0 -0
  108. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_billable_metric_client.py +0 -0
  109. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_client.py +0 -0
  110. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_coupon_client.py +0 -0
  111. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_credit_note_client.py +0 -0
  112. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_event_client.py +0 -0
  113. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_fee_client.py +0 -0
  114. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_functools_ext.py +0 -0
  115. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_gross_revenue_client.py +0 -0
  116. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_invoice_collection_client.py +0 -0
  117. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_invoiced_usage_client.py +0 -0
  118. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_json_services.py +0 -0
  119. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_mrr_client.py +0 -0
  120. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_organization_client.py +0 -0
  121. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_overdue_balance_client.py +0 -0
  122. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_payment_request_client.py +0 -0
  123. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_plan_client.py +0 -0
  124. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_request_services.py +0 -0
  125. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_response_services.py +0 -0
  126. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_subscription_client.py +0 -0
  127. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_tax_client.py +0 -0
  128. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_wallet_client.py +0 -0
  129. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_wallet_transaction_client.py +0 -0
  130. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_webhook_client.py +0 -0
  131. {lago_python_client-1.18.0 → lago_python_client-1.22.0}/tests/test_webhook_endpoint_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lago-python-client
3
- Version: 1.18.0
3
+ Version: 1.22.0
4
4
  Summary: Lago Python API Client
5
5
  Home-page: https://github.com/getlago/lago-python-client
6
6
  Author: Lovro Colic
@@ -15,6 +15,7 @@ from .mrrs.clients import MrrClient
15
15
  from .organizations.clients import OrganizationClient
16
16
  from .overdue_balances.clients import OverdueBalanceClient
17
17
  from .payment_requests.clients import PaymentRequestClient
18
+ from .payments.clients import PaymentClient
18
19
  from .invoice_collections.clients import InvoiceCollectionClient
19
20
  from .plans.clients import PlanClient
20
21
  from .subscriptions.clients import SubscriptionClient
@@ -118,6 +119,10 @@ class Client:
118
119
  def payment_requests(self) -> PaymentRequestClient:
119
120
  return PaymentRequestClient(self.base_api_url, self.api_key)
120
121
 
122
+ @callable_cached_property
123
+ def payments(self) -> PaymentClient:
124
+ return PaymentClient(self.base_api_url, self.api_key)
125
+
121
126
  @callable_cached_property
122
127
  def invoice_collections(self) -> InvoiceCollectionClient:
123
128
  return InvoiceCollectionClient(self.base_api_url, self.api_key)
@@ -1,5 +1,5 @@
1
1
  import sys
2
- from typing import Any, Mapping, ClassVar, Type
2
+ from typing import Any, Mapping, ClassVar, Type, Optional
3
3
 
4
4
  from ..base_client import BaseClient
5
5
  from ..mixins import (
@@ -35,14 +35,18 @@ class CustomerClient(
35
35
  RESPONSE_MODEL: ClassVar[Type[CustomerResponse]] = CustomerResponse
36
36
  ROOT_NAME: ClassVar[str] = "customer"
37
37
 
38
- def current_usage(self, resource_id: str, external_subscription_id: str) -> CustomerUsageResponse:
38
+ def current_usage(
39
+ self, resource_id: str, external_subscription_id: str, apply_taxes: Optional[str] = None
40
+ ) -> CustomerUsageResponse:
41
+ query_params = {"external_subscription_id": external_subscription_id}
42
+ if apply_taxes is not None:
43
+ query_params["apply_taxes"] = apply_taxes
44
+
39
45
  api_response: Response = send_get_request(
40
46
  url=make_url(
41
47
  origin=self.base_url,
42
48
  path_parts=(self.API_RESOURCE, resource_id, "current_usage"),
43
- query_pairs={
44
- "external_subscription_id": external_subscription_id,
45
- },
49
+ query_pairs=query_params,
46
50
  ),
47
51
  headers=make_headers(api_key=self.api_key),
48
52
  )
@@ -7,7 +7,8 @@ from ..mixins import (
7
7
  UpdateCommandMixin,
8
8
  CreateCommandMixin,
9
9
  )
10
- from ..models.invoice import InvoiceResponse
10
+ from ..models.invoice import InvoicePreview, InvoiceResponse
11
+ from ..services.json import to_json
11
12
  from ..services.request import (
12
13
  make_headers,
13
14
  make_url,
@@ -131,3 +132,18 @@ class InvoiceClient(
131
132
 
132
133
  response_data = get_response_data(response=api_response, key="invoice_payment_details")
133
134
  return response_data.get("payment_url", "") if isinstance(response_data, Mapping) else ""
135
+
136
+ def preview(self, input_object: InvoicePreview) -> InvoiceResponse:
137
+ api_response: Response = send_post_request(
138
+ url=make_url(
139
+ origin=self.base_url,
140
+ path_parts=(self.API_RESOURCE, "preview"),
141
+ ),
142
+ content=to_json(input_object.dict()),
143
+ headers=make_headers(api_key=self.api_key),
144
+ )
145
+
146
+ return prepare_object_response(
147
+ response_model=InvoiceResponse,
148
+ data=get_response_data(response=api_response, key=self.ROOT_NAME),
149
+ )
@@ -7,6 +7,10 @@ from .billable_metric import (
7
7
  BillableMetricEvaluateExpression as BillableMetricEvaluateExpression,
8
8
  BillableMetricEvaluateExpressionResponse as BillableMetricEvaluateExpressionResponse,
9
9
  )
10
+ from .billing_period import (
11
+ BillingPeriodResponse as BillingPeriodResponse,
12
+ BillingPeriodsResponse as BillingPeriodsResponse,
13
+ )
10
14
  from .charge import (
11
15
  Charge as Charge,
12
16
  Charges as Charges,
@@ -14,7 +18,7 @@ from .charge import (
14
18
  ChargeFilters as ChargeFilters,
15
19
  ChargeFilter as ChargeFilter,
16
20
  )
17
- from .coupon import Coupon as Coupon, LimitationConfiguration as LimitationConfiguration
21
+ from .coupon import Coupon as Coupon, CouponsList as CouponsList, LimitationConfiguration as LimitationConfiguration
18
22
  from .credit import CreditResponse as CreditResponse, CreditsResponse as CreditsResponse
19
23
  from .credit_note import (
20
24
  Item as Item,
@@ -50,6 +54,7 @@ from .invoice import (
50
54
  InvoiceMetadata as InvoiceMetadata,
51
55
  InvoiceMetadataList as InvoiceMetadataList,
52
56
  OneOffInvoice as OneOffInvoice,
57
+ InvoicePreview as InvoicePreview,
53
58
  InvoiceFeesList as InvoiceFeesList,
54
59
  InvoiceFee as InvoiceFee,
55
60
  )
@@ -86,4 +91,5 @@ from .usage_threshold import (
86
91
  UsageThresholdsResponse as UsageThresholdsResponse,
87
92
  )
88
93
  from .payment_request import PaymentRequest as PaymentRequest
94
+ from .payment import Payment as Payment
89
95
  from .lifetime_usage import LifetimeUsageResponse as LifetimeUsageResponse
@@ -0,0 +1,18 @@
1
+ from typing import List
2
+
3
+ from lago_python_client.base_model import BaseResponseModel
4
+
5
+
6
+ class BillingPeriodResponse(BaseResponseModel):
7
+ lago_subscription_id: str
8
+ external_subscription_id: str
9
+ lago_plan_id: str
10
+ subscription_from_datetime: str
11
+ subscription_to_datetime: str
12
+ charges_from_datetime: str
13
+ charges_to_datetime: str
14
+ invoicing_reason: str
15
+
16
+
17
+ class BillingPeriodsResponse(BaseResponseModel):
18
+ __root__: List[BillingPeriodResponse]
@@ -46,3 +46,7 @@ class CouponResponse(BaseResponseModel):
46
46
  limited_plans: Optional[bool]
47
47
  billable_metric_codes: Optional[List[Any]]
48
48
  limited_billable_metrics: Optional[bool]
49
+
50
+
51
+ class CouponsList(BaseModel):
52
+ __root__: List[Coupon]
@@ -2,10 +2,12 @@ from typing import List, Optional
2
2
 
3
3
  from lago_python_client.base_model import BaseModel
4
4
 
5
+ from .billing_period import BillingPeriodsResponse
6
+ from .coupon import CouponsList
5
7
  from .credit import CreditsResponse
6
- from .customer import CustomerResponse
8
+ from .customer import Customer, CustomerResponse
7
9
  from .fee import FeesResponse
8
- from .subscription import SubscriptionsResponse
10
+ from .subscription import Subscriptions, SubscriptionsResponse
9
11
  from .error_detail import ErrorDetailsResponse
10
12
  from ..base_model import BaseResponseModel
11
13
  from .usage_threshold import UsageThreshold
@@ -51,6 +53,15 @@ class OneOffInvoice(BaseModel):
51
53
  error_details: Optional[ErrorDetailsResponse]
52
54
 
53
55
 
56
+ class InvoicePreview(BaseModel):
57
+ plan_code: Optional[str]
58
+ billing_time: Optional[str]
59
+ subscription_at: Optional[str]
60
+ coupons: Optional[CouponsList]
61
+ customer: Optional[Customer]
62
+ subscriptions: Optional[Subscriptions]
63
+
64
+
54
65
  class InvoiceAppliedTax(BaseResponseModel):
55
66
  lago_id: Optional[str]
56
67
  lago_invoice_id: Optional[str]
@@ -114,10 +125,12 @@ class InvoiceResponse(BaseResponseModel):
114
125
  sub_total_excluding_taxes_amount_cents: int
115
126
  sub_total_including_taxes_amount_cents: int
116
127
  total_amount_cents: int
128
+ total_due_amount_cents: int
117
129
  prepaid_credit_amount_cents: int
118
130
 
119
131
  file_url: Optional[str]
120
132
  customer: Optional[CustomerResponse]
133
+ billing_periods: Optional[BillingPeriodsResponse]
121
134
  subscriptions: Optional[SubscriptionsResponse]
122
135
  fees: Optional[FeesResponse]
123
136
  credits: Optional[CreditsResponse]
@@ -0,0 +1,26 @@
1
+ from typing import List, Optional
2
+
3
+ from ..base_model import BaseModel, BaseResponseModel
4
+
5
+
6
+ class Payment(BaseModel):
7
+ invoice_id: str
8
+ amount_cents: int
9
+ reference: str
10
+ paid_at: Optional[str]
11
+
12
+
13
+ class PaymentResponse(BaseResponseModel):
14
+ lago_id: str
15
+ invoice_ids: List[str]
16
+ amount_cents: int
17
+ amount_currency: str
18
+ payment_status: str
19
+ type: str
20
+ reference: str
21
+ external_payment_id: Optional[str]
22
+ created_at: str
23
+
24
+
25
+ class PaymentsResponse(BaseResponseModel):
26
+ __root__: List[PaymentResponse]
@@ -16,6 +16,10 @@ class Subscription(BaseModel):
16
16
  plan_overrides: Optional[PlanOverrides]
17
17
 
18
18
 
19
+ class Subscriptions(BaseModel):
20
+ external_ids: Optional[List[str]]
21
+
22
+
19
23
  class SubscriptionResponse(BaseResponseModel):
20
24
  lago_id: str
21
25
  lago_customer_id: Optional[str]
@@ -0,0 +1,16 @@
1
+ from typing import ClassVar, Type
2
+
3
+ from ..base_client import BaseClient
4
+ from ..mixins import CreateCommandMixin, FindAllCommandMixin, FindCommandMixin
5
+ from ..models.payment import PaymentResponse
6
+
7
+
8
+ class PaymentClient(
9
+ CreateCommandMixin[PaymentResponse],
10
+ FindAllCommandMixin[PaymentResponse],
11
+ FindCommandMixin[PaymentResponse],
12
+ BaseClient,
13
+ ):
14
+ API_RESOURCE: ClassVar[str] = "payments"
15
+ RESPONSE_MODEL: ClassVar[Type[PaymentResponse]] = PaymentResponse
16
+ ROOT_NAME: ClassVar[str] = "payment"
@@ -0,0 +1 @@
1
+ LAGO_VERSION = "1.22.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lago-python-client
3
- Version: 1.18.0
3
+ Version: 1.22.0
4
4
  Summary: Lago Python API Client
5
5
  Home-page: https://github.com/getlago/lago-python-client
6
6
  Author: Lovro Colic
@@ -37,6 +37,7 @@ setup.cfg
37
37
  ./lago_python_client/models/add_on.py
38
38
  ./lago_python_client/models/applied_coupon.py
39
39
  ./lago_python_client/models/billable_metric.py
40
+ ./lago_python_client/models/billing_period.py
40
41
  ./lago_python_client/models/charge.py
41
42
  ./lago_python_client/models/coupon.py
42
43
  ./lago_python_client/models/credit.py
@@ -56,6 +57,7 @@ setup.cfg
56
57
  ./lago_python_client/models/mrr.py
57
58
  ./lago_python_client/models/organization.py
58
59
  ./lago_python_client/models/overdue_balance.py
60
+ ./lago_python_client/models/payment.py
59
61
  ./lago_python_client/models/payment_request.py
60
62
  ./lago_python_client/models/plan.py
61
63
  ./lago_python_client/models/subscription.py
@@ -72,6 +74,8 @@ setup.cfg
72
74
  ./lago_python_client/overdue_balances/clients.py
73
75
  ./lago_python_client/payment_requests/__init__.py
74
76
  ./lago_python_client/payment_requests/clients.py
77
+ ./lago_python_client/payments/__init__.py
78
+ ./lago_python_client/payments/clients.py
75
79
  ./lago_python_client/plans/__init__.py
76
80
  ./lago_python_client/plans/clients.py
77
81
  ./lago_python_client/services/__init__.py
@@ -107,6 +111,7 @@ setup.cfg
107
111
  ./tests/test_mrr_client.py
108
112
  ./tests/test_organization_client.py
109
113
  ./tests/test_overdue_balance_client.py
114
+ ./tests/test_payment_client.py
110
115
  ./tests/test_payment_request_client.py
111
116
  ./tests/test_plan_client.py
112
117
  ./tests/test_request_services.py
@@ -157,6 +162,7 @@ lago_python_client/models/__init__.py
157
162
  lago_python_client/models/add_on.py
158
163
  lago_python_client/models/applied_coupon.py
159
164
  lago_python_client/models/billable_metric.py
165
+ lago_python_client/models/billing_period.py
160
166
  lago_python_client/models/charge.py
161
167
  lago_python_client/models/coupon.py
162
168
  lago_python_client/models/credit.py
@@ -176,6 +182,7 @@ lago_python_client/models/minimum_commitment.py
176
182
  lago_python_client/models/mrr.py
177
183
  lago_python_client/models/organization.py
178
184
  lago_python_client/models/overdue_balance.py
185
+ lago_python_client/models/payment.py
179
186
  lago_python_client/models/payment_request.py
180
187
  lago_python_client/models/plan.py
181
188
  lago_python_client/models/subscription.py
@@ -192,6 +199,8 @@ lago_python_client/overdue_balances/__init__.py
192
199
  lago_python_client/overdue_balances/clients.py
193
200
  lago_python_client/payment_requests/__init__.py
194
201
  lago_python_client/payment_requests/clients.py
202
+ lago_python_client/payments/__init__.py
203
+ lago_python_client/payments/clients.py
195
204
  lago_python_client/plans/__init__.py
196
205
  lago_python_client/plans/clients.py
197
206
  lago_python_client/services/__init__.py
@@ -227,6 +236,7 @@ tests/test_json_services.py
227
236
  tests/test_mrr_client.py
228
237
  tests/test_organization_client.py
229
238
  tests/test_overdue_balance_client.py
239
+ tests/test_payment_client.py
230
240
  tests/test_payment_request_client.py
231
241
  tests/test_plan_client.py
232
242
  tests/test_request_services.py
File without changes
@@ -129,6 +129,23 @@ def test_valid_current_usage(httpx_mock: HTTPXMock):
129
129
  assert response.charges_usage[0].filters[0].values["country"] == ["france"]
130
130
 
131
131
 
132
+ def test_valid_current_usage_without_taxes(httpx_mock: HTTPXMock):
133
+ client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
134
+
135
+ httpx_mock.add_response(
136
+ method="GET",
137
+ url="https://api.getlago.com/api/v1/customers/external_customer_id/current_usage?external_subscription_id=123&apply_taxes=false",
138
+ content=mock_response("customer_usage"),
139
+ )
140
+ response = client.customers.current_usage("external_customer_id", "123", "false")
141
+
142
+ assert response.from_datetime == "2022-07-01T00:00:00Z"
143
+ assert len(response.charges_usage) == 1
144
+ assert response.charges_usage[0].units == 1.0
145
+ assert len(response.charges_usage[0].filters) == 1
146
+ assert response.charges_usage[0].filters[0].values["country"] == ["france"]
147
+
148
+
132
149
  def test_invalid_current_usage(httpx_mock: HTTPXMock):
133
150
  client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
134
151
 
@@ -6,7 +6,9 @@ from pytest_httpx import HTTPXMock
6
6
  from lago_python_client.client import Client
7
7
  from lago_python_client.exceptions import LagoApiError
8
8
  from lago_python_client.models import (
9
+ Customer,
9
10
  Invoice,
11
+ InvoicePreview,
10
12
  InvoiceMetadata,
11
13
  InvoiceMetadataList,
12
14
  OneOffInvoice,
@@ -29,6 +31,12 @@ def one_off_invoice_object():
29
31
  return OneOffInvoice(customer_external_id="external", currency="EUR", fees=fees_list)
30
32
 
31
33
 
34
+ def invoice_preview():
35
+ customer = Customer(name="John Doe", external_id="test1")
36
+
37
+ return InvoicePreview(customer=customer, plan_code="test", billing_time="anniversary", subscription_at="2025-01-24")
38
+
39
+
32
40
  def mock_response(mock="invoice"):
33
41
  this_dir = os.path.dirname(os.path.abspath(__file__))
34
42
  my_data_path = os.path.join(this_dir, "fixtures/" + mock + ".json")
@@ -268,3 +276,18 @@ def test_valid_payment_url_request(httpx_mock: HTTPXMock):
268
276
  response = client.invoices.payment_url("5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba")
269
277
 
270
278
  assert response == "https://checkout.stripe.com/c/pay/cs_test_a1cuqFkXvH"
279
+
280
+
281
+ def test_valid_preview_request(httpx_mock: HTTPXMock):
282
+ client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
283
+
284
+ httpx_mock.add_response(
285
+ method="POST",
286
+ url="https://api.getlago.com/api/v1/invoices/preview",
287
+ content=mock_response(),
288
+ )
289
+ response = client.invoices.preview(invoice_preview())
290
+
291
+ assert response.lago_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
292
+ assert response.status == "finalized"
293
+ assert response.payment_status == "failed"
@@ -0,0 +1,108 @@
1
+ import os
2
+
3
+ import pytest
4
+ from pytest_httpx import HTTPXMock
5
+
6
+ from lago_python_client.client import Client
7
+ from lago_python_client.exceptions import LagoApiError
8
+ from lago_python_client.models import Payment
9
+
10
+
11
+ def payment_object():
12
+ return Payment(
13
+ amount_cents=100,
14
+ reference="ref1",
15
+ invoice_id="f8e194df-5d90-4382-b146-c881d2c67f28",
16
+ paid_at="2025-01-01T13:00:00Z",
17
+ )
18
+
19
+
20
+ def mock_response():
21
+ this_dir = os.path.dirname(os.path.abspath(__file__))
22
+ data_path = os.path.join(this_dir, "fixtures/payment.json")
23
+
24
+ with open(data_path, "rb") as payment_response:
25
+ return payment_response.read()
26
+
27
+
28
+ def mock_collection_response():
29
+ current_dir = os.path.dirname(os.path.abspath(__file__))
30
+ data_path = os.path.join(current_dir, "fixtures/payment_index.json")
31
+
32
+ with open(data_path, "rb") as payments_response:
33
+ return payments_response.read()
34
+
35
+
36
+ def test_valid_find_all_payments_request(httpx_mock: HTTPXMock):
37
+ client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
38
+
39
+ httpx_mock.add_response(
40
+ method="GET",
41
+ url="https://api.getlago.com/api/v1/payments",
42
+ content=mock_collection_response(),
43
+ )
44
+ response = client.payments.find_all()
45
+
46
+ assert response["payments"][0].lago_id == "8e5d5ec2-bdc7-4c43-a944-5ababae775d4"
47
+ assert response["meta"]["current_page"] == 1
48
+
49
+
50
+ def test_valid_find_all_payments_request_with_options(httpx_mock: HTTPXMock):
51
+ client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
52
+
53
+ httpx_mock.add_response(
54
+ method="GET",
55
+ url="https://api.getlago.com/api/v1/payments?per_page=2&page=1",
56
+ content=mock_collection_response(),
57
+ )
58
+ response = client.payments.find_all({"per_page": 2, "page": 1})
59
+
60
+ assert response["payments"][0].lago_id == "8e5d5ec2-bdc7-4c43-a944-5ababae775d4"
61
+ assert response["meta"]["current_page"] == 1
62
+
63
+
64
+ def test_invalid_find_all_payment_request(httpx_mock: HTTPXMock):
65
+ client = Client(api_key="invalid")
66
+
67
+ httpx_mock.add_response(
68
+ method="GET",
69
+ url="https://api.getlago.com/api/v1/payments",
70
+ status_code=404,
71
+ content=b"",
72
+ )
73
+
74
+ with pytest.raises(LagoApiError):
75
+ client.payments.find_all()
76
+
77
+
78
+ def test_valid_create_payment_request(httpx_mock: HTTPXMock):
79
+ client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
80
+
81
+ httpx_mock.add_response(
82
+ method="POST",
83
+ url="https://api.getlago.com/api/v1/payments",
84
+ content=mock_response(),
85
+ )
86
+ response = client.payments.create(payment_object())
87
+
88
+ assert response is not None
89
+ assert response.lago_id == "8e5d5ec2-bdc7-4c43-a944-5ababae775d4"
90
+ assert response.amount_cents == 100
91
+ assert response.amount_currency == "USD"
92
+ assert response.payment_status == "succeeded"
93
+ assert len(response.invoice_ids) == 1
94
+ assert response.invoice_ids[0] == "f8e194df-5d90-4382-b146-c881d2c67f28"
95
+
96
+
97
+ def test_invalid_create_payment_request(httpx_mock: HTTPXMock):
98
+ client = Client(api_key="invalid")
99
+
100
+ httpx_mock.add_response(
101
+ method="POST",
102
+ url="https://api.getlago.com/api/v1/payments",
103
+ status_code=401,
104
+ content=b"",
105
+ )
106
+
107
+ with pytest.raises(LagoApiError):
108
+ client.payments.create(payment_object())
@@ -1 +0,0 @@
1
- LAGO_VERSION = "1.18.0"