Skip to content

Commit

Permalink
Generate explicit method definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Sep 7, 2023
1 parent fca51fc commit 011e834
Show file tree
Hide file tree
Showing 94 changed files with 3,769 additions and 490 deletions.
53 changes: 53 additions & 0 deletions stripe/api_resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,59 @@ class Account(
tos_acceptance: StripeObject
type: str

@classmethod
def create(
cls,
api_key=None,
idempotency_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
cls.class_url(),
api_key,
idempotency_key,
stripe_version,
stripe_account,
params,
)

@classmethod
def _cls_delete(cls, sid, **params):
url = "%s/%s" % (cls.class_url(), quote_plus(sid))
return cls._static_request("delete", url, params=params)

@util.class_method_variant("_cls_delete")
def delete(self, **params):
return self._request_and_refresh(
"delete",
self.instance_url(),
params=params,
)

@classmethod
def list(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
):
result = cls._static_request(
"get",
cls.class_url(),
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)

return result

@classmethod
def _cls_persons(
cls,
Expand Down
19 changes: 19 additions & 0 deletions stripe/api_resources/account_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ class AccountLink(CreateableAPIResource["AccountLink"]):
expires_at: str
object: Literal["account_link"]
url: str

@classmethod
def create(
cls,
api_key=None,
idempotency_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
cls.class_url(),
api_key,
idempotency_key,
stripe_version,
stripe_account,
params,
)
19 changes: 19 additions & 0 deletions stripe/api_resources/account_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@ class AccountSession(CreateableAPIResource["AccountSession"]):
expires_at: str
livemode: bool
object: Literal["account_session"]

@classmethod
def create(
cls,
api_key=None,
idempotency_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
cls.class_url(),
api_key,
idempotency_key,
stripe_version,
stripe_account,
params,
)
62 changes: 62 additions & 0 deletions stripe/api_resources/apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function

from stripe import util
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import DeletableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.list_object import ListObject
from typing_extensions import Literal
from urllib.parse import quote_plus


class ApplePayDomain(
Expand All @@ -20,6 +23,65 @@ class ApplePayDomain(
livemode: bool
object: Literal["apple_pay_domain"]

@classmethod
def create(
cls,
api_key=None,
idempotency_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
cls.class_url(),
api_key,
idempotency_key,
stripe_version,
stripe_account,
params,
)

@classmethod
def _cls_delete(cls, sid, **params):
url = "%s/%s" % (cls.class_url(), quote_plus(sid))
return cls._static_request("delete", url, params=params)

@util.class_method_variant("_cls_delete")
def delete(self, **params):
return self._request_and_refresh(
"delete",
self.instance_url(),
params=params,
)

@classmethod
def list(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
):
result = cls._static_request(
"get",
cls.class_url(),
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)

return result

@classmethod
def retrieve(cls, id, api_key=None, **params):
instance = cls(id, api_key, **params)
instance.refresh()
return instance

@classmethod
def class_url(cls):
return "/v1/apple_pay/domains"
43 changes: 33 additions & 10 deletions stripe/api_resources/application_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
from stripe import util
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import nested_resource_class_methods
from stripe.api_resources.expandable_field import ExpandableField
from stripe.api_resources.list_object import ListObject
from typing import Any
from typing import Optional
from typing_extensions import Literal

from typing_extensions import TYPE_CHECKING

if TYPE_CHECKING:
from stripe.api_resources.account import Account
from stripe.api_resources.application import Application
from stripe.api_resources.balance_transaction import BalanceTransaction
from stripe.api_resources.charge import Charge
from stripe.api_resources.application_fee_refund import (
ApplicationFeeRefund,
)
Expand All @@ -28,21 +24,42 @@
)
class ApplicationFee(ListableAPIResource["ApplicationFee"]):
OBJECT_NAME = "application_fee"
account: ExpandableField["Account"]
account: Any
amount: int
amount_refunded: int
application: ExpandableField["Application"]
balance_transaction: Optional[ExpandableField["BalanceTransaction"]]
charge: ExpandableField["Charge"]
application: Any
balance_transaction: Optional[Any]
charge: Any
created: str
currency: str
id: str
livemode: bool
object: Literal["application_fee"]
originating_transaction: Optional[ExpandableField["Charge"]]
originating_transaction: Optional[Any]
refunded: bool
refunds: ListObject["ApplicationFeeRefund"]

@classmethod
def list(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
):
result = cls._static_request(
"get",
cls.class_url(),
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)

return result

@classmethod
def _cls_refund(
cls,
Expand Down Expand Up @@ -73,3 +90,9 @@ def refund(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@classmethod
def retrieve(cls, id, api_key=None, **params):
instance = cls(id, api_key, **params)
instance.refresh()
return instance
13 changes: 4 additions & 9 deletions stripe/api_resources/application_fee_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function

from stripe.api_resources import ApplicationFee
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.application_fee import ApplicationFee
from stripe.api_resources.expandable_field import ExpandableField
from typing import Any
from typing import Dict
from typing import Optional
from typing_extensions import Literal
from urllib.parse import quote_plus

from typing_extensions import TYPE_CHECKING

if TYPE_CHECKING:
from stripe.api_resources.balance_transaction import BalanceTransaction


class ApplicationFeeRefund(UpdateableAPIResource["ApplicationFeeRefund"]):
"""
Expand All @@ -27,10 +22,10 @@ class ApplicationFeeRefund(UpdateableAPIResource["ApplicationFeeRefund"]):

OBJECT_NAME = "fee_refund"
amount: int
balance_transaction: Optional[ExpandableField["BalanceTransaction"]]
balance_transaction: Optional[Any]
created: str
currency: str
fee: ExpandableField["ApplicationFee"]
fee: Any
id: str
metadata: Optional[Dict[str, str]]
object: Literal["fee_refund"]
Expand Down
41 changes: 41 additions & 0 deletions stripe/api_resources/apps/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.list_object import ListObject
from stripe.stripe_object import StripeObject
from typing import Optional
from typing_extensions import Literal
Expand Down Expand Up @@ -33,6 +34,25 @@ class Secret(CreateableAPIResource["Secret"], ListableAPIResource["Secret"]):
payload: Optional[str]
scope: StripeObject

@classmethod
def create(
cls,
api_key=None,
idempotency_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
cls.class_url(),
api_key,
idempotency_key,
stripe_version,
stripe_account,
params,
)

@classmethod
def delete_where(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
Expand All @@ -58,3 +78,24 @@ def find(
stripe_account=stripe_account,
params=params,
)

@classmethod
def list(
cls, api_key=None, stripe_version=None, stripe_account=None, **params
):
result = cls._static_request(
"get",
cls.class_url(),
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)

return result
6 changes: 6 additions & 0 deletions stripe/api_resources/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class Balance(SingletonAPIResource["Balance"]):
object: Literal["balance"]
pending: List[StripeObject]

@classmethod
def retrieve(cls, **params):
instance = cls(None, **params)
instance.refresh()
return instance

@classmethod
def class_url(cls):
return "/v1/balance"
Loading

0 comments on commit 011e834

Please sign in to comment.