whop-sdk 0.0.1__py3-none-any.whl → 0.0.3__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.

Potentially problematic release.


This version of whop-sdk might be problematic. Click here for more details.

Files changed (126) hide show
  1. whop_sdk/_client.py +65 -2
  2. whop_sdk/_version.py +1 -1
  3. whop_sdk/resources/__init__.py +98 -0
  4. whop_sdk/resources/checkout_configurations.py +16 -12
  5. whop_sdk/resources/course_chapters.py +602 -0
  6. whop_sdk/resources/course_lessons.py +722 -0
  7. whop_sdk/resources/courses.py +713 -0
  8. whop_sdk/resources/experiences.py +107 -0
  9. whop_sdk/resources/forum_posts.py +123 -1
  10. whop_sdk/resources/forums.py +446 -0
  11. whop_sdk/resources/members.py +429 -0
  12. whop_sdk/resources/memberships.py +16 -8
  13. whop_sdk/resources/messages.py +113 -1
  14. whop_sdk/resources/payments.py +3 -26
  15. whop_sdk/resources/plans.py +84 -6
  16. whop_sdk/resources/products.py +8 -16
  17. whop_sdk/resources/promo_codes.py +652 -0
  18. whop_sdk/resources/reviews.py +315 -0
  19. whop_sdk/types/__init__.py +64 -0
  20. whop_sdk/types/app_list_response.py +16 -1
  21. whop_sdk/types/assessment_question_types.py +7 -0
  22. whop_sdk/types/billing_reasons.py +9 -0
  23. whop_sdk/types/card_brands.py +24 -0
  24. whop_sdk/types/checkout_configuration_create_params.py +70 -7
  25. whop_sdk/types/checkout_configuration_list_response.py +12 -9
  26. whop_sdk/types/course.py +109 -0
  27. whop_sdk/types/course_chapter.py +32 -0
  28. whop_sdk/types/course_chapter_create_params.py +16 -0
  29. whop_sdk/types/course_chapter_delete_response.py +7 -0
  30. whop_sdk/types/course_chapter_list_params.py +25 -0
  31. whop_sdk/types/course_chapter_list_response.py +16 -0
  32. whop_sdk/types/course_chapter_update_params.py +12 -0
  33. whop_sdk/types/course_create_params.py +41 -0
  34. whop_sdk/types/course_delete_response.py +7 -0
  35. whop_sdk/types/course_lesson_create_params.py +27 -0
  36. whop_sdk/types/course_lesson_delete_response.py +7 -0
  37. whop_sdk/types/course_lesson_interaction_completed_webhook_event.py +26 -0
  38. whop_sdk/types/course_lesson_list_params.py +28 -0
  39. whop_sdk/types/course_lesson_list_response.py +35 -0
  40. whop_sdk/types/course_lesson_update_params.py +144 -0
  41. whop_sdk/types/course_list_params.py +28 -0
  42. whop_sdk/types/course_list_response.py +77 -0
  43. whop_sdk/types/course_update_params.py +89 -0
  44. whop_sdk/types/entry_approved_webhook_event.py +26 -0
  45. whop_sdk/types/entry_created_webhook_event.py +26 -0
  46. whop_sdk/types/entry_deleted_webhook_event.py +26 -0
  47. whop_sdk/types/entry_denied_webhook_event.py +26 -0
  48. whop_sdk/types/experience_duplicate_params.py +13 -0
  49. whop_sdk/types/experience_list_response.py +27 -1
  50. whop_sdk/types/forum_list_params.py +28 -0
  51. whop_sdk/types/forum_list_response.py +33 -0
  52. whop_sdk/types/forum_post_list_response.py +7 -0
  53. whop_sdk/types/forum_post_update_params.py +41 -0
  54. whop_sdk/types/forum_update_params.py +23 -0
  55. whop_sdk/types/invoice_create_params.py +10 -2
  56. whop_sdk/types/languages.py +30 -0
  57. whop_sdk/types/ledger_account_retrieve_response.py +15 -1
  58. whop_sdk/types/lesson.py +159 -0
  59. whop_sdk/types/lesson_types.py +7 -0
  60. whop_sdk/types/lesson_visibilities.py +7 -0
  61. whop_sdk/types/member_list_params.py +73 -0
  62. whop_sdk/types/member_list_response.py +65 -0
  63. whop_sdk/types/member_retrieve_response.py +79 -0
  64. whop_sdk/types/membership_activated_webhook_event.py +29 -0
  65. whop_sdk/types/membership_deactivated_webhook_event.py +29 -0
  66. whop_sdk/types/membership_list_params.py +7 -4
  67. whop_sdk/types/membership_list_response.py +12 -1
  68. whop_sdk/types/message_update_params.py +35 -0
  69. whop_sdk/types/payment_failed_webhook_event.py +26 -0
  70. whop_sdk/types/payment_list_params.py +2 -7
  71. whop_sdk/types/payment_list_response.py +23 -13
  72. whop_sdk/types/payment_method_types.py +92 -0
  73. whop_sdk/types/payment_pending_webhook_event.py +26 -0
  74. whop_sdk/types/payment_succeeded_webhook_event.py +26 -0
  75. whop_sdk/types/plan_create_params.py +29 -3
  76. whop_sdk/types/plan_list_response.py +9 -0
  77. whop_sdk/types/plan_update_params.py +18 -0
  78. whop_sdk/types/product_create_params.py +1 -24
  79. whop_sdk/types/product_update_params.py +12 -1
  80. whop_sdk/types/promo_code.py +90 -0
  81. whop_sdk/types/promo_code_create_params.py +70 -0
  82. whop_sdk/types/promo_code_delete_response.py +7 -0
  83. whop_sdk/types/promo_code_list_params.py +37 -0
  84. whop_sdk/types/promo_code_list_response.py +79 -0
  85. whop_sdk/types/promo_code_status.py +7 -0
  86. whop_sdk/types/promo_duration.py +7 -0
  87. whop_sdk/types/review_list_params.py +31 -0
  88. whop_sdk/types/review_list_response.py +78 -0
  89. whop_sdk/types/review_retrieve_response.py +103 -0
  90. whop_sdk/types/review_status.py +7 -0
  91. whop_sdk/types/shared/__init__.py +7 -0
  92. whop_sdk/types/shared/access_level.py +7 -0
  93. whop_sdk/types/shared/app.py +25 -1
  94. whop_sdk/types/shared/checkout_configuration.py +12 -9
  95. whop_sdk/types/shared/company.py +15 -1
  96. whop_sdk/types/shared/course_lesson_interaction.py +20 -1
  97. whop_sdk/types/shared/email_notification_preferences.py +7 -0
  98. whop_sdk/types/shared/experience.py +27 -1
  99. whop_sdk/types/shared/forum.py +33 -0
  100. whop_sdk/types/shared/forum_post.py +7 -0
  101. whop_sdk/types/shared/invoice.py +4 -1
  102. whop_sdk/types/shared/invoice_list_item.py +4 -1
  103. whop_sdk/types/shared/member_most_recent_actions.py +22 -0
  104. whop_sdk/types/shared/member_statuses.py +7 -0
  105. whop_sdk/types/shared/membership.py +12 -1
  106. whop_sdk/types/shared/payment.py +23 -13
  107. whop_sdk/types/shared/plan.py +9 -0
  108. whop_sdk/types/shared/product.py +8 -0
  109. whop_sdk/types/shared/product_list_item.py +8 -0
  110. whop_sdk/types/shared/who_can_comment_types.py +7 -0
  111. whop_sdk/types/shared/who_can_post_types.py +7 -0
  112. whop_sdk/types/shared_params/__init__.py +7 -0
  113. whop_sdk/types/shared_params/access_level.py +9 -0
  114. whop_sdk/types/shared_params/email_notification_preferences.py +9 -0
  115. whop_sdk/types/shared_params/member_most_recent_actions.py +24 -0
  116. whop_sdk/types/shared_params/member_statuses.py +9 -0
  117. whop_sdk/types/shared_params/promo_type.py +9 -0
  118. whop_sdk/types/shared_params/who_can_comment_types.py +9 -0
  119. whop_sdk/types/shared_params/who_can_post_types.py +9 -0
  120. whop_sdk/types/unwrap_webhook_event.py +24 -1
  121. whop_sdk/types/user_check_access_response.py +2 -3
  122. whop_sdk/types/user_retrieve_response.py +12 -1
  123. {whop_sdk-0.0.1.dist-info → whop_sdk-0.0.3.dist-info}/METADATA +2 -2
  124. {whop_sdk-0.0.1.dist-info → whop_sdk-0.0.3.dist-info}/RECORD +126 -50
  125. {whop_sdk-0.0.1.dist-info → whop_sdk-0.0.3.dist-info}/WHEEL +0 -0
  126. {whop_sdk-0.0.1.dist-info → whop_sdk-0.0.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,652 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Union, Optional
6
+ from datetime import datetime
7
+
8
+ import httpx
9
+
10
+ from ..types import PromoCodeStatus, promo_code_list_params, promo_code_create_params
11
+ from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
12
+ from .._utils import maybe_transform, async_maybe_transform
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from ..pagination import SyncCursorPage, AsyncCursorPage
22
+ from .._base_client import AsyncPaginator, make_request_options
23
+ from ..types.promo_code import PromoCode
24
+ from ..types.shared.currency import Currency
25
+ from ..types.promo_code_status import PromoCodeStatus
26
+ from ..types.shared.promo_type import PromoType
27
+ from ..types.promo_code_list_response import PromoCodeListResponse
28
+ from ..types.promo_code_delete_response import PromoCodeDeleteResponse
29
+
30
+ __all__ = ["PromoCodesResource", "AsyncPromoCodesResource"]
31
+
32
+
33
+ class PromoCodesResource(SyncAPIResource):
34
+ @cached_property
35
+ def with_raw_response(self) -> PromoCodesResourceWithRawResponse:
36
+ """
37
+ This property can be used as a prefix for any HTTP method call to return
38
+ the raw response object instead of the parsed content.
39
+
40
+ For more information, see https://www.github.com/whopio/whopsdk-python#accessing-raw-response-data-eg-headers
41
+ """
42
+ return PromoCodesResourceWithRawResponse(self)
43
+
44
+ @cached_property
45
+ def with_streaming_response(self) -> PromoCodesResourceWithStreamingResponse:
46
+ """
47
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
48
+
49
+ For more information, see https://www.github.com/whopio/whopsdk-python#with_streaming_response
50
+ """
51
+ return PromoCodesResourceWithStreamingResponse(self)
52
+
53
+ def create(
54
+ self,
55
+ *,
56
+ amount_off: float,
57
+ base_currency: Currency,
58
+ code: str,
59
+ company_id: str,
60
+ new_users_only: bool,
61
+ promo_duration_months: int,
62
+ promo_type: PromoType,
63
+ churned_users_only: Optional[bool] | Omit = omit,
64
+ existing_memberships_only: Optional[bool] | Omit = omit,
65
+ expires_at: Union[str, datetime, None] | Omit = omit,
66
+ one_per_customer: Optional[bool] | Omit = omit,
67
+ plan_ids: Optional[SequenceNotStr[str]] | Omit = omit,
68
+ product_id: Optional[str] | Omit = omit,
69
+ stock: Optional[int] | Omit = omit,
70
+ unlimited_stock: Optional[bool] | Omit = omit,
71
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
72
+ # The extra values given here take precedence over values defined on the client or passed to this method.
73
+ extra_headers: Headers | None = None,
74
+ extra_query: Query | None = None,
75
+ extra_body: Body | None = None,
76
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
77
+ ) -> PromoCode:
78
+ """
79
+ Create a new promo code for a product or plan
80
+
81
+ Required permissions:
82
+
83
+ - `promo_code:create`
84
+ - `access_pass:basic:read`
85
+
86
+ Args:
87
+ amount_off: The amount off (% or flat amount) for the promo.
88
+
89
+ base_currency: The monetary currency of the promo code.
90
+
91
+ code: The specific code used to apply the promo at checkout.
92
+
93
+ company_id: The id of the company to create the promo code for.
94
+
95
+ new_users_only: Restricts promo use to only users who have never purchased from the company
96
+ before.
97
+
98
+ promo_duration_months: The number of months this promo code is applied and valid for.
99
+
100
+ promo_type: The type (% or flat amount) of the promo.
101
+
102
+ churned_users_only: Restricts promo use to only users who have churned from the company before.
103
+
104
+ existing_memberships_only: Whether this promo code is for existing memberships only (cancelations)
105
+
106
+ expires_at: The date/time of when the promo expires.
107
+
108
+ one_per_customer: Restricts promo use to only be applied once per customer.
109
+
110
+ plan_ids: The IDs of the plans that the promo code applies to. If product_id is provided,
111
+ it will only apply to plans attached to that product
112
+
113
+ product_id: The product to lock the promo code to, if any. If provided will filter out any
114
+ plan ids not attached to this product
115
+
116
+ stock: The quantity limit on the number of uses.
117
+
118
+ unlimited_stock: Whether or not the promo code should have unlimited stock.
119
+
120
+ extra_headers: Send extra headers
121
+
122
+ extra_query: Add additional query parameters to the request
123
+
124
+ extra_body: Add additional JSON properties to the request
125
+
126
+ timeout: Override the client-level default timeout for this request, in seconds
127
+ """
128
+ return self._post(
129
+ "/promo_codes",
130
+ body=maybe_transform(
131
+ {
132
+ "amount_off": amount_off,
133
+ "base_currency": base_currency,
134
+ "code": code,
135
+ "company_id": company_id,
136
+ "new_users_only": new_users_only,
137
+ "promo_duration_months": promo_duration_months,
138
+ "promo_type": promo_type,
139
+ "churned_users_only": churned_users_only,
140
+ "existing_memberships_only": existing_memberships_only,
141
+ "expires_at": expires_at,
142
+ "one_per_customer": one_per_customer,
143
+ "plan_ids": plan_ids,
144
+ "product_id": product_id,
145
+ "stock": stock,
146
+ "unlimited_stock": unlimited_stock,
147
+ },
148
+ promo_code_create_params.PromoCodeCreateParams,
149
+ ),
150
+ options=make_request_options(
151
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
152
+ ),
153
+ cast_to=PromoCode,
154
+ )
155
+
156
+ def retrieve(
157
+ self,
158
+ id: str,
159
+ *,
160
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
161
+ # The extra values given here take precedence over values defined on the client or passed to this method.
162
+ extra_headers: Headers | None = None,
163
+ extra_query: Query | None = None,
164
+ extra_body: Body | None = None,
165
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
166
+ ) -> PromoCode:
167
+ """
168
+ Retrieves a promo code by ID
169
+
170
+ Required permissions:
171
+
172
+ - `promo_code:basic:read`
173
+ - `access_pass:basic:read`
174
+
175
+ Args:
176
+ extra_headers: Send extra headers
177
+
178
+ extra_query: Add additional query parameters to the request
179
+
180
+ extra_body: Add additional JSON properties to the request
181
+
182
+ timeout: Override the client-level default timeout for this request, in seconds
183
+ """
184
+ if not id:
185
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
186
+ return self._get(
187
+ f"/promo_codes/{id}",
188
+ options=make_request_options(
189
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
190
+ ),
191
+ cast_to=PromoCode,
192
+ )
193
+
194
+ def list(
195
+ self,
196
+ *,
197
+ company_id: str,
198
+ after: Optional[str] | Omit = omit,
199
+ before: Optional[str] | Omit = omit,
200
+ first: Optional[int] | Omit = omit,
201
+ last: Optional[int] | Omit = omit,
202
+ plan_ids: Optional[SequenceNotStr[str]] | Omit = omit,
203
+ product_ids: Optional[SequenceNotStr[str]] | Omit = omit,
204
+ status: Optional[PromoCodeStatus] | Omit = omit,
205
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
206
+ # The extra values given here take precedence over values defined on the client or passed to this method.
207
+ extra_headers: Headers | None = None,
208
+ extra_query: Query | None = None,
209
+ extra_body: Body | None = None,
210
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
211
+ ) -> SyncCursorPage[PromoCodeListResponse]:
212
+ """
213
+ Lists promo codes for a company
214
+
215
+ Required permissions:
216
+
217
+ - `promo_code:basic:read`
218
+ - `access_pass:basic:read`
219
+
220
+ Args:
221
+ company_id: The ID of the company to list promo codes for
222
+
223
+ after: Returns the elements in the list that come after the specified cursor.
224
+
225
+ before: Returns the elements in the list that come before the specified cursor.
226
+
227
+ first: Returns the first _n_ elements from the list.
228
+
229
+ last: Returns the last _n_ elements from the list.
230
+
231
+ plan_ids: Filter promo codes by plan ID(s)
232
+
233
+ product_ids: Filter promo codes by product ID(s)
234
+
235
+ status: Statuses for promo codes
236
+
237
+ extra_headers: Send extra headers
238
+
239
+ extra_query: Add additional query parameters to the request
240
+
241
+ extra_body: Add additional JSON properties to the request
242
+
243
+ timeout: Override the client-level default timeout for this request, in seconds
244
+ """
245
+ return self._get_api_list(
246
+ "/promo_codes",
247
+ page=SyncCursorPage[PromoCodeListResponse],
248
+ options=make_request_options(
249
+ extra_headers=extra_headers,
250
+ extra_query=extra_query,
251
+ extra_body=extra_body,
252
+ timeout=timeout,
253
+ query=maybe_transform(
254
+ {
255
+ "company_id": company_id,
256
+ "after": after,
257
+ "before": before,
258
+ "first": first,
259
+ "last": last,
260
+ "plan_ids": plan_ids,
261
+ "product_ids": product_ids,
262
+ "status": status,
263
+ },
264
+ promo_code_list_params.PromoCodeListParams,
265
+ ),
266
+ ),
267
+ model=PromoCodeListResponse,
268
+ )
269
+
270
+ def delete(
271
+ self,
272
+ id: str,
273
+ *,
274
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
275
+ # The extra values given here take precedence over values defined on the client or passed to this method.
276
+ extra_headers: Headers | None = None,
277
+ extra_query: Query | None = None,
278
+ extra_body: Body | None = None,
279
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
280
+ ) -> PromoCodeDeleteResponse:
281
+ """
282
+ Archive a promo code, preventing further use
283
+
284
+ Required permissions:
285
+
286
+ - `promo_code:delete`
287
+
288
+ Args:
289
+ extra_headers: Send extra headers
290
+
291
+ extra_query: Add additional query parameters to the request
292
+
293
+ extra_body: Add additional JSON properties to the request
294
+
295
+ timeout: Override the client-level default timeout for this request, in seconds
296
+ """
297
+ if not id:
298
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
299
+ return self._delete(
300
+ f"/promo_codes/{id}",
301
+ options=make_request_options(
302
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
303
+ ),
304
+ cast_to=PromoCodeDeleteResponse,
305
+ )
306
+
307
+
308
+ class AsyncPromoCodesResource(AsyncAPIResource):
309
+ @cached_property
310
+ def with_raw_response(self) -> AsyncPromoCodesResourceWithRawResponse:
311
+ """
312
+ This property can be used as a prefix for any HTTP method call to return
313
+ the raw response object instead of the parsed content.
314
+
315
+ For more information, see https://www.github.com/whopio/whopsdk-python#accessing-raw-response-data-eg-headers
316
+ """
317
+ return AsyncPromoCodesResourceWithRawResponse(self)
318
+
319
+ @cached_property
320
+ def with_streaming_response(self) -> AsyncPromoCodesResourceWithStreamingResponse:
321
+ """
322
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
323
+
324
+ For more information, see https://www.github.com/whopio/whopsdk-python#with_streaming_response
325
+ """
326
+ return AsyncPromoCodesResourceWithStreamingResponse(self)
327
+
328
+ async def create(
329
+ self,
330
+ *,
331
+ amount_off: float,
332
+ base_currency: Currency,
333
+ code: str,
334
+ company_id: str,
335
+ new_users_only: bool,
336
+ promo_duration_months: int,
337
+ promo_type: PromoType,
338
+ churned_users_only: Optional[bool] | Omit = omit,
339
+ existing_memberships_only: Optional[bool] | Omit = omit,
340
+ expires_at: Union[str, datetime, None] | Omit = omit,
341
+ one_per_customer: Optional[bool] | Omit = omit,
342
+ plan_ids: Optional[SequenceNotStr[str]] | Omit = omit,
343
+ product_id: Optional[str] | Omit = omit,
344
+ stock: Optional[int] | Omit = omit,
345
+ unlimited_stock: Optional[bool] | Omit = omit,
346
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
347
+ # The extra values given here take precedence over values defined on the client or passed to this method.
348
+ extra_headers: Headers | None = None,
349
+ extra_query: Query | None = None,
350
+ extra_body: Body | None = None,
351
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
352
+ ) -> PromoCode:
353
+ """
354
+ Create a new promo code for a product or plan
355
+
356
+ Required permissions:
357
+
358
+ - `promo_code:create`
359
+ - `access_pass:basic:read`
360
+
361
+ Args:
362
+ amount_off: The amount off (% or flat amount) for the promo.
363
+
364
+ base_currency: The monetary currency of the promo code.
365
+
366
+ code: The specific code used to apply the promo at checkout.
367
+
368
+ company_id: The id of the company to create the promo code for.
369
+
370
+ new_users_only: Restricts promo use to only users who have never purchased from the company
371
+ before.
372
+
373
+ promo_duration_months: The number of months this promo code is applied and valid for.
374
+
375
+ promo_type: The type (% or flat amount) of the promo.
376
+
377
+ churned_users_only: Restricts promo use to only users who have churned from the company before.
378
+
379
+ existing_memberships_only: Whether this promo code is for existing memberships only (cancelations)
380
+
381
+ expires_at: The date/time of when the promo expires.
382
+
383
+ one_per_customer: Restricts promo use to only be applied once per customer.
384
+
385
+ plan_ids: The IDs of the plans that the promo code applies to. If product_id is provided,
386
+ it will only apply to plans attached to that product
387
+
388
+ product_id: The product to lock the promo code to, if any. If provided will filter out any
389
+ plan ids not attached to this product
390
+
391
+ stock: The quantity limit on the number of uses.
392
+
393
+ unlimited_stock: Whether or not the promo code should have unlimited stock.
394
+
395
+ extra_headers: Send extra headers
396
+
397
+ extra_query: Add additional query parameters to the request
398
+
399
+ extra_body: Add additional JSON properties to the request
400
+
401
+ timeout: Override the client-level default timeout for this request, in seconds
402
+ """
403
+ return await self._post(
404
+ "/promo_codes",
405
+ body=await async_maybe_transform(
406
+ {
407
+ "amount_off": amount_off,
408
+ "base_currency": base_currency,
409
+ "code": code,
410
+ "company_id": company_id,
411
+ "new_users_only": new_users_only,
412
+ "promo_duration_months": promo_duration_months,
413
+ "promo_type": promo_type,
414
+ "churned_users_only": churned_users_only,
415
+ "existing_memberships_only": existing_memberships_only,
416
+ "expires_at": expires_at,
417
+ "one_per_customer": one_per_customer,
418
+ "plan_ids": plan_ids,
419
+ "product_id": product_id,
420
+ "stock": stock,
421
+ "unlimited_stock": unlimited_stock,
422
+ },
423
+ promo_code_create_params.PromoCodeCreateParams,
424
+ ),
425
+ options=make_request_options(
426
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
427
+ ),
428
+ cast_to=PromoCode,
429
+ )
430
+
431
+ async def retrieve(
432
+ self,
433
+ id: str,
434
+ *,
435
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
436
+ # The extra values given here take precedence over values defined on the client or passed to this method.
437
+ extra_headers: Headers | None = None,
438
+ extra_query: Query | None = None,
439
+ extra_body: Body | None = None,
440
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
441
+ ) -> PromoCode:
442
+ """
443
+ Retrieves a promo code by ID
444
+
445
+ Required permissions:
446
+
447
+ - `promo_code:basic:read`
448
+ - `access_pass:basic:read`
449
+
450
+ Args:
451
+ extra_headers: Send extra headers
452
+
453
+ extra_query: Add additional query parameters to the request
454
+
455
+ extra_body: Add additional JSON properties to the request
456
+
457
+ timeout: Override the client-level default timeout for this request, in seconds
458
+ """
459
+ if not id:
460
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
461
+ return await self._get(
462
+ f"/promo_codes/{id}",
463
+ options=make_request_options(
464
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
465
+ ),
466
+ cast_to=PromoCode,
467
+ )
468
+
469
+ def list(
470
+ self,
471
+ *,
472
+ company_id: str,
473
+ after: Optional[str] | Omit = omit,
474
+ before: Optional[str] | Omit = omit,
475
+ first: Optional[int] | Omit = omit,
476
+ last: Optional[int] | Omit = omit,
477
+ plan_ids: Optional[SequenceNotStr[str]] | Omit = omit,
478
+ product_ids: Optional[SequenceNotStr[str]] | Omit = omit,
479
+ status: Optional[PromoCodeStatus] | Omit = omit,
480
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
481
+ # The extra values given here take precedence over values defined on the client or passed to this method.
482
+ extra_headers: Headers | None = None,
483
+ extra_query: Query | None = None,
484
+ extra_body: Body | None = None,
485
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
486
+ ) -> AsyncPaginator[PromoCodeListResponse, AsyncCursorPage[PromoCodeListResponse]]:
487
+ """
488
+ Lists promo codes for a company
489
+
490
+ Required permissions:
491
+
492
+ - `promo_code:basic:read`
493
+ - `access_pass:basic:read`
494
+
495
+ Args:
496
+ company_id: The ID of the company to list promo codes for
497
+
498
+ after: Returns the elements in the list that come after the specified cursor.
499
+
500
+ before: Returns the elements in the list that come before the specified cursor.
501
+
502
+ first: Returns the first _n_ elements from the list.
503
+
504
+ last: Returns the last _n_ elements from the list.
505
+
506
+ plan_ids: Filter promo codes by plan ID(s)
507
+
508
+ product_ids: Filter promo codes by product ID(s)
509
+
510
+ status: Statuses for promo codes
511
+
512
+ extra_headers: Send extra headers
513
+
514
+ extra_query: Add additional query parameters to the request
515
+
516
+ extra_body: Add additional JSON properties to the request
517
+
518
+ timeout: Override the client-level default timeout for this request, in seconds
519
+ """
520
+ return self._get_api_list(
521
+ "/promo_codes",
522
+ page=AsyncCursorPage[PromoCodeListResponse],
523
+ options=make_request_options(
524
+ extra_headers=extra_headers,
525
+ extra_query=extra_query,
526
+ extra_body=extra_body,
527
+ timeout=timeout,
528
+ query=maybe_transform(
529
+ {
530
+ "company_id": company_id,
531
+ "after": after,
532
+ "before": before,
533
+ "first": first,
534
+ "last": last,
535
+ "plan_ids": plan_ids,
536
+ "product_ids": product_ids,
537
+ "status": status,
538
+ },
539
+ promo_code_list_params.PromoCodeListParams,
540
+ ),
541
+ ),
542
+ model=PromoCodeListResponse,
543
+ )
544
+
545
+ async def delete(
546
+ self,
547
+ id: str,
548
+ *,
549
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
550
+ # The extra values given here take precedence over values defined on the client or passed to this method.
551
+ extra_headers: Headers | None = None,
552
+ extra_query: Query | None = None,
553
+ extra_body: Body | None = None,
554
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
555
+ ) -> PromoCodeDeleteResponse:
556
+ """
557
+ Archive a promo code, preventing further use
558
+
559
+ Required permissions:
560
+
561
+ - `promo_code:delete`
562
+
563
+ Args:
564
+ extra_headers: Send extra headers
565
+
566
+ extra_query: Add additional query parameters to the request
567
+
568
+ extra_body: Add additional JSON properties to the request
569
+
570
+ timeout: Override the client-level default timeout for this request, in seconds
571
+ """
572
+ if not id:
573
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
574
+ return await self._delete(
575
+ f"/promo_codes/{id}",
576
+ options=make_request_options(
577
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
578
+ ),
579
+ cast_to=PromoCodeDeleteResponse,
580
+ )
581
+
582
+
583
+ class PromoCodesResourceWithRawResponse:
584
+ def __init__(self, promo_codes: PromoCodesResource) -> None:
585
+ self._promo_codes = promo_codes
586
+
587
+ self.create = to_raw_response_wrapper(
588
+ promo_codes.create,
589
+ )
590
+ self.retrieve = to_raw_response_wrapper(
591
+ promo_codes.retrieve,
592
+ )
593
+ self.list = to_raw_response_wrapper(
594
+ promo_codes.list,
595
+ )
596
+ self.delete = to_raw_response_wrapper(
597
+ promo_codes.delete,
598
+ )
599
+
600
+
601
+ class AsyncPromoCodesResourceWithRawResponse:
602
+ def __init__(self, promo_codes: AsyncPromoCodesResource) -> None:
603
+ self._promo_codes = promo_codes
604
+
605
+ self.create = async_to_raw_response_wrapper(
606
+ promo_codes.create,
607
+ )
608
+ self.retrieve = async_to_raw_response_wrapper(
609
+ promo_codes.retrieve,
610
+ )
611
+ self.list = async_to_raw_response_wrapper(
612
+ promo_codes.list,
613
+ )
614
+ self.delete = async_to_raw_response_wrapper(
615
+ promo_codes.delete,
616
+ )
617
+
618
+
619
+ class PromoCodesResourceWithStreamingResponse:
620
+ def __init__(self, promo_codes: PromoCodesResource) -> None:
621
+ self._promo_codes = promo_codes
622
+
623
+ self.create = to_streamed_response_wrapper(
624
+ promo_codes.create,
625
+ )
626
+ self.retrieve = to_streamed_response_wrapper(
627
+ promo_codes.retrieve,
628
+ )
629
+ self.list = to_streamed_response_wrapper(
630
+ promo_codes.list,
631
+ )
632
+ self.delete = to_streamed_response_wrapper(
633
+ promo_codes.delete,
634
+ )
635
+
636
+
637
+ class AsyncPromoCodesResourceWithStreamingResponse:
638
+ def __init__(self, promo_codes: AsyncPromoCodesResource) -> None:
639
+ self._promo_codes = promo_codes
640
+
641
+ self.create = async_to_streamed_response_wrapper(
642
+ promo_codes.create,
643
+ )
644
+ self.retrieve = async_to_streamed_response_wrapper(
645
+ promo_codes.retrieve,
646
+ )
647
+ self.list = async_to_streamed_response_wrapper(
648
+ promo_codes.list,
649
+ )
650
+ self.delete = async_to_streamed_response_wrapper(
651
+ promo_codes.delete,
652
+ )