whop-sdk 0.0.1__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 (212) hide show
  1. whop_sdk/__init__.py +94 -0
  2. whop_sdk/_base_client.py +1995 -0
  3. whop_sdk/_client.py +664 -0
  4. whop_sdk/_compat.py +219 -0
  5. whop_sdk/_constants.py +14 -0
  6. whop_sdk/_exceptions.py +112 -0
  7. whop_sdk/_files.py +123 -0
  8. whop_sdk/_models.py +835 -0
  9. whop_sdk/_qs.py +150 -0
  10. whop_sdk/_resource.py +43 -0
  11. whop_sdk/_response.py +830 -0
  12. whop_sdk/_streaming.py +333 -0
  13. whop_sdk/_types.py +260 -0
  14. whop_sdk/_utils/__init__.py +64 -0
  15. whop_sdk/_utils/_compat.py +45 -0
  16. whop_sdk/_utils/_datetime_parse.py +136 -0
  17. whop_sdk/_utils/_logs.py +25 -0
  18. whop_sdk/_utils/_proxy.py +65 -0
  19. whop_sdk/_utils/_reflection.py +42 -0
  20. whop_sdk/_utils/_resources_proxy.py +24 -0
  21. whop_sdk/_utils/_streams.py +12 -0
  22. whop_sdk/_utils/_sync.py +86 -0
  23. whop_sdk/_utils/_transform.py +457 -0
  24. whop_sdk/_utils/_typing.py +156 -0
  25. whop_sdk/_utils/_utils.py +421 -0
  26. whop_sdk/_version.py +4 -0
  27. whop_sdk/lib/.keep +4 -0
  28. whop_sdk/pagination.py +61 -0
  29. whop_sdk/py.typed +0 -0
  30. whop_sdk/resources/__init__.py +316 -0
  31. whop_sdk/resources/app_builds.py +562 -0
  32. whop_sdk/resources/apps.py +665 -0
  33. whop_sdk/resources/authorized_users.py +336 -0
  34. whop_sdk/resources/chat_channels.py +469 -0
  35. whop_sdk/resources/checkout_configurations.py +464 -0
  36. whop_sdk/resources/companies.py +171 -0
  37. whop_sdk/resources/course_lesson_interactions.py +343 -0
  38. whop_sdk/resources/entries.py +539 -0
  39. whop_sdk/resources/experiences.py +859 -0
  40. whop_sdk/resources/forum_posts.py +512 -0
  41. whop_sdk/resources/invoices.py +633 -0
  42. whop_sdk/resources/ledger_accounts.py +171 -0
  43. whop_sdk/resources/memberships.py +810 -0
  44. whop_sdk/resources/messages.py +446 -0
  45. whop_sdk/resources/payments.py +761 -0
  46. whop_sdk/resources/plans.py +906 -0
  47. whop_sdk/resources/products.py +969 -0
  48. whop_sdk/resources/reactions.py +423 -0
  49. whop_sdk/resources/shipments.py +451 -0
  50. whop_sdk/resources/support_channels.py +455 -0
  51. whop_sdk/resources/transfers.py +488 -0
  52. whop_sdk/resources/users.py +248 -0
  53. whop_sdk/resources/webhooks.py +69 -0
  54. whop_sdk/types/__init__.py +135 -0
  55. whop_sdk/types/app_build_create_params.py +59 -0
  56. whop_sdk/types/app_build_list_params.py +34 -0
  57. whop_sdk/types/app_build_list_response.py +50 -0
  58. whop_sdk/types/app_create_params.py +19 -0
  59. whop_sdk/types/app_list_params.py +54 -0
  60. whop_sdk/types/app_list_response.py +91 -0
  61. whop_sdk/types/app_update_params.py +58 -0
  62. whop_sdk/types/authorized_user_list_params.py +33 -0
  63. whop_sdk/types/authorized_user_list_response.py +33 -0
  64. whop_sdk/types/authorized_user_retrieve_response.py +33 -0
  65. whop_sdk/types/chat_channel_list_params.py +28 -0
  66. whop_sdk/types/chat_channel_list_response.py +43 -0
  67. whop_sdk/types/chat_channel_update_params.py +32 -0
  68. whop_sdk/types/checkout_configuration_create_params.py +129 -0
  69. whop_sdk/types/checkout_configuration_list_params.py +33 -0
  70. whop_sdk/types/checkout_configuration_list_response.py +66 -0
  71. whop_sdk/types/course_lesson_interaction_list_params.py +34 -0
  72. whop_sdk/types/entry_approve_response.py +10 -0
  73. whop_sdk/types/entry_list_params.py +44 -0
  74. whop_sdk/types/entry_list_response.py +56 -0
  75. whop_sdk/types/experience_attach_params.py +12 -0
  76. whop_sdk/types/experience_create_params.py +22 -0
  77. whop_sdk/types/experience_delete_response.py +7 -0
  78. whop_sdk/types/experience_detach_params.py +12 -0
  79. whop_sdk/types/experience_list_params.py +31 -0
  80. whop_sdk/types/experience_list_response.py +47 -0
  81. whop_sdk/types/experience_update_params.py +41 -0
  82. whop_sdk/types/forum_post_create_params.py +85 -0
  83. whop_sdk/types/forum_post_list_params.py +31 -0
  84. whop_sdk/types/forum_post_list_response.py +53 -0
  85. whop_sdk/types/invoice_create_params.py +137 -0
  86. whop_sdk/types/invoice_create_response.py +16 -0
  87. whop_sdk/types/invoice_created_webhook_event.py +26 -0
  88. whop_sdk/types/invoice_list_params.py +50 -0
  89. whop_sdk/types/invoice_paid_webhook_event.py +26 -0
  90. whop_sdk/types/invoice_past_due_webhook_event.py +26 -0
  91. whop_sdk/types/invoice_void_response.py +7 -0
  92. whop_sdk/types/invoice_voided_webhook_event.py +26 -0
  93. whop_sdk/types/ledger_account_retrieve_response.py +78 -0
  94. whop_sdk/types/membership_cancel_params.py +13 -0
  95. whop_sdk/types/membership_list_params.py +70 -0
  96. whop_sdk/types/membership_list_response.py +117 -0
  97. whop_sdk/types/membership_pause_params.py +16 -0
  98. whop_sdk/types/membership_update_params.py +13 -0
  99. whop_sdk/types/message_create_params.py +51 -0
  100. whop_sdk/types/message_list_params.py +30 -0
  101. whop_sdk/types/message_list_response.py +90 -0
  102. whop_sdk/types/payment_list_params.py +72 -0
  103. whop_sdk/types/payment_list_response.py +221 -0
  104. whop_sdk/types/payment_refund_params.py +13 -0
  105. whop_sdk/types/plan_create_params.py +106 -0
  106. whop_sdk/types/plan_delete_response.py +7 -0
  107. whop_sdk/types/plan_list_params.py +49 -0
  108. whop_sdk/types/plan_list_response.py +92 -0
  109. whop_sdk/types/plan_update_params.py +95 -0
  110. whop_sdk/types/product_create_params.py +170 -0
  111. whop_sdk/types/product_delete_response.py +7 -0
  112. whop_sdk/types/product_list_params.py +41 -0
  113. whop_sdk/types/product_update_params.py +90 -0
  114. whop_sdk/types/reaction_create_params.py +19 -0
  115. whop_sdk/types/reaction_list_params.py +25 -0
  116. whop_sdk/types/reaction_list_response.py +32 -0
  117. whop_sdk/types/shared/__init__.py +55 -0
  118. whop_sdk/types/shared/access_pass_type.py +7 -0
  119. whop_sdk/types/shared/app.py +159 -0
  120. whop_sdk/types/shared/app_build.py +50 -0
  121. whop_sdk/types/shared/app_build_platforms.py +7 -0
  122. whop_sdk/types/shared/app_build_statuses.py +7 -0
  123. whop_sdk/types/shared/app_statuses.py +7 -0
  124. whop_sdk/types/shared/app_view_type.py +7 -0
  125. whop_sdk/types/shared/authorized_user_roles.py +9 -0
  126. whop_sdk/types/shared/business_types.py +22 -0
  127. whop_sdk/types/shared/chat_channel.py +43 -0
  128. whop_sdk/types/shared/checkout_configuration.py +66 -0
  129. whop_sdk/types/shared/collection_method.py +7 -0
  130. whop_sdk/types/shared/company.py +71 -0
  131. whop_sdk/types/shared/course_lesson_interaction.py +44 -0
  132. whop_sdk/types/shared/course_lesson_interaction_list_item.py +44 -0
  133. whop_sdk/types/shared/currency.py +92 -0
  134. whop_sdk/types/shared/custom_cta.py +21 -0
  135. whop_sdk/types/shared/direction.py +7 -0
  136. whop_sdk/types/shared/dms_post_types.py +7 -0
  137. whop_sdk/types/shared/entry.py +70 -0
  138. whop_sdk/types/shared/entry_status.py +7 -0
  139. whop_sdk/types/shared/experience.py +66 -0
  140. whop_sdk/types/shared/forum_post.py +53 -0
  141. whop_sdk/types/shared/friendly_receipt_status.py +24 -0
  142. whop_sdk/types/shared/global_affiliate_status.py +7 -0
  143. whop_sdk/types/shared/industry_types.py +67 -0
  144. whop_sdk/types/shared/invoice.py +61 -0
  145. whop_sdk/types/shared/invoice_list_item.py +61 -0
  146. whop_sdk/types/shared/invoice_status.py +7 -0
  147. whop_sdk/types/shared/membership.py +117 -0
  148. whop_sdk/types/shared/membership_status.py +9 -0
  149. whop_sdk/types/shared/message.py +90 -0
  150. whop_sdk/types/shared/page_info.py +21 -0
  151. whop_sdk/types/shared/payment.py +211 -0
  152. whop_sdk/types/shared/plan.py +123 -0
  153. whop_sdk/types/shared/plan_type.py +7 -0
  154. whop_sdk/types/shared/product.py +124 -0
  155. whop_sdk/types/shared/product_list_item.py +49 -0
  156. whop_sdk/types/shared/promo_type.py +7 -0
  157. whop_sdk/types/shared/reaction.py +32 -0
  158. whop_sdk/types/shared/receipt_status.py +7 -0
  159. whop_sdk/types/shared/release_method.py +7 -0
  160. whop_sdk/types/shared/shipment.py +48 -0
  161. whop_sdk/types/shared/shipment_carrier.py +84 -0
  162. whop_sdk/types/shared/shipment_status.py +18 -0
  163. whop_sdk/types/shared/shipment_substatus.py +36 -0
  164. whop_sdk/types/shared/support_channel.py +39 -0
  165. whop_sdk/types/shared/tax_type.py +7 -0
  166. whop_sdk/types/shared/transfer.py +109 -0
  167. whop_sdk/types/shared/visibility.py +7 -0
  168. whop_sdk/types/shared/visibility_filter.py +9 -0
  169. whop_sdk/types/shared/who_can_post.py +7 -0
  170. whop_sdk/types/shared/who_can_react.py +7 -0
  171. whop_sdk/types/shared_params/__init__.py +27 -0
  172. whop_sdk/types/shared_params/access_pass_type.py +9 -0
  173. whop_sdk/types/shared_params/app_build_platforms.py +9 -0
  174. whop_sdk/types/shared_params/app_build_statuses.py +9 -0
  175. whop_sdk/types/shared_params/app_statuses.py +9 -0
  176. whop_sdk/types/shared_params/app_view_type.py +9 -0
  177. whop_sdk/types/shared_params/authorized_user_roles.py +11 -0
  178. whop_sdk/types/shared_params/business_types.py +24 -0
  179. whop_sdk/types/shared_params/collection_method.py +9 -0
  180. whop_sdk/types/shared_params/currency.py +94 -0
  181. whop_sdk/types/shared_params/custom_cta.py +23 -0
  182. whop_sdk/types/shared_params/direction.py +9 -0
  183. whop_sdk/types/shared_params/entry_status.py +9 -0
  184. whop_sdk/types/shared_params/friendly_receipt_status.py +26 -0
  185. whop_sdk/types/shared_params/global_affiliate_status.py +9 -0
  186. whop_sdk/types/shared_params/industry_types.py +69 -0
  187. whop_sdk/types/shared_params/invoice_status.py +9 -0
  188. whop_sdk/types/shared_params/membership_status.py +11 -0
  189. whop_sdk/types/shared_params/plan_type.py +9 -0
  190. whop_sdk/types/shared_params/receipt_status.py +9 -0
  191. whop_sdk/types/shared_params/release_method.py +9 -0
  192. whop_sdk/types/shared_params/tax_type.py +9 -0
  193. whop_sdk/types/shared_params/visibility.py +9 -0
  194. whop_sdk/types/shared_params/visibility_filter.py +11 -0
  195. whop_sdk/types/shared_params/who_can_post.py +9 -0
  196. whop_sdk/types/shared_params/who_can_react.py +9 -0
  197. whop_sdk/types/shipment_create_params.py +18 -0
  198. whop_sdk/types/shipment_list_params.py +31 -0
  199. whop_sdk/types/shipment_list_response.py +48 -0
  200. whop_sdk/types/support_channel_create_params.py +15 -0
  201. whop_sdk/types/support_channel_list_params.py +40 -0
  202. whop_sdk/types/support_channel_list_response.py +39 -0
  203. whop_sdk/types/transfer_create_params.py +36 -0
  204. whop_sdk/types/transfer_list_params.py +42 -0
  205. whop_sdk/types/transfer_list_response.py +35 -0
  206. whop_sdk/types/unwrap_webhook_event.py +15 -0
  207. whop_sdk/types/user_check_access_response.py +15 -0
  208. whop_sdk/types/user_retrieve_response.py +25 -0
  209. whop_sdk-0.0.1.dist-info/METADATA +522 -0
  210. whop_sdk-0.0.1.dist-info/RECORD +212 -0
  211. whop_sdk-0.0.1.dist-info/WHEEL +4 -0
  212. whop_sdk-0.0.1.dist-info/licenses/LICENSE +201 -0
