Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integrations): add support for integration customers #243

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lago_python_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .event import Event, BatchEvent
from .fee import Fee
from .customer import Customer, CustomerBillingConfiguration, Metadata, MetadataList,\
MetadataResponse, MetadataResponseList
MetadataResponse, MetadataResponseList, IntegrationCustomer
from .invoice import InvoicePaymentStatusChange, Invoice, InvoiceMetadata, InvoiceMetadataList,\
OneOffInvoice, InvoiceFeesList, InvoiceFee
from .invoice_item import InvoiceItemResponse
Expand Down
10 changes: 10 additions & 0 deletions lago_python_client/models/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class CustomerBillingConfiguration(BaseModel):
provider_payment_methods: Optional[List[str]]


class IntegrationCustomer(BaseModel):
external_customer_id: Optional[str]
integration_type: Optional[str]
integration_code: Optional[str]
subsidiary_id: Optional[str]
sync_with_provider: Optional[bool]


class Metadata(BaseModel):
id: Optional[str]
key: Optional[str]
Expand Down Expand Up @@ -61,6 +69,7 @@ class Customer(BaseModel):
zipcode: Optional[str]
metadata: Optional[MetadataList]
billing_configuration: Optional[CustomerBillingConfiguration]
integration_customer: Optional[IntegrationCustomer]
tax_codes: Optional[List[str]]


Expand Down Expand Up @@ -89,4 +98,5 @@ class CustomerResponse(BaseResponseModel):
zipcode: Optional[str]
metadata: Optional[MetadataResponseList]
billing_configuration: Optional[CustomerBillingConfiguration]
integration_customer: Optional[IntegrationCustomer]
taxes: Optional[TaxesResponse]
7 changes: 7 additions & 0 deletions tests/fixtures/customer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
"document_locale": "fr",
"provider_payment_methods": ["card", "sepa_debit"]
},
"integration_customer": {
"external_customer_id": "test-12345",
"integration_type": "netsuite",
"integration_code": "test",
"subsidiary_id": "2",
"sync_with_provider": true
},
"metadata": [
{
"lago_id": "12345",
Expand Down
11 changes: 10 additions & 1 deletion tests/test_customer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Customer, CustomerBillingConfiguration, Metadata, MetadataList
from lago_python_client.models import Customer, IntegrationCustomer, CustomerBillingConfiguration,\
Metadata, MetadataList


def create_customer():
Expand All @@ -31,6 +32,12 @@ def create_customer():
document_locale="fr",
provider_payment_methods=["card", "sepa_debit"],
),
integration_customer=IntegrationCustomer(
integration_type='netsuite',
integration_code='test-123',
subsidiary_id='2',
sync_with_provider=True
),
metadata=metadata_list
)

Expand Down Expand Up @@ -61,6 +68,8 @@ def test_valid_create_customers_request(httpx_mock: HTTPXMock):
assert response.billing_configuration.provider_customer_id == 'cus_12345'
assert response.billing_configuration.sync_with_provider == True
assert response.billing_configuration.document_locale == "fr"
assert response.integration_customer.external_customer_id == 'test-12345'
assert response.integration_customer.integration_type == "netsuite"
assert response.metadata.__root__[0].lago_id == '12345'
assert response.metadata.__root__[0].key == 'key'
assert response.metadata.__root__[0].value == 'value'
Expand Down
Loading