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(invoice_display_name): Add invoice display name #195

Merged
merged 2 commits into from
Oct 5, 2023
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: 2 additions & 0 deletions lago_python_client/models/add_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class AddOn(BaseModel):
name: Optional[str]
invoice_display_name: Optional[str]
code: Optional[str]
amount_cents: Optional[int]
amount_currency: Optional[str]
Expand All @@ -18,6 +19,7 @@ class AddOn(BaseModel):
class AddOnResponse(BaseResponseModel):
lago_id: str
name: str
invoice_display_name: Optional[str]
code: str
amount_cents: int
amount_currency: str
Expand Down
3 changes: 3 additions & 0 deletions lago_python_client/models/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class GroupProperties(BaseModel):
group_id: Optional[str]
values: Optional[Dict[str, Any]]
invoice_display_name: Optional[str]


class GroupPropertiesList(BaseModel):
Expand All @@ -22,6 +23,7 @@ class Charge(BaseModel):
pay_in_advance: Optional[bool]
prorated: Optional[bool]
invoiceable: Optional[bool]
invoice_display_name: Optional[str]
min_amount_cents: Optional[int]
properties: Optional[Dict[str, Any]]
group_properties: Optional[GroupPropertiesList]
Expand All @@ -40,6 +42,7 @@ class ChargeResponse(BaseResponseModel):
pay_in_advance: Optional[bool]
prorated: Optional[bool]
invoiceable: Optional[bool]
invoice_display_name: Optional[str]
min_amount_cents: Optional[int]
properties: Optional[Dict[str, Any]]
group_properties: Optional[GroupPropertiesList]
Expand Down
2 changes: 2 additions & 0 deletions lago_python_client/models/fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class Fee(BaseModel):
payment_status: Optional[str]
invoice_display_name: Optional[str]


class FeeAppliedTax(BaseResponseModel):
Expand Down Expand Up @@ -45,6 +46,7 @@ class FeeResponse(BaseResponseModel):
description: Optional[str]
pay_in_advance: Optional[bool]
invoiceable: Optional[bool]
invoice_display_name: Optional[str]
succeeded_at: Optional[str]
failed_at: Optional[str]
refunded_at: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions lago_python_client/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class InvoiceFee(BaseModel):
unit_amount_cents: Optional[int]
units: Optional[float]
description: Optional[str]
invoice_display_name: Optional[str]
tax_codes: Optional[List[str]]


