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

Inner resource classes #1103

Merged
merged 3 commits into from
Oct 26, 2023
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
988 changes: 980 additions & 8 deletions stripe/api_resources/account.py

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion stripe/api_resources/account_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class AccountSession(CreateableAPIResource["AccountSession"]):
"""

OBJECT_NAME: ClassVar[Literal["account_session"]] = "account_session"

class Components(StripeObject):
class AccountOnboarding(StripeObject):
enabled: bool
"""
Whether the embedded component is enabled.
"""

account_onboarding: AccountOnboarding
_inner_class_types = {"account_onboarding": AccountOnboarding}

if TYPE_CHECKING:

class CreateParams(RequestOptions):
Expand Down Expand Up @@ -67,7 +78,7 @@ class CreateParamsComponentsAccountOnboarding(TypedDict):

Refer to our docs to [setup Connect embedded components](https://stripe.com/docs/connect/get-started-connect-embedded-components) and learn about how `client_secret` should be handled.
"""
components: StripeObject
components: Components
expires_at: int
"""
The timestamp at which this AccountSession will expire.
Expand Down Expand Up @@ -102,3 +113,5 @@ def create(
params,
),
)

_inner_class_types = {"components": Components}
15 changes: 14 additions & 1 deletion stripe/api_resources/apps/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ class Secret(CreateableAPIResource["Secret"], ListableAPIResource["Secret"]):
"""

OBJECT_NAME: ClassVar[Literal["apps.secret"]] = "apps.secret"

class Scope(StripeObject):
type: Literal["account", "user"]
"""
The secret scope type.
"""
user: Optional[str]
"""
The user ID, if type is set to "user"
"""

if TYPE_CHECKING:

class CreateParams(RequestOptions):
Expand Down Expand Up @@ -177,7 +188,7 @@ class ListParamsScope(TypedDict):
"""
The plaintext secret value to be stored.
"""
scope: StripeObject
scope: Scope

@classmethod
def create(
Expand Down Expand Up @@ -265,3 +276,5 @@ def list(
)

return result

_inner_class_types = {"scope": Scope}
156 changes: 151 additions & 5 deletions stripe/api_resources/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,144 @@ class Balance(SingletonAPIResource["Balance"]):
"""

OBJECT_NAME: ClassVar[Literal["balance"]] = "balance"

class Available(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Balance amount.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

class ConnectReserved(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Balance amount.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

class InstantAvailable(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Balance amount.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

class Issuing(StripeObject):
class Available(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Balance amount.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

available: List[Available]
"""
Funds that are available for use.
"""
_inner_class_types = {"available": Available}

class Pending(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Balance amount.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

if TYPE_CHECKING:

class RetrieveParams(RequestOptions):
Expand All @@ -31,19 +169,19 @@ class RetrieveParams(RequestOptions):
Specifies which fields in the response should be expanded.
"""

available: List[StripeObject]
available: List[Available]
"""
Available funds that you can transfer or pay out automatically by Stripe or explicitly through the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). You can find the available balance for each currency and payment type in the `source_types` property.
"""
connect_reserved: Optional[List[StripeObject]]
connect_reserved: Optional[List[ConnectReserved]]
"""
Funds held due to negative balances on connected Custom accounts. You can find the connect reserve balance for each currency and payment type in the `source_types` property.
"""
instant_available: Optional[List[StripeObject]]
instant_available: Optional[List[InstantAvailable]]
"""
Funds that you can pay out using Instant Payouts.
"""
issuing: Optional[StripeObject]
issuing: Optional[Issuing]
livemode: bool
"""
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Expand All @@ -52,7 +190,7 @@ class RetrieveParams(RequestOptions):
"""
String representing the object's type. Objects of the same type share the same value.
"""
pending: List[StripeObject]
pending: List[Pending]
"""
Funds that aren't available in the balance yet. You can find the pending balance for each currency and each payment type in the `source_types` property.
"""
Expand All @@ -66,3 +204,11 @@ def retrieve(cls, **params: Unpack["Balance.RetrieveParams"]) -> "Balance":
@classmethod
def class_url(cls):
return "/v1/balance"

_inner_class_types = {
"available": Available,
"connect_reserved": ConnectReserved,
"instant_available": InstantAvailable,
"issuing": Issuing,
"pending": Pending,
}
27 changes: 26 additions & 1 deletion stripe/api_resources/balance_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ class BalanceTransaction(ListableAPIResource["BalanceTransaction"]):
OBJECT_NAME: ClassVar[
Literal["balance_transaction"]
] = "balance_transaction"

class FeeDetail(StripeObject):
amount: int
"""
Amount of the fee, in cents.
"""
application: Optional[str]
"""
ID of the Connect application that earned the fee.
"""
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
description: Optional[str]
"""
An arbitrary string attached to the object. Often useful for displaying to users.
"""
type: str
"""
Type of the fee, one of: `application_fee`, `stripe_fee` or `tax`.
"""

if TYPE_CHECKING:

class ListParams(RequestOptions):
Expand Down Expand Up @@ -144,7 +167,7 @@ class RetrieveParams(RequestOptions):
"""
Fees (in cents (or local equivalent)) paid for this transaction. Represented as a positive integer when assessed.
"""
fee_details: List[StripeObject]
fee_details: List[FeeDetail]
"""
Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
"""
Expand Down Expand Up @@ -271,3 +294,5 @@ def retrieve(
instance = cls(id, **params)
instance.refresh()
return instance

_inner_class_types = {"fee_details": FeeDetail}
Loading