whop-sdk 0.0.10__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.
Files changed (352) hide show
  1. whop_sdk/__init__.py +94 -0
  2. whop_sdk/_base_client.py +1995 -0
  3. whop_sdk/_client.py +800 -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 +857 -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 +58 -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 +540 -0
  31. whop_sdk/resources/access_tokens.py +341 -0
  32. whop_sdk/resources/account_links.py +211 -0
  33. whop_sdk/resources/app_builds.py +587 -0
  34. whop_sdk/resources/apps.py +684 -0
  35. whop_sdk/resources/authorized_users.py +353 -0
  36. whop_sdk/resources/chat_channels.py +469 -0
  37. whop_sdk/resources/checkout_configurations.py +776 -0
  38. whop_sdk/resources/companies.py +465 -0
  39. whop_sdk/resources/course_chapters.py +602 -0
  40. whop_sdk/resources/course_lesson_interactions.py +343 -0
  41. whop_sdk/resources/course_lessons.py +1040 -0
  42. whop_sdk/resources/course_students.py +327 -0
  43. whop_sdk/resources/courses.py +776 -0
  44. whop_sdk/resources/disputes.py +693 -0
  45. whop_sdk/resources/entries.py +556 -0
  46. whop_sdk/resources/experiences.py +983 -0
  47. whop_sdk/resources/forum_posts.py +656 -0
  48. whop_sdk/resources/forums.py +446 -0
  49. whop_sdk/resources/invoices.py +1099 -0
  50. whop_sdk/resources/ledger_accounts.py +171 -0
  51. whop_sdk/resources/members.py +429 -0
  52. whop_sdk/resources/memberships.py +818 -0
  53. whop_sdk/resources/messages.py +558 -0
  54. whop_sdk/resources/notifications.py +388 -0
  55. whop_sdk/resources/payment_tokens.py +359 -0
  56. whop_sdk/resources/payments.py +1040 -0
  57. whop_sdk/resources/plans.py +1001 -0
  58. whop_sdk/resources/products.py +970 -0
  59. whop_sdk/resources/promo_codes.py +668 -0
  60. whop_sdk/resources/reactions.py +423 -0
  61. whop_sdk/resources/refunds.py +347 -0
  62. whop_sdk/resources/reviews.py +332 -0
  63. whop_sdk/resources/setup_intents.py +349 -0
  64. whop_sdk/resources/shipments.py +451 -0
  65. whop_sdk/resources/support_channels.py +455 -0
  66. whop_sdk/resources/transfers.py +513 -0
  67. whop_sdk/resources/users.py +248 -0
  68. whop_sdk/resources/webhooks.py +69 -0
  69. whop_sdk/resources/withdrawals.py +341 -0
  70. whop_sdk/types/__init__.py +262 -0
  71. whop_sdk/types/access_token_create_params.py +64 -0
  72. whop_sdk/types/access_token_create_response.py +15 -0
  73. whop_sdk/types/account_link_create_params.py +27 -0
  74. whop_sdk/types/account_link_create_response.py +15 -0
  75. whop_sdk/types/app_build_create_params.py +72 -0
  76. whop_sdk/types/app_build_list_params.py +42 -0
  77. whop_sdk/types/app_build_list_response.py +50 -0
  78. whop_sdk/types/app_create_params.py +19 -0
  79. whop_sdk/types/app_list_params.py +59 -0
  80. whop_sdk/types/app_list_response.py +110 -0
  81. whop_sdk/types/app_type.py +7 -0
  82. whop_sdk/types/app_update_params.py +67 -0
  83. whop_sdk/types/assessment_question_types.py +7 -0
  84. whop_sdk/types/authorized_user_list_params.py +41 -0
  85. whop_sdk/types/authorized_user_list_response.py +33 -0
  86. whop_sdk/types/authorized_user_retrieve_response.py +33 -0
  87. whop_sdk/types/billing_reasons.py +9 -0
  88. whop_sdk/types/card_brands.py +25 -0
  89. whop_sdk/types/chat_channel_list_params.py +28 -0
  90. whop_sdk/types/chat_channel_list_response.py +43 -0
  91. whop_sdk/types/chat_channel_update_params.py +32 -0
  92. whop_sdk/types/checkout_configuration_create_params.py +373 -0
  93. whop_sdk/types/checkout_configuration_list_params.py +41 -0
  94. whop_sdk/types/checkout_configuration_list_response.py +104 -0
  95. whop_sdk/types/checkout_modes.py +7 -0
  96. whop_sdk/types/company_create_params.py +22 -0
  97. whop_sdk/types/company_list_params.py +38 -0
  98. whop_sdk/types/company_list_response.py +76 -0
  99. whop_sdk/types/course.py +122 -0
  100. whop_sdk/types/course_chapter.py +32 -0
  101. whop_sdk/types/course_chapter_create_params.py +16 -0
  102. whop_sdk/types/course_chapter_delete_response.py +7 -0
  103. whop_sdk/types/course_chapter_list_params.py +25 -0
  104. whop_sdk/types/course_chapter_list_response.py +16 -0
  105. whop_sdk/types/course_chapter_update_params.py +12 -0
  106. whop_sdk/types/course_create_params.py +78 -0
  107. whop_sdk/types/course_delete_response.py +7 -0
  108. whop_sdk/types/course_lesson_create_params.py +63 -0
  109. whop_sdk/types/course_lesson_delete_response.py +7 -0
  110. whop_sdk/types/course_lesson_interaction_completed_webhook_event.py +26 -0
  111. whop_sdk/types/course_lesson_interaction_list_params.py +34 -0
  112. whop_sdk/types/course_lesson_list_params.py +28 -0
  113. whop_sdk/types/course_lesson_list_response.py +57 -0
  114. whop_sdk/types/course_lesson_mark_as_completed_response.py +7 -0
  115. whop_sdk/types/course_lesson_start_response.py +7 -0
  116. whop_sdk/types/course_lesson_submit_assessment_params.py +26 -0
  117. whop_sdk/types/course_lesson_submit_assessment_response.py +62 -0
  118. whop_sdk/types/course_lesson_update_params.py +222 -0
  119. whop_sdk/types/course_list_params.py +28 -0
  120. whop_sdk/types/course_list_response.py +90 -0
  121. whop_sdk/types/course_student_list_params.py +28 -0
  122. whop_sdk/types/course_student_list_response.py +42 -0
  123. whop_sdk/types/course_student_retrieve_response.py +61 -0
  124. whop_sdk/types/course_update_params.py +114 -0
  125. whop_sdk/types/course_visibilities.py +7 -0
  126. whop_sdk/types/dispute.py +284 -0
  127. whop_sdk/types/dispute_created_webhook_event.py +26 -0
  128. whop_sdk/types/dispute_list_params.py +38 -0
  129. whop_sdk/types/dispute_list_response.py +77 -0
  130. whop_sdk/types/dispute_statuses.py +17 -0
  131. whop_sdk/types/dispute_update_evidence_params.py +159 -0
  132. whop_sdk/types/dispute_updated_webhook_event.py +26 -0
  133. whop_sdk/types/embed_type.py +7 -0
  134. whop_sdk/types/entry_approve_response.py +10 -0
  135. whop_sdk/types/entry_approved_webhook_event.py +26 -0
  136. whop_sdk/types/entry_created_webhook_event.py +26 -0
  137. whop_sdk/types/entry_deleted_webhook_event.py +26 -0
  138. whop_sdk/types/entry_denied_webhook_event.py +26 -0
  139. whop_sdk/types/entry_list_params.py +52 -0
  140. whop_sdk/types/entry_list_response.py +56 -0
  141. whop_sdk/types/experience_attach_params.py +12 -0
  142. whop_sdk/types/experience_create_params.py +22 -0
  143. whop_sdk/types/experience_delete_response.py +7 -0
  144. whop_sdk/types/experience_detach_params.py +12 -0
  145. whop_sdk/types/experience_duplicate_params.py +13 -0
  146. whop_sdk/types/experience_list_params.py +40 -0
  147. whop_sdk/types/experience_list_response.py +73 -0
  148. whop_sdk/types/experience_update_params.py +46 -0
  149. whop_sdk/types/forum_list_params.py +28 -0
  150. whop_sdk/types/forum_list_response.py +33 -0
  151. whop_sdk/types/forum_post_create_params.py +101 -0
  152. whop_sdk/types/forum_post_list_params.py +31 -0
  153. whop_sdk/types/forum_post_list_response.py +60 -0
  154. whop_sdk/types/forum_post_update_params.py +56 -0
  155. whop_sdk/types/forum_post_visibility_type.py +7 -0
  156. whop_sdk/types/forum_update_params.py +23 -0
  157. whop_sdk/types/invoice_create_params.py +515 -0
  158. whop_sdk/types/invoice_created_webhook_event.py +26 -0
  159. whop_sdk/types/invoice_list_params.py +53 -0
  160. whop_sdk/types/invoice_paid_webhook_event.py +26 -0
  161. whop_sdk/types/invoice_past_due_webhook_event.py +26 -0
  162. whop_sdk/types/invoice_void_response.py +7 -0
  163. whop_sdk/types/invoice_voided_webhook_event.py +26 -0
  164. whop_sdk/types/languages.py +30 -0
  165. whop_sdk/types/ledger_account_retrieve_response.py +93 -0
  166. whop_sdk/types/lesson.py +219 -0
  167. whop_sdk/types/lesson_types.py +7 -0
  168. whop_sdk/types/lesson_visibilities.py +7 -0
  169. whop_sdk/types/member_list_params.py +73 -0
  170. whop_sdk/types/member_list_response.py +65 -0
  171. whop_sdk/types/member_retrieve_response.py +79 -0
  172. whop_sdk/types/membership_activated_webhook_event.py +29 -0
  173. whop_sdk/types/membership_cancel_params.py +13 -0
  174. whop_sdk/types/membership_deactivated_webhook_event.py +29 -0
  175. whop_sdk/types/membership_list_params.py +73 -0
  176. whop_sdk/types/membership_list_response.py +128 -0
  177. whop_sdk/types/membership_pause_params.py +16 -0
  178. whop_sdk/types/membership_update_params.py +13 -0
  179. whop_sdk/types/message_create_params.py +63 -0
  180. whop_sdk/types/message_list_params.py +30 -0
  181. whop_sdk/types/message_list_response.py +90 -0
  182. whop_sdk/types/message_update_params.py +45 -0
  183. whop_sdk/types/notification_create_params.py +93 -0
  184. whop_sdk/types/notification_create_response.py +10 -0
  185. whop_sdk/types/payment_create_params.py +162 -0
  186. whop_sdk/types/payment_failed_webhook_event.py +26 -0
  187. whop_sdk/types/payment_list_params.py +67 -0
  188. whop_sdk/types/payment_list_response.py +273 -0
  189. whop_sdk/types/payment_method_types.py +94 -0
  190. whop_sdk/types/payment_pending_webhook_event.py +26 -0
  191. whop_sdk/types/payment_provider.py +9 -0
  192. whop_sdk/types/payment_refund_params.py +13 -0
  193. whop_sdk/types/payment_succeeded_webhook_event.py +26 -0
  194. whop_sdk/types/payment_token_list_params.py +38 -0
  195. whop_sdk/types/payment_token_list_response.py +41 -0
  196. whop_sdk/types/payment_token_retrieve_params.py +12 -0
  197. whop_sdk/types/payment_token_retrieve_response.py +41 -0
  198. whop_sdk/types/plan_create_params.py +162 -0
  199. whop_sdk/types/plan_delete_response.py +7 -0
  200. whop_sdk/types/plan_list_params.py +57 -0
  201. whop_sdk/types/plan_list_response.py +128 -0
  202. whop_sdk/types/plan_update_params.py +155 -0
  203. whop_sdk/types/product_create_params.py +147 -0
  204. whop_sdk/types/product_delete_response.py +7 -0
  205. whop_sdk/types/product_list_params.py +49 -0
  206. whop_sdk/types/product_update_params.py +82 -0
  207. whop_sdk/types/promo_code.py +90 -0
  208. whop_sdk/types/promo_code_create_params.py +70 -0
  209. whop_sdk/types/promo_code_delete_response.py +7 -0
  210. whop_sdk/types/promo_code_list_params.py +45 -0
  211. whop_sdk/types/promo_code_list_response.py +79 -0
  212. whop_sdk/types/promo_code_status.py +7 -0
  213. whop_sdk/types/promo_duration.py +7 -0
  214. whop_sdk/types/reaction_create_params.py +19 -0
  215. whop_sdk/types/reaction_list_params.py +25 -0
  216. whop_sdk/types/reaction_list_response.py +32 -0
  217. whop_sdk/types/refund_created_webhook_event.py +154 -0
  218. whop_sdk/types/refund_list_params.py +38 -0
  219. whop_sdk/types/refund_list_response.py +53 -0
  220. whop_sdk/types/refund_reference_status.py +7 -0
  221. whop_sdk/types/refund_reference_type.py +9 -0
  222. whop_sdk/types/refund_retrieve_response.py +129 -0
  223. whop_sdk/types/refund_status.py +7 -0
  224. whop_sdk/types/refund_updated_webhook_event.py +154 -0
  225. whop_sdk/types/review_list_params.py +40 -0
  226. whop_sdk/types/review_list_response.py +78 -0
  227. whop_sdk/types/review_retrieve_response.py +103 -0
  228. whop_sdk/types/review_status.py +7 -0
  229. whop_sdk/types/setup_intent.py +111 -0
  230. whop_sdk/types/setup_intent_canceled_webhook_event.py +29 -0
  231. whop_sdk/types/setup_intent_list_params.py +38 -0
  232. whop_sdk/types/setup_intent_list_response.py +111 -0
  233. whop_sdk/types/setup_intent_requires_action_webhook_event.py +29 -0
  234. whop_sdk/types/setup_intent_status.py +7 -0
  235. whop_sdk/types/setup_intent_succeeded_webhook_event.py +29 -0
  236. whop_sdk/types/shared/__init__.py +62 -0
  237. whop_sdk/types/shared/access_level.py +7 -0
  238. whop_sdk/types/shared/access_pass_type.py +7 -0
  239. whop_sdk/types/shared/app.py +187 -0
  240. whop_sdk/types/shared/app_build.py +50 -0
  241. whop_sdk/types/shared/app_build_platforms.py +7 -0
  242. whop_sdk/types/shared/app_build_statuses.py +7 -0
  243. whop_sdk/types/shared/app_statuses.py +7 -0
  244. whop_sdk/types/shared/app_view_type.py +7 -0
  245. whop_sdk/types/shared/authorized_user_roles.py +9 -0
  246. whop_sdk/types/shared/business_types.py +22 -0
  247. whop_sdk/types/shared/chat_channel.py +43 -0
  248. whop_sdk/types/shared/checkout_configuration.py +104 -0
  249. whop_sdk/types/shared/collection_method.py +7 -0
  250. whop_sdk/types/shared/company.py +91 -0
  251. whop_sdk/types/shared/course_lesson_interaction.py +63 -0
  252. whop_sdk/types/shared/course_lesson_interaction_list_item.py +44 -0
  253. whop_sdk/types/shared/currency.py +93 -0
  254. whop_sdk/types/shared/custom_cta.py +21 -0
  255. whop_sdk/types/shared/direction.py +7 -0
  256. whop_sdk/types/shared/dms_post_types.py +7 -0
  257. whop_sdk/types/shared/email_notification_preferences.py +7 -0
  258. whop_sdk/types/shared/entry.py +70 -0
  259. whop_sdk/types/shared/entry_status.py +7 -0
  260. whop_sdk/types/shared/experience.py +91 -0
  261. whop_sdk/types/shared/forum.py +33 -0
  262. whop_sdk/types/shared/forum_post.py +60 -0
  263. whop_sdk/types/shared/friendly_receipt_status.py +24 -0
  264. whop_sdk/types/shared/global_affiliate_status.py +7 -0
  265. whop_sdk/types/shared/industry_types.py +67 -0
  266. whop_sdk/types/shared/invoice.py +64 -0
  267. whop_sdk/types/shared/invoice_list_item.py +64 -0
  268. whop_sdk/types/shared/invoice_status.py +7 -0
  269. whop_sdk/types/shared/member_most_recent_actions.py +22 -0
  270. whop_sdk/types/shared/member_statuses.py +7 -0
  271. whop_sdk/types/shared/membership.py +128 -0
  272. whop_sdk/types/shared/membership_status.py +9 -0
  273. whop_sdk/types/shared/message.py +90 -0
  274. whop_sdk/types/shared/page_info.py +21 -0
  275. whop_sdk/types/shared/payment.py +273 -0
  276. whop_sdk/types/shared/plan.py +159 -0
  277. whop_sdk/types/shared/plan_type.py +7 -0
  278. whop_sdk/types/shared/product.py +132 -0
  279. whop_sdk/types/shared/product_list_item.py +57 -0
  280. whop_sdk/types/shared/promo_type.py +7 -0
  281. whop_sdk/types/shared/reaction.py +32 -0
  282. whop_sdk/types/shared/receipt_status.py +7 -0
  283. whop_sdk/types/shared/release_method.py +7 -0
  284. whop_sdk/types/shared/shipment.py +48 -0
  285. whop_sdk/types/shared/shipment_carrier.py +84 -0
  286. whop_sdk/types/shared/shipment_status.py +18 -0
  287. whop_sdk/types/shared/shipment_substatus.py +36 -0
  288. whop_sdk/types/shared/support_channel.py +39 -0
  289. whop_sdk/types/shared/tax_type.py +7 -0
  290. whop_sdk/types/shared/transfer.py +112 -0
  291. whop_sdk/types/shared/visibility.py +7 -0
  292. whop_sdk/types/shared/visibility_filter.py +9 -0
  293. whop_sdk/types/shared/who_can_comment_types.py +7 -0
  294. whop_sdk/types/shared/who_can_post.py +7 -0
  295. whop_sdk/types/shared/who_can_post_types.py +7 -0
  296. whop_sdk/types/shared/who_can_react.py +7 -0
  297. whop_sdk/types/shared_params/__init__.py +34 -0
  298. whop_sdk/types/shared_params/access_level.py +9 -0
  299. whop_sdk/types/shared_params/access_pass_type.py +9 -0
  300. whop_sdk/types/shared_params/app_build_platforms.py +9 -0
  301. whop_sdk/types/shared_params/app_build_statuses.py +9 -0
  302. whop_sdk/types/shared_params/app_statuses.py +9 -0
  303. whop_sdk/types/shared_params/app_view_type.py +9 -0
  304. whop_sdk/types/shared_params/authorized_user_roles.py +11 -0
  305. whop_sdk/types/shared_params/business_types.py +24 -0
  306. whop_sdk/types/shared_params/collection_method.py +9 -0
  307. whop_sdk/types/shared_params/currency.py +95 -0
  308. whop_sdk/types/shared_params/custom_cta.py +23 -0
  309. whop_sdk/types/shared_params/direction.py +9 -0
  310. whop_sdk/types/shared_params/email_notification_preferences.py +9 -0
  311. whop_sdk/types/shared_params/entry_status.py +9 -0
  312. whop_sdk/types/shared_params/friendly_receipt_status.py +26 -0
  313. whop_sdk/types/shared_params/global_affiliate_status.py +9 -0
  314. whop_sdk/types/shared_params/industry_types.py +69 -0
  315. whop_sdk/types/shared_params/invoice_status.py +9 -0
  316. whop_sdk/types/shared_params/member_most_recent_actions.py +24 -0
  317. whop_sdk/types/shared_params/member_statuses.py +9 -0
  318. whop_sdk/types/shared_params/membership_status.py +11 -0
  319. whop_sdk/types/shared_params/plan_type.py +9 -0
  320. whop_sdk/types/shared_params/promo_type.py +9 -0
  321. whop_sdk/types/shared_params/receipt_status.py +9 -0
  322. whop_sdk/types/shared_params/release_method.py +9 -0
  323. whop_sdk/types/shared_params/tax_type.py +9 -0
  324. whop_sdk/types/shared_params/visibility.py +9 -0
  325. whop_sdk/types/shared_params/visibility_filter.py +11 -0
  326. whop_sdk/types/shared_params/who_can_comment_types.py +9 -0
  327. whop_sdk/types/shared_params/who_can_post.py +9 -0
  328. whop_sdk/types/shared_params/who_can_post_types.py +9 -0
  329. whop_sdk/types/shared_params/who_can_react.py +9 -0
  330. whop_sdk/types/shipment_create_params.py +18 -0
  331. whop_sdk/types/shipment_list_params.py +31 -0
  332. whop_sdk/types/shipment_list_response.py +48 -0
  333. whop_sdk/types/support_channel_create_params.py +15 -0
  334. whop_sdk/types/support_channel_list_params.py +40 -0
  335. whop_sdk/types/support_channel_list_response.py +39 -0
  336. whop_sdk/types/transfer_create_params.py +39 -0
  337. whop_sdk/types/transfer_list_params.py +50 -0
  338. whop_sdk/types/transfer_list_response.py +38 -0
  339. whop_sdk/types/unwrap_webhook_event.py +52 -0
  340. whop_sdk/types/user_check_access_response.py +14 -0
  341. whop_sdk/types/user_retrieve_response.py +36 -0
  342. whop_sdk/types/withdrawal_fee_types.py +7 -0
  343. whop_sdk/types/withdrawal_list_params.py +38 -0
  344. whop_sdk/types/withdrawal_list_response.py +45 -0
  345. whop_sdk/types/withdrawal_retrieve_response.py +154 -0
  346. whop_sdk/types/withdrawal_speeds.py +7 -0
  347. whop_sdk/types/withdrawal_status.py +9 -0
  348. whop_sdk/types/withdrawal_types.py +7 -0
  349. whop_sdk-0.0.10.dist-info/METADATA +509 -0
  350. whop_sdk-0.0.10.dist-info/RECORD +352 -0
  351. whop_sdk-0.0.10.dist-info/WHEEL +4 -0
  352. whop_sdk-0.0.10.dist-info/licenses/LICENSE +201 -0
