| 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._request_options import RequestOptions |
| 10 |
from stripe.params.v2.core._event_destination_create_params import ( |
| 11 |
EventDestinationCreateParams, |
| 12 |
) |
| 13 |
from stripe.params.v2.core._event_destination_delete_params import ( |
| 14 |
EventDestinationDeleteParams, |
| 15 |
) |
| 16 |
from stripe.params.v2.core._event_destination_disable_params import ( |
| 17 |
EventDestinationDisableParams, |
| 18 |
) |
| 19 |
from stripe.params.v2.core._event_destination_enable_params import ( |
| 20 |
EventDestinationEnableParams, |
| 21 |
) |
| 22 |
from stripe.params.v2.core._event_destination_list_params import ( |
| 23 |
EventDestinationListParams, |
| 24 |
) |
| 25 |
from stripe.params.v2.core._event_destination_ping_params import ( |
| 26 |
EventDestinationPingParams, |
| 27 |
) |
| 28 |
from stripe.params.v2.core._event_destination_retrieve_params import ( |
| 29 |
EventDestinationRetrieveParams, |
| 30 |
) |
| 31 |
from stripe.params.v2.core._event_destination_update_params import ( |
| 32 |
EventDestinationUpdateParams, |
| 33 |
) |
| 34 |
from stripe.v2._deleted_object import DeletedObject |
| 35 |
from stripe.v2._list_object import ListObject |
| 36 |
from stripe.v2.core._event import Event |
| 37 |
from stripe.v2.core._event_destination import EventDestination |
| 38 |
|
| 39 |
|
| 40 |
class EventDestinationService(StripeService): |
| 41 |
def list( |
| 42 |
self, |
| 43 |
params: Optional["EventDestinationListParams"] = None, |
| 44 |
options: Optional["RequestOptions"] = None, |
| 45 |
) -> "ListObject[EventDestination]": |
| 46 |
""" |
| 47 |
Lists all event destinations. |
| 48 |
""" |
| 49 |
return cast( |
| 50 |
"ListObject[EventDestination]", |
| 51 |
self._request( |
| 52 |
"get", |
| 53 |
"/v2/core/event_destinations", |
| 54 |
base_address="api", |
| 55 |
params=params, |
| 56 |
options=options, |
| 57 |
), |
| 58 |
) |
| 59 |
|
| 60 |
async def list_async( |
| 61 |
self, |
| 62 |
params: Optional["EventDestinationListParams"] = None, |
| 63 |
options: Optional["RequestOptions"] = None, |
| 64 |
) -> "ListObject[EventDestination]": |
| 65 |
""" |
| 66 |
Lists all event destinations. |
| 67 |
""" |
| 68 |
return cast( |
| 69 |
"ListObject[EventDestination]", |
| 70 |
await self._request_async( |
| 71 |
"get", |
| 72 |
"/v2/core/event_destinations", |
| 73 |
base_address="api", |
| 74 |
params=params, |
| 75 |
options=options, |
| 76 |
), |
| 77 |
) |
| 78 |
|
| 79 |
def create( |
| 80 |
self, |
| 81 |
params: "EventDestinationCreateParams", |
| 82 |
options: Optional["RequestOptions"] = None, |
| 83 |
) -> "EventDestination": |
| 84 |
""" |
| 85 |
Create a new event destination. |
| 86 |
""" |
| 87 |
return cast( |
| 88 |
"EventDestination", |
| 89 |
self._request( |
| 90 |
"post", |
| 91 |
"/v2/core/event_destinations", |
| 92 |
base_address="api", |
| 93 |
params=params, |
| 94 |
options=options, |
| 95 |
), |
| 96 |
) |
| 97 |
|
| 98 |
async def create_async( |
| 99 |
self, |
| 100 |
params: "EventDestinationCreateParams", |
| 101 |
options: Optional["RequestOptions"] = None, |
| 102 |
) -> "EventDestination": |
| 103 |
""" |
| 104 |
Create a new event destination. |
| 105 |
""" |
| 106 |
return cast( |
| 107 |
"EventDestination", |
| 108 |
await self._request_async( |
| 109 |
"post", |
| 110 |
"/v2/core/event_destinations", |
| 111 |
base_address="api", |
| 112 |
params=params, |
| 113 |
options=options, |
| 114 |
), |
| 115 |
) |
| 116 |
|
| 117 |
def delete( |
| 118 |
self, |
| 119 |
id: str, |
| 120 |
params: Optional["EventDestinationDeleteParams"] = None, |
| 121 |
options: Optional["RequestOptions"] = None, |
| 122 |
) -> "DeletedObject": |
| 123 |
""" |
| 124 |
Delete an event destination. |
| 125 |
""" |
| 126 |
return cast( |
| 127 |
"DeletedObject", |
| 128 |
self._request( |
| 129 |
"delete", |
| 130 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 131 |
base_address="api", |
| 132 |
params=params, |
| 133 |
options=options, |
| 134 |
), |
| 135 |
) |
| 136 |
|
| 137 |
async def delete_async( |
| 138 |
self, |
| 139 |
id: str, |
| 140 |
params: Optional["EventDestinationDeleteParams"] = None, |
| 141 |
options: Optional["RequestOptions"] = None, |
| 142 |
) -> "DeletedObject": |
| 143 |
""" |
| 144 |
Delete an event destination. |
| 145 |
""" |
| 146 |
return cast( |
| 147 |
"DeletedObject", |
| 148 |
await self._request_async( |
| 149 |
"delete", |
| 150 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 151 |
base_address="api", |
| 152 |
params=params, |
| 153 |
options=options, |
| 154 |
), |
| 155 |
) |
| 156 |
|
| 157 |
def retrieve( |
| 158 |
self, |
| 159 |
id: str, |
| 160 |
params: Optional["EventDestinationRetrieveParams"] = None, |
| 161 |
options: Optional["RequestOptions"] = None, |
| 162 |
) -> "EventDestination": |
| 163 |
""" |
| 164 |
Retrieves the details of an event destination. |
| 165 |
""" |
| 166 |
return cast( |
| 167 |
"EventDestination", |
| 168 |
self._request( |
| 169 |
"get", |
| 170 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 171 |
base_address="api", |
| 172 |
params=params, |
| 173 |
options=options, |
| 174 |
), |
| 175 |
) |
| 176 |
|
| 177 |
async def retrieve_async( |
| 178 |
self, |
| 179 |
id: str, |
| 180 |
params: Optional["EventDestinationRetrieveParams"] = None, |
| 181 |
options: Optional["RequestOptions"] = None, |
| 182 |
) -> "EventDestination": |
| 183 |
""" |
| 184 |
Retrieves the details of an event destination. |
| 185 |
""" |
| 186 |
return cast( |
| 187 |
"EventDestination", |
| 188 |
await self._request_async( |
| 189 |
"get", |
| 190 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 191 |
base_address="api", |
| 192 |
params=params, |
| 193 |
options=options, |
| 194 |
), |
| 195 |
) |
| 196 |
|
| 197 |
def update( |
| 198 |
self, |
| 199 |
id: str, |
| 200 |
params: Optional["EventDestinationUpdateParams"] = None, |
| 201 |
options: Optional["RequestOptions"] = None, |
| 202 |
) -> "EventDestination": |
| 203 |
""" |
| 204 |
Update the details of an event destination. |
| 205 |
""" |
| 206 |
return cast( |
| 207 |
"EventDestination", |
| 208 |
self._request( |
| 209 |
"post", |
| 210 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 211 |
base_address="api", |
| 212 |
params=params, |
| 213 |
options=options, |
| 214 |
), |
| 215 |
) |
| 216 |
|
| 217 |
async def update_async( |
| 218 |
self, |
| 219 |
id: str, |
| 220 |
params: Optional["EventDestinationUpdateParams"] = None, |
| 221 |
options: Optional["RequestOptions"] = None, |
| 222 |
) -> "EventDestination": |
| 223 |
""" |
| 224 |
Update the details of an event destination. |
| 225 |
""" |
| 226 |
return cast( |
| 227 |
"EventDestination", |
| 228 |
await self._request_async( |
| 229 |
"post", |
| 230 |
"/v2/core/event_destinations/{id}".format(id=sanitize_id(id)), |
| 231 |
base_address="api", |
| 232 |
params=params, |
| 233 |
options=options, |
| 234 |
), |
| 235 |
) |
| 236 |
|
| 237 |
def disable( |
| 238 |
self, |
| 239 |
id: str, |
| 240 |
params: Optional["EventDestinationDisableParams"] = None, |
| 241 |
options: Optional["RequestOptions"] = None, |
| 242 |
) -> "EventDestination": |
| 243 |
""" |
| 244 |
Disable an event destination. |
| 245 |
""" |
| 246 |
return cast( |
| 247 |
"EventDestination", |
| 248 |
self._request( |
| 249 |
"post", |
| 250 |
"/v2/core/event_destinations/{id}/disable".format( |
| 251 |
id=sanitize_id(id), |
| 252 |
), |
| 253 |
base_address="api", |
| 254 |
params=params, |
| 255 |
options=options, |
| 256 |
), |
| 257 |
) |
| 258 |
|
| 259 |
async def disable_async( |
| 260 |
self, |
| 261 |
id: str, |
| 262 |
params: Optional["EventDestinationDisableParams"] = None, |
| 263 |
options: Optional["RequestOptions"] = None, |
| 264 |
) -> "EventDestination": |
| 265 |
""" |
| 266 |
Disable an event destination. |
| 267 |
""" |
| 268 |
return cast( |
| 269 |
"EventDestination", |
| 270 |
await self._request_async( |
| 271 |
"post", |
| 272 |
"/v2/core/event_destinations/{id}/disable".format( |
| 273 |
id=sanitize_id(id), |
| 274 |
), |
| 275 |
base_address="api", |
| 276 |
params=params, |
| 277 |
options=options, |
| 278 |
), |
| 279 |
) |
| 280 |
|
| 281 |
def enable( |
| 282 |
self, |
| 283 |
id: str, |
| 284 |
params: Optional["EventDestinationEnableParams"] = None, |
| 285 |
options: Optional["RequestOptions"] = None, |
| 286 |
) -> "EventDestination": |
| 287 |
""" |
| 288 |
Enable an event destination. |
| 289 |
""" |
| 290 |
return cast( |
| 291 |
"EventDestination", |
| 292 |
self._request( |
| 293 |
"post", |
| 294 |
"/v2/core/event_destinations/{id}/enable".format( |
| 295 |
id=sanitize_id(id), |
| 296 |
), |
| 297 |
base_address="api", |
| 298 |
params=params, |
| 299 |
options=options, |
| 300 |
), |
| 301 |
) |
| 302 |
|
| 303 |
async def enable_async( |
| 304 |
self, |
| 305 |
id: str, |
| 306 |
params: Optional["EventDestinationEnableParams"] = None, |
| 307 |
options: Optional["RequestOptions"] = None, |
| 308 |
) -> "EventDestination": |
| 309 |
""" |
| 310 |
Enable an event destination. |
| 311 |
""" |
| 312 |
return cast( |
| 313 |
"EventDestination", |
| 314 |
await self._request_async( |
| 315 |
"post", |
| 316 |
"/v2/core/event_destinations/{id}/enable".format( |
| 317 |
id=sanitize_id(id), |
| 318 |
), |
| 319 |
base_address="api", |
| 320 |
params=params, |
| 321 |
options=options, |
| 322 |
), |
| 323 |
) |
| 324 |
|
| 325 |
def ping( |
| 326 |
self, |
| 327 |
id: str, |
| 328 |
params: Optional["EventDestinationPingParams"] = None, |
| 329 |
options: Optional["RequestOptions"] = None, |
| 330 |
) -> "Event": |
| 331 |
""" |
| 332 |
Send a `ping` event to an event destination. |
| 333 |
""" |
| 334 |
return cast( |
| 335 |
"Event", |
| 336 |
self._request( |
| 337 |
"post", |
| 338 |
"/v2/core/event_destinations/{id}/ping".format( |
| 339 |
id=sanitize_id(id), |
| 340 |
), |
| 341 |
base_address="api", |
| 342 |
params=params, |
| 343 |
options=options, |
| 344 |
), |
| 345 |
) |
| 346 |
|
| 347 |
async def ping_async( |
| 348 |
self, |
| 349 |
id: str, |
| 350 |
params: Optional["EventDestinationPingParams"] = None, |
| 351 |
options: Optional["RequestOptions"] = None, |
| 352 |
) -> "Event": |
| 353 |
""" |
| 354 |
Send a `ping` event to an event destination. |
| 355 |
""" |
| 356 |
return cast( |
| 357 |
"Event", |
| 358 |
await self._request_async( |
| 359 |
"post", |
| 360 |
"/v2/core/event_destinations/{id}/ping".format( |
| 361 |
id=sanitize_id(id), |
| 362 |
), |
| 363 |
base_address="api", |
| 364 |
params=params, |
| 365 |
options=options, |
| 366 |
), |
| 367 |
) |