Skip to content

Commit cea0810

Browse files
authored
feat(subscription): Add on_termination_credit_note field to subscription (#325)
This also updates the `setup.cfg` to include `ruff` as a dependency and add a "Linting" section in the README.
1 parent 49923c8 commit cea0810

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ This is a python wrapper for Lago API
77

88
## Current Releases
99

10-
| Project | Release Badge |
11-
|--------------------|-----------------------------------------------------------------------------------------------------|
12-
| **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
13-
| **Lago Python Client** | [![Lago Python Client Release](https://img.shields.io/github/v/release/getlago/lago-python-client)](https://github.com/getlago/lago-python-client/releases) |
10+
| Project | Release Badge |
11+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
12+
| **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) |
13+
| **Lago Python Client** | [![Lago Python Client Release](https://img.shields.io/github/v/release/getlago/lago-python-client)](https://github.com/getlago/lago-python-client/releases) |
1414

1515
## Installation
1616

@@ -32,7 +32,7 @@ Check the [lago API reference](https://doc.getlago.com/docs/api/intro)
3232

3333
```bash
3434
python -m pip install --upgrade pip setuptools wheel
35-
python -m pip install '.[test]'
35+
python -m pip install '.[test,lint]'
3636
```
3737

3838
### Run tests
@@ -41,6 +41,12 @@ python -m pip install '.[test]'
4141
pytest
4242
```
4343

44+
### Lint
45+
46+
```bash
47+
ruff format
48+
```
49+
4450
## Documentation
4551

4652
The Lago documentation is available at [doc.getlago.com](https://doc.getlago.com/docs/api/intro).

lago_python_client/models/subscription.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SubscriptionResponse(BaseResponseModel):
4444
downgrade_plan_date: Optional[str]
4545
current_billing_period_started_at: Optional[str]
4646
current_billing_period_ending_at: Optional[str]
47+
on_termination_credit_note: Optional[str]
4748

4849

4950
class SubscriptionsResponse(BaseResponseModel):

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ test =
3939
pytest
4040
pytest_httpx
4141

42+
lint =
43+
ruff
44+
4245
[options.package_data]
4346
* = py.typed

tests/fixtures/subscription.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"status": "active",
1212
"billing_time": "anniversary",
1313
"terminated_at": null,
14+
"on_termination_credit_note": "skip",
1415
"subscription_at": "2022-04-29T08:59:51Z",
1516
"previous_plan_code": null,
1617
"next_plan_code": null,

tests/test_subscription_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ def test_valid_destroy_subscription_request(httpx_mock: HTTPXMock):
140140
assert response.plan_code == "eartha lynch"
141141

142142

143+
def test_valid_destroy_subscription_with_on_termination_credit_note_request(httpx_mock: HTTPXMock):
144+
client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
145+
identifier = "sub_id"
146+
147+
httpx_mock.add_response(
148+
method="DELETE",
149+
url="https://api.getlago.com/api/v1/subscriptions/" + identifier + "?on_termination_credit_note=skip",
150+
content=mock_response(),
151+
)
152+
response = client.subscriptions.destroy(identifier, {"on_termination_credit_note": "skip"})
153+
154+
assert response.external_customer_id == "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
155+
assert response.status == "active"
156+
assert response.plan_code == "eartha lynch"
157+
assert response.on_termination_credit_note == "skip"
158+
159+
143160
def test_valid_destroy_pending_subscription_request(httpx_mock: HTTPXMock):
144161
client = Client(api_key="886fe239-927d-4072-ab72-6dd345e8dd0d")
145162
identifier = "sub_id"

0 commit comments

Comments
 (0)