@whop/sdk 0.0.2 → 0.0.4

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 (196) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/client.d.mts +30 -12
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +30 -12
  5. package/client.d.ts.map +1 -1
  6. package/client.js +19 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +21 -3
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/app-builds.d.mts +16 -13
  12. package/resources/app-builds.d.mts.map +1 -1
  13. package/resources/app-builds.d.ts +16 -13
  14. package/resources/app-builds.d.ts.map +1 -1
  15. package/resources/app-builds.js +1 -1
  16. package/resources/app-builds.mjs +1 -1
  17. package/resources/apps.d.mts +15 -10
  18. package/resources/apps.d.mts.map +1 -1
  19. package/resources/apps.d.ts +15 -10
  20. package/resources/apps.d.ts.map +1 -1
  21. package/resources/checkout-configurations.d.mts +252 -140
  22. package/resources/checkout-configurations.d.mts.map +1 -1
  23. package/resources/checkout-configurations.d.ts +252 -140
  24. package/resources/checkout-configurations.d.ts.map +1 -1
  25. package/resources/checkout-configurations.js +6 -20
  26. package/resources/checkout-configurations.js.map +1 -1
  27. package/resources/checkout-configurations.mjs +6 -20
  28. package/resources/checkout-configurations.mjs.map +1 -1
  29. package/resources/companies.d.mts +157 -0
  30. package/resources/companies.d.mts.map +1 -1
  31. package/resources/companies.d.ts +157 -0
  32. package/resources/companies.d.ts.map +1 -1
  33. package/resources/companies.js +22 -0
  34. package/resources/companies.js.map +1 -1
  35. package/resources/companies.mjs +22 -0
  36. package/resources/companies.mjs.map +1 -1
  37. package/resources/course-chapters.d.mts +185 -0
  38. package/resources/course-chapters.d.mts.map +1 -0
  39. package/resources/course-chapters.d.ts +185 -0
  40. package/resources/course-chapters.d.ts.map +1 -0
  41. package/resources/course-chapters.js +103 -0
  42. package/resources/course-chapters.js.map +1 -0
  43. package/resources/course-chapters.mjs +99 -0
  44. package/resources/course-chapters.mjs.map +1 -0
  45. package/resources/course-lesson-interactions.d.mts +2 -2
  46. package/resources/course-lesson-interactions.d.ts +2 -2
  47. package/resources/course-lesson-interactions.js +2 -2
  48. package/resources/course-lesson-interactions.mjs +2 -2
  49. package/resources/course-lessons.d.mts +563 -0
  50. package/resources/course-lessons.d.mts.map +1 -0
  51. package/resources/course-lessons.d.ts +563 -0
  52. package/resources/course-lessons.d.ts.map +1 -0
  53. package/resources/course-lessons.js +101 -0
  54. package/resources/course-lessons.js.map +1 -0
  55. package/resources/course-lessons.mjs +97 -0
  56. package/resources/course-lessons.mjs.map +1 -0
  57. package/resources/course-students.d.mts +187 -0
  58. package/resources/course-students.d.mts.map +1 -0
  59. package/resources/course-students.d.ts +187 -0
  60. package/resources/course-students.d.ts.map +1 -0
  61. package/resources/course-students.js +36 -0
  62. package/resources/course-students.js.map +1 -0
  63. package/resources/course-students.mjs +32 -0
  64. package/resources/course-students.mjs.map +1 -0
  65. package/resources/courses.d.mts +485 -0
  66. package/resources/courses.d.mts.map +1 -0
  67. package/resources/courses.d.ts +485 -0
  68. package/resources/courses.d.ts.map +1 -0
  69. package/resources/courses.js +98 -0
  70. package/resources/courses.js.map +1 -0
  71. package/resources/courses.mjs +94 -0
  72. package/resources/courses.mjs.map +1 -0
  73. package/resources/experiences.d.mts +42 -11
  74. package/resources/experiences.d.mts.map +1 -1
  75. package/resources/experiences.d.ts +42 -11
  76. package/resources/experiences.d.ts.map +1 -1
  77. package/resources/experiences.js +22 -0
  78. package/resources/experiences.js.map +1 -1
  79. package/resources/experiences.mjs +22 -0
  80. package/resources/experiences.mjs.map +1 -1
  81. package/resources/forum-posts.d.mts +75 -10
  82. package/resources/forum-posts.d.mts.map +1 -1
  83. package/resources/forum-posts.d.ts +75 -10
  84. package/resources/forum-posts.d.ts.map +1 -1
  85. package/resources/forum-posts.js +11 -0
  86. package/resources/forum-posts.js.map +1 -1
  87. package/resources/forum-posts.mjs +11 -0
  88. package/resources/forum-posts.mjs.map +1 -1
  89. package/resources/index.d.mts +12 -6
  90. package/resources/index.d.mts.map +1 -1
  91. package/resources/index.d.ts +12 -6
  92. package/resources/index.d.ts.map +1 -1
  93. package/resources/index.js +13 -1
  94. package/resources/index.js.map +1 -1
  95. package/resources/index.mjs +7 -1
  96. package/resources/index.mjs.map +1 -1
  97. package/resources/invoices.d.mts +529 -146
  98. package/resources/invoices.d.mts.map +1 -1
  99. package/resources/invoices.d.ts +529 -146
  100. package/resources/invoices.d.ts.map +1 -1
  101. package/resources/invoices.js +2 -24
  102. package/resources/invoices.js.map +1 -1
  103. package/resources/invoices.mjs +2 -24
  104. package/resources/invoices.mjs.map +1 -1
  105. package/resources/ledger-accounts.d.mts +1 -1
  106. package/resources/ledger-accounts.d.mts.map +1 -1
  107. package/resources/ledger-accounts.d.ts +1 -1
  108. package/resources/ledger-accounts.d.ts.map +1 -1
  109. package/resources/members.d.mts +4 -0
  110. package/resources/members.d.mts.map +1 -1
  111. package/resources/members.d.ts +4 -0
  112. package/resources/members.d.ts.map +1 -1
  113. package/resources/memberships.d.mts +26 -5
  114. package/resources/memberships.d.mts.map +1 -1
  115. package/resources/memberships.d.ts +26 -5
  116. package/resources/memberships.d.ts.map +1 -1
  117. package/resources/memberships.js +1 -1
  118. package/resources/memberships.js.map +1 -1
  119. package/resources/memberships.mjs +1 -1
  120. package/resources/memberships.mjs.map +1 -1
  121. package/resources/messages.d.mts +57 -10
  122. package/resources/messages.d.mts.map +1 -1
  123. package/resources/messages.d.ts +57 -10
  124. package/resources/messages.d.ts.map +1 -1
  125. package/resources/messages.js +6 -0
  126. package/resources/messages.js.map +1 -1
  127. package/resources/messages.mjs +6 -0
  128. package/resources/messages.mjs.map +1 -1
  129. package/resources/payments.d.mts +35 -13
  130. package/resources/payments.d.mts.map +1 -1
  131. package/resources/payments.d.ts +35 -13
  132. package/resources/payments.d.ts.map +1 -1
  133. package/resources/plans.d.mts +161 -17
  134. package/resources/plans.d.mts.map +1 -1
  135. package/resources/plans.d.ts +161 -17
  136. package/resources/plans.d.ts.map +1 -1
  137. package/resources/plans.js.map +1 -1
  138. package/resources/plans.mjs.map +1 -1
  139. package/resources/products.d.mts +30 -33
  140. package/resources/products.d.mts.map +1 -1
  141. package/resources/products.d.ts +30 -33
  142. package/resources/products.d.ts.map +1 -1
  143. package/resources/promo-codes.d.mts +394 -0
  144. package/resources/promo-codes.d.mts.map +1 -0
  145. package/resources/promo-codes.d.ts +394 -0
  146. package/resources/promo-codes.d.ts.map +1 -0
  147. package/resources/promo-codes.js +91 -0
  148. package/resources/promo-codes.js.map +1 -0
  149. package/resources/promo-codes.mjs +87 -0
  150. package/resources/promo-codes.mjs.map +1 -0
  151. package/resources/reviews.d.mts +277 -0
  152. package/resources/reviews.d.mts.map +1 -0
  153. package/resources/reviews.d.ts +277 -0
  154. package/resources/reviews.d.ts.map +1 -0
  155. package/resources/reviews.js +23 -0
  156. package/resources/reviews.js.map +1 -0
  157. package/resources/reviews.mjs +19 -0
  158. package/resources/reviews.mjs.map +1 -0
  159. package/resources/shared.d.mts +117 -14
  160. package/resources/shared.d.mts.map +1 -1
  161. package/resources/shared.d.ts +117 -14
  162. package/resources/shared.d.ts.map +1 -1
  163. package/resources/transfers.d.mts +12 -0
  164. package/resources/transfers.d.mts.map +1 -1
  165. package/resources/transfers.d.ts +12 -0
  166. package/resources/transfers.d.ts.map +1 -1
  167. package/src/client.ts +166 -11
  168. package/src/resources/app-builds.ts +19 -14
  169. package/src/resources/apps.ts +16 -11
  170. package/src/resources/checkout-configurations.ts +278 -143
  171. package/src/resources/companies.ts +196 -0
  172. package/src/resources/course-chapters.ts +236 -0
  173. package/src/resources/course-lesson-interactions.ts +2 -2
  174. package/src/resources/course-lessons.ts +699 -0
  175. package/src/resources/course-students.ts +238 -0
  176. package/src/resources/courses.ts +622 -0
  177. package/src/resources/experiences.ts +54 -11
  178. package/src/resources/forum-posts.ts +95 -10
  179. package/src/resources/index.ts +73 -2
  180. package/src/resources/invoices.ts +620 -149
  181. package/src/resources/ledger-accounts.ts +13 -1
  182. package/src/resources/members.ts +5 -0
  183. package/src/resources/memberships.ts +31 -6
  184. package/src/resources/messages.ts +74 -10
  185. package/src/resources/payments.ts +146 -19
  186. package/src/resources/plans.ts +184 -17
  187. package/src/resources/products.ts +36 -37
  188. package/src/resources/promo-codes.ts +490 -0
  189. package/src/resources/reviews.ts +348 -0
  190. package/src/resources/shared.ts +128 -14
  191. package/src/resources/transfers.ts +10 -0
  192. package/src/version.ts +1 -1
  193. package/version.d.mts +1 -1
  194. package/version.d.ts +1 -1
  195. package/version.js +1 -1
  196. package/version.mjs +1 -1
