Debian Codegraph @

stripe/terminal/_connection_token.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from typing import ClassVar, Optional, cast
5 from typing_extensions import Literal, Unpack, TYPE_CHECKING
6
7 if TYPE_CHECKING:
8 from stripe.params.terminal._connection_token_create_params import (
9 ConnectionTokenCreateParams,
10 )
11
12
13 class ConnectionToken(CreateableAPIResource["ConnectionToken"]):
14 """
15 A Connection Token is used by the Stripe Terminal SDK to connect to a reader.
16
17 Related guide: [Fleet management](https://docs.stripe.com/terminal/fleet/locations)
18 """
19
20 OBJECT_NAME: ClassVar[Literal["terminal.connection_token"]] = (
21 "terminal.connection_token"
22 )
23 location: Optional[str]
24 """
25 The id of the location that this connection token is scoped to. Note that location scoping only applies to internet-connected readers. For more details, see [the docs on scoping connection tokens](https://docs.stripe.com/terminal/fleet/locations-and-zones?dashboard-or-api=api#connection-tokens).
26 """
27 object: Literal["terminal.connection_token"]
28 """
29 String representing the object's type. Objects of the same type share the same value.
30 """
31 secret: str
32 """
33 Your application should pass this token to the Stripe Terminal SDK.
34 """
35
36 @classmethod
37 def create(
38 cls, **params: Unpack["ConnectionTokenCreateParams"]
39 ) -> "ConnectionToken":
40 """
41 To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. On your backend, add an endpoint that creates and returns a connection token.
42 """
43 return cast(
44 "ConnectionToken",
45 cls._static_request(
46 "post",
47 cls.class_url(),
48 params=params,
49 ),
50 )
51
52 @classmethod
53 async def create_async(
54 cls, **params: Unpack["ConnectionTokenCreateParams"]
55 ) -> "ConnectionToken":
56 """
57 To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. On your backend, add an endpoint that creates and returns a connection token.
58 """
59 return cast(
60 "ConnectionToken",
61 await cls._static_request_async(
62 "post",
63 cls.class_url(),
64 params=params,
65 ),
66 )