whop_sdk/_qs.py ADDED
@@ -0,0 +1,150 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, List, Tuple, Union, Mapping, TypeVar
4
+ from urllib.parse import parse_qs, urlencode
5
+ from typing_extensions import Literal, get_args
6
+
7
+ from ._types import NotGiven, not_given
8
+ from ._utils import flatten
9
+
10
+ _T = TypeVar("_T")
11
+
12
+
13
+ ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
14
+ NestedFormat = Literal["dots", "brackets"]
15
+
16
+ PrimitiveData = Union[str, int, float, bool, None]
17
+ # this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
18
+ # https://github.com/microsoft/pyright/issues/3555
19
+ Data = Union[PrimitiveData, List[Any], Tuple[Any], "Mapping[str, Any]"]
20
+ Params = Mapping[str, Data]
21
+
22
+
23
+ class Querystring:
24
+ array_format: ArrayFormat
25
+ nested_format: NestedFormat
26
+
27
+ def __init__(
28
+ self,
29
+ *,
30
+ array_format: ArrayFormat = "repeat",
31
+ nested_format: NestedFormat = "brackets",
32
+ ) -> None:
33
+ self.array_format = array_format
34
+ self.nested_format = nested_format
35
+
36
+ def parse(self, query: str) -> Mapping[str, object]:
37
+ # Note: custom format syntax is not supported yet
38
+ return parse_qs(query)
39
+
40
+ def stringify(
41
+ self,
42
+ params: Params,
43
+ *,
44
+ array_format: ArrayFormat | NotGiven = not_given,
45
+ nested_format: NestedFormat | NotGiven = not_given,
46
+ ) -> str:
47
+ return urlencode(
48
+ self.stringify_items(
49
+ params,
50
+ array_format=array_format,
51
+ nested_format=nested_format,
52
+ )
53
+ )
54
+
55
+ def stringify_items(
56
+ self,
57
+ params: Params,
58
+ *,
59
+ array_format: ArrayFormat | NotGiven = not_given,
60
+ nested_format: NestedFormat | NotGiven = not_given,
61
+ ) -> list[tuple[str, str]]:
62
+ opts = Options(
63
+ qs=self,
64
+ array_format=array_format,
65
+ nested_format=nested_format,
66
+ )
67
+ return flatten([self._stringify_item(key, value, opts) for key, value in params.items()])
68
+
69
+ def _stringify_item(
70
+ self,
71
+ key: str,
72
+ value: Data,
73
+ opts: Options,
74
+ ) -> list[tuple[str, str]]:
75
+ if isinstance(value, Mapping):
76
+ items: list[tuple[str, str]] = []
77
+ nested_format = opts.nested_format
78
+ for subkey, subvalue in value.items():
79
+ items.extend(
80
+ self._stringify_item(
81
+ # TODO: error if unknown format
82
+ f"{key}.{subkey}" if nested_format == "dots" else f"{key}[{subkey}]",
83
+ subvalue,
84
+ opts,
85
+ )
86
+ )
87
+ return items
88
+
89
+ if isinstance(value, (list, tuple)):
90
+ array_format = opts.array_format
91
+ if array_format == "comma":
92
+ return [
93
+ (
94
+ key,
95
+ ",".join(self._primitive_value_to_str(item) for item in value if item is not None),
96
+ ),
97
+ ]
98
+ elif array_format == "repeat":
99
+ items = []
100
+ for item in value:
101
+ items.extend(self._stringify_item(key, item, opts))
102
+ return items
103
+ elif array_format == "indices":
104
+ raise NotImplementedError("The array indices format is not supported yet")
105
+ elif array_format == "brackets":
106
+ items = []
107
+ key = key + "[]"
108
+ for item in value:
109
+ items.extend(self._stringify_item(key, item, opts))
110
+ return items
111
+ else:
112
+ raise NotImplementedError(
113
+ f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
114
+ )
115
+
116
+ serialised = self._primitive_value_to_str(value)
117
+ if not serialised:
118
+ return []
119
+ return [(key, serialised)]
120
+
121
+ def _primitive_value_to_str(self, value: PrimitiveData) -> str:
122
+ # copied from httpx
123
+ if value is True:
124
+ return "true"
125
+ elif value is False:
126
+ return "false"
127
+ elif value is None:
128
+ return ""
129
+ return str(value)
130
+
131
+
132
+ _qs = Querystring()
133
+ parse = _qs.parse
134
+ stringify = _qs.stringify
135
+ stringify_items = _qs.stringify_items
136
+
137
+
138
+ class Options:
139
+ array_format: ArrayFormat
140
+ nested_format: NestedFormat
141
+
142
+ def __init__(
143
+ self,
144
+ qs: Querystring = _qs,
145
+ *,
146
+ array_format: ArrayFormat | NotGiven = not_given,
147
+ nested_format: NestedFormat | NotGiven = not_given,
148
+ ) -> None:
149
+ self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
150
+ self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
whop_sdk/_resource.py ADDED
@@ -0,0 +1,43 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from typing import TYPE_CHECKING
7
+
8
+ import anyio
9
+
10
+ if TYPE_CHECKING:
11
+ from ._client import Whop, AsyncWhop
12
+
13
+
14
+ class SyncAPIResource:
15
+ _client: Whop
16
+
17
+ def __init__(self, client: Whop) -> None:
18
+ self._client = client
19
+ self._get = client.get
20
+ self._post = client.post
21
+ self._patch = client.patch
22
+ self._put = client.put
23
+ self._delete = client.delete
24
+ self._get_api_list = client.get_api_list
25
+
26
+ def _sleep(self, seconds: float) -> None:
27
+ time.sleep(seconds)
28
+
29
+
30
+ class AsyncAPIResource:
31
+ _client: AsyncWhop
32
+
33
+ def __init__(self, client: AsyncWhop) -> None:
34
+ self._client = client
35
+ self._get = client.get
36
+ self._post = client.post
37
+ self._patch = client.patch
38
+ self._put = client.put
39
+ self._delete = client.delete
40
+ self._get_api_list = client.get_api_list
41
+
42
+ async def _sleep(self, seconds: float) -> None:
43
+ await anyio.sleep(seconds)