Debian Codegraph @

stripe/test_helpers/terminal/_reader_service.py

raw
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.test_helpers.terminal._reader_present_payment_method_params import (
11 ReaderPresentPaymentMethodParams,
12 )
13 from stripe.params.test_helpers.terminal._reader_succeed_input_collection_params import (
14 ReaderSucceedInputCollectionParams,
15 )
16 from stripe.params.test_helpers.terminal._reader_timeout_input_collection_params import (
17 ReaderTimeoutInputCollectionParams,
18 )
19 from stripe.terminal._reader import Reader
20
21
22 class ReaderService(StripeService):
23 def present_payment_method(
24 self,
25 reader: str,
26 params: Optional["ReaderPresentPaymentMethodParams"] = None,
27 options: Optional["RequestOptions"] = None,
28 ) -> "Reader":
29 """
30 Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction.
31 """
32 return cast(
33 "Reader",
34 self._request(
35 "post",
36 "/v1/test_helpers/terminal/readers/{reader}/present_payment_method".format(
37 reader=sanitize_id(reader),
38 ),
39 base_address="api",
40 params=params,
41 options=options,
42 ),
43 )
44
45 async def present_payment_method_async(
46 self,
47 reader: str,
48 params: Optional["ReaderPresentPaymentMethodParams"] = None,
49 options: Optional["RequestOptions"] = None,
50 ) -> "Reader":
51 """
52 Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction.
53 """
54 return cast(
55 "Reader",
56 await self._request_async(
57 "post",
58 "/v1/test_helpers/terminal/readers/{reader}/present_payment_method".format(
59 reader=sanitize_id(reader),
60 ),
61 base_address="api",
62 params=params,
63 options=options,
64 ),
65 )
66
67 def succeed_input_collection(
68 self,
69 reader: str,
70 params: Optional["ReaderSucceedInputCollectionParams"] = None,
71 options: Optional["RequestOptions"] = None,
72 ) -> "Reader":
73 """
74 Use this endpoint to trigger a successful input collection on a simulated reader.
75 """
76 return cast(
77 "Reader",
78 self._request(
79 "post",
80 "/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection".format(
81 reader=sanitize_id(reader),
82 ),
83 base_address="api",
84 params=params,
85 options=options,
86 ),
87 )
88
89 async def succeed_input_collection_async(
90 self,
91 reader: str,
92 params: Optional["ReaderSucceedInputCollectionParams"] = None,
93 options: Optional["RequestOptions"] = None,
94 ) -> "Reader":
95 """
96 Use this endpoint to trigger a successful input collection on a simulated reader.
97 """
98 return cast(
99 "Reader",
100 await self._request_async(
101 "post",
102 "/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection".format(
103 reader=sanitize_id(reader),
104 ),
105 base_address="api",
106 params=params,
107 options=options,
108 ),
109 )
110
111 def timeout_input_collection(
112 self,
113 reader: str,
114 params: Optional["ReaderTimeoutInputCollectionParams"] = None,
115 options: Optional["RequestOptions"] = None,
116 ) -> "Reader":
117 """
118 Use this endpoint to complete an input collection with a timeout error on a simulated reader.
119 """
120 return cast(
121 "Reader",
122 self._request(
123 "post",
124 "/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection".format(
125 reader=sanitize_id(reader),
126 ),
127 base_address="api",
128 params=params,
129 options=options,
130 ),
131 )
132
133 async def timeout_input_collection_async(
134 self,
135 reader: str,
136 params: Optional["ReaderTimeoutInputCollectionParams"] = None,
137 options: Optional["RequestOptions"] = None,
138 ) -> "Reader":
139 """
140 Use this endpoint to complete an input collection with a timeout error on a simulated reader.
141 """
142 return cast(
143 "Reader",
144 await self._request_async(
145 "post",
146 "/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection".format(
147 reader=sanitize_id(reader),
148 ),
149 base_address="api",
150 params=params,
151 options=options,
152 ),
153 )