Skip to content

Commit

Permalink
misc: Remove deprecated fields (#252)
Browse files Browse the repository at this point in the history
* misc: Remove deprecated fields

* misc: Force external_subscription_id when creating an event

---------

Co-authored-by: Romain Sempé <[email protected]>
  • Loading branch information
vincent-pochet and rsempe committed Jul 15, 2024
1 parent 50a6261 commit 971a52f
Show file tree
Hide file tree
Showing 42 changed files with 65 additions and 223 deletions.
23 changes: 0 additions & 23 deletions lago_python_client/billable_metrics/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from ..base_client import BaseClient
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
from ..models.billable_metric import BillableMetricResponse
from ..models.group import GroupResponse
from ..services.request import make_headers, make_url, send_get_request
from ..services.response import get_response_data, prepare_index_response, Response

Expand All @@ -25,25 +24,3 @@ class BillableMetricClient(
API_RESOURCE: ClassVar[str] = 'billable_metrics'
RESPONSE_MODEL: ClassVar[Type[BillableMetricResponse]] = BillableMetricResponse
ROOT_NAME: ClassVar[str] = 'billable_metric'


class GroupClient(BaseClient):
API_RESOURCE: ClassVar[str] = 'groups'
RESPONSE_MODEL: ClassVar[Type[GroupResponse]] = GroupResponse
ROOT_NAME: ClassVar[str] = 'group'

def find_all(self, metric_code: str, options: Mapping[str, Union[int, str]] = {}) -> Mapping[str, Any]:
api_response: Response = send_get_request(
url=make_url(
origin=self.base_url,
path_parts=('billable_metrics', metric_code, self.API_RESOURCE),
query_pairs=options,
),
headers=make_headers(api_key=self.api_key),
)

return prepare_index_response(
api_resource=self.API_RESOURCE,
response_model=self.RESPONSE_MODEL,
data=get_response_data(response=api_response),
)
6 changes: 1 addition & 5 deletions lago_python_client/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from urllib.parse import urljoin

from .add_ons.clients import AddOnClient
from .billable_metrics.clients import BillableMetricClient, GroupClient
from .billable_metrics.clients import BillableMetricClient
from .coupons.clients import AppliedCouponClient, CouponClient
from .credit_notes.clients import CreditNoteClient
from .customers.clients import CustomerClient
Expand Down Expand Up @@ -47,10 +47,6 @@ def add_ons(self) -> AddOnClient:
def billable_metrics(self) -> BillableMetricClient:
return BillableMetricClient(self.base_api_url, self.api_key)

@callable_cached_property
def groups(self) -> GroupClient:
return GroupClient(self.base_api_url, self.api_key)

@callable_cached_property
def coupons(self) -> CouponClient:
return CouponClient(self.base_api_url, self.api_key)
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .applied_coupon import AppliedCoupon
from .billable_metric import BillableMetric, BillableMetricGroup
from .billable_metric import BillableMetric, BillableMetricFilter, BillableMetricFilters
from .charge import Charge, Charges, ChargesResponse
from .coupon import Coupon, LimitationConfiguration
from .credit import CreditResponse, CreditsResponse
Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/applied_coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AppliedCouponResponse(BaseResponseModel):
amount_cents: Optional[int]
amount_cents_remaining: Optional[int]
amount_currency: Optional[str]
expiration_date: Optional[str]
expiration_at: Optional[str]
created_at: str
terminated_at: Optional[str]
percentage_rate: Optional[float]
Expand Down
7 changes: 0 additions & 7 deletions lago_python_client/models/billable_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
from ..base_model import BaseResponseModel


class BillableMetricGroup(BaseModel):
key: Optional[str]
values: Optional[List[Union[str, Dict[str, Any]]]]


class BillableMetricFilter(BaseModel):
key: Optional[str]
values: Optional[List[str]]
Expand All @@ -27,7 +22,6 @@ class BillableMetric(BaseModel):
aggregation_type: Optional[str]
weighted_interval: Optional[str]
field_name: Optional[str]
group: Optional[BillableMetricGroup]
filters: Optional[BillableMetricFilters]


Expand All @@ -41,7 +35,6 @@ class BillableMetricResponse(BaseResponseModel):
weighted_interval: Optional[str]
field_name: Optional[str]
created_at: str
group: BillableMetricGroup
filters: BillableMetricFilters
active_subscriptions_count: int
draft_invoices_count: int
Expand Down
13 changes: 0 additions & 13 deletions lago_python_client/models/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
from ..base_model import BaseResponseModel


class GroupProperties(BaseModel):
group_id: Optional[str]
values: Optional[Dict[str, Any]]
invoice_display_name: Optional[str]


class GroupPropertiesList(BaseModel):
__root__: List[GroupProperties]


class ChargeFilter(BaseModel):
invoice_display_name: Optional[str]
properties: Optional[Dict[str, Any]]
Expand All @@ -36,7 +26,6 @@ class Charge(BaseModel):
invoice_display_name: Optional[str]
min_amount_cents: Optional[int]
properties: Optional[Dict[str, Any]]
group_properties: Optional[GroupPropertiesList]
filters: Optional[ChargeFilters]
tax_codes: Optional[List[str]]

Expand All @@ -56,7 +45,6 @@ class ChargeResponse(BaseResponseModel):
invoice_display_name: Optional[str]
min_amount_cents: Optional[int]
properties: Optional[Dict[str, Any]]
group_properties: Optional[GroupPropertiesList]
filters: Optional[ChargeFilters]
taxes: Optional[TaxesResponse]

Expand All @@ -70,7 +58,6 @@ class ChargeOverrides(BaseModel):
invoice_display_name: Optional[str]
min_amount_cents: Optional[int]
properties: Optional[Dict[str, Any]]
group_properties: Optional[GroupPropertiesList]
filters: Optional[ChargeFilters]
tax_codes: Optional[List[str]]

Expand Down
2 changes: 1 addition & 1 deletion lago_python_client/models/credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CreditResponse(BaseResponseModel):
lago_id: Optional[str]
amount_cents: Optional[int]
amount_currency: Optional[str]
before_vat: bool
before_taxes: bool
item: Optional[InvoiceItemResponse]
invoice: Optional[InvoiceShortDetails]

Expand Down
9 changes: 0 additions & 9 deletions lago_python_client/models/customer_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ class Metric(BaseModel):
code: str
aggregation_type: str

class Group(BaseModel):
lago_id: str
key: Optional[str]
value: str
units: str
amount_cents: int


class ChargeFilterUsage(BaseModel):
invoice_display_name: Optional[str]
Expand All @@ -37,7 +30,6 @@ class GroupedUsage(BaseModel):
events_count: int
units: float
grouped_by: Dict[str, str]
groups: List[Group]
filters: List[ChargeFilterUsage]

class ChargeUsage(BaseModel):
Expand All @@ -47,7 +39,6 @@ class ChargeUsage(BaseModel):
amount_currency: str
charge: ChargeObject
billable_metric: Metric
groups: List[Group]
filters: List[ChargeFilterUsage]
grouped_usage: Optional[List[GroupedUsage]]

Expand Down
6 changes: 2 additions & 4 deletions lago_python_client/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

class Event(BaseModel):
transaction_id: str
external_customer_id: Optional[str]
external_subscription_id: Optional[str]
external_subscription_id: str
code: str
timestamp: Optional[Union[int, str]]
properties: Optional[Dict[str, Any]]
Expand All @@ -20,10 +19,9 @@ class BatchEvent(BaseModel):
class EventResponse(BaseResponseModel):
lago_id: str
transaction_id: str
external_customer_id: Optional[str]
lago_customer_id: Optional[str]
lago_subscription_id: Optional[str]
external_subscription_id: Optional[str]
external_subscription_id: str
code: str
timestamp: str
properties: Optional[Dict[str, Any]]
Expand Down
1 change: 0 additions & 1 deletion lago_python_client/models/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class FeeAppliedTaxes(BaseResponseModel):

class FeeResponse(BaseResponseModel):
lago_id: Optional[str]
lago_group_id: Optional[str]
lago_charge_filter_id: Optional[str]
lago_invoice_id: Optional[str]
lago_true_up_fee_id: Optional[str]
Expand Down
17 changes: 0 additions & 17 deletions lago_python_client/models/group.py

This file was deleted.

2 changes: 0 additions & 2 deletions lago_python_client/models/invoice_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class InvoiceItemResponse(BaseResponseModel):
type: Optional[str]
code: Optional[str]
name: Optional[str]
lago_id: Optional[str]
invoice_display_name: Optional[str]
group_invoice_display_name: Optional[str]
filter_invoice_display_name: Optional[str]
filters: Optional[Dict[str, List[str]]]
lago_item_id: Optional[str]
Expand Down
1 change: 0 additions & 1 deletion lago_python_client/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class OrganizationBillingConfiguration(BaseModel):
invoice_footer: Optional[str]
invoice_grace_period: Optional[int]
vat_rate: Optional[float]
document_locale: Optional[str]


Expand Down
4 changes: 2 additions & 2 deletions lago_python_client/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Subscription(BaseModel):
external_customer_id: Optional[str]
name: Optional[str]
external_id: Optional[str]
subscription_date: Optional[str]
subscription_at: Optional[str]
billing_time: Optional[str]
ending_at: Optional[str]
plan_overrides: Optional[PlanOverrides]
Expand All @@ -30,7 +30,7 @@ class SubscriptionResponse(BaseResponseModel):
billing_time: Optional[str]
terminated_at: Optional[str]
ending_at: Optional[str]
subscription_date: Optional[str]
subscription_at: Optional[str]
previous_plan_code: Optional[str]
next_plan_code: Optional[str]
downgrade_plan_date: Optional[str]
Expand Down
1 change: 0 additions & 1 deletion lago_python_client/models/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ class WalletResponse(BaseResponseModel):
ongoing_usage_balance_cents: int
credits_ongoing_balance: str
credits_ongoing_usage_balance: str
balance: str # NOTE(legacy)
2 changes: 1 addition & 1 deletion tests/fixtures/applied_coupon.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lago_customer_id": "99a6094e-199b-4101-896a-54e927ce7bd7",
"amount_cents": 123,
"amount_currency": "EUR",
"expiration_date": "2022-04-29",
"expiration_at": "2022-04-29T08:59:51Z",
"created_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-04-29T08:59:51Z",
"percentage_rate": null,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/applied_coupon_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"amount_cents": 123,
"amount_cents_remaining": 12,
"amount_currency": "EUR",
"expiration_date": "2022-04-29",
"expiration_at": "2022-04-29T08:59:51Z",
"created_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-04-29T08:59:51Z",
"percentage_rate": null,
Expand All @@ -28,7 +28,7 @@
"amount_cents": 123,
"amount_cents_remaining": 12,
"amount_currency": "EUR",
"expiration_date": "2022-04-29",
"expiration_at": "2022-04-29T08:59:51Z",
"created_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-04-29T08:59:51Z",
"percentage_rate": null,
Expand Down
8 changes: 0 additions & 8 deletions tests/fixtures/billable_metric.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
"recurring": false,
"field_name": "amount_sum",
"created_at": "2022-04-29T08:59:51Z",
"group": {
"key": "country",
"values": [
"france",
"italy",
"spain"
]
},
"filters": [
{
"key": "country",
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/billable_metric_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"recurring": false,
"field_name": "amount_sum",
"created_at": "2022-04-29T08:59:51Z",
"group": {},
"filters": [],
"active_subscriptions_count": 0,
"draft_invoices_count": 0,
Expand All @@ -26,7 +25,6 @@
"recurring": false,
"field_name": "amount_sum",
"created_at": "2022-04-30T08:59:51Z",
"group": {},
"filters": [],
"active_subscriptions_count": 0,
"draft_invoices_count": 0,
Expand Down
12 changes: 8 additions & 4 deletions tests/fixtures/coupon_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"amount_cents": 5000,
"amount_currency": "USD",
"expiration": "no_expiration",
"expiration_date": "2022-08-08",
"expiration_at": "2022-08-08T08:59:51Z",
"percentage_rate": null,
"frequency": "once",
"frequency_duration": null,
"reusable": false,
"coupon_type": "fixed_amount",
"limited_plans": true,
"limited_billable_metrics": false,
"plan_codes": ["plan1"],
"plan_codes": [
"plan1"
],
"billable_metric_codes": [],
"created_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-08-08T23:59:59Z"
Expand All @@ -27,15 +29,17 @@
"amount_cents": 7000,
"amount_currency": "USD",
"expiration": "no_expiration",
"expiration_date": "2022-08-08",
"expiration_at": "2022-08-08T08:59:51Z",
"percentage_rate": null,
"frequency": "once",
"frequency_duration": null,
"reusable": false,
"coupon_type": "fixed_amount",
"limited_plans": true,
"limited_billable_metrics": false,
"plan_codes": ["plan1"],
"plan_codes": [
"plan1"
],
"billable_metric_codes": [],
"created_at": "2022-04-29T08:59:51Z",
"terminated_at": null
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/customer_past_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"code": "usage_metric",
"aggregation_type": "sum"
},
"groups": [],
"filters": [
{
"units": "3.0",
Expand Down
Loading

0 comments on commit 971a52f

Please sign in to comment.