Skip to content

Commit

Permalink
Codegen for openapi v163
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe committed Jul 7, 2022
1 parent 38127f7 commit b56f0b1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v161
v163
21 changes: 11 additions & 10 deletions stripe/api_resources/credit_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ class CreditNote(
):
OBJECT_NAME = "credit_note"

def void_credit_note(self, idempotency_key=None, **params):
url = "/v1/credit_notes/{id}/void".format(
id=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

@classmethod
def preview(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
):
requestor = api_requestor.APIRequestor(
api_key, api_version=stripe_version, account=stripe_account
)
url = cls.class_url() + "/preview"
url = "/v1/credit_notes/preview"
response, api_key = requestor.request("get", url, params)
return util.convert_to_stripe_object(
stripe_object = util.convert_to_stripe_object(
response, api_key, stripe_version, stripe_account
)
return stripe_object

def void_credit_note(self, idempotency_key=None, **params):
url = "/v1/credit_notes/{id}/void".format(
id=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
2 changes: 1 addition & 1 deletion stripe/api_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class _ApiVersion:
CURRENT = "2020-08-27"
CURRENT = "2020-08-27; server_side_confirmation_beta=v1"
32 changes: 31 additions & 1 deletion tests/test_generated_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def test_financial_connections_session_retrieve(self, request_mock):
"/v1/financial_connections/sessions/fcsess_xyz",
)

def test_invoice_upcoming(self, request_mock):
stripe.Invoice.upcoming(customer="cus_9utnxg47pWjV1e")
request_mock.assert_requested("get", "/v1/invoices/upcoming")

def test_order_create(self, request_mock):
stripe.Order.create(
description="description",
Expand Down Expand Up @@ -210,6 +214,19 @@ def test_paymentlink_list_line_items(self, request_mock):
"get", "/v1/payment_links/pl_xyz/line_items"
)

def test_price_create(self, request_mock):
stripe.Price.create(
unit_amount=2000,
currency="usd",
currency_options={
"uah": {"unit_amount": 5000},
"eur": {"unit_amount": 1800},
},
recurring={"interval": "month"},
product="prod_xxxxxxxxxxxxx",
)
request_mock.assert_requested("post", "/v1/prices")

def test_setupattempt_list(self, request_mock):
stripe.SetupAttempt.list(limit=3, setup_intent="si_xyz")
request_mock.assert_requested("get", "/v1/setup_attempts")
Expand Down Expand Up @@ -736,6 +753,19 @@ def test_creditnote_void_credit_note(self, request_mock):
"/v1/credit_notes/cn_xxxxxxxxxxxxx/void",
)

def test_creditnote_preview(self, request_mock):
stripe.CreditNote.preview(
invoice="in_xxxxxxxxxxxxx",
lines=[
{
"type": "invoice_line_item",
"invoice_line_item": "il_xxxxxxxxxxxxx",
"quantity": 1,
},
],
)
request_mock.assert_requested("get", "/v1/credit_notes/preview")

def test_customer_list(self, request_mock):
stripe.Customer.list(limit=3)
request_mock.assert_requested("get", "/v1/customers")
Expand Down Expand Up @@ -1429,7 +1459,7 @@ def test_price_list(self, request_mock):
stripe.Price.list(limit=3)
request_mock.assert_requested("get", "/v1/prices")

def test_price_create(self, request_mock):
def test_price_create2(self, request_mock):
stripe.Price.create(
unit_amount=2000,
currency="usd",
Expand Down

0 comments on commit b56f0b1

Please sign in to comment.