Expand Down
1 change: 1 addition & 0 deletions lago_python_client/models/invoice_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ class InvoiceItemResponse(BaseResponseModel):
code: Optional[str]
name: Optional[str]
lago_id: Optional[str]
invoice_display_name: Optional[str]
lago_item_id: Optional[str]
item_type: Optional[str]
2 changes: 2 additions & 0 deletions lago_python_client/models/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class Plan(BaseModel):
name: Optional[str]
invoice_display_name: Optional[str]
code: Optional[str]
interval: Optional[str]
description: Optional[str]
Expand All @@ -24,6 +25,7 @@ class Plan(BaseModel):
class PlanResponse(BaseResponseModel):
lago_id: str
name: str
invoice_display_name: Optional[str]
created_at: str
code: str
interval: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/add_on.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"add_on": {
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
"name": "add_on_name",
"invoice_display_name": "add_on_invoice_display_name",
"code": "add_on_code",
"amount_cents": 5000,
"amount_currency": "USD",
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/add_on_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac1111",
"name": "add_on_name",
"invoice_display_name": "add_on_invoice_display_name",
"code": "add_on_code",
"amount_cents": 5000,
"amount_currency": "USD",
Expand All @@ -12,6 +13,7 @@
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac1222",
"name": "add_on_name",
"invoice_display_name": "add_on_invoice_display_name",
"code": "add_on_code",
"amount_cents": 7000,
"amount_currency": "USD",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/credit_note.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"lago_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"fee": {
"lago_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"invoice_display_name": "credit_note_invoice_display_name",
"item": {
"type": "charge",
"code": "seats",
"name": "User Seats"
"name": "User Seats",
"invoice_display_name": "credit_note_invoice_display_name"
},
"credit_amount_cents": 100,
"credit_amount_currency": "EUR",
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/customer_usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"amount_currency": "EUR",
"charge": {
"lago_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"charge_model": "graduated"
"charge_model": "graduated",
"invoice_display_name": "add_on_invoice_display_name"
},
"billable_metric": {
"lago_id": "99a6094e-199b-4101-896a-54e927ce7bd7",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/fee.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"lago_invoice_id": "1a2d9c8d-5875-4688-9854-5ccfd414bc5e",
"lago_true_up_fee_id": "1a2d9c8d-5875-4688-9854-5ccfd414bc5e",
"lago_true_up_parent_fee_id": null,
"invoice_display_name": "fee_invoice_display_name",
"item": {
"type": "charge",
"code": "fee_code",
"name": "Fee Code"
"name": "Fee Code",
"invoice_display_name": "charge_invoice_display_name"
},
"amount_cents": 120,
"amount_currency": "EUR",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/fees.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"lago_invoice_id": "1a2d9c8d-5875-4688-9854-5ccfd414bc5e",
"lago_true_up_fee_id": "1a2d9c8d-5875-4688-9854-5ccfd414bc5e",
"lago_true_up_parent_fee_id": null,
"invoice_display_name": "fee_invoice_display_name",
"item": {
"type": "instant_charge",
"code": "fee_code",
"name": "Fee Code"
"name": "Fee Code",
"invoice_display_name": "charge_invoice_display_name"
},
"amount_cents": 120,
"amount_currency": "EUR",
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/graduated_plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"plan": {
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
"name": "test1",
"invoice_display_name": "test plan 1",
"created_at": "2022-07-01T14:47:14Z",
"code": "plan_code",
"interval": "weekly",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@
"fees": [
{
"lago_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"invoice_display_name": "fee_invoice_display_name",
"item": {
"type": "charge",
"code": "seats",
"name": "User Seats"
"name": "User Seats",
"invoice_display_name": "charge_invoice_display_name"
},
"amount_cents": 100,
"amount_currency": "EUR",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/one_off_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@
"fees": [
{
"lago_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"invoice_display_name": "fee_invoice_display_name",
"item": {
"type": "one_off",
"code": "one",
"name": "Name"
"name": "Name",
"invoice_display_name": "one_off_invoice_display_name"
},
"amount_cents": 100,
"amount_currency": "EUR",
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"plan": {
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac129b",
"name": "test1",
"invoice_display_name": "test plan 1",
"created_at": "2022-07-01T14:47:14Z",
"code": "plan_code",
"interval": "weekly",
Expand All @@ -24,6 +25,7 @@
"charge_model": "standard",
"pay_in_advance": true,
"invoiceable": true,
"invoice_display_name": "Setup",
"min_amount_cents": 0,
"properties": {
"amount": "0.22"
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/plan_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"lago_id": "b7ab2926-1de8-4428-9bcd-779314ac1111",
"name": "test1",
"invoice_display_name": "test plan 1",
"created_at": "2022-07-01T14:47:14Z",
"code": "plan_api4",
"interval": "weekly",
Expand All @@ -28,7 +29,8 @@
"group_properties": [
{
"group_id": "gfc1e851-5be6-4343-a0ee-39a81d8b4ee1",
"values": { "amount": "0.22" }
"values": { "amount": "0.22" },
"invoice_display_name": "Europe"
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions tests/test_add_on_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
def add_on_object():
return AddOn(
name='name',
invoice_display_name='add_on_invoice_display_name',
code='add_on_first',
amount_cents=1000,
amount_currency='EUR',
Expand Down Expand Up @@ -42,6 +43,7 @@ def test_valid_create_add_on_request(httpx_mock: HTTPXMock):

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == 'add_on_code'
assert response.invoice_display_name == 'add_on_invoice_display_name'


def test_invalid_create_add_on_request(httpx_mock: HTTPXMock):
Expand All @@ -56,12 +58,14 @@ def test_invalid_create_add_on_request(httpx_mock: HTTPXMock):
def test_valid_update_add_on_request(httpx_mock: HTTPXMock):
client = Client(api_key='886fe239-927d-4072-ab72-6dd345e8dd0d')
code = 'add_on_code'
invoice_display_name = 'add_on_invoice_display_name'

httpx_mock.add_response(method='PUT', url='https://api.getlago.com/api/v1/add_ons/' + code, content=mock_response())
response = client.add_ons.update(add_on_object(), code)

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == code
assert response.invoice_display_name == invoice_display_name


def test_invalid_update_add_on_request(httpx_mock: HTTPXMock):
Expand All @@ -77,12 +81,15 @@ def test_invalid_update_add_on_request(httpx_mock: HTTPXMock):
def test_valid_find_add_on_request(httpx_mock: HTTPXMock):
client = Client(api_key='886fe239-927d-4072-ab72-6dd345e8dd0d')
code = 'add_on_code'
invoice_display_name = 'add_on_invoice_display_name'

httpx_mock.add_response(method='GET', url='https://api.getlago.com/api/v1/add_ons/' + code, content=mock_response())
response = client.add_ons.find(code)

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == code
assert response.invoice_display_name == invoice_display_name



def test_invalid_find_add_on_request(httpx_mock: HTTPXMock):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_fee_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def mock_response():
def test_valid_find_fee_request(httpx_mock: HTTPXMock):
client = Client(api_key='886fe239-927d-4072-ab72-6dd345e8dd0d')
identifier = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba'
fee_invoice_display_name = 'fee_invoice_display_name'
charge_invoice_display_name = 'charge_invoice_display_name'

httpx_mock.add_response(method='GET', url='https://api.getlago.com/api/v1/fees/' + identifier, content=mock_response())
response = client.fees.find(identifier)

assert response.lago_id == identifier
assert response.invoice_display_name == fee_invoice_display_name
assert response.item.invoice_display_name == charge_invoice_display_name
2 changes: 2 additions & 0 deletions tests/test_invoice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def test_valid_create_invoice_request(httpx_mock: HTTPXMock):

assert response.lago_id == '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba'
assert response.invoice_type == 'one_off'
assert response.fees.__root__[0].invoice_display_name == 'fee_invoice_display_name'
assert response.fees.__root__[0].item.invoice_display_name == 'one_off_invoice_display_name'


def test_invalid_create_invoice_request(httpx_mock: HTTPXMock):
Expand Down
11 changes: 10 additions & 1 deletion tests/test_plan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ def plan_object():
'group_id': 'id',
'values': {
'amount': '0.22'
}
},
'invoice_display_name': 'Europe'
}
]
)
charges = Charges(__root__=[charge])

return Plan(
name='name',
invoice_display_name='invoice_display_name',
code='code_first',
amount_cents=1000,
amount_currency='EUR',
Expand Down Expand Up @@ -109,6 +111,8 @@ def test_valid_create_plan_request(httpx_mock: HTTPXMock):

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == 'plan_code'
assert response.invoice_display_name == 'test plan 1'
assert response.charges.__root__[0].invoice_display_name == 'Setup'


def test_valid_create_graduated_plan_request(httpx_mock: HTTPXMock):
Expand All @@ -119,6 +123,7 @@ def test_valid_create_graduated_plan_request(httpx_mock: HTTPXMock):

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == 'plan_code'
assert response.invoice_display_name == 'test plan 1'


def test_invalid_create_plan_request(httpx_mock: HTTPXMock):
Expand All @@ -139,6 +144,7 @@ def test_valid_update_plan_request(httpx_mock: HTTPXMock):

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == code
assert response.invoice_display_name == 'test plan 1'


def test_invalid_update_plan_request(httpx_mock: HTTPXMock):
Expand All @@ -160,6 +166,7 @@ def test_valid_find_plan_request(httpx_mock: HTTPXMock):

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.code == code
assert response.invoice_display_name == 'test plan 1'
assert response.charges.__root__[0].charge_model == 'standard'
assert response.charges.__root__[0].min_amount_cents == 0

Expand Down Expand Up @@ -202,9 +209,11 @@ def test_valid_find_all_plan_request(httpx_mock: HTTPXMock):
response = client.plans.find_all()

assert response['plans'][0].lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac1111'
assert response['plans'][0].invoice_display_name == 'test plan 1'
assert response['plans'][0].charges.__root__[0].lago_id == '51c1e851-5be6-4343-a0ee-39a81d8b4ee1'
assert response['plans'][0].charges.__root__[0].group_properties.__root__[0].group_id == 'gfc1e851-5be6-4343-a0ee-39a81d8b4ee1'
assert response['plans'][0].charges.__root__[0].group_properties.__root__[0].values['amount'] == '0.22'
assert response['plans'][0].charges.__root__[0].group_properties.__root__[0].invoice_display_name == 'Europe'
assert response['meta']['current_page'] == 1


Expand Down