gmt-python-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gmt/__init__.py +92 -0
- gmt/_base_client.py +1995 -0
- gmt/_client.py +418 -0
- gmt/_compat.py +219 -0
- gmt/_constants.py +14 -0
- gmt/_exceptions.py +108 -0
- gmt/_files.py +123 -0
- gmt/_models.py +857 -0
- gmt/_qs.py +150 -0
- gmt/_resource.py +43 -0
- gmt/_response.py +830 -0
- gmt/_streaming.py +333 -0
- gmt/_types.py +260 -0
- gmt/_utils/__init__.py +64 -0
- gmt/_utils/_compat.py +45 -0
- gmt/_utils/_datetime_parse.py +136 -0
- gmt/_utils/_logs.py +25 -0
- gmt/_utils/_proxy.py +65 -0
- gmt/_utils/_reflection.py +42 -0
- gmt/_utils/_resources_proxy.py +24 -0
- gmt/_utils/_streams.py +12 -0
- gmt/_utils/_sync.py +58 -0
- gmt/_utils/_transform.py +457 -0
- gmt/_utils/_typing.py +156 -0
- gmt/_utils/_utils.py +421 -0
- gmt/_version.py +4 -0
- gmt/lib/.keep +4 -0
- gmt/pagination.py +101 -0
- gmt/py.typed +0 -0
- gmt/resources/__init__.py +61 -0
- gmt/resources/accounts.py +423 -0
- gmt/resources/profile.py +141 -0
- gmt/resources/purchases.py +557 -0
- gmt/resources/service.py +186 -0
- gmt/types/__init__.py +20 -0
- gmt/types/account_list_countries_params.py +24 -0
- gmt/types/account_list_countries_response.py +36 -0
- gmt/types/account_list_params.py +24 -0
- gmt/types/account_list_response.py +33 -0
- gmt/types/account_retrieve_response.py +43 -0
- gmt/types/profile_retrieve_response.py +89 -0
- gmt/types/purchase_create_params.py +12 -0
- gmt/types/purchase_create_response.py +108 -0
- gmt/types/purchase_list_params.py +31 -0
- gmt/types/purchase_list_response.py +108 -0
- gmt/types/purchase_request_verification_code_response.py +108 -0
- gmt/types/purchase_retrieve_response.py +108 -0
- gmt/types/service_get_server_time_response.py +18 -0
- gmt/types/service_health_check_response.py +32 -0
- gmt_python_sdk-0.1.0.dist-info/METADATA +473 -0
- gmt_python_sdk-0.1.0.dist-info/RECORD +53 -0
- gmt_python_sdk-0.1.0.dist-info/WHEEL +4 -0
- gmt_python_sdk-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ..types import purchase_list_params, purchase_create_params
|
|
10
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
12
|
+
from .._compat import cached_property
|
|
13
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
14
|
+
from .._response import (
|
|
15
|
+
to_raw_response_wrapper,
|
|
16
|
+
to_streamed_response_wrapper,
|
|
17
|
+
async_to_raw_response_wrapper,
|
|
18
|
+
async_to_streamed_response_wrapper,
|
|
19
|
+
)
|
|
20
|
+
from ..pagination import SyncPageNumber, AsyncPageNumber
|
|
21
|
+
from .._base_client import AsyncPaginator, make_request_options
|
|
22
|
+
from ..types.purchase_list_response import PurchaseListResponse
|
|
23
|
+
from ..types.purchase_create_response import PurchaseCreateResponse
|
|
24
|
+
from ..types.purchase_retrieve_response import PurchaseRetrieveResponse
|
|
25
|
+
from ..types.purchase_request_verification_code_response import PurchaseRequestVerificationCodeResponse
|
|
26
|
+
|
|
27
|
+
__all__ = ["PurchasesResource", "AsyncPurchasesResource"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PurchasesResource(SyncAPIResource):
|
|
31
|
+
@cached_property
|
|
32
|
+
def with_raw_response(self) -> PurchasesResourceWithRawResponse:
|
|
33
|
+
"""
|
|
34
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
35
|
+
the raw response object instead of the parsed content.
|
|
36
|
+
|
|
37
|
+
For more information, see https://www.github.com/cameo6/gmt-python-sdk#accessing-raw-response-data-eg-headers
|
|
38
|
+
"""
|
|
39
|
+
return PurchasesResourceWithRawResponse(self)
|
|
40
|
+
|
|
41
|
+
@cached_property
|
|
42
|
+
def with_streaming_response(self) -> PurchasesResourceWithStreamingResponse:
|
|
43
|
+
"""
|
|
44
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
45
|
+
|
|
46
|
+
For more information, see https://www.github.com/cameo6/gmt-python-sdk#with_streaming_response
|
|
47
|
+
"""
|
|
48
|
+
return PurchasesResourceWithStreamingResponse(self)
|
|
49
|
+
|
|
50
|
+
def create(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
country_code: str,
|
|
54
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
55
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
56
|
+
extra_headers: Headers | None = None,
|
|
57
|
+
extra_query: Query | None = None,
|
|
58
|
+
extra_body: Body | None = None,
|
|
59
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
60
|
+
) -> PurchaseCreateResponse:
|
|
61
|
+
"""Creates a new purchase for specified country.
|
|
62
|
+
|
|
63
|
+
Deducts balance immediately and
|
|
64
|
+
returns purchase with `PENDING` status.
|
|
65
|
+
|
|
66
|
+
**Purchase Creation Process**
|
|
67
|
+
|
|
68
|
+
1. Validates country availability and user balance.
|
|
69
|
+
2. Reserves account from provider.
|
|
70
|
+
3. Atomically deducts balance and creates purchase record.
|
|
71
|
+
4. Returns purchase in `PENDING` status.
|
|
72
|
+
|
|
73
|
+
**Next steps.** Call `POST /purchases/:id/request-code` to retrieve login
|
|
74
|
+
credentials.
|
|
75
|
+
|
|
76
|
+
**Country availability.** Accounts may become unavailable between checking
|
|
77
|
+
`/accounts` and creating purchase. Always handle availability errors gracefully.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
country_code: ISO 3166-1 alpha-2 country code.
|
|
81
|
+
|
|
82
|
+
extra_headers: Send extra headers
|
|
83
|
+
|
|
84
|
+
extra_query: Add additional query parameters to the request
|
|
85
|
+
|
|
86
|
+
extra_body: Add additional JSON properties to the request
|
|
87
|
+
|
|
88
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
89
|
+
"""
|
|
90
|
+
return self._post(
|
|
91
|
+
"/v1/purchases/",
|
|
92
|
+
body=maybe_transform({"country_code": country_code}, purchase_create_params.PurchaseCreateParams),
|
|
93
|
+
options=make_request_options(
|
|
94
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
95
|
+
),
|
|
96
|
+
cast_to=PurchaseCreateResponse,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def retrieve(
|
|
100
|
+
self,
|
|
101
|
+
purchase_id: int,
|
|
102
|
+
*,
|
|
103
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
104
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
105
|
+
extra_headers: Headers | None = None,
|
|
106
|
+
extra_query: Query | None = None,
|
|
107
|
+
extra_body: Body | None = None,
|
|
108
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
109
|
+
) -> PurchaseRetrieveResponse:
|
|
110
|
+
"""
|
|
111
|
+
Returns detailed information about specific purchase including verification data
|
|
112
|
+
if available.
|
|
113
|
+
|
|
114
|
+
**Security.** Verification data is only visible to the purchase owner.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
purchase_id: Unique purchase identifier.
|
|
118
|
+
|
|
119
|
+
extra_headers: Send extra headers
|
|
120
|
+
|
|
121
|
+
extra_query: Add additional query parameters to the request
|
|
122
|
+
|
|
123
|
+
extra_body: Add additional JSON properties to the request
|
|
124
|
+
|
|
125
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
126
|
+
"""
|
|
127
|
+
return self._get(
|
|
128
|
+
f"/v1/purchases/{purchase_id}",
|
|
129
|
+
options=make_request_options(
|
|
130
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
131
|
+
),
|
|
132
|
+
cast_to=PurchaseRetrieveResponse,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def list(
|
|
136
|
+
self,
|
|
137
|
+
*,
|
|
138
|
+
page: int,
|
|
139
|
+
page_size: int,
|
|
140
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"] | Omit = omit,
|
|
141
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
142
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
143
|
+
extra_headers: Headers | None = None,
|
|
144
|
+
extra_query: Query | None = None,
|
|
145
|
+
extra_body: Body | None = None,
|
|
146
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
147
|
+
) -> SyncPageNumber[PurchaseListResponse]:
|
|
148
|
+
"""
|
|
149
|
+
Returns paginated list of user's purchases with optional status filtering.
|
|
150
|
+
|
|
151
|
+
**Chronological Ordering.** Purchases are always returned **newest first**
|
|
152
|
+
(descending by `created_at`).
|
|
153
|
+
|
|
154
|
+
**Pagination behavior**
|
|
155
|
+
|
|
156
|
+
- Results are consistent during session (no duplicates or missing items when
|
|
157
|
+
paginating).
|
|
158
|
+
- `has_next: true` indicates more pages available.
|
|
159
|
+
- Maximum `page_size` is 50 items.
|
|
160
|
+
|
|
161
|
+
**Filtering.** Combine `status` filter with pagination for subset queries (e.g.,
|
|
162
|
+
all successful purchases).
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
page: Page number (starts from 1).
|
|
166
|
+
|
|
167
|
+
page_size: Number of items per page (max 50).
|
|
168
|
+
|
|
169
|
+
status: **Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
170
|
+
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
171
|
+
via admin action.
|
|
172
|
+
|
|
173
|
+
**Important.** Status is immutable once set to `SUCCESS`, `ERROR`, or `REFUND`.
|
|
174
|
+
|
|
175
|
+
**Filter options**
|
|
176
|
+
|
|
177
|
+
- `PENDING` - code not requested.
|
|
178
|
+
- `SUCCESS` - code ready.
|
|
179
|
+
- `ERROR` - provider failed.
|
|
180
|
+
- `REFUND` - money returned.
|
|
181
|
+
|
|
182
|
+
extra_headers: Send extra headers
|
|
183
|
+
|
|
184
|
+
extra_query: Add additional query parameters to the request
|
|
185
|
+
|
|
186
|
+
extra_body: Add additional JSON properties to the request
|
|
187
|
+
|
|
188
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
189
|
+
"""
|
|
190
|
+
return self._get_api_list(
|
|
191
|
+
"/v1/purchases/",
|
|
192
|
+
page=SyncPageNumber[PurchaseListResponse],
|
|
193
|
+
options=make_request_options(
|
|
194
|
+
extra_headers=extra_headers,
|
|
195
|
+
extra_query=extra_query,
|
|
196
|
+
extra_body=extra_body,
|
|
197
|
+
timeout=timeout,
|
|
198
|
+
query=maybe_transform(
|
|
199
|
+
{
|
|
200
|
+
"page": page,
|
|
201
|
+
"page_size": page_size,
|
|
202
|
+
"status": status,
|
|
203
|
+
},
|
|
204
|
+
purchase_list_params.PurchaseListParams,
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
model=PurchaseListResponse,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
def request_verification_code(
|
|
211
|
+
self,
|
|
212
|
+
purchase_id: int,
|
|
213
|
+
*,
|
|
214
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
215
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
216
|
+
extra_headers: Headers | None = None,
|
|
217
|
+
extra_query: Query | None = None,
|
|
218
|
+
extra_body: Body | None = None,
|
|
219
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
220
|
+
) -> PurchaseRequestVerificationCodeResponse:
|
|
221
|
+
"""Requests verification code and password from provider.
|
|
222
|
+
|
|
223
|
+
Updates purchase status
|
|
224
|
+
to SUCCESS.
|
|
225
|
+
|
|
226
|
+
**Idempotent Operation.** Safe to retry on network errors - will not generate
|
|
227
|
+
duplicate codes.
|
|
228
|
+
|
|
229
|
+
**Behavior.**
|
|
230
|
+
|
|
231
|
+
- First call: Fetches code from provider, updates status to `SUCCESS`
|
|
232
|
+
- Subsequent calls: Returns conflict error (use `GET /purchases/:id` to retrieve
|
|
233
|
+
existing code)
|
|
234
|
+
|
|
235
|
+
**Provider timeout.** Code retrieval may take 5-30 seconds depending on provider
|
|
236
|
+
availability.
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
purchase_id: Unique purchase identifier.
|
|
240
|
+
|
|
241
|
+
extra_headers: Send extra headers
|
|
242
|
+
|
|
243
|
+
extra_query: Add additional query parameters to the request
|
|
244
|
+
|
|
245
|
+
extra_body: Add additional JSON properties to the request
|
|
246
|
+
|
|
247
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
248
|
+
"""
|
|
249
|
+
return self._post(
|
|
250
|
+
f"/v1/purchases/{purchase_id}/request-code",
|
|
251
|
+
options=make_request_options(
|
|
252
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
253
|
+
),
|
|
254
|
+
cast_to=PurchaseRequestVerificationCodeResponse,
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class AsyncPurchasesResource(AsyncAPIResource):
|
|
259
|
+
@cached_property
|
|
260
|
+
def with_raw_response(self) -> AsyncPurchasesResourceWithRawResponse:
|
|
261
|
+
"""
|
|
262
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
263
|
+
the raw response object instead of the parsed content.
|
|
264
|
+
|
|
265
|
+
For more information, see https://www.github.com/cameo6/gmt-python-sdk#accessing-raw-response-data-eg-headers
|
|
266
|
+
"""
|
|
267
|
+
return AsyncPurchasesResourceWithRawResponse(self)
|
|
268
|
+
|
|
269
|
+
@cached_property
|
|
270
|
+
def with_streaming_response(self) -> AsyncPurchasesResourceWithStreamingResponse:
|
|
271
|
+
"""
|
|
272
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
273
|
+
|
|
274
|
+
For more information, see https://www.github.com/cameo6/gmt-python-sdk#with_streaming_response
|
|
275
|
+
"""
|
|
276
|
+
return AsyncPurchasesResourceWithStreamingResponse(self)
|
|
277
|
+
|
|
278
|
+
async def create(
|
|
279
|
+
self,
|
|
280
|
+
*,
|
|
281
|
+
country_code: str,
|
|
282
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
283
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
284
|
+
extra_headers: Headers | None = None,
|
|
285
|
+
extra_query: Query | None = None,
|
|
286
|
+
extra_body: Body | None = None,
|
|
287
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
288
|
+
) -> PurchaseCreateResponse:
|
|
289
|
+
"""Creates a new purchase for specified country.
|
|
290
|
+
|
|
291
|
+
Deducts balance immediately and
|
|
292
|
+
returns purchase with `PENDING` status.
|
|
293
|
+
|
|
294
|
+
**Purchase Creation Process**
|
|
295
|
+
|
|
296
|
+
1. Validates country availability and user balance.
|
|
297
|
+
2. Reserves account from provider.
|
|
298
|
+
3. Atomically deducts balance and creates purchase record.
|
|
299
|
+
4. Returns purchase in `PENDING` status.
|
|
300
|
+
|
|
301
|
+
**Next steps.** Call `POST /purchases/:id/request-code` to retrieve login
|
|
302
|
+
credentials.
|
|
303
|
+
|
|
304
|
+
**Country availability.** Accounts may become unavailable between checking
|
|
305
|
+
`/accounts` and creating purchase. Always handle availability errors gracefully.
|
|
306
|
+
|
|
307
|
+
Args:
|
|
308
|
+
country_code: ISO 3166-1 alpha-2 country code.
|
|
309
|
+
|
|
310
|
+
extra_headers: Send extra headers
|
|
311
|
+
|
|
312
|
+
extra_query: Add additional query parameters to the request
|
|
313
|
+
|
|
314
|
+
extra_body: Add additional JSON properties to the request
|
|
315
|
+
|
|
316
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
317
|
+
"""
|
|
318
|
+
return await self._post(
|
|
319
|
+
"/v1/purchases/",
|
|
320
|
+
body=await async_maybe_transform(
|
|
321
|
+
{"country_code": country_code}, purchase_create_params.PurchaseCreateParams
|
|
322
|
+
),
|
|
323
|
+
options=make_request_options(
|
|
324
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
325
|
+
),
|
|
326
|
+
cast_to=PurchaseCreateResponse,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
async def retrieve(
|
|
330
|
+
self,
|
|
331
|
+
purchase_id: int,
|
|
332
|
+
*,
|
|
333
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
334
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
335
|
+
extra_headers: Headers | None = None,
|
|
336
|
+
extra_query: Query | None = None,
|
|
337
|
+
extra_body: Body | None = None,
|
|
338
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
339
|
+
) -> PurchaseRetrieveResponse:
|
|
340
|
+
"""
|
|
341
|
+
Returns detailed information about specific purchase including verification data
|
|
342
|
+
if available.
|
|
343
|
+
|
|
344
|
+
**Security.** Verification data is only visible to the purchase owner.
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
purchase_id: Unique purchase identifier.
|
|
348
|
+
|
|
349
|
+
extra_headers: Send extra headers
|
|
350
|
+
|
|
351
|
+
extra_query: Add additional query parameters to the request
|
|
352
|
+
|
|
353
|
+
extra_body: Add additional JSON properties to the request
|
|
354
|
+
|
|
355
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
356
|
+
"""
|
|
357
|
+
return await self._get(
|
|
358
|
+
f"/v1/purchases/{purchase_id}",
|
|
359
|
+
options=make_request_options(
|
|
360
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
361
|
+
),
|
|
362
|
+
cast_to=PurchaseRetrieveResponse,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
def list(
|
|
366
|
+
self,
|
|
367
|
+
*,
|
|
368
|
+
page: int,
|
|
369
|
+
page_size: int,
|
|
370
|
+
status: Literal["PENDING", "SUCCESS", "ERROR", "REFUND"] | Omit = omit,
|
|
371
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
372
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
373
|
+
extra_headers: Headers | None = None,
|
|
374
|
+
extra_query: Query | None = None,
|
|
375
|
+
extra_body: Body | None = None,
|
|
376
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
377
|
+
) -> AsyncPaginator[PurchaseListResponse, AsyncPageNumber[PurchaseListResponse]]:
|
|
378
|
+
"""
|
|
379
|
+
Returns paginated list of user's purchases with optional status filtering.
|
|
380
|
+
|
|
381
|
+
**Chronological Ordering.** Purchases are always returned **newest first**
|
|
382
|
+
(descending by `created_at`).
|
|
383
|
+
|
|
384
|
+
**Pagination behavior**
|
|
385
|
+
|
|
386
|
+
- Results are consistent during session (no duplicates or missing items when
|
|
387
|
+
paginating).
|
|
388
|
+
- `has_next: true` indicates more pages available.
|
|
389
|
+
- Maximum `page_size` is 50 items.
|
|
390
|
+
|
|
391
|
+
**Filtering.** Combine `status` filter with pagination for subset queries (e.g.,
|
|
392
|
+
all successful purchases).
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
page: Page number (starts from 1).
|
|
396
|
+
|
|
397
|
+
page_size: Number of items per page (max 50).
|
|
398
|
+
|
|
399
|
+
status: **Purchase Status Lifecycle.** `PENDING` (initial) → `SUCCESS` (after code
|
|
400
|
+
request) or `ERROR` (provider failure). Any status can transition to `REFUND`
|
|
401
|
+
via admin action.
|
|
402
|
+
|
|
403
|
+
**Important.** Status is immutable once set to `SUCCESS`, `ERROR`, or `REFUND`.
|
|
404
|
+
|
|
405
|
+
**Filter options**
|
|
406
|
+
|
|
407
|
+
- `PENDING` - code not requested.
|
|
408
|
+
- `SUCCESS` - code ready.
|
|
409
|
+
- `ERROR` - provider failed.
|
|
410
|
+
- `REFUND` - money returned.
|
|
411
|
+
|
|
412
|
+
extra_headers: Send extra headers
|
|
413
|
+
|
|
414
|
+
extra_query: Add additional query parameters to the request
|
|
415
|
+
|
|
416
|
+
extra_body: Add additional JSON properties to the request
|
|
417
|
+
|
|
418
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
419
|
+
"""
|
|
420
|
+
return self._get_api_list(
|
|
421
|
+
"/v1/purchases/",
|
|
422
|
+
page=AsyncPageNumber[PurchaseListResponse],
|
|
423
|
+
options=make_request_options(
|
|
424
|
+
extra_headers=extra_headers,
|
|
425
|
+
extra_query=extra_query,
|
|
426
|
+
extra_body=extra_body,
|
|
427
|
+
timeout=timeout,
|
|
428
|
+
query=maybe_transform(
|
|
429
|
+
{
|
|
430
|
+
"page": page,
|
|
431
|
+
"page_size": page_size,
|
|
432
|
+
"status": status,
|
|
433
|
+
},
|
|
434
|
+
purchase_list_params.PurchaseListParams,
|
|
435
|
+
),
|
|
436
|
+
),
|
|
437
|
+
model=PurchaseListResponse,
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
async def request_verification_code(
|
|
441
|
+
self,
|
|
442
|
+
purchase_id: int,
|
|
443
|
+
*,
|
|
444
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
445
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
446
|
+
extra_headers: Headers | None = None,
|
|
447
|
+
extra_query: Query | None = None,
|
|
448
|
+
extra_body: Body | None = None,
|
|
449
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
450
|
+
) -> PurchaseRequestVerificationCodeResponse:
|
|
451
|
+
"""Requests verification code and password from provider.
|
|
452
|
+
|
|
453
|
+
Updates purchase status
|
|
454
|
+
to SUCCESS.
|
|
455
|
+
|
|
456
|
+
**Idempotent Operation.** Safe to retry on network errors - will not generate
|
|
457
|
+
duplicate codes.
|
|
458
|
+
|
|
459
|
+
**Behavior.**
|
|
460
|
+
|
|
461
|
+
- First call: Fetches code from provider, updates status to `SUCCESS`
|
|
462
|
+
- Subsequent calls: Returns conflict error (use `GET /purchases/:id` to retrieve
|
|
463
|
+
existing code)
|
|
464
|
+
|
|
465
|
+
**Provider timeout.** Code retrieval may take 5-30 seconds depending on provider
|
|
466
|
+
availability.
|
|
467
|
+
|
|
468
|
+
Args:
|
|
469
|
+
purchase_id: Unique purchase identifier.
|
|
470
|
+
|
|
471
|
+
extra_headers: Send extra headers
|
|
472
|
+
|
|
473
|
+
extra_query: Add additional query parameters to the request
|
|
474
|
+
|
|
475
|
+
extra_body: Add additional JSON properties to the request
|
|
476
|
+
|
|
477
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
478
|
+
"""
|
|
479
|
+
return await self._post(
|
|
480
|
+
f"/v1/purchases/{purchase_id}/request-code",
|
|
481
|
+
options=make_request_options(
|
|
482
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
483
|
+
),
|
|
484
|
+
cast_to=PurchaseRequestVerificationCodeResponse,
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
class PurchasesResourceWithRawResponse:
|
|
489
|
+
def __init__(self, purchases: PurchasesResource) -> None:
|
|
490
|
+
self._purchases = purchases
|
|
491
|
+
|
|
492
|
+
self.create = to_raw_response_wrapper(
|
|
493
|
+
purchases.create,
|
|
494
|
+
)
|
|
495
|
+
self.retrieve = to_raw_response_wrapper(
|
|
496
|
+
purchases.retrieve,
|
|
497
|
+
)
|
|
498
|
+
self.list = to_raw_response_wrapper(
|
|
499
|
+
purchases.list,
|
|
500
|
+
)
|
|
501
|
+
self.request_verification_code = to_raw_response_wrapper(
|
|
502
|
+
purchases.request_verification_code,
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
class AsyncPurchasesResourceWithRawResponse:
|
|
507
|
+
def __init__(self, purchases: AsyncPurchasesResource) -> None:
|
|
508
|
+
self._purchases = purchases
|
|
509
|
+
|
|
510
|
+
self.create = async_to_raw_response_wrapper(
|
|
511
|
+
purchases.create,
|
|
512
|
+
)
|
|
513
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
514
|
+
purchases.retrieve,
|
|
515
|
+
)
|
|
516
|
+
self.list = async_to_raw_response_wrapper(
|
|
517
|
+
purchases.list,
|
|
518
|
+
)
|
|
519
|
+
self.request_verification_code = async_to_raw_response_wrapper(
|
|
520
|
+
purchases.request_verification_code,
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
class PurchasesResourceWithStreamingResponse:
|
|
525
|
+
def __init__(self, purchases: PurchasesResource) -> None:
|
|
526
|
+
self._purchases = purchases
|
|
527
|
+
|
|
528
|
+
self.create = to_streamed_response_wrapper(
|
|
529
|
+
purchases.create,
|
|
530
|
+
)
|
|
531
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
532
|
+
purchases.retrieve,
|
|
533
|
+
)
|
|
534
|
+
self.list = to_streamed_response_wrapper(
|
|
535
|
+
purchases.list,
|
|
536
|
+
)
|
|
537
|
+
self.request_verification_code = to_streamed_response_wrapper(
|
|
538
|
+
purchases.request_verification_code,
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
class AsyncPurchasesResourceWithStreamingResponse:
|
|
543
|
+
def __init__(self, purchases: AsyncPurchasesResource) -> None:
|
|
544
|
+
self._purchases = purchases
|
|
545
|
+
|
|
546
|
+
self.create = async_to_streamed_response_wrapper(
|
|
547
|
+
purchases.create,
|
|
548
|
+
)
|
|
549
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
550
|
+
purchases.retrieve,
|
|
551
|
+
)
|
|
552
|
+
self.list = async_to_streamed_response_wrapper(
|
|
553
|
+
purchases.list,
|
|
554
|
+
)
|
|
555
|
+
self.request_verification_code = async_to_streamed_response_wrapper(
|
|
556
|
+
purchases.request_verification_code,
|
|
557
|
+
)
|