@whop/sdk 0.0.34 → 0.0.36

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 (139) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/client.d.mts +12 -6
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +12 -6
  5. package/client.d.ts.map +1 -1
  6. package/client.js +6 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +7 -1
  9. package/client.mjs.map +1 -1
  10. package/internal/utils/env.js +2 -2
  11. package/internal/utils/env.js.map +1 -1
  12. package/internal/utils/env.mjs +2 -2
  13. package/internal/utils/env.mjs.map +1 -1
  14. package/package.json +1 -1
  15. package/resources/affiliates/affiliates.d.mts +353 -0
  16. package/resources/affiliates/affiliates.d.mts.map +1 -0
  17. package/resources/affiliates/affiliates.d.ts +353 -0
  18. package/resources/affiliates/affiliates.d.ts.map +1 -0
  19. package/resources/affiliates/affiliates.js +112 -0
  20. package/resources/affiliates/affiliates.js.map +1 -0
  21. package/resources/affiliates/affiliates.mjs +107 -0
  22. package/resources/affiliates/affiliates.mjs.map +1 -0
  23. package/resources/affiliates/index.d.mts +3 -0
  24. package/resources/affiliates/index.d.mts.map +1 -0
  25. package/resources/affiliates/index.d.ts +3 -0
  26. package/resources/affiliates/index.d.ts.map +1 -0
  27. package/resources/affiliates/index.js +9 -0
  28. package/resources/affiliates/index.js.map +1 -0
  29. package/resources/affiliates/index.mjs +4 -0
  30. package/resources/affiliates/index.mjs.map +1 -0
  31. package/resources/affiliates/overrides.d.mts +451 -0
  32. package/resources/affiliates/overrides.d.mts.map +1 -0
  33. package/resources/affiliates/overrides.d.ts +451 -0
  34. package/resources/affiliates/overrides.d.ts.map +1 -0
  35. package/resources/affiliates/overrides.js +117 -0
  36. package/resources/affiliates/overrides.js.map +1 -0
  37. package/resources/affiliates/overrides.mjs +113 -0
  38. package/resources/affiliates/overrides.mjs.map +1 -0
  39. package/resources/affiliates.d.mts +2 -0
  40. package/resources/affiliates.d.mts.map +1 -0
  41. package/resources/affiliates.d.ts +2 -0
  42. package/resources/affiliates.d.ts.map +1 -0
  43. package/resources/affiliates.js +6 -0
  44. package/resources/affiliates.js.map +1 -0
  45. package/resources/affiliates.mjs +3 -0
  46. package/resources/affiliates.mjs.map +1 -0
  47. package/resources/ai-chats.d.mts +21 -2
  48. package/resources/ai-chats.d.mts.map +1 -1
  49. package/resources/ai-chats.d.ts +21 -2
  50. package/resources/ai-chats.d.ts.map +1 -1
  51. package/resources/ai-chats.js +2 -1
  52. package/resources/ai-chats.js.map +1 -1
  53. package/resources/ai-chats.mjs +2 -1
  54. package/resources/ai-chats.mjs.map +1 -1
  55. package/resources/apps.d.mts +26 -0
  56. package/resources/apps.d.mts.map +1 -1
  57. package/resources/apps.d.ts +26 -0
  58. package/resources/apps.d.ts.map +1 -1
  59. package/resources/checkout-configurations.d.mts +69 -0
  60. package/resources/checkout-configurations.d.mts.map +1 -1
  61. package/resources/checkout-configurations.d.ts +69 -0
  62. package/resources/checkout-configurations.d.ts.map +1 -1
  63. package/resources/companies.d.mts +19 -0
  64. package/resources/companies.d.mts.map +1 -1
  65. package/resources/companies.d.ts +19 -0
  66. package/resources/companies.d.ts.map +1 -1
  67. package/resources/index.d.mts +4 -3
  68. package/resources/index.d.mts.map +1 -1
  69. package/resources/index.d.ts +4 -3
  70. package/resources/index.d.ts.map +1 -1
  71. package/resources/index.js +4 -2
  72. package/resources/index.js.map +1 -1
  73. package/resources/index.mjs +1 -0
  74. package/resources/index.mjs.map +1 -1
  75. package/resources/invoices.d.mts +179 -345
  76. package/resources/invoices.d.mts.map +1 -1
  77. package/resources/invoices.d.ts +179 -345
  78. package/resources/invoices.d.ts.map +1 -1
  79. package/resources/invoices.js +20 -2
  80. package/resources/invoices.js.map +1 -1
  81. package/resources/invoices.mjs +20 -2
  82. package/resources/invoices.mjs.map +1 -1
  83. package/resources/memberships.d.mts +1 -1
  84. package/resources/memberships.d.mts.map +1 -1
  85. package/resources/memberships.d.ts +1 -1
  86. package/resources/memberships.d.ts.map +1 -1
  87. package/resources/payments.d.mts +21 -2
  88. package/resources/payments.d.mts.map +1 -1
  89. package/resources/payments.d.ts +21 -2
  90. package/resources/payments.d.ts.map +1 -1
  91. package/resources/plans.d.mts +46 -0
  92. package/resources/plans.d.mts.map +1 -1
  93. package/resources/plans.d.ts +46 -0
  94. package/resources/plans.d.ts.map +1 -1
  95. package/resources/products.d.mts +2 -2
  96. package/resources/products.d.ts +2 -2
  97. package/resources/refunds.d.mts +1 -1
  98. package/resources/refunds.d.mts.map +1 -1
  99. package/resources/refunds.d.ts +1 -1
  100. package/resources/refunds.d.ts.map +1 -1
  101. package/resources/setup-intents.d.mts +74 -0
  102. package/resources/setup-intents.d.mts.map +1 -1
  103. package/resources/setup-intents.d.ts +74 -0
  104. package/resources/setup-intents.d.ts.map +1 -1
  105. package/resources/shared.d.mts +54 -5
  106. package/resources/shared.d.mts.map +1 -1
  107. package/resources/shared.d.ts +54 -5
  108. package/resources/shared.d.ts.map +1 -1
  109. package/resources/webhooks.d.mts +653 -3
  110. package/resources/webhooks.d.mts.map +1 -1
  111. package/resources/webhooks.d.ts +653 -3
  112. package/resources/webhooks.d.ts.map +1 -1
  113. package/resources/webhooks.js.map +1 -1
  114. package/resources/webhooks.mjs.map +1 -1
  115. package/src/client.ts +50 -1
  116. package/src/internal/utils/env.ts +2 -2
  117. package/src/resources/affiliates/affiliates.ts +475 -0
  118. package/src/resources/affiliates/index.ts +32 -0
  119. package/src/resources/affiliates/overrides.ts +593 -0
  120. package/src/resources/affiliates.ts +3 -0
  121. package/src/resources/ai-chats.ts +25 -1
  122. package/src/resources/apps.ts +31 -0
  123. package/src/resources/checkout-configurations.ts +81 -0
  124. package/src/resources/companies.ts +23 -0
  125. package/src/resources/index.ts +19 -0
  126. package/src/resources/invoices.ts +316 -397
  127. package/src/resources/memberships.ts +1 -1
  128. package/src/resources/payments.ts +26 -1
  129. package/src/resources/plans.ts +54 -0
  130. package/src/resources/products.ts +2 -2
  131. package/src/resources/refunds.ts +2 -1
  132. package/src/resources/setup-intents.ts +90 -0
  133. package/src/resources/shared.ts +65 -5
  134. package/src/resources/webhooks.ts +818 -0
  135. package/src/version.ts +1 -1
  136. package/version.d.mts +1 -1
  137. package/version.d.ts +1 -1
  138. package/version.js +1 -1
  139. package/version.mjs +1 -1