@@ -0,0 +1,490 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as Shared from './shared';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { path } from '../internal/utils/path';
9
+
10
+ export class PromoCodes extends APIResource {
11
+ /**
12
+ * Create a new promo code for a product or plan
13
+ *
14
+ * Required permissions:
15
+ *
16
+ * - `promo_code:create`
17
+ * - `access_pass:basic:read`
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const promoCode = await client.promoCodes.create({
22
+ * amount_off: 6.9,
23
+ * base_currency: 'usd',
24
+ * code: 'code',
25
+ * company_id: 'biz_xxxxxxxxxxxxxx',
26
+ * new_users_only: true,
27
+ * promo_duration_months: 42,
28
+ * promo_type: 'percentage',
29
+ * });
30
+ * ```
31
+ */
32
+ create(body: PromoCodeCreateParams, options?: RequestOptions): APIPromise<PromoCode> {
33
+ return this._client.post('/promo_codes', { body, ...options });
34
+ }
35
+
36
+ /**
37
+ * Retrieves a promo code by ID
38
+ *
39
+ * Required permissions:
40
+ *
41
+ * - `promo_code:basic:read`
42
+ * - `access_pass:basic:read`
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const promoCode = await client.promoCodes.retrieve(
47
+ * 'promo_xxxxxxxxxxxx',
48
+ * );
49
+ * ```
50
+ */
51
+ retrieve(id: string, options?: RequestOptions): APIPromise<PromoCode> {
52
+ return this._client.get(path`/promo_codes/${id}`, options);
53
+ }
54
+
55
+ /**
56
+ * Lists promo codes for a company
57
+ *
58
+ * Required permissions:
59
+ *
60
+ * - `promo_code:basic:read`
61
+ * - `access_pass:basic:read`
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * // Automatically fetches more pages as needed.
66
+ * for await (const promoCodeListResponse of client.promoCodes.list(
67
+ * { company_id: 'biz_xxxxxxxxxxxxxx' },
68
+ * )) {
69
+ * // ...
70
+ * }
71
+ * ```
72
+ */
73
+ list(
74
+ query: PromoCodeListParams,
75
+ options?: RequestOptions,
76
+ ): PagePromise<PromoCodeListResponsesCursorPage, PromoCodeListResponse> {
77
+ return this._client.getAPIList('/promo_codes', CursorPage<PromoCodeListResponse>, { query, ...options });
78
+ }
79
+
80
+ /**
81
+ * Archive a promo code, preventing further use
82
+ *
83
+ * Required permissions:
84
+ *
85
+ * - `promo_code:delete`
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const promoCode = await client.promoCodes.delete(
90
+ * 'promo_xxxxxxxxxxxx',
91
+ * );
92
+ * ```
93
+ */
94
+ delete(id: string, options?: RequestOptions): APIPromise<PromoCodeDeleteResponse> {
95
+ return this._client.delete(path`/promo_codes/${id}`, options);
96
+ }
97
+ }
98
+
99
+ export type PromoCodeListResponsesCursorPage = CursorPage<PromoCodeListResponse>;
100
+
101
+ /**
102
+ * An object representing a promo code for a plan.
103
+ */
104
+ export interface PromoCode {
105
+ /**
106
+ * The ID of the promo.
107
+ */
108
+ id: string;
109
+
110
+ /**
111
+ * The amount off (% or flat amount) for the promo.
112
+ */
113
+ amount_off: number;
114
+
115
+ /**
116
+ * Restricts promo use to only users who have churned from the company before.
117
+ */
118
+ churned_users_only: boolean;
119
+
120
+ /**
121
+ * The specific code used to apply the promo at checkout.
122
+ */
123
+ code: string | null;
124
+
125
+ /**
126
+ * The company for the promo code.
127
+ */
128
+ company: PromoCode.Company;
129
+
130
+ /**
131
+ * The timestamp of when the promo was created.
132
+ */
133
+ created_at: string;
134
+
135
+ /**
136
+ * The monetary currency of the promo code.
137
+ */
138
+ currency: Shared.Currency;
139
+
140
+ /**
141
+ * The duration setting for the promo code
142
+ */
143
+ duration: PromoDuration | null;
144
+
145
+ /**
146
+ * Restricts promo use to only be applied to already purchased memberships.
147
+ */
148
+ existing_memberships_only: boolean;
149
+
150
+ /**
151
+ * The date/time of when the promo expires.
152
+ */
153
+ expires_at: string | null;
154
+
155
+ /**
156
+ * Restricts promo use to only users who have never purchased from the company
157
+ * before.
158
+ */
159
+ new_users_only: boolean;
160
+
161
+ /**
162
+ * Restricts promo use to only be applied once per customer.
163
+ */
164
+ one_per_customer: boolean;
165
+
166
+ /**
167
+ * The access pass associated with the promo code.
168
+ */
169
+ product: PromoCode.Product | null;
170
+
171
+ /**
172
+ * The number of months the promo is applied for.
173
+ */
174
+ promo_duration_months: number | null;
175
+
176
+ /**
177
+ * The type (% or flat amount) of the promo.
178
+ */
179
+ promo_type: Shared.PromoType;
180
+
181
+ /**
182
+ * Indicates if the promo code is live or disabled.
183
+ */
184
+ status: PromoCodeStatus;
185
+
186
+ /**
187
+ * The quantity limit on the number of uses.
188
+ */
189
+ stock: number;
190
+
191
+ /**
192
+ * Whether or not the promo code has unlimited stock.
193
+ */
194
+ unlimited_stock: boolean;
195
+
196
+ /**
197
+ * The amount of times the promo codes has been used.
198
+ */
199
+ uses: number;
200
+ }
201
+
202
+ export namespace PromoCode {
203
+ /**
204
+ * The company for the promo code.
205
+ */
206
+ export interface Company {
207
+ /**
208
+ * The ID of the company
209
+ */
210
+ id: string;
211
+
212
+ /**
213
+ * The written name of the company.
214
+ */
215
+ title: string;
216
+ }
217
+
218
+ /**
219
+ * The access pass associated with the promo code.
220
+ */
221
+ export interface Product {
222
+ /**
223
+ * The internal ID of the public product.
224
+ */
225
+ id: string;
226
+
227
+ /**
228
+ * The title of the product. Use for Whop 4.0.
229
+ */
230
+ title: string;
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Statuses for promo codes
236
+ */
237
+ export type PromoCodeStatus = 'active' | 'inactive' | 'archived';
238
+
239
+ /**
240
+ * The duration setting for the promo code
241
+ */
242
+ export type PromoDuration = 'forever' | 'once' | 'repeating';
243
+
244
+ /**
245
+ * An object representing a promo code for a plan.
246
+ */
247
+ export interface PromoCodeListResponse {
248
+ /**
249
+ * The ID of the promo.
250
+ */
251
+ id: string;
252
+
253
+ /**
254
+ * The amount off (% or flat amount) for the promo.
255
+ */
256
+ amount_off: number;
257
+
258
+ /**
259
+ * Restricts promo use to only users who have churned from the company before.
260
+ */
261
+ churned_users_only: boolean;
262
+
263
+ /**
264
+ * The specific code used to apply the promo at checkout.
265
+ */
266
+ code: string | null;
267
+
268
+ /**
269
+ * The timestamp of when the promo was created.
270
+ */
271
+ created_at: string;
272
+
273
+ /**
274
+ * The monetary currency of the promo code.
275
+ */
276
+ currency: Shared.Currency;
277
+
278
+ /**
279
+ * The duration setting for the promo code
280
+ */
281
+ duration: PromoDuration | null;
282
+
283
+ /**
284
+ * Restricts promo use to only be applied to already purchased memberships.
285
+ */
286
+ existing_memberships_only: boolean;
287
+
288
+ /**
289
+ * The date/time of when the promo expires.
290
+ */
291
+ expires_at: string | null;
292
+
293
+ /**
294
+ * Restricts promo use to only users who have never purchased from the company
295
+ * before.
296
+ */
297
+ new_users_only: boolean;
298
+
299
+ /**
300
+ * Restricts promo use to only be applied once per customer.
301
+ */
302
+ one_per_customer: boolean;
303
+
304
+ /**
305
+ * The access pass associated with the promo code.
306
+ */
307
+ product: PromoCodeListResponse.Product | null;
308
+
309
+ /**
310
+ * The number of months the promo is applied for.
311
+ */
312
+ promo_duration_months: number | null;
313
+
314
+ /**
315
+ * The type (% or flat amount) of the promo.
316
+ */
317
+ promo_type: Shared.PromoType;
318
+
319
+ /**
320
+ * Indicates if the promo code is live or disabled.
321
+ */
322
+ status: PromoCodeStatus;
323
+
324
+ /**
325
+ * The quantity limit on the number of uses.
326
+ */
327
+ stock: number;
328
+
329
+ /**
330
+ * Whether or not the promo code has unlimited stock.
331
+ */
332
+ unlimited_stock: boolean;
333
+
334
+ /**
335
+ * The amount of times the promo codes has been used.
336
+ */
337
+ uses: number;
338
+ }
339
+
340
+ export namespace PromoCodeListResponse {
341
+ /**
342
+ * The access pass associated with the promo code.
343
+ */
344
+ export interface Product {
345
+ /**
346
+ * The internal ID of the public product.
347
+ */
348
+ id: string;
349
+
350
+ /**
351
+ * The title of the product. Use for Whop 4.0.
352
+ */
353
+ title: string;
354
+ }
355
+ }
356
+
357
+ /**
358
+ * Represents `true` or `false` values.
359
+ */
360
+ export type PromoCodeDeleteResponse = boolean;
361
+
362
+ export interface PromoCodeCreateParams {
363
+ /**
364
+ * The amount off (% or flat amount) for the promo.
365
+ */
366
+ amount_off: number;
367
+
368
+ /**
369
+ * The monetary currency of the promo code.
370
+ */
371
+ base_currency: Shared.Currency;
372
+
373
+ /**
374
+ * The specific code used to apply the promo at checkout.
375
+ */
376
+ code: string;
377
+
378
+ /**
379
+ * The id of the company to create the promo code for.
380
+ */
381
+ company_id: string;
382
+
383
+ /**
384
+ * Restricts promo use to only users who have never purchased from the company
385
+ * before.
386
+ */
387
+ new_users_only: boolean;
388
+
389
+ /**
390
+ * The number of months this promo code is applied and valid for.
391
+ */
392
+ promo_duration_months: number;
393
+
394
+ /**
395
+ * The type (% or flat amount) of the promo.
396
+ */
397
+ promo_type: Shared.PromoType;
398
+
399
+ /**
400
+ * Restricts promo use to only users who have churned from the company before.
401
+ */
402
+ churned_users_only?: boolean | null;
403
+
404
+ /**
405
+ * Whether this promo code is for existing memberships only (cancelations)
406
+ */
407
+ existing_memberships_only?: boolean | null;
408
+
409
+ /**
410
+ * The date/time of when the promo expires.
411
+ */
412
+ expires_at?: string | null;
413
+
414
+ /**
415
+ * Restricts promo use to only be applied once per customer.
416
+ */
417
+ one_per_customer?: boolean | null;
418
+
419
+ /**
420
+ * The IDs of the plans that the promo code applies to. If product_id is provided,
421
+ * it will only apply to plans attached to that product
422
+ */
423
+ plan_ids?: Array<string> | null;
424
+
425
+ /**
426
+ * The product to lock the promo code to, if any. If provided will filter out any
427
+ * plan ids not attached to this product
428
+ */
429
+ product_id?: string | null;
430
+
431
+ /**
432
+ * The quantity limit on the number of uses.
433
+ */
434
+ stock?: number | null;
435
+
436
+ /**
437
+ * Whether or not the promo code should have unlimited stock.
438
+ */
439
+ unlimited_stock?: boolean | null;
440
+ }
441
+
442
+ export interface PromoCodeListParams extends CursorPageParams {
443
+ /**
444
+ * The ID of the company to list promo codes for
445
+ */
446
+ company_id: string;
447
+
448
+ /**
449
+ * Returns the elements in the list that come before the specified cursor.
450
+ */
451
+ before?: string | null;
452
+
453
+ /**
454
+ * Returns the first _n_ elements from the list.
455
+ */
456
+ first?: number | null;
457
+
458
+ /**
459
+ * Returns the last _n_ elements from the list.
460
+ */
461
+ last?: number | null;
462
+
463
+ /**
464
+ * Filter promo codes by plan ID(s)
465
+ */
466
+ plan_ids?: Array<string> | null;
467
+
468
+ /**
469
+ * Filter promo codes by product ID(s)
470
+ */
471
+ product_ids?: Array<string> | null;
472
+
473
+ /**
474
+ * Statuses for promo codes
475
+ */
476
+ status?: PromoCodeStatus | null;
477
+ }
478
+
479
+ export declare namespace PromoCodes {
480
+ export {
481
+ type PromoCode as PromoCode,
482
+ type PromoCodeStatus as PromoCodeStatus,
483
+ type PromoDuration as PromoDuration,
484
+ type PromoCodeListResponse as PromoCodeListResponse,
485
+ type PromoCodeDeleteResponse as PromoCodeDeleteResponse,
486
+ type PromoCodeListResponsesCursorPage as PromoCodeListResponsesCursorPage,
487
+ type PromoCodeCreateParams as PromoCodeCreateParams,
488
+ type PromoCodeListParams as PromoCodeListParams,
489
+ };
490
+ }