vatly-api-python 0.1.0a2__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.
vatly/resources.py ADDED
@@ -0,0 +1,2003 @@
1
+ """Generated resource interfaces. Run uv run python scripts/generate.py."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import AsyncIterator, Iterator
6
+ from typing import Any
7
+ from urllib.parse import quote
8
+
9
+ from . import models
10
+ from ._transport import AsyncTransport, RequestOptions, SyncTransport
11
+ from .pagination import Page, next_params
12
+
13
+
14
+ class Checkouts:
15
+ def __init__(self, transport: SyncTransport) -> None:
16
+ self._transport = transport
17
+
18
+ def list(
19
+ self,
20
+ params: models.ListCheckoutsParams | dict[str, Any] | None = None,
21
+ *,
22
+ options: RequestOptions | None = None,
23
+ ) -> Page[models.Checkout]:
24
+ """List all checkouts."""
25
+ return self._transport.request(
26
+ "GET", "/checkouts", Page[models.Checkout], body=None, params=params, options=options
27
+ )
28
+
29
+ def list_all(
30
+ self,
31
+ params: models.ListCheckoutsParams | dict[str, Any] | None = None,
32
+ *,
33
+ options: RequestOptions | None = None,
34
+ ) -> Iterator[models.Checkout]:
35
+ query = self._transport.serialize(params) or {}
36
+ seen: set[str] = set()
37
+ if query.get("startingAfter"):
38
+ seen.add(str(query["startingAfter"]))
39
+ while True:
40
+ page = self.list(query, options=options)
41
+ yield from page.data
42
+ following = next_params(page, query, seen)
43
+ if following is None:
44
+ return
45
+ query = following
46
+
47
+ def create(
48
+ self,
49
+ body: models.CreateCheckoutRequest | dict[str, Any],
50
+ *,
51
+ options: RequestOptions | None = None,
52
+ ) -> models.Checkout:
53
+ """Create a checkout."""
54
+ return self._transport.request(
55
+ "POST", "/checkouts", models.Checkout, body=body, params=None, options=options
56
+ )
57
+
58
+ def get(self, checkout_id: str, *, options: RequestOptions | None = None) -> models.Checkout:
59
+ """Get a checkout."""
60
+ return self._transport.request(
61
+ "GET",
62
+ f"/checkouts/{quote(checkout_id, safe='')}",
63
+ models.Checkout,
64
+ body=None,
65
+ params=None,
66
+ options=options,
67
+ )
68
+
69
+
70
+ class AsyncCheckouts:
71
+ def __init__(self, transport: AsyncTransport) -> None:
72
+ self._transport = transport
73
+
74
+ async def list(
75
+ self,
76
+ params: models.ListCheckoutsParams | dict[str, Any] | None = None,
77
+ *,
78
+ options: RequestOptions | None = None,
79
+ ) -> Page[models.Checkout]:
80
+ """List all checkouts."""
81
+ return await self._transport.request(
82
+ "GET", "/checkouts", Page[models.Checkout], body=None, params=params, options=options
83
+ )
84
+
85
+ async def list_all(
86
+ self,
87
+ params: models.ListCheckoutsParams | dict[str, Any] | None = None,
88
+ *,
89
+ options: RequestOptions | None = None,
90
+ ) -> AsyncIterator[models.Checkout]:
91
+ query = self._transport.serialize(params) or {}
92
+ seen: set[str] = set()
93
+ if query.get("startingAfter"):
94
+ seen.add(str(query["startingAfter"]))
95
+ while True:
96
+ page = await self.list(query, options=options)
97
+ for item in page.data:
98
+ yield item
99
+ following = next_params(page, query, seen)
100
+ if following is None:
101
+ return
102
+ query = following
103
+
104
+ async def create(
105
+ self,
106
+ body: models.CreateCheckoutRequest | dict[str, Any],
107
+ *,
108
+ options: RequestOptions | None = None,
109
+ ) -> models.Checkout:
110
+ """Create a checkout."""
111
+ return await self._transport.request(
112
+ "POST", "/checkouts", models.Checkout, body=body, params=None, options=options
113
+ )
114
+
115
+ async def get(
116
+ self, checkout_id: str, *, options: RequestOptions | None = None
117
+ ) -> models.Checkout:
118
+ """Get a checkout."""
119
+ return await self._transport.request(
120
+ "GET",
121
+ f"/checkouts/{quote(checkout_id, safe='')}",
122
+ models.Checkout,
123
+ body=None,
124
+ params=None,
125
+ options=options,
126
+ )
127
+
128
+
129
+ class Customers:
130
+ def __init__(self, transport: SyncTransport) -> None:
131
+ self._transport = transport
132
+
133
+ def list(
134
+ self,
135
+ params: models.ListCustomersParams | dict[str, Any] | None = None,
136
+ *,
137
+ options: RequestOptions | None = None,
138
+ ) -> Page[models.Customer]:
139
+ """List all customers."""
140
+ return self._transport.request(
141
+ "GET", "/customers", Page[models.Customer], body=None, params=params, options=options
142
+ )
143
+
144
+ def list_all(
145
+ self,
146
+ params: models.ListCustomersParams | dict[str, Any] | None = None,
147
+ *,
148
+ options: RequestOptions | None = None,
149
+ ) -> Iterator[models.Customer]:
150
+ query = self._transport.serialize(params) or {}
151
+ seen: set[str] = set()
152
+ if query.get("startingAfter"):
153
+ seen.add(str(query["startingAfter"]))
154
+ while True:
155
+ page = self.list(query, options=options)
156
+ yield from page.data
157
+ following = next_params(page, query, seen)
158
+ if following is None:
159
+ return
160
+ query = following
161
+
162
+ def create(
163
+ self,
164
+ body: models.CreateCustomerRequest | dict[str, Any],
165
+ *,
166
+ options: RequestOptions | None = None,
167
+ ) -> models.Customer:
168
+ """Create a customer."""
169
+ return self._transport.request(
170
+ "POST", "/customers", models.Customer, body=body, params=None, options=options
171
+ )
172
+
173
+ def get(self, customer_id: str, *, options: RequestOptions | None = None) -> models.Customer:
174
+ """Get a customer."""
175
+ return self._transport.request(
176
+ "GET",
177
+ f"/customers/{quote(customer_id, safe='')}",
178
+ models.Customer,
179
+ body=None,
180
+ params=None,
181
+ options=options,
182
+ )
183
+
184
+ def update(
185
+ self,
186
+ customer_id: str,
187
+ body: models.UpdateCustomerRequest | dict[str, Any],
188
+ *,
189
+ options: RequestOptions | None = None,
190
+ ) -> models.Customer:
191
+ """Update a customer."""
192
+ return self._transport.request(
193
+ "PATCH",
194
+ f"/customers/{quote(customer_id, safe='')}",
195
+ models.Customer,
196
+ body=body,
197
+ params=None,
198
+ options=options,
199
+ )
200
+
201
+ def create_portal_session(
202
+ self,
203
+ customer_id: str,
204
+ body: models.CreatePortalSessionRequest | dict[str, Any],
205
+ *,
206
+ options: RequestOptions | None = None,
207
+ ) -> models.PortalSession:
208
+ """Create a hosted customer portal session."""
209
+ return self._transport.request(
210
+ "POST",
211
+ f"/customers/{quote(customer_id, safe='')}/portal-sessions",
212
+ models.PortalSession,
213
+ body=body,
214
+ params=None,
215
+ options=options,
216
+ )
217
+
218
+ def list_subscriptions(
219
+ self,
220
+ customer_id: str,
221
+ params: models.ListCustomerSubscriptionsParams | dict[str, Any] | None = None,
222
+ *,
223
+ options: RequestOptions | None = None,
224
+ ) -> Page[models.Subscription]:
225
+ """List customer subscriptions."""
226
+ return self._transport.request(
227
+ "GET",
228
+ f"/customers/{quote(customer_id, safe='')}/subscriptions",
229
+ Page[models.Subscription],
230
+ body=None,
231
+ params=params,
232
+ options=options,
233
+ )
234
+
235
+ def list_all_subscriptions(
236
+ self,
237
+ customer_id: str,
238
+ params: models.ListCustomerSubscriptionsParams | dict[str, Any] | None = None,
239
+ *,
240
+ options: RequestOptions | None = None,
241
+ ) -> Iterator[models.Subscription]:
242
+ query = self._transport.serialize(params) or {}
243
+ seen: set[str] = set()
244
+ if query.get("startingAfter"):
245
+ seen.add(str(query["startingAfter"]))
246
+ while True:
247
+ page = self.list_subscriptions(customer_id, query, options=options)
248
+ yield from page.data
249
+ following = next_params(page, query, seen)
250
+ if following is None:
251
+ return
252
+ query = following
253
+
254
+ def get_subscription(
255
+ self, customer_id: str, subscription_id: str, *, options: RequestOptions | None = None
256
+ ) -> models.Subscription:
257
+ """Get a customer subscription."""
258
+ return self._transport.request(
259
+ "GET",
260
+ f"/customers/{quote(customer_id, safe='')}/subscriptions/{quote(subscription_id, safe='')}",
261
+ models.Subscription,
262
+ body=None,
263
+ params=None,
264
+ options=options,
265
+ )
266
+
267
+
268
+ class AsyncCustomers:
269
+ def __init__(self, transport: AsyncTransport) -> None:
270
+ self._transport = transport
271
+
272
+ async def list(
273
+ self,
274
+ params: models.ListCustomersParams | dict[str, Any] | None = None,
275
+ *,
276
+ options: RequestOptions | None = None,
277
+ ) -> Page[models.Customer]:
278
+ """List all customers."""
279
+ return await self._transport.request(
280
+ "GET", "/customers", Page[models.Customer], body=None, params=params, options=options
281
+ )
282
+
283
+ async def list_all(
284
+ self,
285
+ params: models.ListCustomersParams | dict[str, Any] | None = None,
286
+ *,
287
+ options: RequestOptions | None = None,
288
+ ) -> AsyncIterator[models.Customer]:
289
+ query = self._transport.serialize(params) or {}
290
+ seen: set[str] = set()
291
+ if query.get("startingAfter"):
292
+ seen.add(str(query["startingAfter"]))
293
+ while True:
294
+ page = await self.list(query, options=options)
295
+ for item in page.data:
296
+ yield item
297
+ following = next_params(page, query, seen)
298
+ if following is None:
299
+ return
300
+ query = following
301
+
302
+ async def create(
303
+ self,
304
+ body: models.CreateCustomerRequest | dict[str, Any],
305
+ *,
306
+ options: RequestOptions | None = None,
307
+ ) -> models.Customer:
308
+ """Create a customer."""
309
+ return await self._transport.request(
310
+ "POST", "/customers", models.Customer, body=body, params=None, options=options
311
+ )
312
+
313
+ async def get(
314
+ self, customer_id: str, *, options: RequestOptions | None = None
315
+ ) -> models.Customer:
316
+ """Get a customer."""
317
+ return await self._transport.request(
318
+ "GET",
319
+ f"/customers/{quote(customer_id, safe='')}",
320
+ models.Customer,
321
+ body=None,
322
+ params=None,
323
+ options=options,
324
+ )
325
+
326
+ async def update(
327
+ self,
328
+ customer_id: str,
329
+ body: models.UpdateCustomerRequest | dict[str, Any],
330
+ *,
331
+ options: RequestOptions | None = None,
332
+ ) -> models.Customer:
333
+ """Update a customer."""
334
+ return await self._transport.request(
335
+ "PATCH",
336
+ f"/customers/{quote(customer_id, safe='')}",
337
+ models.Customer,
338
+ body=body,
339
+ params=None,
340
+ options=options,
341
+ )
342
+
343
+ async def create_portal_session(
344
+ self,
345
+ customer_id: str,
346
+ body: models.CreatePortalSessionRequest | dict[str, Any],
347
+ *,
348
+ options: RequestOptions | None = None,
349
+ ) -> models.PortalSession:
350
+ """Create a hosted customer portal session."""
351
+ return await self._transport.request(
352
+ "POST",
353
+ f"/customers/{quote(customer_id, safe='')}/portal-sessions",
354
+ models.PortalSession,
355
+ body=body,
356
+ params=None,
357
+ options=options,
358
+ )
359
+
360
+ async def list_subscriptions(
361
+ self,
362
+ customer_id: str,
363
+ params: models.ListCustomerSubscriptionsParams | dict[str, Any] | None = None,
364
+ *,
365
+ options: RequestOptions | None = None,
366
+ ) -> Page[models.Subscription]:
367
+ """List customer subscriptions."""
368
+ return await self._transport.request(
369
+ "GET",
370
+ f"/customers/{quote(customer_id, safe='')}/subscriptions",
371
+ Page[models.Subscription],
372
+ body=None,
373
+ params=params,
374
+ options=options,
375
+ )
376
+
377
+ async def list_all_subscriptions(
378
+ self,
379
+ customer_id: str,
380
+ params: models.ListCustomerSubscriptionsParams | dict[str, Any] | None = None,
381
+ *,
382
+ options: RequestOptions | None = None,
383
+ ) -> AsyncIterator[models.Subscription]:
384
+ query = self._transport.serialize(params) or {}
385
+ seen: set[str] = set()
386
+ if query.get("startingAfter"):
387
+ seen.add(str(query["startingAfter"]))
388
+ while True:
389
+ page = await self.list_subscriptions(customer_id, query, options=options)
390
+ for item in page.data:
391
+ yield item
392
+ following = next_params(page, query, seen)
393
+ if following is None:
394
+ return
395
+ query = following
396
+
397
+ async def get_subscription(
398
+ self, customer_id: str, subscription_id: str, *, options: RequestOptions | None = None
399
+ ) -> models.Subscription:
400
+ """Get a customer subscription."""
401
+ return await self._transport.request(
402
+ "GET",
403
+ f"/customers/{quote(customer_id, safe='')}/subscriptions/{quote(subscription_id, safe='')}",
404
+ models.Subscription,
405
+ body=None,
406
+ params=None,
407
+ options=options,
408
+ )
409
+
410
+
411
+ class OneOffProducts:
412
+ def __init__(self, transport: SyncTransport) -> None:
413
+ self._transport = transport
414
+
415
+ def list(
416
+ self,
417
+ params: models.ListOneOffProductsParams | dict[str, Any] | None = None,
418
+ *,
419
+ options: RequestOptions | None = None,
420
+ ) -> Page[models.OneOffProduct]:
421
+ """List all one-off products."""
422
+ return self._transport.request(
423
+ "GET",
424
+ "/one-off-products",
425
+ Page[models.OneOffProduct],
426
+ body=None,
427
+ params=params,
428
+ options=options,
429
+ )
430
+
431
+ def list_all(
432
+ self,
433
+ params: models.ListOneOffProductsParams | dict[str, Any] | None = None,
434
+ *,
435
+ options: RequestOptions | None = None,
436
+ ) -> Iterator[models.OneOffProduct]:
437
+ query = self._transport.serialize(params) or {}
438
+ seen: set[str] = set()
439
+ if query.get("startingAfter"):
440
+ seen.add(str(query["startingAfter"]))
441
+ while True:
442
+ page = self.list(query, options=options)
443
+ yield from page.data
444
+ following = next_params(page, query, seen)
445
+ if following is None:
446
+ return
447
+ query = following
448
+
449
+ def create(
450
+ self,
451
+ body: models.CreateOneOffProductRequest | dict[str, Any],
452
+ *,
453
+ options: RequestOptions | None = None,
454
+ ) -> models.OneOffProduct:
455
+ """Create a one-off product."""
456
+ return self._transport.request(
457
+ "POST",
458
+ "/one-off-products",
459
+ models.OneOffProduct,
460
+ body=body,
461
+ params=None,
462
+ options=options,
463
+ )
464
+
465
+ def get(
466
+ self, one_off_product_id: str, *, options: RequestOptions | None = None
467
+ ) -> models.OneOffProduct:
468
+ """Get a one-off product."""
469
+ return self._transport.request(
470
+ "GET",
471
+ f"/one-off-products/{quote(one_off_product_id, safe='')}",
472
+ models.OneOffProduct,
473
+ body=None,
474
+ params=None,
475
+ options=options,
476
+ )
477
+
478
+ def update(
479
+ self,
480
+ one_off_product_id: str,
481
+ body: models.UpdateOneOffProductRequest | dict[str, Any],
482
+ *,
483
+ options: RequestOptions | None = None,
484
+ ) -> models.OneOffProduct:
485
+ """Request an update to a one-off product."""
486
+ return self._transport.request(
487
+ "PATCH",
488
+ f"/one-off-products/{quote(one_off_product_id, safe='')}",
489
+ models.OneOffProduct,
490
+ body=body,
491
+ params=None,
492
+ options=options,
493
+ )
494
+
495
+ def archive(self, one_off_product_id: str, *, options: RequestOptions | None = None) -> None:
496
+ """Archive a one-off product."""
497
+ return self._transport.request(
498
+ "POST",
499
+ f"/one-off-products/{quote(one_off_product_id, safe='')}/archive",
500
+ type(None),
501
+ body=None,
502
+ params=None,
503
+ options=options,
504
+ )
505
+
506
+ def unarchive(
507
+ self, one_off_product_id: str, *, options: RequestOptions | None = None
508
+ ) -> models.OneOffProduct:
509
+ """Unarchive a one-off product."""
510
+ return self._transport.request(
511
+ "DELETE",
512
+ f"/one-off-products/{quote(one_off_product_id, safe='')}/archive",
513
+ models.OneOffProduct,
514
+ body=None,
515
+ params=None,
516
+ options=options,
517
+ )
518
+
519
+
520
+ class AsyncOneOffProducts:
521
+ def __init__(self, transport: AsyncTransport) -> None:
522
+ self._transport = transport
523
+
524
+ async def list(
525
+ self,
526
+ params: models.ListOneOffProductsParams | dict[str, Any] | None = None,
527
+ *,
528
+ options: RequestOptions | None = None,
529
+ ) -> Page[models.OneOffProduct]:
530
+ """List all one-off products."""
531
+ return await self._transport.request(
532
+ "GET",
533
+ "/one-off-products",
534
+ Page[models.OneOffProduct],
535
+ body=None,
536
+ params=params,
537
+ options=options,
538
+ )
539
+
540
+ async def list_all(
541
+ self,
542
+ params: models.ListOneOffProductsParams | dict[str, Any] | None = None,
543
+ *,
544
+ options: RequestOptions | None = None,
545
+ ) -> AsyncIterator[models.OneOffProduct]:
546
+ query = self._transport.serialize(params) or {}
547
+ seen: set[str] = set()
548
+ if query.get("startingAfter"):
549
+ seen.add(str(query["startingAfter"]))
550
+ while True:
551
+ page = await self.list(query, options=options)
552
+ for item in page.data:
553
+ yield item
554
+ following = next_params(page, query, seen)
555
+ if following is None:
556
+ return
557
+ query = following
558
+
559
+ async def create(
560
+ self,
561
+ body: models.CreateOneOffProductRequest | dict[str, Any],
562
+ *,
563
+ options: RequestOptions | None = None,
564
+ ) -> models.OneOffProduct:
565
+ """Create a one-off product."""
566
+ return await self._transport.request(
567
+ "POST",
568
+ "/one-off-products",
569
+ models.OneOffProduct,
570
+ body=body,
571
+ params=None,
572
+ options=options,
573
+ )
574
+
575
+ async def get(
576
+ self, one_off_product_id: str, *, options: RequestOptions | None = None
577
+ ) -> models.OneOffProduct:
578
+ """Get a one-off product."""
579
+ return await self._transport.request(
580
+ "GET",
581
+ f"/one-off-products/{quote(one_off_product_id, safe='')}",
582
+ models.OneOffProduct,
583
+ body=None,
584
+ params=None,
585
+ options=options,
586
+ )
587
+
588
+ async def update(
589
+ self,
590
+ one_off_product_id: str,
591
+ body: models.UpdateOneOffProductRequest | dict[str, Any],
592
+ *,
593
+ options: RequestOptions | None = None,
594
+ ) -> models.OneOffProduct:
595
+ """Request an update to a one-off product."""
596
+ return await self._transport.request(
597
+ "PATCH",
598
+ f"/one-off-products/{quote(one_off_product_id, safe='')}",
599
+ models.OneOffProduct,
600
+ body=body,
601
+ params=None,
602
+ options=options,
603
+ )
604
+
605
+ async def archive(
606
+ self, one_off_product_id: str, *, options: RequestOptions | None = None
607
+ ) -> None:
608
+ """Archive a one-off product."""
609
+ return await self._transport.request(
610
+ "POST",
611
+ f"/one-off-products/{quote(one_off_product_id, safe='')}/archive",
612
+ type(None),
613
+ body=None,
614
+ params=None,
615
+ options=options,
616
+ )
617
+
618
+ async def unarchive(
619
+ self, one_off_product_id: str, *, options: RequestOptions | None = None
620
+ ) -> models.OneOffProduct:
621
+ """Unarchive a one-off product."""
622
+ return await self._transport.request(
623
+ "DELETE",
624
+ f"/one-off-products/{quote(one_off_product_id, safe='')}/archive",
625
+ models.OneOffProduct,
626
+ body=None,
627
+ params=None,
628
+ options=options,
629
+ )
630
+
631
+
632
+ class SubscriptionPlans:
633
+ def __init__(self, transport: SyncTransport) -> None:
634
+ self._transport = transport
635
+
636
+ def list(
637
+ self,
638
+ params: models.ListSubscriptionPlansParams | dict[str, Any] | None = None,
639
+ *,
640
+ options: RequestOptions | None = None,
641
+ ) -> Page[models.SubscriptionPlan]:
642
+ """List all subscription plans."""
643
+ return self._transport.request(
644
+ "GET",
645
+ "/subscription-plans",
646
+ Page[models.SubscriptionPlan],
647
+ body=None,
648
+ params=params,
649
+ options=options,
650
+ )
651
+
652
+ def list_all(
653
+ self,
654
+ params: models.ListSubscriptionPlansParams | dict[str, Any] | None = None,
655
+ *,
656
+ options: RequestOptions | None = None,
657
+ ) -> Iterator[models.SubscriptionPlan]:
658
+ query = self._transport.serialize(params) or {}
659
+ seen: set[str] = set()
660
+ if query.get("startingAfter"):
661
+ seen.add(str(query["startingAfter"]))
662
+ while True:
663
+ page = self.list(query, options=options)
664
+ yield from page.data
665
+ following = next_params(page, query, seen)
666
+ if following is None:
667
+ return
668
+ query = following
669
+
670
+ def create(
671
+ self,
672
+ body: models.CreateSubscriptionPlanRequest | dict[str, Any],
673
+ *,
674
+ options: RequestOptions | None = None,
675
+ ) -> models.SubscriptionPlan:
676
+ """Create a subscription plan."""
677
+ return self._transport.request(
678
+ "POST",
679
+ "/subscription-plans",
680
+ models.SubscriptionPlan,
681
+ body=body,
682
+ params=None,
683
+ options=options,
684
+ )
685
+
686
+ def get(
687
+ self, subscription_plan_id: str, *, options: RequestOptions | None = None
688
+ ) -> models.SubscriptionPlan:
689
+ """Get a subscription plan."""
690
+ return self._transport.request(
691
+ "GET",
692
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}",
693
+ models.SubscriptionPlan,
694
+ body=None,
695
+ params=None,
696
+ options=options,
697
+ )
698
+
699
+ def update(
700
+ self,
701
+ subscription_plan_id: str,
702
+ body: models.UpdateSubscriptionPlanRequest | dict[str, Any],
703
+ *,
704
+ options: RequestOptions | None = None,
705
+ ) -> models.SubscriptionPlan:
706
+ """Request an update to a subscription plan."""
707
+ return self._transport.request(
708
+ "PATCH",
709
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}",
710
+ models.SubscriptionPlan,
711
+ body=body,
712
+ params=None,
713
+ options=options,
714
+ )
715
+
716
+ def archive(self, subscription_plan_id: str, *, options: RequestOptions | None = None) -> None:
717
+ """Archive a subscription plan."""
718
+ return self._transport.request(
719
+ "POST",
720
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}/archive",
721
+ type(None),
722
+ body=None,
723
+ params=None,
724
+ options=options,
725
+ )
726
+
727
+ def unarchive(
728
+ self, subscription_plan_id: str, *, options: RequestOptions | None = None
729
+ ) -> models.SubscriptionPlan:
730
+ """Unarchive a subscription plan."""
731
+ return self._transport.request(
732
+ "DELETE",
733
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}/archive",
734
+ models.SubscriptionPlan,
735
+ body=None,
736
+ params=None,
737
+ options=options,
738
+ )
739
+
740
+
741
+ class AsyncSubscriptionPlans:
742
+ def __init__(self, transport: AsyncTransport) -> None:
743
+ self._transport = transport
744
+
745
+ async def list(
746
+ self,
747
+ params: models.ListSubscriptionPlansParams | dict[str, Any] | None = None,
748
+ *,
749
+ options: RequestOptions | None = None,
750
+ ) -> Page[models.SubscriptionPlan]:
751
+ """List all subscription plans."""
752
+ return await self._transport.request(
753
+ "GET",
754
+ "/subscription-plans",
755
+ Page[models.SubscriptionPlan],
756
+ body=None,
757
+ params=params,
758
+ options=options,
759
+ )
760
+
761
+ async def list_all(
762
+ self,
763
+ params: models.ListSubscriptionPlansParams | dict[str, Any] | None = None,
764
+ *,
765
+ options: RequestOptions | None = None,
766
+ ) -> AsyncIterator[models.SubscriptionPlan]:
767
+ query = self._transport.serialize(params) or {}
768
+ seen: set[str] = set()
769
+ if query.get("startingAfter"):
770
+ seen.add(str(query["startingAfter"]))
771
+ while True:
772
+ page = await self.list(query, options=options)
773
+ for item in page.data:
774
+ yield item
775
+ following = next_params(page, query, seen)
776
+ if following is None:
777
+ return
778
+ query = following
779
+
780
+ async def create(
781
+ self,
782
+ body: models.CreateSubscriptionPlanRequest | dict[str, Any],
783
+ *,
784
+ options: RequestOptions | None = None,
785
+ ) -> models.SubscriptionPlan:
786
+ """Create a subscription plan."""
787
+ return await self._transport.request(
788
+ "POST",
789
+ "/subscription-plans",
790
+ models.SubscriptionPlan,
791
+ body=body,
792
+ params=None,
793
+ options=options,
794
+ )
795
+
796
+ async def get(
797
+ self, subscription_plan_id: str, *, options: RequestOptions | None = None
798
+ ) -> models.SubscriptionPlan:
799
+ """Get a subscription plan."""
800
+ return await self._transport.request(
801
+ "GET",
802
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}",
803
+ models.SubscriptionPlan,
804
+ body=None,
805
+ params=None,
806
+ options=options,
807
+ )
808
+
809
+ async def update(
810
+ self,
811
+ subscription_plan_id: str,
812
+ body: models.UpdateSubscriptionPlanRequest | dict[str, Any],
813
+ *,
814
+ options: RequestOptions | None = None,
815
+ ) -> models.SubscriptionPlan:
816
+ """Request an update to a subscription plan."""
817
+ return await self._transport.request(
818
+ "PATCH",
819
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}",
820
+ models.SubscriptionPlan,
821
+ body=body,
822
+ params=None,
823
+ options=options,
824
+ )
825
+
826
+ async def archive(
827
+ self, subscription_plan_id: str, *, options: RequestOptions | None = None
828
+ ) -> None:
829
+ """Archive a subscription plan."""
830
+ return await self._transport.request(
831
+ "POST",
832
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}/archive",
833
+ type(None),
834
+ body=None,
835
+ params=None,
836
+ options=options,
837
+ )
838
+
839
+ async def unarchive(
840
+ self, subscription_plan_id: str, *, options: RequestOptions | None = None
841
+ ) -> models.SubscriptionPlan:
842
+ """Unarchive a subscription plan."""
843
+ return await self._transport.request(
844
+ "DELETE",
845
+ f"/subscription-plans/{quote(subscription_plan_id, safe='')}/archive",
846
+ models.SubscriptionPlan,
847
+ body=None,
848
+ params=None,
849
+ options=options,
850
+ )
851
+
852
+
853
+ class Orders:
854
+ def __init__(self, transport: SyncTransport) -> None:
855
+ self._transport = transport
856
+
857
+ def list(
858
+ self,
859
+ params: models.ListOrdersParams | dict[str, Any] | None = None,
860
+ *,
861
+ options: RequestOptions | None = None,
862
+ ) -> Page[models.Order]:
863
+ """List all orders."""
864
+ return self._transport.request(
865
+ "GET", "/orders", Page[models.Order], body=None, params=params, options=options
866
+ )
867
+
868
+ def list_all(
869
+ self,
870
+ params: models.ListOrdersParams | dict[str, Any] | None = None,
871
+ *,
872
+ options: RequestOptions | None = None,
873
+ ) -> Iterator[models.Order]:
874
+ query = self._transport.serialize(params) or {}
875
+ seen: set[str] = set()
876
+ if query.get("startingAfter"):
877
+ seen.add(str(query["startingAfter"]))
878
+ while True:
879
+ page = self.list(query, options=options)
880
+ yield from page.data
881
+ following = next_params(page, query, seen)
882
+ if following is None:
883
+ return
884
+ query = following
885
+
886
+ def get(self, order_id: str, *, options: RequestOptions | None = None) -> models.Order:
887
+ """Get an order."""
888
+ return self._transport.request(
889
+ "GET",
890
+ f"/orders/{quote(order_id, safe='')}",
891
+ models.Order,
892
+ body=None,
893
+ params=None,
894
+ options=options,
895
+ )
896
+
897
+ def create_invoice_update_link(
898
+ self, order_id: str, *, options: RequestOptions | None = None
899
+ ) -> models.InvoiceUpdateLink:
900
+ """Create invoice update link."""
901
+ return self._transport.request(
902
+ "POST",
903
+ f"/orders/{quote(order_id, safe='')}/invoice-update-link",
904
+ models.InvoiceUpdateLink,
905
+ body=None,
906
+ params=None,
907
+ options=options,
908
+ )
909
+
910
+ def list_refunds(
911
+ self,
912
+ order_id: str,
913
+ params: models.ListOrderRefundsParams | dict[str, Any] | None = None,
914
+ *,
915
+ options: RequestOptions | None = None,
916
+ ) -> Page[models.Refund]:
917
+ """List order refunds."""
918
+ return self._transport.request(
919
+ "GET",
920
+ f"/orders/{quote(order_id, safe='')}/refunds",
921
+ Page[models.Refund],
922
+ body=None,
923
+ params=params,
924
+ options=options,
925
+ )
926
+
927
+ def list_all_refunds(
928
+ self,
929
+ order_id: str,
930
+ params: models.ListOrderRefundsParams | dict[str, Any] | None = None,
931
+ *,
932
+ options: RequestOptions | None = None,
933
+ ) -> Iterator[models.Refund]:
934
+ query = self._transport.serialize(params) or {}
935
+ seen: set[str] = set()
936
+ if query.get("startingAfter"):
937
+ seen.add(str(query["startingAfter"]))
938
+ while True:
939
+ page = self.list_refunds(order_id, query, options=options)
940
+ yield from page.data
941
+ following = next_params(page, query, seen)
942
+ if following is None:
943
+ return
944
+ query = following
945
+
946
+ def create_refund(
947
+ self,
948
+ order_id: str,
949
+ body: models.CreateRefundRequest | dict[str, Any],
950
+ *,
951
+ options: RequestOptions | None = None,
952
+ ) -> models.Refund:
953
+ """Create a partial refund."""
954
+ return self._transport.request(
955
+ "POST",
956
+ f"/orders/{quote(order_id, safe='')}/refunds",
957
+ models.Refund,
958
+ body=body,
959
+ params=None,
960
+ options=options,
961
+ )
962
+
963
+ def create_full_refund(
964
+ self,
965
+ order_id: str,
966
+ body: models.CreateFullRefundRequest | dict[str, Any],
967
+ *,
968
+ options: RequestOptions | None = None,
969
+ ) -> models.Refund:
970
+ """Create a full refund."""
971
+ return self._transport.request(
972
+ "POST",
973
+ f"/orders/{quote(order_id, safe='')}/refunds/full",
974
+ models.Refund,
975
+ body=body,
976
+ params=None,
977
+ options=options,
978
+ )
979
+
980
+ def get_refund(
981
+ self, order_id: str, refund_id: str, *, options: RequestOptions | None = None
982
+ ) -> models.Refund:
983
+ """Get an order refund."""
984
+ return self._transport.request(
985
+ "GET",
986
+ f"/orders/{quote(order_id, safe='')}/refunds/{quote(refund_id, safe='')}",
987
+ models.Refund,
988
+ body=None,
989
+ params=None,
990
+ options=options,
991
+ )
992
+
993
+ def cancel_refund(
994
+ self, order_id: str, refund_id: str, *, options: RequestOptions | None = None
995
+ ) -> None:
996
+ """Cancel a refund."""
997
+ return self._transport.request(
998
+ "DELETE",
999
+ f"/orders/{quote(order_id, safe='')}/refunds/{quote(refund_id, safe='')}",
1000
+ type(None),
1001
+ body=None,
1002
+ params=None,
1003
+ options=options,
1004
+ )
1005
+
1006
+ def list_chargebacks(
1007
+ self,
1008
+ order_id: str,
1009
+ params: models.ListOrderChargebacksParams | dict[str, Any] | None = None,
1010
+ *,
1011
+ options: RequestOptions | None = None,
1012
+ ) -> Page[models.Chargeback]:
1013
+ """List order chargebacks."""
1014
+ return self._transport.request(
1015
+ "GET",
1016
+ f"/orders/{quote(order_id, safe='')}/chargebacks",
1017
+ Page[models.Chargeback],
1018
+ body=None,
1019
+ params=params,
1020
+ options=options,
1021
+ )
1022
+
1023
+ def list_all_chargebacks(
1024
+ self,
1025
+ order_id: str,
1026
+ params: models.ListOrderChargebacksParams | dict[str, Any] | None = None,
1027
+ *,
1028
+ options: RequestOptions | None = None,
1029
+ ) -> Iterator[models.Chargeback]:
1030
+ query = self._transport.serialize(params) or {}
1031
+ seen: set[str] = set()
1032
+ if query.get("startingAfter"):
1033
+ seen.add(str(query["startingAfter"]))
1034
+ while True:
1035
+ page = self.list_chargebacks(order_id, query, options=options)
1036
+ yield from page.data
1037
+ following = next_params(page, query, seen)
1038
+ if following is None:
1039
+ return
1040
+ query = following
1041
+
1042
+ def get_chargeback(
1043
+ self, order_id: str, chargeback_id: str, *, options: RequestOptions | None = None
1044
+ ) -> models.Chargeback:
1045
+ """Get an order chargeback."""
1046
+ return self._transport.request(
1047
+ "GET",
1048
+ f"/orders/{quote(order_id, safe='')}/chargebacks/{quote(chargeback_id, safe='')}",
1049
+ models.Chargeback,
1050
+ body=None,
1051
+ params=None,
1052
+ options=options,
1053
+ )
1054
+
1055
+
1056
+ class AsyncOrders:
1057
+ def __init__(self, transport: AsyncTransport) -> None:
1058
+ self._transport = transport
1059
+
1060
+ async def list(
1061
+ self,
1062
+ params: models.ListOrdersParams | dict[str, Any] | None = None,
1063
+ *,
1064
+ options: RequestOptions | None = None,
1065
+ ) -> Page[models.Order]:
1066
+ """List all orders."""
1067
+ return await self._transport.request(
1068
+ "GET", "/orders", Page[models.Order], body=None, params=params, options=options
1069
+ )
1070
+
1071
+ async def list_all(
1072
+ self,
1073
+ params: models.ListOrdersParams | dict[str, Any] | None = None,
1074
+ *,
1075
+ options: RequestOptions | None = None,
1076
+ ) -> AsyncIterator[models.Order]:
1077
+ query = self._transport.serialize(params) or {}
1078
+ seen: set[str] = set()
1079
+ if query.get("startingAfter"):
1080
+ seen.add(str(query["startingAfter"]))
1081
+ while True:
1082
+ page = await self.list(query, options=options)
1083
+ for item in page.data:
1084
+ yield item
1085
+ following = next_params(page, query, seen)
1086
+ if following is None:
1087
+ return
1088
+ query = following
1089
+
1090
+ async def get(self, order_id: str, *, options: RequestOptions | None = None) -> models.Order:
1091
+ """Get an order."""
1092
+ return await self._transport.request(
1093
+ "GET",
1094
+ f"/orders/{quote(order_id, safe='')}",
1095
+ models.Order,
1096
+ body=None,
1097
+ params=None,
1098
+ options=options,
1099
+ )
1100
+
1101
+ async def create_invoice_update_link(
1102
+ self, order_id: str, *, options: RequestOptions | None = None
1103
+ ) -> models.InvoiceUpdateLink:
1104
+ """Create invoice update link."""
1105
+ return await self._transport.request(
1106
+ "POST",
1107
+ f"/orders/{quote(order_id, safe='')}/invoice-update-link",
1108
+ models.InvoiceUpdateLink,
1109
+ body=None,
1110
+ params=None,
1111
+ options=options,
1112
+ )
1113
+
1114
+ async def list_refunds(
1115
+ self,
1116
+ order_id: str,
1117
+ params: models.ListOrderRefundsParams | dict[str, Any] | None = None,
1118
+ *,
1119
+ options: RequestOptions | None = None,
1120
+ ) -> Page[models.Refund]:
1121
+ """List order refunds."""
1122
+ return await self._transport.request(
1123
+ "GET",
1124
+ f"/orders/{quote(order_id, safe='')}/refunds",
1125
+ Page[models.Refund],
1126
+ body=None,
1127
+ params=params,
1128
+ options=options,
1129
+ )
1130
+
1131
+ async def list_all_refunds(
1132
+ self,
1133
+ order_id: str,
1134
+ params: models.ListOrderRefundsParams | dict[str, Any] | None = None,
1135
+ *,
1136
+ options: RequestOptions | None = None,
1137
+ ) -> AsyncIterator[models.Refund]:
1138
+ query = self._transport.serialize(params) or {}
1139
+ seen: set[str] = set()
1140
+ if query.get("startingAfter"):
1141
+ seen.add(str(query["startingAfter"]))
1142
+ while True:
1143
+ page = await self.list_refunds(order_id, query, options=options)
1144
+ for item in page.data:
1145
+ yield item
1146
+ following = next_params(page, query, seen)
1147
+ if following is None:
1148
+ return
1149
+ query = following
1150
+
1151
+ async def create_refund(
1152
+ self,
1153
+ order_id: str,
1154
+ body: models.CreateRefundRequest | dict[str, Any],
1155
+ *,
1156
+ options: RequestOptions | None = None,
1157
+ ) -> models.Refund:
1158
+ """Create a partial refund."""
1159
+ return await self._transport.request(
1160
+ "POST",
1161
+ f"/orders/{quote(order_id, safe='')}/refunds",
1162
+ models.Refund,
1163
+ body=body,
1164
+ params=None,
1165
+ options=options,
1166
+ )
1167
+
1168
+ async def create_full_refund(
1169
+ self,
1170
+ order_id: str,
1171
+ body: models.CreateFullRefundRequest | dict[str, Any],
1172
+ *,
1173
+ options: RequestOptions | None = None,
1174
+ ) -> models.Refund:
1175
+ """Create a full refund."""
1176
+ return await self._transport.request(
1177
+ "POST",
1178
+ f"/orders/{quote(order_id, safe='')}/refunds/full",
1179
+ models.Refund,
1180
+ body=body,
1181
+ params=None,
1182
+ options=options,
1183
+ )
1184
+
1185
+ async def get_refund(
1186
+ self, order_id: str, refund_id: str, *, options: RequestOptions | None = None
1187
+ ) -> models.Refund:
1188
+ """Get an order refund."""
1189
+ return await self._transport.request(
1190
+ "GET",
1191
+ f"/orders/{quote(order_id, safe='')}/refunds/{quote(refund_id, safe='')}",
1192
+ models.Refund,
1193
+ body=None,
1194
+ params=None,
1195
+ options=options,
1196
+ )
1197
+
1198
+ async def cancel_refund(
1199
+ self, order_id: str, refund_id: str, *, options: RequestOptions | None = None
1200
+ ) -> None:
1201
+ """Cancel a refund."""
1202
+ return await self._transport.request(
1203
+ "DELETE",
1204
+ f"/orders/{quote(order_id, safe='')}/refunds/{quote(refund_id, safe='')}",
1205
+ type(None),
1206
+ body=None,
1207
+ params=None,
1208
+ options=options,
1209
+ )
1210
+
1211
+ async def list_chargebacks(
1212
+ self,
1213
+ order_id: str,
1214
+ params: models.ListOrderChargebacksParams | dict[str, Any] | None = None,
1215
+ *,
1216
+ options: RequestOptions | None = None,
1217
+ ) -> Page[models.Chargeback]:
1218
+ """List order chargebacks."""
1219
+ return await self._transport.request(
1220
+ "GET",
1221
+ f"/orders/{quote(order_id, safe='')}/chargebacks",
1222
+ Page[models.Chargeback],
1223
+ body=None,
1224
+ params=params,
1225
+ options=options,
1226
+ )
1227
+
1228
+ async def list_all_chargebacks(
1229
+ self,
1230
+ order_id: str,
1231
+ params: models.ListOrderChargebacksParams | dict[str, Any] | None = None,
1232
+ *,
1233
+ options: RequestOptions | None = None,
1234
+ ) -> AsyncIterator[models.Chargeback]:
1235
+ query = self._transport.serialize(params) or {}
1236
+ seen: set[str] = set()
1237
+ if query.get("startingAfter"):
1238
+ seen.add(str(query["startingAfter"]))
1239
+ while True:
1240
+ page = await self.list_chargebacks(order_id, query, options=options)
1241
+ for item in page.data:
1242
+ yield item
1243
+ following = next_params(page, query, seen)
1244
+ if following is None:
1245
+ return
1246
+ query = following
1247
+
1248
+ async def get_chargeback(
1249
+ self, order_id: str, chargeback_id: str, *, options: RequestOptions | None = None
1250
+ ) -> models.Chargeback:
1251
+ """Get an order chargeback."""
1252
+ return await self._transport.request(
1253
+ "GET",
1254
+ f"/orders/{quote(order_id, safe='')}/chargebacks/{quote(chargeback_id, safe='')}",
1255
+ models.Chargeback,
1256
+ body=None,
1257
+ params=None,
1258
+ options=options,
1259
+ )
1260
+
1261
+
1262
+ class Refunds:
1263
+ def __init__(self, transport: SyncTransport) -> None:
1264
+ self._transport = transport
1265
+
1266
+ def list(
1267
+ self,
1268
+ params: models.ListRefundsParams | dict[str, Any] | None = None,
1269
+ *,
1270
+ options: RequestOptions | None = None,
1271
+ ) -> Page[models.Refund]:
1272
+ """List all refunds."""
1273
+ return self._transport.request(
1274
+ "GET", "/refunds", Page[models.Refund], body=None, params=params, options=options
1275
+ )
1276
+
1277
+ def list_all(
1278
+ self,
1279
+ params: models.ListRefundsParams | dict[str, Any] | None = None,
1280
+ *,
1281
+ options: RequestOptions | None = None,
1282
+ ) -> Iterator[models.Refund]:
1283
+ query = self._transport.serialize(params) or {}
1284
+ seen: set[str] = set()
1285
+ if query.get("startingAfter"):
1286
+ seen.add(str(query["startingAfter"]))
1287
+ while True:
1288
+ page = self.list(query, options=options)
1289
+ yield from page.data
1290
+ following = next_params(page, query, seen)
1291
+ if following is None:
1292
+ return
1293
+ query = following
1294
+
1295
+ def get(self, refund_id: str, *, options: RequestOptions | None = None) -> models.Refund:
1296
+ """Get a refund."""
1297
+ return self._transport.request(
1298
+ "GET",
1299
+ f"/refunds/{quote(refund_id, safe='')}",
1300
+ models.Refund,
1301
+ body=None,
1302
+ params=None,
1303
+ options=options,
1304
+ )
1305
+
1306
+
1307
+ class AsyncRefunds:
1308
+ def __init__(self, transport: AsyncTransport) -> None:
1309
+ self._transport = transport
1310
+
1311
+ async def list(
1312
+ self,
1313
+ params: models.ListRefundsParams | dict[str, Any] | None = None,
1314
+ *,
1315
+ options: RequestOptions | None = None,
1316
+ ) -> Page[models.Refund]:
1317
+ """List all refunds."""
1318
+ return await self._transport.request(
1319
+ "GET", "/refunds", Page[models.Refund], body=None, params=params, options=options
1320
+ )
1321
+
1322
+ async def list_all(
1323
+ self,
1324
+ params: models.ListRefundsParams | dict[str, Any] | None = None,
1325
+ *,
1326
+ options: RequestOptions | None = None,
1327
+ ) -> AsyncIterator[models.Refund]:
1328
+ query = self._transport.serialize(params) or {}
1329
+ seen: set[str] = set()
1330
+ if query.get("startingAfter"):
1331
+ seen.add(str(query["startingAfter"]))
1332
+ while True:
1333
+ page = await self.list(query, options=options)
1334
+ for item in page.data:
1335
+ yield item
1336
+ following = next_params(page, query, seen)
1337
+ if following is None:
1338
+ return
1339
+ query = following
1340
+
1341
+ async def get(self, refund_id: str, *, options: RequestOptions | None = None) -> models.Refund:
1342
+ """Get a refund."""
1343
+ return await self._transport.request(
1344
+ "GET",
1345
+ f"/refunds/{quote(refund_id, safe='')}",
1346
+ models.Refund,
1347
+ body=None,
1348
+ params=None,
1349
+ options=options,
1350
+ )
1351
+
1352
+
1353
+ class Chargebacks:
1354
+ def __init__(self, transport: SyncTransport) -> None:
1355
+ self._transport = transport
1356
+
1357
+ def list(
1358
+ self,
1359
+ params: models.ListChargebacksParams | dict[str, Any] | None = None,
1360
+ *,
1361
+ options: RequestOptions | None = None,
1362
+ ) -> Page[models.Chargeback]:
1363
+ """List all chargebacks."""
1364
+ return self._transport.request(
1365
+ "GET",
1366
+ "/chargebacks",
1367
+ Page[models.Chargeback],
1368
+ body=None,
1369
+ params=params,
1370
+ options=options,
1371
+ )
1372
+
1373
+ def list_all(
1374
+ self,
1375
+ params: models.ListChargebacksParams | dict[str, Any] | None = None,
1376
+ *,
1377
+ options: RequestOptions | None = None,
1378
+ ) -> Iterator[models.Chargeback]:
1379
+ query = self._transport.serialize(params) or {}
1380
+ seen: set[str] = set()
1381
+ if query.get("startingAfter"):
1382
+ seen.add(str(query["startingAfter"]))
1383
+ while True:
1384
+ page = self.list(query, options=options)
1385
+ yield from page.data
1386
+ following = next_params(page, query, seen)
1387
+ if following is None:
1388
+ return
1389
+ query = following
1390
+
1391
+ def get(
1392
+ self, chargeback_id: str, *, options: RequestOptions | None = None
1393
+ ) -> models.Chargeback:
1394
+ """Get a chargeback."""
1395
+ return self._transport.request(
1396
+ "GET",
1397
+ f"/chargebacks/{quote(chargeback_id, safe='')}",
1398
+ models.Chargeback,
1399
+ body=None,
1400
+ params=None,
1401
+ options=options,
1402
+ )
1403
+
1404
+
1405
+ class AsyncChargebacks:
1406
+ def __init__(self, transport: AsyncTransport) -> None:
1407
+ self._transport = transport
1408
+
1409
+ async def list(
1410
+ self,
1411
+ params: models.ListChargebacksParams | dict[str, Any] | None = None,
1412
+ *,
1413
+ options: RequestOptions | None = None,
1414
+ ) -> Page[models.Chargeback]:
1415
+ """List all chargebacks."""
1416
+ return await self._transport.request(
1417
+ "GET",
1418
+ "/chargebacks",
1419
+ Page[models.Chargeback],
1420
+ body=None,
1421
+ params=params,
1422
+ options=options,
1423
+ )
1424
+
1425
+ async def list_all(
1426
+ self,
1427
+ params: models.ListChargebacksParams | dict[str, Any] | None = None,
1428
+ *,
1429
+ options: RequestOptions | None = None,
1430
+ ) -> AsyncIterator[models.Chargeback]:
1431
+ query = self._transport.serialize(params) or {}
1432
+ seen: set[str] = set()
1433
+ if query.get("startingAfter"):
1434
+ seen.add(str(query["startingAfter"]))
1435
+ while True:
1436
+ page = await self.list(query, options=options)
1437
+ for item in page.data:
1438
+ yield item
1439
+ following = next_params(page, query, seen)
1440
+ if following is None:
1441
+ return
1442
+ query = following
1443
+
1444
+ async def get(
1445
+ self, chargeback_id: str, *, options: RequestOptions | None = None
1446
+ ) -> models.Chargeback:
1447
+ """Get a chargeback."""
1448
+ return await self._transport.request(
1449
+ "GET",
1450
+ f"/chargebacks/{quote(chargeback_id, safe='')}",
1451
+ models.Chargeback,
1452
+ body=None,
1453
+ params=None,
1454
+ options=options,
1455
+ )
1456
+
1457
+
1458
+ class WebhookEvents:
1459
+ def __init__(self, transport: SyncTransport) -> None:
1460
+ self._transport = transport
1461
+
1462
+ def get(self, event_id: str, *, options: RequestOptions | None = None) -> models.WebhookEvent:
1463
+ """Get webhook event."""
1464
+ return self._transport.request(
1465
+ "GET",
1466
+ f"/webhook-events/{quote(event_id, safe='')}",
1467
+ models.WebhookEvent,
1468
+ body=None,
1469
+ params=None,
1470
+ options=options,
1471
+ )
1472
+
1473
+
1474
+ class AsyncWebhookEvents:
1475
+ def __init__(self, transport: AsyncTransport) -> None:
1476
+ self._transport = transport
1477
+
1478
+ async def get(
1479
+ self, event_id: str, *, options: RequestOptions | None = None
1480
+ ) -> models.WebhookEvent:
1481
+ """Get webhook event."""
1482
+ return await self._transport.request(
1483
+ "GET",
1484
+ f"/webhook-events/{quote(event_id, safe='')}",
1485
+ models.WebhookEvent,
1486
+ body=None,
1487
+ params=None,
1488
+ options=options,
1489
+ )
1490
+
1491
+
1492
+ class WebhookEndpoints:
1493
+ def __init__(self, transport: SyncTransport) -> None:
1494
+ self._transport = transport
1495
+
1496
+ def list(
1497
+ self,
1498
+ params: models.ListWebhookEndpointsParams | dict[str, Any] | None = None,
1499
+ *,
1500
+ options: RequestOptions | None = None,
1501
+ ) -> Page[models.WebhookEndpoint]:
1502
+ """List webhook endpoints."""
1503
+ return self._transport.request(
1504
+ "GET",
1505
+ "/webhook-endpoints",
1506
+ Page[models.WebhookEndpoint],
1507
+ body=None,
1508
+ params=params,
1509
+ options=options,
1510
+ )
1511
+
1512
+ def list_all(
1513
+ self,
1514
+ params: models.ListWebhookEndpointsParams | dict[str, Any] | None = None,
1515
+ *,
1516
+ options: RequestOptions | None = None,
1517
+ ) -> Iterator[models.WebhookEndpoint]:
1518
+ query = self._transport.serialize(params) or {}
1519
+ seen: set[str] = set()
1520
+ if query.get("startingAfter"):
1521
+ seen.add(str(query["startingAfter"]))
1522
+ while True:
1523
+ page = self.list(query, options=options)
1524
+ yield from page.data
1525
+ following = next_params(page, query, seen)
1526
+ if following is None:
1527
+ return
1528
+ query = following
1529
+
1530
+ def create(
1531
+ self,
1532
+ body: models.CreateWebhookEndpointRequest | dict[str, Any],
1533
+ *,
1534
+ options: RequestOptions | None = None,
1535
+ ) -> models.WebhookEndpoint:
1536
+ """Register a webhook endpoint."""
1537
+ return self._transport.request(
1538
+ "POST",
1539
+ "/webhook-endpoints",
1540
+ models.WebhookEndpoint,
1541
+ body=body,
1542
+ params=None,
1543
+ options=options,
1544
+ )
1545
+
1546
+ def get(
1547
+ self, webhook_endpoint_id: str, *, options: RequestOptions | None = None
1548
+ ) -> models.WebhookEndpoint:
1549
+ """Get a webhook endpoint."""
1550
+ return self._transport.request(
1551
+ "GET",
1552
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1553
+ models.WebhookEndpoint,
1554
+ body=None,
1555
+ params=None,
1556
+ options=options,
1557
+ )
1558
+
1559
+ def update(
1560
+ self,
1561
+ webhook_endpoint_id: str,
1562
+ body: models.UpdateWebhookEndpointRequest | dict[str, Any],
1563
+ *,
1564
+ options: RequestOptions | None = None,
1565
+ ) -> models.WebhookEndpoint:
1566
+ """Update a webhook endpoint."""
1567
+ return self._transport.request(
1568
+ "PATCH",
1569
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1570
+ models.WebhookEndpoint,
1571
+ body=body,
1572
+ params=None,
1573
+ options=options,
1574
+ )
1575
+
1576
+ def delete(self, webhook_endpoint_id: str, *, options: RequestOptions | None = None) -> None:
1577
+ """Delete a webhook endpoint."""
1578
+ return self._transport.request(
1579
+ "DELETE",
1580
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1581
+ type(None),
1582
+ body=None,
1583
+ params=None,
1584
+ options=options,
1585
+ )
1586
+
1587
+
1588
+ class AsyncWebhookEndpoints:
1589
+ def __init__(self, transport: AsyncTransport) -> None:
1590
+ self._transport = transport
1591
+
1592
+ async def list(
1593
+ self,
1594
+ params: models.ListWebhookEndpointsParams | dict[str, Any] | None = None,
1595
+ *,
1596
+ options: RequestOptions | None = None,
1597
+ ) -> Page[models.WebhookEndpoint]:
1598
+ """List webhook endpoints."""
1599
+ return await self._transport.request(
1600
+ "GET",
1601
+ "/webhook-endpoints",
1602
+ Page[models.WebhookEndpoint],
1603
+ body=None,
1604
+ params=params,
1605
+ options=options,
1606
+ )
1607
+
1608
+ async def list_all(
1609
+ self,
1610
+ params: models.ListWebhookEndpointsParams | dict[str, Any] | None = None,
1611
+ *,
1612
+ options: RequestOptions | None = None,
1613
+ ) -> AsyncIterator[models.WebhookEndpoint]:
1614
+ query = self._transport.serialize(params) or {}
1615
+ seen: set[str] = set()
1616
+ if query.get("startingAfter"):
1617
+ seen.add(str(query["startingAfter"]))
1618
+ while True:
1619
+ page = await self.list(query, options=options)
1620
+ for item in page.data:
1621
+ yield item
1622
+ following = next_params(page, query, seen)
1623
+ if following is None:
1624
+ return
1625
+ query = following
1626
+
1627
+ async def create(
1628
+ self,
1629
+ body: models.CreateWebhookEndpointRequest | dict[str, Any],
1630
+ *,
1631
+ options: RequestOptions | None = None,
1632
+ ) -> models.WebhookEndpoint:
1633
+ """Register a webhook endpoint."""
1634
+ return await self._transport.request(
1635
+ "POST",
1636
+ "/webhook-endpoints",
1637
+ models.WebhookEndpoint,
1638
+ body=body,
1639
+ params=None,
1640
+ options=options,
1641
+ )
1642
+
1643
+ async def get(
1644
+ self, webhook_endpoint_id: str, *, options: RequestOptions | None = None
1645
+ ) -> models.WebhookEndpoint:
1646
+ """Get a webhook endpoint."""
1647
+ return await self._transport.request(
1648
+ "GET",
1649
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1650
+ models.WebhookEndpoint,
1651
+ body=None,
1652
+ params=None,
1653
+ options=options,
1654
+ )
1655
+
1656
+ async def update(
1657
+ self,
1658
+ webhook_endpoint_id: str,
1659
+ body: models.UpdateWebhookEndpointRequest | dict[str, Any],
1660
+ *,
1661
+ options: RequestOptions | None = None,
1662
+ ) -> models.WebhookEndpoint:
1663
+ """Update a webhook endpoint."""
1664
+ return await self._transport.request(
1665
+ "PATCH",
1666
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1667
+ models.WebhookEndpoint,
1668
+ body=body,
1669
+ params=None,
1670
+ options=options,
1671
+ )
1672
+
1673
+ async def delete(
1674
+ self, webhook_endpoint_id: str, *, options: RequestOptions | None = None
1675
+ ) -> None:
1676
+ """Delete a webhook endpoint."""
1677
+ return await self._transport.request(
1678
+ "DELETE",
1679
+ f"/webhook-endpoints/{quote(webhook_endpoint_id, safe='')}",
1680
+ type(None),
1681
+ body=None,
1682
+ params=None,
1683
+ options=options,
1684
+ )
1685
+
1686
+
1687
+ class Subscriptions:
1688
+ def __init__(self, transport: SyncTransport) -> None:
1689
+ self._transport = transport
1690
+
1691
+ def list(
1692
+ self,
1693
+ params: models.ListSubscriptionsParams | dict[str, Any] | None = None,
1694
+ *,
1695
+ options: RequestOptions | None = None,
1696
+ ) -> Page[models.Subscription]:
1697
+ """List all subscriptions."""
1698
+ return self._transport.request(
1699
+ "GET",
1700
+ "/subscriptions",
1701
+ Page[models.Subscription],
1702
+ body=None,
1703
+ params=params,
1704
+ options=options,
1705
+ )
1706
+
1707
+ def list_all(
1708
+ self,
1709
+ params: models.ListSubscriptionsParams | dict[str, Any] | None = None,
1710
+ *,
1711
+ options: RequestOptions | None = None,
1712
+ ) -> Iterator[models.Subscription]:
1713
+ query = self._transport.serialize(params) or {}
1714
+ seen: set[str] = set()
1715
+ if query.get("startingAfter"):
1716
+ seen.add(str(query["startingAfter"]))
1717
+ while True:
1718
+ page = self.list(query, options=options)
1719
+ yield from page.data
1720
+ following = next_params(page, query, seen)
1721
+ if following is None:
1722
+ return
1723
+ query = following
1724
+
1725
+ def get(
1726
+ self, subscription_id: str, *, options: RequestOptions | None = None
1727
+ ) -> models.Subscription:
1728
+ """Get a subscription."""
1729
+ return self._transport.request(
1730
+ "GET",
1731
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1732
+ models.Subscription,
1733
+ body=None,
1734
+ params=None,
1735
+ options=options,
1736
+ )
1737
+
1738
+ def update(
1739
+ self,
1740
+ subscription_id: str,
1741
+ body: models.UpdateSubscriptionRequest | dict[str, Any],
1742
+ *,
1743
+ options: RequestOptions | None = None,
1744
+ ) -> models.Subscription:
1745
+ """Update a subscription."""
1746
+ return self._transport.request(
1747
+ "PATCH",
1748
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1749
+ models.Subscription,
1750
+ body=body,
1751
+ params=None,
1752
+ options=options,
1753
+ )
1754
+
1755
+ def cancel(
1756
+ self,
1757
+ subscription_id: str,
1758
+ params: models.CancelSubscriptionParams | dict[str, Any] | None = None,
1759
+ *,
1760
+ options: RequestOptions | None = None,
1761
+ ) -> None:
1762
+ """Cancel a subscription."""
1763
+ return self._transport.request(
1764
+ "DELETE",
1765
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1766
+ type(None),
1767
+ body=None,
1768
+ params=params,
1769
+ options=options,
1770
+ )
1771
+
1772
+ def create_billing_update_link(
1773
+ self,
1774
+ subscription_id: str,
1775
+ body: models.UpdateSubscriptionBillingRequest | dict[str, Any],
1776
+ *,
1777
+ options: RequestOptions | None = None,
1778
+ ) -> models.CreateSubscriptionBillingUpdateLinkResponse:
1779
+ """Create billing update link."""
1780
+ return self._transport.request(
1781
+ "POST",
1782
+ f"/subscriptions/{quote(subscription_id, safe='')}/billing-update-link",
1783
+ models.CreateSubscriptionBillingUpdateLinkResponse,
1784
+ body=body,
1785
+ params=None,
1786
+ options=options,
1787
+ )
1788
+
1789
+ def resume(
1790
+ self, subscription_id: str, *, options: RequestOptions | None = None
1791
+ ) -> models.Subscription:
1792
+ """Resume a canceled subscription."""
1793
+ return self._transport.request(
1794
+ "POST",
1795
+ f"/subscriptions/{quote(subscription_id, safe='')}/resume",
1796
+ models.Subscription,
1797
+ body=None,
1798
+ params=None,
1799
+ options=options,
1800
+ )
1801
+
1802
+
1803
+ class AsyncSubscriptions:
1804
+ def __init__(self, transport: AsyncTransport) -> None:
1805
+ self._transport = transport
1806
+
1807
+ async def list(
1808
+ self,
1809
+ params: models.ListSubscriptionsParams | dict[str, Any] | None = None,
1810
+ *,
1811
+ options: RequestOptions | None = None,
1812
+ ) -> Page[models.Subscription]:
1813
+ """List all subscriptions."""
1814
+ return await self._transport.request(
1815
+ "GET",
1816
+ "/subscriptions",
1817
+ Page[models.Subscription],
1818
+ body=None,
1819
+ params=params,
1820
+ options=options,
1821
+ )
1822
+
1823
+ async def list_all(
1824
+ self,
1825
+ params: models.ListSubscriptionsParams | dict[str, Any] | None = None,
1826
+ *,
1827
+ options: RequestOptions | None = None,
1828
+ ) -> AsyncIterator[models.Subscription]:
1829
+ query = self._transport.serialize(params) or {}
1830
+ seen: set[str] = set()
1831
+ if query.get("startingAfter"):
1832
+ seen.add(str(query["startingAfter"]))
1833
+ while True:
1834
+ page = await self.list(query, options=options)
1835
+ for item in page.data:
1836
+ yield item
1837
+ following = next_params(page, query, seen)
1838
+ if following is None:
1839
+ return
1840
+ query = following
1841
+
1842
+ async def get(
1843
+ self, subscription_id: str, *, options: RequestOptions | None = None
1844
+ ) -> models.Subscription:
1845
+ """Get a subscription."""
1846
+ return await self._transport.request(
1847
+ "GET",
1848
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1849
+ models.Subscription,
1850
+ body=None,
1851
+ params=None,
1852
+ options=options,
1853
+ )
1854
+
1855
+ async def update(
1856
+ self,
1857
+ subscription_id: str,
1858
+ body: models.UpdateSubscriptionRequest | dict[str, Any],
1859
+ *,
1860
+ options: RequestOptions | None = None,
1861
+ ) -> models.Subscription:
1862
+ """Update a subscription."""
1863
+ return await self._transport.request(
1864
+ "PATCH",
1865
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1866
+ models.Subscription,
1867
+ body=body,
1868
+ params=None,
1869
+ options=options,
1870
+ )
1871
+
1872
+ async def cancel(
1873
+ self,
1874
+ subscription_id: str,
1875
+ params: models.CancelSubscriptionParams | dict[str, Any] | None = None,
1876
+ *,
1877
+ options: RequestOptions | None = None,
1878
+ ) -> None:
1879
+ """Cancel a subscription."""
1880
+ return await self._transport.request(
1881
+ "DELETE",
1882
+ f"/subscriptions/{quote(subscription_id, safe='')}",
1883
+ type(None),
1884
+ body=None,
1885
+ params=params,
1886
+ options=options,
1887
+ )
1888
+
1889
+ async def create_billing_update_link(
1890
+ self,
1891
+ subscription_id: str,
1892
+ body: models.UpdateSubscriptionBillingRequest | dict[str, Any],
1893
+ *,
1894
+ options: RequestOptions | None = None,
1895
+ ) -> models.CreateSubscriptionBillingUpdateLinkResponse:
1896
+ """Create billing update link."""
1897
+ return await self._transport.request(
1898
+ "POST",
1899
+ f"/subscriptions/{quote(subscription_id, safe='')}/billing-update-link",
1900
+ models.CreateSubscriptionBillingUpdateLinkResponse,
1901
+ body=body,
1902
+ params=None,
1903
+ options=options,
1904
+ )
1905
+
1906
+ async def resume(
1907
+ self, subscription_id: str, *, options: RequestOptions | None = None
1908
+ ) -> models.Subscription:
1909
+ """Resume a canceled subscription."""
1910
+ return await self._transport.request(
1911
+ "POST",
1912
+ f"/subscriptions/{quote(subscription_id, safe='')}/resume",
1913
+ models.Subscription,
1914
+ body=None,
1915
+ params=None,
1916
+ options=options,
1917
+ )
1918
+
1919
+
1920
+ class TestHelpers:
1921
+ def __init__(self, transport: SyncTransport) -> None:
1922
+ self._transport = transport
1923
+
1924
+ def fast_forward_renewal(
1925
+ self,
1926
+ subscription_id: str,
1927
+ body: models.FastForwardSubscriptionRenewalRequest | dict[str, Any],
1928
+ *,
1929
+ options: RequestOptions | None = None,
1930
+ ) -> models.Subscription:
1931
+ """Fast-forward subscription renewal."""
1932
+ if self._transport.mode != "test":
1933
+ raise ValueError("Test helpers require a test-mode API key")
1934
+ return self._transport.request(
1935
+ "POST",
1936
+ f"/test-helpers/subscriptions/{quote(subscription_id, safe='')}/fast-forward-renewal",
1937
+ models.Subscription,
1938
+ body=body,
1939
+ params=None,
1940
+ options=options,
1941
+ )
1942
+
1943
+ def simulate_order_payment(
1944
+ self,
1945
+ order_id: str,
1946
+ body: models.SimulateOrderPaymentRequest | dict[str, Any],
1947
+ *,
1948
+ options: RequestOptions | None = None,
1949
+ ) -> models.Order:
1950
+ """Simulate an order payment outcome."""
1951
+ if self._transport.mode != "test":
1952
+ raise ValueError("Test helpers require a test-mode API key")
1953
+ return self._transport.request(
1954
+ "POST",
1955
+ f"/test-helpers/orders/{quote(order_id, safe='')}/simulate-payment",
1956
+ models.Order,
1957
+ body=body,
1958
+ params=None,
1959
+ options=options,
1960
+ )
1961
+
1962
+
1963
+ class AsyncTestHelpers:
1964
+ def __init__(self, transport: AsyncTransport) -> None:
1965
+ self._transport = transport
1966
+
1967
+ async def fast_forward_renewal(
1968
+ self,
1969
+ subscription_id: str,
1970
+ body: models.FastForwardSubscriptionRenewalRequest | dict[str, Any],
1971
+ *,
1972
+ options: RequestOptions | None = None,
1973
+ ) -> models.Subscription:
1974
+ """Fast-forward subscription renewal."""
1975
+ if self._transport.mode != "test":
1976
+ raise ValueError("Test helpers require a test-mode API key")
1977
+ return await self._transport.request(
1978
+ "POST",
1979
+ f"/test-helpers/subscriptions/{quote(subscription_id, safe='')}/fast-forward-renewal",
1980
+ models.Subscription,
1981
+ body=body,
1982
+ params=None,
1983
+ options=options,
1984
+ )
1985
+
1986
+ async def simulate_order_payment(
1987
+ self,
1988
+ order_id: str,
1989
+ body: models.SimulateOrderPaymentRequest | dict[str, Any],
1990
+ *,
1991
+ options: RequestOptions | None = None,
1992
+ ) -> models.Order:
1993
+ """Simulate an order payment outcome."""
1994
+ if self._transport.mode != "test":
1995
+ raise ValueError("Test helpers require a test-mode API key")
1996
+ return await self._transport.request(
1997
+ "POST",
1998
+ f"/test-helpers/orders/{quote(order_id, safe='')}/simulate-payment",
1999
+ models.Order,
2000
+ body=body,
2001
+ params=None,
2002
+ options=options,
2003
+ )