@@ -0,0 +1,475 @@
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 * as OverridesAPI from './overrides';
6
+ import {
7
+ AffiliateAppliesToPayments,
8
+ AffiliateAppliesToProducts,
9
+ AffiliateOverrideRoles,
10
+ AffiliatePayoutTypes,
11
+ AffiliateRevenueBases,
12
+ OverrideCreateParams,
13
+ OverrideCreateResponse,
14
+ OverrideDeleteParams,
15
+ OverrideDeleteResponse,
16
+ OverrideListParams,
17
+ OverrideListResponse,
18
+ OverrideListResponsesCursorPage,
19
+ OverrideRetrieveParams,
20
+ OverrideRetrieveResponse,
21
+ OverrideUpdateParams,
22
+ OverrideUpdateResponse,
23
+ Overrides,
24
+ } from './overrides';
25
+ import { APIPromise } from '../../core/api-promise';
26
+ import { CursorPage, type CursorPageParams, PagePromise } from '../../core/pagination';
27
+ import { RequestOptions } from '../../internal/request-options';
28
+ import { path } from '../../internal/utils/path';
29
+
30
+ /**
31
+ * Affiliates
32
+ */
33
+ export class Affiliates extends APIResource {
34
+ overrides: OverridesAPI.Overrides = new OverridesAPI.Overrides(this._client);
35
+
36
+ /**
37
+ * Creates or finds an affiliate for a company and user.
38
+ *
39
+ * Required permissions:
40
+ *
41
+ * - `affiliate:create`
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const affiliate = await client.affiliates.create({
46
+ * company_id: 'biz_xxxxxxxxxxxxxx',
47
+ * user_identifier: 'user_identifier',
48
+ * });
49
+ * ```
50
+ */
51
+ create(body: AffiliateCreateParams, options?: RequestOptions): APIPromise<Affiliate> {
52
+ return this._client.post('/affiliates', { body, ...options });
53
+ }
54
+
55
+ /**
56
+ * Retrieves the details of an existing affiliate.
57
+ *
58
+ * Required permissions:
59
+ *
60
+ * - `affiliate:basic:read`
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const affiliate = await client.affiliates.retrieve(
65
+ * 'aff_xxxxxxxxxxxxxx',
66
+ * );
67
+ * ```
68
+ */
69
+ retrieve(id: string, options?: RequestOptions): APIPromise<Affiliate> {
70
+ return this._client.get(path`/affiliates/${id}`, options);
71
+ }
72
+
73
+ /**
74
+ * Returns a paginated list of affiliates for the actor in context, with optional
75
+ * filtering by status, search, and sorting.
76
+ *
77
+ * Required permissions:
78
+ *
79
+ * - `affiliate:basic:read`
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // Automatically fetches more pages as needed.
84
+ * for await (const affiliateListResponse of client.affiliates.list(
85
+ * { company_id: 'biz_xxxxxxxxxxxxxx' },
86
+ * )) {
87
+ * // ...
88
+ * }
89
+ * ```
90
+ */
91
+ list(
92
+ query: AffiliateListParams,
93
+ options?: RequestOptions,
94
+ ): PagePromise<AffiliateListResponsesCursorPage, AffiliateListResponse> {
95
+ return this._client.getAPIList('/affiliates', CursorPage<AffiliateListResponse>, { query, ...options });
96
+ }
97
+
98
+ /**
99
+ * Archives an existing Affiliate
100
+ *
101
+ * Required permissions:
102
+ *
103
+ * - `affiliate:update`
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const response = await client.affiliates.archive(
108
+ * 'aff_xxxxxxxxxxxxxx',
109
+ * );
110
+ * ```
111
+ */
112
+ archive(id: string, options?: RequestOptions): APIPromise<AffiliateArchiveResponse> {
113
+ return this._client.post(path`/affiliates/${id}/archive`, options);
114
+ }
115
+
116
+ /**
117
+ * Unarchives an existing Affiliate
118
+ *
119
+ * Required permissions:
120
+ *
121
+ * - `affiliate:update`
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const response = await client.affiliates.unarchive(
126
+ * 'aff_xxxxxxxxxxxxxx',
127
+ * );
128
+ * ```
129
+ */
130
+ unarchive(id: string, options?: RequestOptions): APIPromise<AffiliateUnarchiveResponse> {
131
+ return this._client.post(path`/affiliates/${id}/unarchive`, options);
132
+ }
133
+ }
134
+
135
+ export type AffiliateListResponsesCursorPage = CursorPage<AffiliateListResponse>;
136
+
137
+ /**
138
+ * An affiliate tracks a user's referral performance and commission earnings for a
139
+ * company, including retention rates, revenue metrics, and payout configurations.
140
+ */
141
+ export interface Affiliate {
142
+ /**
143
+ * The unique identifier for the affiliate.
144
+ */
145
+ id: string;
146
+
147
+ /**
148
+ * The total active members of the affiliate
149
+ */
150
+ active_members_count: number;
151
+
152
+ /**
153
+ * The company attached to this affiliate
154
+ */
155
+ company: Affiliate.Company;
156
+
157
+ /**
158
+ * The datetime the affiliate was created.
159
+ */
160
+ created_at: string;
161
+
162
+ /**
163
+ * The percentage of referred customers who are still active members
164
+ */
165
+ customer_retention_rate: string;
166
+
167
+ /**
168
+ * The percentage of referred customers who remained active over the last 90 days
169
+ */
170
+ customer_retention_rate_ninety_days: string;
171
+
172
+ /**
173
+ * The monthly recurring revenue generated by this affiliate's referrals, formatted
174
+ * as a USD currency string
175
+ */
176
+ monthly_recurring_revenue_usd: string;
177
+
178
+ /**
179
+ * Statuses for resources
180
+ */
181
+ status: Status | null;
182
+
183
+ /**
184
+ * The total count of all overrides for this affiliate
185
+ */
186
+ total_overrides_count: number;
187
+
188
+ /**
189
+ * The total commission earnings paid to this affiliate, formatted as a USD
190
+ * currency string
191
+ */
192
+ total_referral_earnings_usd: string;
193
+
194
+ /**
195
+ * The total referrals of the affiliate
196
+ */
197
+ total_referrals_count: number;
198
+
199
+ /**
200
+ * The total revenue generated from this affiliate's referrals, formatted as a USD
201
+ * currency string
202
+ */
203
+ total_revenue_usd: string;
204
+
205
+ /**
206
+ * The datetime the affiliate was last updated.
207
+ */
208
+ updated_at: string;
209
+
210
+ /**
211
+ * The user attached to this affiliate
212
+ */
213
+ user: Affiliate.User;
214
+ }
215
+
216
+ export namespace Affiliate {
217
+ /**
218
+ * The company attached to this affiliate
219
+ */
220
+ export interface Company {
221
+ /**
222
+ * The unique identifier for the company.
223
+ */
224
+ id: string;
225
+
226
+ /**
227
+ * The written name of the company.
228
+ */
229
+ title: string;
230
+ }
231
+
232
+ /**
233
+ * The user attached to this affiliate
234
+ */
235
+ export interface User {
236
+ /**
237
+ * The unique identifier for the user.
238
+ */
239
+ id: string;
240
+
241
+ /**
242
+ * The display name set on the user's Whop profile. Null if the user has not set a
243
+ * name.
244
+ */
245
+ name: string | null;
246
+
247
+ /**
248
+ * The unique username chosen by the user for their Whop profile. Null if the user
249
+ * has not set a username.
250
+ */
251
+ username: string | null;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Statuses for resources
257
+ */
258
+ export type Status = 'active' | 'archived' | 'deleted';
259
+
260
+ /**
261
+ * An affiliate tracks a user's referral performance and commission earnings for a
262
+ * company, including retention rates, revenue metrics, and payout configurations.
263
+ */
264
+ export interface AffiliateListResponse {
265
+ /**
266
+ * The unique identifier for the affiliate.
267
+ */
268
+ id: string;
269
+
270
+ /**
271
+ * The total active members of the affiliate
272
+ */
273
+ active_members_count: number;
274
+
275
+ /**
276
+ * The company attached to this affiliate
277
+ */
278
+ company: AffiliateListResponse.Company;
279
+
280
+ /**
281
+ * The datetime the affiliate was created.
282
+ */
283
+ created_at: string;
284
+
285
+ /**
286
+ * The percentage of referred customers who are still active members
287
+ */
288
+ customer_retention_rate: string;
289
+
290
+ /**
291
+ * The percentage of referred customers who remained active over the last 90 days
292
+ */
293
+ customer_retention_rate_ninety_days: string;
294
+
295
+ /**
296
+ * The monthly recurring revenue generated by this affiliate's referrals, formatted
297
+ * as a USD currency string
298
+ */
299
+ monthly_recurring_revenue_usd: string;
300
+
301
+ /**
302
+ * Statuses for resources
303
+ */
304
+ status: Status | null;
305
+
306
+ /**
307
+ * The total count of all overrides for this affiliate
308
+ */
309
+ total_overrides_count: number;
310
+
311
+ /**
312
+ * The total commission earnings paid to this affiliate, formatted as a USD
313
+ * currency string
314
+ */
315
+ total_referral_earnings_usd: string;
316
+
317
+ /**
318
+ * The total referrals of the affiliate
319
+ */
320
+ total_referrals_count: number;
321
+
322
+ /**
323
+ * The total revenue generated from this affiliate's referrals, formatted as a USD
324
+ * currency string
325
+ */
326
+ total_revenue_usd: string;
327
+
328
+ /**
329
+ * The datetime the affiliate was last updated.
330
+ */
331
+ updated_at: string;
332
+
333
+ /**
334
+ * The user attached to this affiliate
335
+ */
336
+ user: AffiliateListResponse.User;
337
+ }
338
+
339
+ export namespace AffiliateListResponse {
340
+ /**
341
+ * The company attached to this affiliate
342
+ */
343
+ export interface Company {
344
+ /**
345
+ * The unique identifier for the company.
346
+ */
347
+ id: string;
348
+
349
+ /**
350
+ * The written name of the company.
351
+ */
352
+ title: string;
353
+ }
354
+
355
+ /**
356
+ * The user attached to this affiliate
357
+ */
358
+ export interface User {
359
+ /**
360
+ * The unique identifier for the user.
361
+ */
362
+ id: string;
363
+
364
+ /**
365
+ * The display name set on the user's Whop profile. Null if the user has not set a
366
+ * name.
367
+ */
368
+ name: string | null;
369
+
370
+ /**
371
+ * The unique username chosen by the user for their Whop profile. Null if the user
372
+ * has not set a username.
373
+ */
374
+ username: string | null;
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Represents `true` or `false` values.
380
+ */
381
+ export type AffiliateArchiveResponse = boolean;
382
+
383
+ /**
384
+ * Represents `true` or `false` values.
385
+ */
386
+ export type AffiliateUnarchiveResponse = boolean;
387
+
388
+ export interface AffiliateCreateParams {
389
+ /**
390
+ * The ID of the company to create the affiliate for.
391
+ */
392
+ company_id: string;
393
+
394
+ /**
395
+ * The user identifier (username, email, user ID, or Discord ID).
396
+ */
397
+ user_identifier: string;
398
+ }
399
+
400
+ export interface AffiliateListParams extends CursorPageParams {
401
+ /**
402
+ * The unique identifier of the company to list affiliates for.
403
+ */
404
+ company_id: string;
405
+
406
+ /**
407
+ * Returns the elements in the list that come before the specified cursor.
408
+ */
409
+ before?: string | null;
410
+
411
+ /**
412
+ * The direction of the sort.
413
+ */
414
+ direction?: Shared.Direction | null;
415
+
416
+ /**
417
+ * Returns the first _n_ elements from the list.
418
+ */
419
+ first?: number | null;
420
+
421
+ /**
422
+ * Returns the last _n_ elements from the list.
423
+ */
424
+ last?: number | null;
425
+
426
+ /**
427
+ * Which columns can be used to sort.
428
+ */
429
+ order?: 'id' | 'created_at' | 'cached_total_referrals' | 'cached_total_rewards' | null;
430
+
431
+ /**
432
+ * Search affiliates by username.
433
+ */
434
+ query?: string | null;
435
+
436
+ /**
437
+ * Statuses for resources
438
+ */
439
+ status?: Status | null;
440
+ }
441
+
442
+ Affiliates.Overrides = Overrides;
443
+
444
+ export declare namespace Affiliates {
445
+ export {
446
+ type Affiliate as Affiliate,
447
+ type Status as Status,
448
+ type AffiliateListResponse as AffiliateListResponse,
449
+ type AffiliateArchiveResponse as AffiliateArchiveResponse,
450
+ type AffiliateUnarchiveResponse as AffiliateUnarchiveResponse,
451
+ type AffiliateListResponsesCursorPage as AffiliateListResponsesCursorPage,
452
+ type AffiliateCreateParams as AffiliateCreateParams,
453
+ type AffiliateListParams as AffiliateListParams,
454
+ };
455
+
456
+ export {
457
+ Overrides as Overrides,
458
+ type AffiliateAppliesToPayments as AffiliateAppliesToPayments,
459
+ type AffiliateAppliesToProducts as AffiliateAppliesToProducts,
460
+ type AffiliateOverrideRoles as AffiliateOverrideRoles,
461
+ type AffiliatePayoutTypes as AffiliatePayoutTypes,
462
+ type AffiliateRevenueBases as AffiliateRevenueBases,
463
+ type OverrideCreateResponse as OverrideCreateResponse,
464
+ type OverrideRetrieveResponse as OverrideRetrieveResponse,
465
+ type OverrideUpdateResponse as OverrideUpdateResponse,
466
+ type OverrideListResponse as OverrideListResponse,
467
+ type OverrideDeleteResponse as OverrideDeleteResponse,
468
+ type OverrideListResponsesCursorPage as OverrideListResponsesCursorPage,
469
+ type OverrideCreateParams as OverrideCreateParams,
470
+ type OverrideRetrieveParams as OverrideRetrieveParams,
471
+ type OverrideUpdateParams as OverrideUpdateParams,
472
+ type OverrideListParams as OverrideListParams,
473
+ type OverrideDeleteParams as OverrideDeleteParams,
474
+ };
475
+ }
@@ -0,0 +1,32 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Affiliates,
5
+ type Affiliate,
6
+ type Status,
7
+ type AffiliateListResponse,
8
+ type AffiliateArchiveResponse,
9
+ type AffiliateUnarchiveResponse,
10
+ type AffiliateCreateParams,
11
+ type AffiliateListParams,
12
+ type AffiliateListResponsesCursorPage,
13
+ } from './affiliates';
14
+ export {
15
+ Overrides,
16
+ type AffiliateAppliesToPayments,
17
+ type AffiliateAppliesToProducts,
18
+ type AffiliateOverrideRoles,
19
+ type AffiliatePayoutTypes,
20
+ type AffiliateRevenueBases,
21
+ type OverrideCreateResponse,
22
+ type OverrideRetrieveResponse,
23
+ type OverrideUpdateResponse,
24
+ type OverrideListResponse,
25
+ type OverrideDeleteResponse,
26
+ type OverrideCreateParams,
27
+ type OverrideRetrieveParams,
28
+ type OverrideUpdateParams,
29
+ type OverrideListParams,
30
+ type OverrideDeleteParams,
31
+ type OverrideListResponsesCursorPage,
32
+ } from './overrides';