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

API Updates #831

Merged
merged 3 commits into from
Jun 30, 2022
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 OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v157
v161
8 changes: 6 additions & 2 deletions stripe/api_resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ class Account(
OBJECT_NAME = "account"

def persons(self, idempotency_key=None, **params):
url = self.instance_url() + "/persons"
url = "/v1/accounts/{account}/persons".format(
account=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
resp = self.request("get", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
stripe_object._retrieve_params = params
return stripe_object

def reject(self, idempotency_key=None, **params):
url = self.instance_url() + "/reject"
url = "/v1/accounts/{account}/reject".format(
account=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
Expand Down
6 changes: 4 additions & 2 deletions stripe/api_resources/apps/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ def delete_where(
)
url = "/v1/apps/secrets/delete"
response, api_key = requestor.request("post", 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

@classmethod
def find(
Expand All @@ -32,6 +33,7 @@ def find(
)
url = "/v1/apps/secrets/find"
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
4 changes: 4 additions & 0 deletions stripe/api_resources/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@

class Balance(SingletonAPIResource):
OBJECT_NAME = "balance"

@classmethod
def class_url(cls):
return "/v1/balance"
8 changes: 4 additions & 4 deletions stripe/api_resources/bitcoin_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
class BitcoinReceiver(ListableAPIResource):
OBJECT_NAME = "bitcoin_receiver"

@classmethod
def class_url(cls):
return "/v1/bitcoin/receivers"

def instance_url(self):
token = util.utf8(self.id)
extn = quote_plus(token)
Expand All @@ -22,7 +26,3 @@ def instance_url(self):
else:
base = BitcoinReceiver.class_url()
return "%s/%s" % (base, extn)

@classmethod
def class_url(cls):
return "/v1/bitcoin/receivers"
4 changes: 3 additions & 1 deletion stripe/api_resources/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class Charge(
OBJECT_NAME = "charge"

def capture(self, idempotency_key=None, **params):
url = self.instance_url() + "/capture"
url = "/v1/charges/{charge}/capture".format(
charge=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/checkout/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Session(CreateableAPIResource, ListableAPIResource):
OBJECT_NAME = "checkout.session"

def expire(self, idempotency_key=None, **params):
url = self.instance_url() + "/expire"
url = "/v1/checkout/sessions/{session}/expire".format(
session=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
4 changes: 3 additions & 1 deletion stripe/api_resources/credit_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class CreditNote(
OBJECT_NAME = "credit_note"

def void_credit_note(self, idempotency_key=None, **params):
url = self.instance_url() + "/void"
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
Expand Down
44 changes: 37 additions & 7 deletions stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ class Customer(
OBJECT_NAME = "customer"

def create_funding_instructions(self, idempotency_key=None, **params):
url = self.instance_url() + "/funding_instructions"
url = "/v1/customers/{customer}/funding_instructions".format(
customer=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
resp = self.request("post", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
return stripe_object

def list_payment_methods(self, idempotency_key=None, **params):
url = self.instance_url() + "/payment_methods"
url = "/v1/customers/{customer}/payment_methods".format(
customer=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
resp = self.request("get", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
Expand All @@ -82,9 +86,10 @@ def _cls_retrieve_payment_method(
)
)
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

@util.class_method_variant("_cls_retrieve_payment_method")
def retrieve_payment_method(
Expand Down Expand Up @@ -137,9 +142,10 @@ def retrieve_cash_balance(
customer=util.sanitize_id(customer)
)
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

@classmethod
def modify_cash_balance(
Expand All @@ -159,14 +165,38 @@ def modify_cash_balance(
customer=util.sanitize_id(customer)
)
response, api_key = requestor.request("post", 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

@custom_method("fund_cash_balance", http_verb="post")
class TestHelpers(APIResourceTestHelpers):
@classmethod
def _cls_fund_cash_balance(
cls,
customer,
api_key=None,
stripe_version=None,
stripe_account=None,
**params
):
requestor = api_requestor.APIRequestor(
api_key, api_version=stripe_version, account=stripe_account
)
url = "/v1/test_helpers/customers/{customer}/fund_cash_balance".format(
customer=util.sanitize_id(customer)
)
response, api_key = requestor.request("post", url, params)
stripe_object = util.convert_to_stripe_object(
response, api_key, stripe_version, stripe_account
)
return stripe_object

@util.class_method_variant("_cls_fund_cash_balance")
def fund_cash_balance(self, idempotency_key=None, **params):
url = self.instance_url() + "/fund_cash_balance"
url = "/v1/test_helpers/customers/{customer}/fund_cash_balance".format(
customer=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.resource.refresh_from(
self.resource.request("post", url, params, headers)
Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class Dispute(ListableAPIResource, UpdateableAPIResource):
OBJECT_NAME = "dispute"

def close(self, idempotency_key=None, **params):
url = self.instance_url() + "/close"
url = "/v1/disputes/{dispute}/close".format(
dispute=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
12 changes: 9 additions & 3 deletions stripe/api_resources/financial_connections/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@ class Account(ListableAPIResource):
OBJECT_NAME = "financial_connections.account"

def disconnect(self, idempotency_key=None, **params):
url = self.instance_url() + "/disconnect"
url = "/v1/financial_connections/accounts/{account}/disconnect".format(
account=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def list_owners(self, idempotency_key=None, **params):
url = self.instance_url() + "/owners"
url = "/v1/financial_connections/accounts/{account}/owners".format(
account=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
resp = self.request("get", url, params, headers)
stripe_object = util.convert_to_stripe_object(resp)
stripe_object._retrieve_params = params
return stripe_object

def refresh_account(self, idempotency_key=None, **params):
url = self.instance_url() + "/refresh"
url = "/v1/financial_connections/accounts/{account}/refresh".format(
account=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
8 changes: 6 additions & 2 deletions stripe/api_resources/identity/verification_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ class VerificationSession(
OBJECT_NAME = "identity.verification_session"

def cancel(self, idempotency_key=None, **params):
url = self.instance_url() + "/cancel"
url = "/v1/identity/verification_sessions/{session}/cancel".format(
session=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def redact(self, idempotency_key=None, **params):
url = self.instance_url() + "/redact"
url = "/v1/identity/verification_sessions/{session}/redact".format(
session=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
20 changes: 15 additions & 5 deletions stripe/api_resources/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,41 @@ class Invoice(
OBJECT_NAME = "invoice"

def finalize_invoice(self, idempotency_key=None, **params):
url = self.instance_url() + "/finalize"
url = "/v1/invoices/{invoice}/finalize".format(
invoice=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def mark_uncollectible(self, idempotency_key=None, **params):
url = self.instance_url() + "/mark_uncollectible"
url = "/v1/invoices/{invoice}/mark_uncollectible".format(
invoice=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def pay(self, idempotency_key=None, **params):
url = self.instance_url() + "/pay"
url = "/v1/invoices/{invoice}/pay".format(
invoice=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def send_invoice(self, idempotency_key=None, **params):
url = self.instance_url() + "/send"
url = "/v1/invoices/{invoice}/send".format(
invoice=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def void_invoice(self, idempotency_key=None, **params):
url = self.instance_url() + "/void"
url = "/v1/invoices/{invoice}/void".format(
invoice=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
Expand Down
8 changes: 6 additions & 2 deletions stripe/api_resources/issuing/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ class Authorization(ListableAPIResource, UpdateableAPIResource):
OBJECT_NAME = "issuing.authorization"

def approve(self, idempotency_key=None, **params):
url = self.instance_url() + "/approve"
url = "/v1/issuing/authorizations/{authorization}/approve".format(
authorization=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def decline(self, idempotency_key=None, **params):
url = self.instance_url() + "/decline"
url = "/v1/issuing/authorizations/{authorization}/decline".format(
authorization=util.sanitize_id(self.get("id"))
)
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
Loading