File: _token_service.py

package info (click to toggle)
python-stripe 13.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,476 kB
  • sloc: python: 187,843; makefile: 13; sh: 9
file content (94 lines) | stat: -rw-r--r-- 3,435 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._stripe_service import StripeService
from stripe._util import sanitize_id
from typing import Optional, cast
from typing_extensions import TYPE_CHECKING

if TYPE_CHECKING:
    from stripe._request_options import RequestOptions
    from stripe._token import Token
    from stripe.params._token_create_params import TokenCreateParams
    from stripe.params._token_retrieve_params import TokenRetrieveParams


class TokenService(StripeService):
    def retrieve(
        self,
        token: str,
        params: Optional["TokenRetrieveParams"] = None,
        options: Optional["RequestOptions"] = None,
    ) -> "Token":
        """
        Retrieves the token with the given ID.
        """
        return cast(
            "Token",
            self._request(
                "get",
                "/v1/tokens/{token}".format(token=sanitize_id(token)),
                base_address="api",
                params=params,
                options=options,
            ),
        )

    async def retrieve_async(
        self,
        token: str,
        params: Optional["TokenRetrieveParams"] = None,
        options: Optional["RequestOptions"] = None,
    ) -> "Token":
        """
        Retrieves the token with the given ID.
        """
        return cast(
            "Token",
            await self._request_async(
                "get",
                "/v1/tokens/{token}".format(token=sanitize_id(token)),
                base_address="api",
                params=params,
                options=options,
            ),
        )

    def create(
        self,
        params: Optional["TokenCreateParams"] = None,
        options: Optional["RequestOptions"] = None,
    ) -> "Token":
        """
        Creates a single-use token that represents a bank account's details.
        You can use this token with any v1 API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://docs.stripe.com/api#accounts) where [controller.requirement_collection](https://docs.stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
        """
        return cast(
            "Token",
            self._request(
                "post",
                "/v1/tokens",
                base_address="api",
                params=params,
                options=options,
            ),
        )

    async def create_async(
        self,
        params: Optional["TokenCreateParams"] = None,
        options: Optional["RequestOptions"] = None,
    ) -> "Token":
        """
        Creates a single-use token that represents a bank account's details.
        You can use this token with any v1 API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://docs.stripe.com/api#accounts) where [controller.requirement_collection](https://docs.stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
        """
        return cast(
            "Token",
            await self._request_async(
                "post",
                "/v1/tokens",
                base_address="api",
                params=params,
                options=options,
            ),
        )