Skip to content

Commit 383f43a

Browse files
wscourgeclaude
andcommitted
Add Invoice update-status and disable endpoint support
Add Invoice.update_status (PATCH /invoices/{uuid}) for updating invoice status and Invoice.disable (PATCH /invoices/{uuid}/disable) for disabling invoices. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6daf595 commit 383f43a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

chartmogul/api/invoice.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,5 @@ def all(cls, config, **kwargs):
9898
"/data_sources{/data_source_uuid}/customers{/customer_uuid}/invoices",
9999
)
100100
Invoice.retrieve = Invoice._method("retrieve", "get", "/invoices{/uuid}")
101+
Invoice.update_status = Invoice._method("modify", "patch", "/invoices{/uuid}")
102+
Invoice.disable = Invoice._method("patch", "patch", "/invoices{/uuid}/disable")

test/api/test_invoice.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,52 @@ def test_line_item_and_transaction_errors(self, mock_requests):
673673
self.assertEqual(result.line_items[0].errors["amount_in_cents"], ["must be positive"])
674674
self.assertIsNotNone(result.transactions[0].errors)
675675
self.assertEqual(result.transactions[0].errors["date"], ["is in the future"])
676+
677+
@requests_mock.mock()
678+
def test_update_status(self, mock_requests):
679+
updatedInvoice = dict(retrieveInvoiceExample)
680+
updatedInvoice["disabled"] = False
681+
682+
mock_requests.register_uri(
683+
"PATCH",
684+
"https://api.chartmogul.com/v1/invoices/inv_22910fc6-c931-48e7-ac12-90d2cb5f0059",
685+
request_headers={"Authorization": "Basic dG9rZW46"},
686+
headers={"Content-Type": "application/json"},
687+
status_code=200,
688+
json=updatedInvoice,
689+
)
690+
691+
config = Config("token")
692+
result = Invoice.update_status(
693+
config,
694+
uuid="inv_22910fc6-c931-48e7-ac12-90d2cb5f0059",
695+
data={"disabled": False}
696+
).get()
697+
698+
self.assertEqual(mock_requests.call_count, 1, "expected call")
699+
self.assertTrue(isinstance(result, Invoice))
700+
self.assertEqual(result.uuid, "inv_22910fc6-c931-48e7-ac12-90d2cb5f0059")
701+
702+
@requests_mock.mock()
703+
def test_disable(self, mock_requests):
704+
disabledInvoice = dict(retrieveInvoiceExample)
705+
disabledInvoice["disabled"] = True
706+
707+
mock_requests.register_uri(
708+
"PATCH",
709+
"https://api.chartmogul.com/v1/invoices/inv_22910fc6-c931-48e7-ac12-90d2cb5f0059/disable",
710+
request_headers={"Authorization": "Basic dG9rZW46"},
711+
headers={"Content-Type": "application/json"},
712+
status_code=200,
713+
json=disabledInvoice,
714+
)
715+
716+
config = Config("token")
717+
result = Invoice.disable(
718+
config,
719+
uuid="inv_22910fc6-c931-48e7-ac12-90d2cb5f0059",
720+
).get()
721+
722+
self.assertEqual(mock_requests.call_count, 1, "expected call")
723+
self.assertTrue(isinstance(result, Invoice))
724+
self.assertTrue(result.disabled)

0 commit comments

Comments
 (0)