whop_sdk/_client.py ADDED
@@ -0,0 +1,664 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Any, Mapping
7
+ from typing_extensions import Self, override
8
+
9
+ import httpx
10
+
11
+ from . import _exceptions
12
+ from ._qs import Querystring
13
+ from ._types import (
14
+ Omit,
15
+ Timeout,
16
+ NotGiven,
17
+ Transport,
18
+ ProxiesTypes,
19
+ RequestOptions,
20
+ not_given,
21
+ )
22
+ from ._utils import is_given, get_async_library
23
+ from ._version import __version__
24
+ from .resources import (
25
+ apps,
26
+ plans,
27
+ users,
28
+ entries,
29
+ invoices,
30
+ messages,
31
+ payments,
32
+ products,
33
+ webhooks,
34
+ companies,
35
+ reactions,
36
+ shipments,
37
+ transfers,
38
+ app_builds,
39
+ experiences,
40
+ forum_posts,
41
+ memberships,
42
+ chat_channels,
43
+ ledger_accounts,
44
+ authorized_users,
45
+ support_channels,
46
+ checkout_configurations,
47
+ course_lesson_interactions,
48
+ )
49
+ from ._streaming import Stream as Stream, AsyncStream as AsyncStream
50
+ from ._exceptions import WhopError, APIStatusError
51
+ from ._base_client import (
52
+ DEFAULT_MAX_RETRIES,
53
+ SyncAPIClient,
54
+ AsyncAPIClient,
55
+ )
56
+
57
+ __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Whop", "AsyncWhop", "Client", "AsyncClient"]
58
+
59
+
60
+ class Whop(SyncAPIClient):
61
+ apps: apps.AppsResource
62
+ invoices: invoices.InvoicesResource
63
+ course_lesson_interactions: course_lesson_interactions.CourseLessonInteractionsResource
64
+ products: products.ProductsResource
65
+ companies: companies.CompaniesResource
66
+ webhooks: webhooks.WebhooksResource
67
+ plans: plans.PlansResource
68
+ entries: entries.EntriesResource
69
+ forum_posts: forum_posts.ForumPostsResource
70
+ transfers: transfers.TransfersResource
71
+ ledger_accounts: ledger_accounts.LedgerAccountsResource
72
+ memberships: memberships.MembershipsResource
73
+ authorized_users: authorized_users.AuthorizedUsersResource
74
+ app_builds: app_builds.AppBuildsResource
75
+ shipments: shipments.ShipmentsResource
76
+ checkout_configurations: checkout_configurations.CheckoutConfigurationsResource
77
+ messages: messages.MessagesResource
78
+ chat_channels: chat_channels.ChatChannelsResource
79
+ users: users.UsersResource
80
+ payments: payments.PaymentsResource
81
+ support_channels: support_channels.SupportChannelsResource
82
+ experiences: experiences.ExperiencesResource
83
+ reactions: reactions.ReactionsResource
84
+ with_raw_response: WhopWithRawResponse
85
+ with_streaming_response: WhopWithStreamedResponse
86
+
87
+ # client options
88
+ api_key: str
89
+ webhook_key: str | None
90
+ app_id: str
91
+
92
+ def __init__(
93
+ self,
94
+ *,
95
+ api_key: str | None = None,
96
+ webhook_key: str | None = None,
97
+ app_id: str | None = None,
98
+ base_url: str | httpx.URL | None = None,
99
+ timeout: float | Timeout | None | NotGiven = not_given,
100
+ max_retries: int = DEFAULT_MAX_RETRIES,
101
+ default_headers: Mapping[str, str] | None = None,
102
+ default_query: Mapping[str, object] | None = None,
103
+ # Configure a custom httpx client.
104
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
105
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
106
+ http_client: httpx.Client | None = None,
107
+ # Enable or disable schema validation for data returned by the API.
108
+ # When enabled an error APIResponseValidationError is raised
109
+ # if the API responds with invalid data for the expected schema.
110
+ #
111
+ # This parameter may be removed or changed in the future.
112
+ # If you rely on this feature, please open a GitHub issue
113
+ # outlining your use-case to help us decide if it should be
114
+ # part of our public interface in the future.
115
+ _strict_response_validation: bool = False,
116
+ ) -> None:
117
+ """Construct a new synchronous Whop client instance.
118
+
119
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
120
+ - `api_key` from `WHOP_API_KEY`
121
+ - `webhook_key` from `WHOP_WEBHOOK_SECRET`
122
+ - `app_id` from `WHOP_APP_ID`
123
+ """
124
+ if api_key is None:
125
+ api_key = os.environ.get("WHOP_API_KEY")
126
+ if api_key is None:
127
+ raise WhopError(
128
+ "The api_key client option must be set either by passing api_key to the client or by setting the WHOP_API_KEY environment variable"
129
+ )
130
+ self.api_key = api_key
131
+
132
+ if webhook_key is None:
133
+ webhook_key = os.environ.get("WHOP_WEBHOOK_SECRET")
134
+ self.webhook_key = webhook_key
135
+
136
+ if app_id is None:
137
+ app_id = os.environ.get("WHOP_APP_ID")
138
+ if app_id is None:
139
+ raise WhopError(
140
+ "The app_id client option must be set either by passing app_id to the client or by setting the WHOP_APP_ID environment variable"
141
+ )
142
+ self.app_id = app_id
143
+
144
+ if base_url is None:
145
+ base_url = os.environ.get("WHOP_BASE_URL")
146
+ if base_url is None:
147
+ base_url = f"https://api.whop.com/api/v1"
148
+
149
+ super().__init__(
150
+ version=__version__,
151
+ base_url=base_url,
152
+ max_retries=max_retries,
153
+ timeout=timeout,
154
+ http_client=http_client,
155
+ custom_headers=default_headers,
156
+ custom_query=default_query,
157
+ _strict_response_validation=_strict_response_validation,
158
+ )
159
+
160
+ self.apps = apps.AppsResource(self)
161
+ self.invoices = invoices.InvoicesResource(self)
162
+ self.course_lesson_interactions = course_lesson_interactions.CourseLessonInteractionsResource(self)
163
+ self.products = products.ProductsResource(self)
164
+ self.companies = companies.CompaniesResource(self)
165
+ self.webhooks = webhooks.WebhooksResource(self)
166
+ self.plans = plans.PlansResource(self)
167
+ self.entries = entries.EntriesResource(self)
168
+ self.forum_posts = forum_posts.ForumPostsResource(self)
169
+ self.transfers = transfers.TransfersResource(self)
170
+ self.ledger_accounts = ledger_accounts.LedgerAccountsResource(self)
171
+ self.memberships = memberships.MembershipsResource(self)
172
+ self.authorized_users = authorized_users.AuthorizedUsersResource(self)
173
+ self.app_builds = app_builds.AppBuildsResource(self)
174
+ self.shipments = shipments.ShipmentsResource(self)
175
+ self.checkout_configurations = checkout_configurations.CheckoutConfigurationsResource(self)
176
+ self.messages = messages.MessagesResource(self)
177
+ self.chat_channels = chat_channels.ChatChannelsResource(self)
178
+ self.users = users.UsersResource(self)
179
+ self.payments = payments.PaymentsResource(self)
180
+ self.support_channels = support_channels.SupportChannelsResource(self)
181
+ self.experiences = experiences.ExperiencesResource(self)
182
+ self.reactions = reactions.ReactionsResource(self)
183
+ self.with_raw_response = WhopWithRawResponse(self)
184
+ self.with_streaming_response = WhopWithStreamedResponse(self)
185
+
186
+ @property
187
+ @override
188
+ def qs(self) -> Querystring:
189
+ return Querystring(array_format="comma")
190
+
191
+ @property
192
+ @override
193
+ def auth_headers(self) -> dict[str, str]:
194
+ api_key = self.api_key
195
+ return {"Authorization": f"Bearer {api_key}"}
196
+
197
+ @property
198
+ @override
199
+ def default_headers(self) -> dict[str, str | Omit]:
200
+ return {
201
+ **super().default_headers,
202
+ "X-Stainless-Async": "false",
203
+ "X-Whop-App-Id": self.app_id,
204
+ **self._custom_headers,
205
+ }
206
+
207
+ def copy(
208
+ self,
209
+ *,
210
+ api_key: str | None = None,
211
+ webhook_key: str | None = None,
212
+ app_id: str | None = None,
213
+ base_url: str | httpx.URL | None = None,
214
+ timeout: float | Timeout | None | NotGiven = not_given,
215
+ http_client: httpx.Client | None = None,
216
+ max_retries: int | NotGiven = not_given,
217
+ default_headers: Mapping[str, str] | None = None,
218
+ set_default_headers: Mapping[str, str] | None = None,
219
+ default_query: Mapping[str, object] | None = None,
220
+ set_default_query: Mapping[str, object] | None = None,
221
+ _extra_kwargs: Mapping[str, Any] = {},
222
+ ) -> Self:
223
+ """
224
+ Create a new client instance re-using the same options given to the current client with optional overriding.
225
+ """
226
+ if default_headers is not None and set_default_headers is not None:
227
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
228
+
229
+ if default_query is not None and set_default_query is not None:
230
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
231
+
232
+ headers = self._custom_headers
233
+ if default_headers is not None:
234
+ headers = {**headers, **default_headers}
235
+ elif set_default_headers is not None:
236
+ headers = set_default_headers
237
+
238
+ params = self._custom_query
239
+ if default_query is not None:
240
+ params = {**params, **default_query}
241
+ elif set_default_query is not None:
242
+ params = set_default_query
243
+
244
+ http_client = http_client or self._client
245
+ return self.__class__(
246
+ api_key=api_key or self.api_key,
247
+ webhook_key=webhook_key or self.webhook_key,
248
+ app_id=app_id or self.app_id,
249
+ base_url=base_url or self.base_url,
250
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
251
+ http_client=http_client,
252
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
253
+ default_headers=headers,
254
+ default_query=params,
255
+ **_extra_kwargs,
256
+ )
257
+
258
+ # Alias for `copy` for nicer inline usage, e.g.
259
+ # client.with_options(timeout=10).foo.create(...)
260
+ with_options = copy
261
+
262
+ @override
263
+ def _make_status_error(
264
+ self,
265
+ err_msg: str,
266
+ *,
267
+ body: object,
268
+ response: httpx.Response,
269
+ ) -> APIStatusError:
270
+ if response.status_code == 400:
271
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
272
+
273
+ if response.status_code == 401:
274
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
275
+
276
+ if response.status_code == 403:
277
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
278
+
279
+ if response.status_code == 404:
280
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
281
+
282
+ if response.status_code == 409:
283
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
284
+
285
+ if response.status_code == 422:
286
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
287
+
288
+ if response.status_code == 429:
289
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
290
+
291
+ if response.status_code >= 500:
292
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
293
+ return APIStatusError(err_msg, response=response, body=body)
294
+
295
+
296
+ class AsyncWhop(AsyncAPIClient):
297
+ apps: apps.AsyncAppsResource
298
+ invoices: invoices.AsyncInvoicesResource
299
+ course_lesson_interactions: course_lesson_interactions.AsyncCourseLessonInteractionsResource
300
+ products: products.AsyncProductsResource
301
+ companies: companies.AsyncCompaniesResource
302
+ webhooks: webhooks.AsyncWebhooksResource
303
+ plans: plans.AsyncPlansResource
304
+ entries: entries.AsyncEntriesResource
305
+ forum_posts: forum_posts.AsyncForumPostsResource
306
+ transfers: transfers.AsyncTransfersResource
307
+ ledger_accounts: ledger_accounts.AsyncLedgerAccountsResource
308
+ memberships: memberships.AsyncMembershipsResource
309
+ authorized_users: authorized_users.AsyncAuthorizedUsersResource
310
+ app_builds: app_builds.AsyncAppBuildsResource
311
+ shipments: shipments.AsyncShipmentsResource
312
+ checkout_configurations: checkout_configurations.AsyncCheckoutConfigurationsResource
313
+ messages: messages.AsyncMessagesResource
314
+ chat_channels: chat_channels.AsyncChatChannelsResource
315
+ users: users.AsyncUsersResource
316
+ payments: payments.AsyncPaymentsResource
317
+ support_channels: support_channels.AsyncSupportChannelsResource
318
+ experiences: experiences.AsyncExperiencesResource
319
+ reactions: reactions.AsyncReactionsResource
320
+ with_raw_response: AsyncWhopWithRawResponse
321
+ with_streaming_response: AsyncWhopWithStreamedResponse
322
+
323
+ # client options
324
+ api_key: str
325
+ webhook_key: str | None
326
+ app_id: str
327
+
328
+ def __init__(
329
+ self,
330
+ *,
331
+ api_key: str | None = None,
332
+ webhook_key: str | None = None,
333
+ app_id: str | None = None,
334
+ base_url: str | httpx.URL | None = None,
335
+ timeout: float | Timeout | None | NotGiven = not_given,
336
+ max_retries: int = DEFAULT_MAX_RETRIES,
337
+ default_headers: Mapping[str, str] | None = None,
338
+ default_query: Mapping[str, object] | None = None,
339
+ # Configure a custom httpx client.
340
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
341
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
342
+ http_client: httpx.AsyncClient | None = None,
343
+ # Enable or disable schema validation for data returned by the API.
344
+ # When enabled an error APIResponseValidationError is raised
345
+ # if the API responds with invalid data for the expected schema.
346
+ #
347
+ # This parameter may be removed or changed in the future.
348
+ # If you rely on this feature, please open a GitHub issue
349
+ # outlining your use-case to help us decide if it should be
350
+ # part of our public interface in the future.
351
+ _strict_response_validation: bool = False,
352
+ ) -> None:
353
+ """Construct a new async AsyncWhop client instance.
354
+
355
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
356
+ - `api_key` from `WHOP_API_KEY`
357
+ - `webhook_key` from `WHOP_WEBHOOK_SECRET`
358
+ - `app_id` from `WHOP_APP_ID`
359
+ """
360
+ if api_key is None:
361
+ api_key = os.environ.get("WHOP_API_KEY")
362
+ if api_key is None:
363
+ raise WhopError(
364
+ "The api_key client option must be set either by passing api_key to the client or by setting the WHOP_API_KEY environment variable"
365
+ )
366
+ self.api_key = api_key
367
+
368
+ if webhook_key is None:
369
+ webhook_key = os.environ.get("WHOP_WEBHOOK_SECRET")
370
+ self.webhook_key = webhook_key
371
+
372
+ if app_id is None:
373
+ app_id = os.environ.get("WHOP_APP_ID")
374
+ if app_id is None:
375
+ raise WhopError(
376
+ "The app_id client option must be set either by passing app_id to the client or by setting the WHOP_APP_ID environment variable"
377
+ )
378
+ self.app_id = app_id
379
+
380
+ if base_url is None:
381
+ base_url = os.environ.get("WHOP_BASE_URL")
382
+ if base_url is None:
383
+ base_url = f"https://api.whop.com/api/v1"
384
+
385
+ super().__init__(
386
+ version=__version__,
387
+ base_url=base_url,
388
+ max_retries=max_retries,
389
+ timeout=timeout,
390
+ http_client=http_client,
391
+ custom_headers=default_headers,
392
+ custom_query=default_query,
393
+ _strict_response_validation=_strict_response_validation,
394
+ )
395
+
396
+ self.apps = apps.AsyncAppsResource(self)
397
+ self.invoices = invoices.AsyncInvoicesResource(self)
398
+ self.course_lesson_interactions = course_lesson_interactions.AsyncCourseLessonInteractionsResource(self)
399
+ self.products = products.AsyncProductsResource(self)
400
+ self.companies = companies.AsyncCompaniesResource(self)
401
+ self.webhooks = webhooks.AsyncWebhooksResource(self)
402
+ self.plans = plans.AsyncPlansResource(self)
403
+ self.entries = entries.AsyncEntriesResource(self)
404
+ self.forum_posts = forum_posts.AsyncForumPostsResource(self)
405
+ self.transfers = transfers.AsyncTransfersResource(self)
406
+ self.ledger_accounts = ledger_accounts.AsyncLedgerAccountsResource(self)
407
+ self.memberships = memberships.AsyncMembershipsResource(self)
408
+ self.authorized_users = authorized_users.AsyncAuthorizedUsersResource(self)
409
+ self.app_builds = app_builds.AsyncAppBuildsResource(self)
410
+ self.shipments = shipments.AsyncShipmentsResource(self)
411
+ self.checkout_configurations = checkout_configurations.AsyncCheckoutConfigurationsResource(self)
412
+ self.messages = messages.AsyncMessagesResource(self)
413
+ self.chat_channels = chat_channels.AsyncChatChannelsResource(self)
414
+ self.users = users.AsyncUsersResource(self)
415
+ self.payments = payments.AsyncPaymentsResource(self)
416
+ self.support_channels = support_channels.AsyncSupportChannelsResource(self)
417
+ self.experiences = experiences.AsyncExperiencesResource(self)
418
+ self.reactions = reactions.AsyncReactionsResource(self)
419
+ self.with_raw_response = AsyncWhopWithRawResponse(self)
420
+ self.with_streaming_response = AsyncWhopWithStreamedResponse(self)
421
+
422
+ @property
423
+ @override
424
+ def qs(self) -> Querystring:
425
+ return Querystring(array_format="comma")
426
+
427
+ @property
428
+ @override
429
+ def auth_headers(self) -> dict[str, str]:
430
+ api_key = self.api_key
431
+ return {"Authorization": f"Bearer {api_key}"}
432
+
433
+ @property
434
+ @override
435
+ def default_headers(self) -> dict[str, str | Omit]:
436
+ return {
437
+ **super().default_headers,
438
+ "X-Stainless-Async": f"async:{get_async_library()}",
439
+ "X-Whop-App-Id": self.app_id,
440
+ **self._custom_headers,
441
+ }
442
+
443
+ def copy(
444
+ self,
445
+ *,
446
+ api_key: str | None = None,
447
+ webhook_key: str | None = None,
448
+ app_id: str | None = None,
449
+ base_url: str | httpx.URL | None = None,
450
+ timeout: float | Timeout | None | NotGiven = not_given,
451
+ http_client: httpx.AsyncClient | None = None,
452
+ max_retries: int | NotGiven = not_given,
453
+ default_headers: Mapping[str, str] | None = None,
454
+ set_default_headers: Mapping[str, str] | None = None,
455
+ default_query: Mapping[str, object] | None = None,
456
+ set_default_query: Mapping[str, object] | None = None,
457
+ _extra_kwargs: Mapping[str, Any] = {},
458
+ ) -> Self:
459
+ """
460
+ Create a new client instance re-using the same options given to the current client with optional overriding.
461
+ """
462
+ if default_headers is not None and set_default_headers is not None:
463
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
464
+
465
+ if default_query is not None and set_default_query is not None:
466
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
467
+
468
+ headers = self._custom_headers
469
+ if default_headers is not None:
470
+ headers = {**headers, **default_headers}
471
+ elif set_default_headers is not None:
472
+ headers = set_default_headers
473
+
474
+ params = self._custom_query
475
+ if default_query is not None:
476
+ params = {**params, **default_query}
477
+ elif set_default_query is not None:
478
+ params = set_default_query
479
+
480
+ http_client = http_client or self._client
481
+ return self.__class__(
482
+ api_key=api_key or self.api_key,
483
+ webhook_key=webhook_key or self.webhook_key,
484
+ app_id=app_id or self.app_id,
485
+ base_url=base_url or self.base_url,
486
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
487
+ http_client=http_client,
488
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
489
+ default_headers=headers,
490
+ default_query=params,
491
+ **_extra_kwargs,
492
+ )
493
+
494
+ # Alias for `copy` for nicer inline usage, e.g.
495
+ # client.with_options(timeout=10).foo.create(...)
496
+ with_options = copy
497
+
498
+ @override
499
+ def _make_status_error(
500
+ self,
501
+ err_msg: str,
502
+ *,
503
+ body: object,
504
+ response: httpx.Response,
505
+ ) -> APIStatusError:
506
+ if response.status_code == 400:
507
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
508
+
509
+ if response.status_code == 401:
510
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
511
+
512
+ if response.status_code == 403:
513
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
514
+
515
+ if response.status_code == 404:
516
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
517
+
518
+ if response.status_code == 409:
519
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
520
+
521
+ if response.status_code == 422:
522
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
523
+
524
+ if response.status_code == 429:
525
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
526
+
527
+ if response.status_code >= 500:
528
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
529
+ return APIStatusError(err_msg, response=response, body=body)
530
+
531
+
532
+ class WhopWithRawResponse:
533
+ def __init__(self, client: Whop) -> None:
534
+ self.apps = apps.AppsResourceWithRawResponse(client.apps)
535
+ self.invoices = invoices.InvoicesResourceWithRawResponse(client.invoices)
536
+ self.course_lesson_interactions = course_lesson_interactions.CourseLessonInteractionsResourceWithRawResponse(
537
+ client.course_lesson_interactions
538
+ )
539
+ self.products = products.ProductsResourceWithRawResponse(client.products)
540
+ self.companies = companies.CompaniesResourceWithRawResponse(client.companies)
541
+ self.plans = plans.PlansResourceWithRawResponse(client.plans)
542
+ self.entries = entries.EntriesResourceWithRawResponse(client.entries)
543
+ self.forum_posts = forum_posts.ForumPostsResourceWithRawResponse(client.forum_posts)
544
+ self.transfers = transfers.TransfersResourceWithRawResponse(client.transfers)
545
+ self.ledger_accounts = ledger_accounts.LedgerAccountsResourceWithRawResponse(client.ledger_accounts)
546
+ self.memberships = memberships.MembershipsResourceWithRawResponse(client.memberships)
547
+ self.authorized_users = authorized_users.AuthorizedUsersResourceWithRawResponse(client.authorized_users)
548
+ self.app_builds = app_builds.AppBuildsResourceWithRawResponse(client.app_builds)
549
+ self.shipments = shipments.ShipmentsResourceWithRawResponse(client.shipments)
550
+ self.checkout_configurations = checkout_configurations.CheckoutConfigurationsResourceWithRawResponse(
551
+ client.checkout_configurations
552
+ )
553
+ self.messages = messages.MessagesResourceWithRawResponse(client.messages)
554
+ self.chat_channels = chat_channels.ChatChannelsResourceWithRawResponse(client.chat_channels)
555
+ self.users = users.UsersResourceWithRawResponse(client.users)
556
+ self.payments = payments.PaymentsResourceWithRawResponse(client.payments)
557
+ self.support_channels = support_channels.SupportChannelsResourceWithRawResponse(client.support_channels)
558
+ self.experiences = experiences.ExperiencesResourceWithRawResponse(client.experiences)
559
+ self.reactions = reactions.ReactionsResourceWithRawResponse(client.reactions)
560
+
561
+
562
+ class AsyncWhopWithRawResponse:
563
+ def __init__(self, client: AsyncWhop) -> None:
564
+ self.apps = apps.AsyncAppsResourceWithRawResponse(client.apps)
565
+ self.invoices = invoices.AsyncInvoicesResourceWithRawResponse(client.invoices)
566
+ self.course_lesson_interactions = (
567
+ course_lesson_interactions.AsyncCourseLessonInteractionsResourceWithRawResponse(
568
+ client.course_lesson_interactions
569
+ )
570
+ )
571
+ self.products = products.AsyncProductsResourceWithRawResponse(client.products)
572
+ self.companies = companies.AsyncCompaniesResourceWithRawResponse(client.companies)
573
+ self.plans = plans.AsyncPlansResourceWithRawResponse(client.plans)
574
+ self.entries = entries.AsyncEntriesResourceWithRawResponse(client.entries)
575
+ self.forum_posts = forum_posts.AsyncForumPostsResourceWithRawResponse(client.forum_posts)
576
+ self.transfers = transfers.AsyncTransfersResourceWithRawResponse(client.transfers)
577
+ self.ledger_accounts = ledger_accounts.AsyncLedgerAccountsResourceWithRawResponse(client.ledger_accounts)
578
+ self.memberships = memberships.AsyncMembershipsResourceWithRawResponse(client.memberships)
579
+ self.authorized_users = authorized_users.AsyncAuthorizedUsersResourceWithRawResponse(client.authorized_users)
580
+ self.app_builds = app_builds.AsyncAppBuildsResourceWithRawResponse(client.app_builds)
581
+ self.shipments = shipments.AsyncShipmentsResourceWithRawResponse(client.shipments)
582
+ self.checkout_configurations = checkout_configurations.AsyncCheckoutConfigurationsResourceWithRawResponse(
583
+ client.checkout_configurations
584
+ )
585
+ self.messages = messages.AsyncMessagesResourceWithRawResponse(client.messages)
586
+ self.chat_channels = chat_channels.AsyncChatChannelsResourceWithRawResponse(client.chat_channels)
587
+ self.users = users.AsyncUsersResourceWithRawResponse(client.users)
588
+ self.payments = payments.AsyncPaymentsResourceWithRawResponse(client.payments)
589
+ self.support_channels = support_channels.AsyncSupportChannelsResourceWithRawResponse(client.support_channels)
590
+ self.experiences = experiences.AsyncExperiencesResourceWithRawResponse(client.experiences)
591
+ self.reactions = reactions.AsyncReactionsResourceWithRawResponse(client.reactions)
592
+
593
+
594
+ class WhopWithStreamedResponse:
595
+ def __init__(self, client: Whop) -> None:
596
+ self.apps = apps.AppsResourceWithStreamingResponse(client.apps)
597
+ self.invoices = invoices.InvoicesResourceWithStreamingResponse(client.invoices)
598
+ self.course_lesson_interactions = (
599
+ course_lesson_interactions.CourseLessonInteractionsResourceWithStreamingResponse(
600
+ client.course_lesson_interactions
601
+ )
602
+ )
603
+ self.products = products.ProductsResourceWithStreamingResponse(client.products)
604
+ self.companies = companies.CompaniesResourceWithStreamingResponse(client.companies)
605
+ self.plans = plans.PlansResourceWithStreamingResponse(client.plans)
606
+ self.entries = entries.EntriesResourceWithStreamingResponse(client.entries)
607
+ self.forum_posts = forum_posts.ForumPostsResourceWithStreamingResponse(client.forum_posts)
608
+ self.transfers = transfers.TransfersResourceWithStreamingResponse(client.transfers)
609
+ self.ledger_accounts = ledger_accounts.LedgerAccountsResourceWithStreamingResponse(client.ledger_accounts)
610
+ self.memberships = memberships.MembershipsResourceWithStreamingResponse(client.memberships)
611
+ self.authorized_users = authorized_users.AuthorizedUsersResourceWithStreamingResponse(client.authorized_users)
612
+ self.app_builds = app_builds.AppBuildsResourceWithStreamingResponse(client.app_builds)
613
+ self.shipments = shipments.ShipmentsResourceWithStreamingResponse(client.shipments)
614
+ self.checkout_configurations = checkout_configurations.CheckoutConfigurationsResourceWithStreamingResponse(
615
+ client.checkout_configurations
616
+ )
617
+ self.messages = messages.MessagesResourceWithStreamingResponse(client.messages)
618
+ self.chat_channels = chat_channels.ChatChannelsResourceWithStreamingResponse(client.chat_channels)
619
+ self.users = users.UsersResourceWithStreamingResponse(client.users)
620
+ self.payments = payments.PaymentsResourceWithStreamingResponse(client.payments)
621
+ self.support_channels = support_channels.SupportChannelsResourceWithStreamingResponse(client.support_channels)
622
+ self.experiences = experiences.ExperiencesResourceWithStreamingResponse(client.experiences)
623
+ self.reactions = reactions.ReactionsResourceWithStreamingResponse(client.reactions)
624
+
625
+
626
+ class AsyncWhopWithStreamedResponse:
627
+ def __init__(self, client: AsyncWhop) -> None:
628
+ self.apps = apps.AsyncAppsResourceWithStreamingResponse(client.apps)
629
+ self.invoices = invoices.AsyncInvoicesResourceWithStreamingResponse(client.invoices)
630
+ self.course_lesson_interactions = (
631
+ course_lesson_interactions.AsyncCourseLessonInteractionsResourceWithStreamingResponse(
632
+ client.course_lesson_interactions
633
+ )
634
+ )
635
+ self.products = products.AsyncProductsResourceWithStreamingResponse(client.products)
636
+ self.companies = companies.AsyncCompaniesResourceWithStreamingResponse(client.companies)
637
+ self.plans = plans.AsyncPlansResourceWithStreamingResponse(client.plans)
638
+ self.entries = entries.AsyncEntriesResourceWithStreamingResponse(client.entries)
639
+ self.forum_posts = forum_posts.AsyncForumPostsResourceWithStreamingResponse(client.forum_posts)
640
+ self.transfers = transfers.AsyncTransfersResourceWithStreamingResponse(client.transfers)
641
+ self.ledger_accounts = ledger_accounts.AsyncLedgerAccountsResourceWithStreamingResponse(client.ledger_accounts)
642
+ self.memberships = memberships.AsyncMembershipsResourceWithStreamingResponse(client.memberships)
643
+ self.authorized_users = authorized_users.AsyncAuthorizedUsersResourceWithStreamingResponse(
644
+ client.authorized_users
645
+ )
646
+ self.app_builds = app_builds.AsyncAppBuildsResourceWithStreamingResponse(client.app_builds)
647
+ self.shipments = shipments.AsyncShipmentsResourceWithStreamingResponse(client.shipments)
648
+ self.checkout_configurations = checkout_configurations.AsyncCheckoutConfigurationsResourceWithStreamingResponse(
649
+ client.checkout_configurations
650
+ )
651
+ self.messages = messages.AsyncMessagesResourceWithStreamingResponse(client.messages)
652
+ self.chat_channels = chat_channels.AsyncChatChannelsResourceWithStreamingResponse(client.chat_channels)
653
+ self.users = users.AsyncUsersResourceWithStreamingResponse(client.users)
654
+ self.payments = payments.AsyncPaymentsResourceWithStreamingResponse(client.payments)
655
+ self.support_channels = support_channels.AsyncSupportChannelsResourceWithStreamingResponse(
656
+ client.support_channels
657
+ )
658
+ self.experiences = experiences.AsyncExperiencesResourceWithStreamingResponse(client.experiences)
659
+ self.reactions = reactions.AsyncReactionsResourceWithStreamingResponse(client.reactions)
660
+
661
+
662
+ Client = Whop
663
+
664
+ AsyncClient = AsyncWhop