| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from stripe._stripe_service import StripeService |
| 4 |
from stripe._util import sanitize_id |
| 5 |
from typing import Optional, cast |
| 6 |
from typing_extensions import TYPE_CHECKING |
| 7 |
|
| 8 |
if TYPE_CHECKING: |
| 9 |
from stripe._list_object import ListObject |
| 10 |
from stripe._request_options import RequestOptions |
| 11 |
from stripe.issuing._authorization import Authorization |
| 12 |
from stripe.params.issuing._authorization_approve_params import ( |
| 13 |
AuthorizationApproveParams, |
| 14 |
) |
| 15 |
from stripe.params.issuing._authorization_decline_params import ( |
| 16 |
AuthorizationDeclineParams, |
| 17 |
) |
| 18 |
from stripe.params.issuing._authorization_list_params import ( |
| 19 |
AuthorizationListParams, |
| 20 |
) |
| 21 |
from stripe.params.issuing._authorization_retrieve_params import ( |
| 22 |
AuthorizationRetrieveParams, |
| 23 |
) |
| 24 |
from stripe.params.issuing._authorization_update_params import ( |
| 25 |
AuthorizationUpdateParams, |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
class AuthorizationService(StripeService): |
| 30 |
def list( |
| 31 |
self, |
| 32 |
params: Optional["AuthorizationListParams"] = None, |
| 33 |
options: Optional["RequestOptions"] = None, |
| 34 |
) -> "ListObject[Authorization]": |
| 35 |
""" |
| 36 |
Returns a list of Issuing Authorization objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. |
| 37 |
""" |
| 38 |
return cast( |
| 39 |
"ListObject[Authorization]", |
| 40 |
self._request( |
| 41 |
"get", |
| 42 |
"/v1/issuing/authorizations", |
| 43 |
base_address="api", |
| 44 |
params=params, |
| 45 |
options=options, |
| 46 |
), |
| 47 |
) |
| 48 |
|
| 49 |
async def list_async( |
| 50 |
self, |
| 51 |
params: Optional["AuthorizationListParams"] = None, |
| 52 |
options: Optional["RequestOptions"] = None, |
| 53 |
) -> "ListObject[Authorization]": |
| 54 |
""" |
| 55 |
Returns a list of Issuing Authorization objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. |
| 56 |
""" |
| 57 |
return cast( |
| 58 |
"ListObject[Authorization]", |
| 59 |
await self._request_async( |
| 60 |
"get", |
| 61 |
"/v1/issuing/authorizations", |
| 62 |
base_address="api", |
| 63 |
params=params, |
| 64 |
options=options, |
| 65 |
), |
| 66 |
) |
| 67 |
|
| 68 |
def retrieve( |
| 69 |
self, |
| 70 |
authorization: str, |
| 71 |
params: Optional["AuthorizationRetrieveParams"] = None, |
| 72 |
options: Optional["RequestOptions"] = None, |
| 73 |
) -> "Authorization": |
| 74 |
""" |
| 75 |
Retrieves an Issuing Authorization object. |
| 76 |
""" |
| 77 |
return cast( |
| 78 |
"Authorization", |
| 79 |
self._request( |
| 80 |
"get", |
| 81 |
"/v1/issuing/authorizations/{authorization}".format( |
| 82 |
authorization=sanitize_id(authorization), |
| 83 |
), |
| 84 |
base_address="api", |
| 85 |
params=params, |
| 86 |
options=options, |
| 87 |
), |
| 88 |
) |
| 89 |
|
| 90 |
async def retrieve_async( |
| 91 |
self, |
| 92 |
authorization: str, |
| 93 |
params: Optional["AuthorizationRetrieveParams"] = None, |
| 94 |
options: Optional["RequestOptions"] = None, |
| 95 |
) -> "Authorization": |
| 96 |
""" |
| 97 |
Retrieves an Issuing Authorization object. |
| 98 |
""" |
| 99 |
return cast( |
| 100 |
"Authorization", |
| 101 |
await self._request_async( |
| 102 |
"get", |
| 103 |
"/v1/issuing/authorizations/{authorization}".format( |
| 104 |
authorization=sanitize_id(authorization), |
| 105 |
), |
| 106 |
base_address="api", |
| 107 |
params=params, |
| 108 |
options=options, |
| 109 |
), |
| 110 |
) |
| 111 |
|
| 112 |
def update( |
| 113 |
self, |
| 114 |
authorization: str, |
| 115 |
params: Optional["AuthorizationUpdateParams"] = None, |
| 116 |
options: Optional["RequestOptions"] = None, |
| 117 |
) -> "Authorization": |
| 118 |
""" |
| 119 |
Updates the specified Issuing Authorization object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. |
| 120 |
""" |
| 121 |
return cast( |
| 122 |
"Authorization", |
| 123 |
self._request( |
| 124 |
"post", |
| 125 |
"/v1/issuing/authorizations/{authorization}".format( |
| 126 |
authorization=sanitize_id(authorization), |
| 127 |
), |
| 128 |
base_address="api", |
| 129 |
params=params, |
| 130 |
options=options, |
| 131 |
), |
| 132 |
) |
| 133 |
|
| 134 |
async def update_async( |
| 135 |
self, |
| 136 |
authorization: str, |
| 137 |
params: Optional["AuthorizationUpdateParams"] = None, |
| 138 |
options: Optional["RequestOptions"] = None, |
| 139 |
) -> "Authorization": |
| 140 |
""" |
| 141 |
Updates the specified Issuing Authorization object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. |
| 142 |
""" |
| 143 |
return cast( |
| 144 |
"Authorization", |
| 145 |
await self._request_async( |
| 146 |
"post", |
| 147 |
"/v1/issuing/authorizations/{authorization}".format( |
| 148 |
authorization=sanitize_id(authorization), |
| 149 |
), |
| 150 |
base_address="api", |
| 151 |
params=params, |
| 152 |
options=options, |
| 153 |
), |
| 154 |
) |
| 155 |
|
| 156 |
def approve( |
| 157 |
self, |
| 158 |
authorization: str, |
| 159 |
params: Optional["AuthorizationApproveParams"] = None, |
| 160 |
options: Optional["RequestOptions"] = None, |
| 161 |
) -> "Authorization": |
| 162 |
""" |
| 163 |
[Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations) flow. |
| 164 |
This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). |
| 165 |
""" |
| 166 |
return cast( |
| 167 |
"Authorization", |
| 168 |
self._request( |
| 169 |
"post", |
| 170 |
"/v1/issuing/authorizations/{authorization}/approve".format( |
| 171 |
authorization=sanitize_id(authorization), |
| 172 |
), |
| 173 |
base_address="api", |
| 174 |
params=params, |
| 175 |
options=options, |
| 176 |
), |
| 177 |
) |
| 178 |
|
| 179 |
async def approve_async( |
| 180 |
self, |
| 181 |
authorization: str, |
| 182 |
params: Optional["AuthorizationApproveParams"] = None, |
| 183 |
options: Optional["RequestOptions"] = None, |
| 184 |
) -> "Authorization": |
| 185 |
""" |
| 186 |
[Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations) flow. |
| 187 |
This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). |
| 188 |
""" |
| 189 |
return cast( |
| 190 |
"Authorization", |
| 191 |
await self._request_async( |
| 192 |
"post", |
| 193 |
"/v1/issuing/authorizations/{authorization}/approve".format( |
| 194 |
authorization=sanitize_id(authorization), |
| 195 |
), |
| 196 |
base_address="api", |
| 197 |
params=params, |
| 198 |
options=options, |
| 199 |
), |
| 200 |
) |
| 201 |
|
| 202 |
def decline( |
| 203 |
self, |
| 204 |
authorization: str, |
| 205 |
params: Optional["AuthorizationDeclineParams"] = None, |
| 206 |
options: Optional["RequestOptions"] = None, |
| 207 |
) -> "Authorization": |
| 208 |
""" |
| 209 |
[Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations) flow. |
| 210 |
This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). |
| 211 |
""" |
| 212 |
return cast( |
| 213 |
"Authorization", |
| 214 |
self._request( |
| 215 |
"post", |
| 216 |
"/v1/issuing/authorizations/{authorization}/decline".format( |
| 217 |
authorization=sanitize_id(authorization), |
| 218 |
), |
| 219 |
base_address="api", |
| 220 |
params=params, |
| 221 |
options=options, |
| 222 |
), |
| 223 |
) |
| 224 |
|
| 225 |
async def decline_async( |
| 226 |
self, |
| 227 |
authorization: str, |
| 228 |
params: Optional["AuthorizationDeclineParams"] = None, |
| 229 |
options: Optional["RequestOptions"] = None, |
| 230 |
) -> "Authorization": |
| 231 |
""" |
| 232 |
[Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations) flow. |
| 233 |
This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://docs.stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). |
| 234 |
""" |
| 235 |
return cast( |
| 236 |
"Authorization", |
| 237 |
await self._request_async( |
| 238 |
"post", |
| 239 |
"/v1/issuing/authorizations/{authorization}/decline".format( |
| 240 |
authorization=sanitize_id(authorization), |
| 241 |
), |
| 242 |
base_address="api", |
| 243 |
params=params, |
| 244 |
options=options, |
| 245 |
), |
| 246 |
) |