@whop/sdk 0.0.33 → 0.0.35

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 (103) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/client.d.mts +10 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +10 -4
  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 +6 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/affiliates/affiliates.d.mts +345 -0
  12. package/resources/affiliates/affiliates.d.mts.map +1 -0
  13. package/resources/affiliates/affiliates.d.ts +345 -0
  14. package/resources/affiliates/affiliates.d.ts.map +1 -0
  15. package/resources/affiliates/affiliates.js +112 -0
  16. package/resources/affiliates/affiliates.js.map +1 -0
  17. package/resources/affiliates/affiliates.mjs +107 -0
  18. package/resources/affiliates/affiliates.mjs.map +1 -0
  19. package/resources/affiliates/index.d.mts +3 -0
  20. package/resources/affiliates/index.d.mts.map +1 -0
  21. package/resources/affiliates/index.d.ts +3 -0
  22. package/resources/affiliates/index.d.ts.map +1 -0
  23. package/resources/affiliates/index.js +9 -0
  24. package/resources/affiliates/index.js.map +1 -0
  25. package/resources/affiliates/index.mjs +4 -0
  26. package/resources/affiliates/index.mjs.map +1 -0
  27. package/resources/affiliates/overrides.d.mts +443 -0
  28. package/resources/affiliates/overrides.d.mts.map +1 -0
  29. package/resources/affiliates/overrides.d.ts +443 -0
  30. package/resources/affiliates/overrides.d.ts.map +1 -0
  31. package/resources/affiliates/overrides.js +117 -0
  32. package/resources/affiliates/overrides.js.map +1 -0
  33. package/resources/affiliates/overrides.mjs +113 -0
  34. package/resources/affiliates/overrides.mjs.map +1 -0
  35. package/resources/affiliates.d.mts +2 -0
  36. package/resources/affiliates.d.mts.map +1 -0
  37. package/resources/affiliates.d.ts +2 -0
  38. package/resources/affiliates.d.ts.map +1 -0
  39. package/resources/affiliates.js +6 -0
  40. package/resources/affiliates.js.map +1 -0
  41. package/resources/affiliates.mjs +3 -0
  42. package/resources/affiliates.mjs.map +1 -0
  43. package/resources/ai-chats.d.mts +21 -2
  44. package/resources/ai-chats.d.mts.map +1 -1
  45. package/resources/ai-chats.d.ts +21 -2
  46. package/resources/ai-chats.d.ts.map +1 -1
  47. package/resources/ai-chats.js +2 -1
  48. package/resources/ai-chats.js.map +1 -1
  49. package/resources/ai-chats.mjs +2 -1
  50. package/resources/ai-chats.mjs.map +1 -1
  51. package/resources/index.d.mts +3 -2
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +3 -2
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js +4 -2
  56. package/resources/index.js.map +1 -1
  57. package/resources/index.mjs +1 -0
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/payments.d.mts +1 -1
  60. package/resources/payments.d.mts.map +1 -1
  61. package/resources/payments.d.ts +1 -1
  62. package/resources/payments.d.ts.map +1 -1
  63. package/resources/refunds.d.mts +15 -7
  64. package/resources/refunds.d.mts.map +1 -1
  65. package/resources/refunds.d.ts +15 -7
  66. package/resources/refunds.d.ts.map +1 -1
  67. package/resources/refunds.js +3 -3
  68. package/resources/refunds.js.map +1 -1
  69. package/resources/refunds.mjs +3 -3
  70. package/resources/refunds.mjs.map +1 -1
  71. package/resources/setup-intents.d.mts +74 -0
  72. package/resources/setup-intents.d.mts.map +1 -1
  73. package/resources/setup-intents.d.ts +74 -0
  74. package/resources/setup-intents.d.ts.map +1 -1
  75. package/resources/shared.d.mts +1 -1
  76. package/resources/shared.d.mts.map +1 -1
  77. package/resources/shared.d.ts +1 -1
  78. package/resources/shared.d.ts.map +1 -1
  79. package/resources/users.d.mts +70 -1
  80. package/resources/users.d.mts.map +1 -1
  81. package/resources/users.d.ts +70 -1
  82. package/resources/users.d.ts.map +1 -1
  83. package/resources/users.js +8 -0
  84. package/resources/users.js.map +1 -1
  85. package/resources/users.mjs +8 -0
  86. package/resources/users.mjs.map +1 -1
  87. package/src/client.ts +36 -0
  88. package/src/resources/affiliates/affiliates.ts +467 -0
  89. package/src/resources/affiliates/index.ts +32 -0
  90. package/src/resources/affiliates/overrides.ts +585 -0
  91. package/src/resources/affiliates.ts +3 -0
  92. package/src/resources/ai-chats.ts +25 -1
  93. package/src/resources/index.ts +15 -0
  94. package/src/resources/payments.ts +1 -0
  95. package/src/resources/refunds.ts +17 -7
  96. package/src/resources/setup-intents.ts +90 -0
  97. package/src/resources/shared.ts +1 -0
  98. package/src/resources/users.ts +90 -0
  99. package/src/version.ts +1 -1
  100. package/version.d.mts +1 -1
  101. package/version.d.ts +1 -1
  102. package/version.js +1 -1
  103. package/version.mjs +1 -1
@@ -0,0 +1,467 @@
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 of a company or a global affiliate
139
+ */
140
+ export interface Affiliate {
141
+ /**
142
+ * The unique identifier for the affiliate.
143
+ */
144
+ id: string;
145
+
146
+ /**
147
+ * The total active members of the affiliate
148
+ */
149
+ active_members_count: number;
150
+
151
+ /**
152
+ * The company attached to this affiliate
153
+ */
154
+ company: Affiliate.Company;
155
+
156
+ /**
157
+ * The datetime the affiliate was created.
158
+ */
159
+ created_at: string;
160
+
161
+ /**
162
+ * How many referrals have remained since they joined as members
163
+ */
164
+ customer_retention_rate: string;
165
+
166
+ /**
167
+ * A rolling 90-day retention rate for this affiliate
168
+ */
169
+ customer_retention_rate_ninety_days: string;
170
+
171
+ /**
172
+ * The total MRR of the affiliate
173
+ */
174
+ monthly_recurring_revenue_usd: string;
175
+
176
+ /**
177
+ * Statuses for resources
178
+ */
179
+ status: Status | null;
180
+
181
+ /**
182
+ * The total count of all overrides for this affiliate
183
+ */
184
+ total_overrides_count: number;
185
+
186
+ /**
187
+ * The total earnings of the affiliate from the users they referred
188
+ */
189
+ total_referral_earnings_usd: string;
190
+
191
+ /**
192
+ * The total referrals of the affiliate
193
+ */
194
+ total_referrals_count: number;
195
+
196
+ /**
197
+ * The total revenue of the affiliate from their referrals
198
+ */
199
+ total_revenue_usd: string;
200
+
201
+ /**
202
+ * The datetime the affiliate was last updated.
203
+ */
204
+ updated_at: string;
205
+
206
+ /**
207
+ * The user attached to this affiliate
208
+ */
209
+ user: Affiliate.User;
210
+ }
211
+
212
+ export namespace Affiliate {
213
+ /**
214
+ * The company attached to this affiliate
215
+ */
216
+ export interface Company {
217
+ /**
218
+ * The unique identifier for the company.
219
+ */
220
+ id: string;
221
+
222
+ /**
223
+ * The written name of the company.
224
+ */
225
+ title: string;
226
+ }
227
+
228
+ /**
229
+ * The user attached to this affiliate
230
+ */
231
+ export interface User {
232
+ /**
233
+ * The unique identifier for the user.
234
+ */
235
+ id: string;
236
+
237
+ /**
238
+ * The display name set on the user's Whop profile. Null if the user has not set a
239
+ * name.
240
+ */
241
+ name: string | null;
242
+
243
+ /**
244
+ * The unique username chosen by the user for their Whop profile. Null if the user
245
+ * has not set a username.
246
+ */
247
+ username: string | null;
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Statuses for resources
253
+ */
254
+ export type Status = 'active' | 'archived' | 'deleted';
255
+
256
+ /**
257
+ * An affiliate of a company or a global affiliate
258
+ */
259
+ export interface AffiliateListResponse {
260
+ /**
261
+ * The unique identifier for the affiliate.
262
+ */
263
+ id: string;
264
+
265
+ /**
266
+ * The total active members of the affiliate
267
+ */
268
+ active_members_count: number;
269
+
270
+ /**
271
+ * The company attached to this affiliate
272
+ */
273
+ company: AffiliateListResponse.Company;
274
+
275
+ /**
276
+ * The datetime the affiliate was created.
277
+ */
278
+ created_at: string;
279
+
280
+ /**
281
+ * How many referrals have remained since they joined as members
282
+ */
283
+ customer_retention_rate: string;
284
+
285
+ /**
286
+ * A rolling 90-day retention rate for this affiliate
287
+ */
288
+ customer_retention_rate_ninety_days: string;
289
+
290
+ /**
291
+ * The total MRR of the affiliate
292
+ */
293
+ monthly_recurring_revenue_usd: string;
294
+
295
+ /**
296
+ * Statuses for resources
297
+ */
298
+ status: Status | null;
299
+
300
+ /**
301
+ * The total count of all overrides for this affiliate
302
+ */
303
+ total_overrides_count: number;
304
+
305
+ /**
306
+ * The total earnings of the affiliate from the users they referred
307
+ */
308
+ total_referral_earnings_usd: string;
309
+
310
+ /**
311
+ * The total referrals of the affiliate
312
+ */
313
+ total_referrals_count: number;
314
+
315
+ /**
316
+ * The total revenue of the affiliate from their referrals
317
+ */
318
+ total_revenue_usd: string;
319
+
320
+ /**
321
+ * The datetime the affiliate was last updated.
322
+ */
323
+ updated_at: string;
324
+
325
+ /**
326
+ * The user attached to this affiliate
327
+ */
328
+ user: AffiliateListResponse.User;
329
+ }
330
+
331
+ export namespace AffiliateListResponse {
332
+ /**
333
+ * The company attached to this affiliate
334
+ */
335
+ export interface Company {
336
+ /**
337
+ * The unique identifier for the company.
338
+ */
339
+ id: string;
340
+
341
+ /**
342
+ * The written name of the company.
343
+ */
344
+ title: string;
345
+ }
346
+
347
+ /**
348
+ * The user attached to this affiliate
349
+ */
350
+ export interface User {
351
+ /**
352
+ * The unique identifier for the user.
353
+ */
354
+ id: string;
355
+
356
+ /**
357
+ * The display name set on the user's Whop profile. Null if the user has not set a
358
+ * name.
359
+ */
360
+ name: string | null;
361
+
362
+ /**
363
+ * The unique username chosen by the user for their Whop profile. Null if the user
364
+ * has not set a username.
365
+ */
366
+ username: string | null;
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Represents `true` or `false` values.
372
+ */
373
+ export type AffiliateArchiveResponse = boolean;
374
+
375
+ /**
376
+ * Represents `true` or `false` values.
377
+ */
378
+ export type AffiliateUnarchiveResponse = boolean;
379
+
380
+ export interface AffiliateCreateParams {
381
+ /**
382
+ * The ID of the company to create the affiliate for.
383
+ */
384
+ company_id: string;
385
+
386
+ /**
387
+ * The user identifier (username, email, user ID, or Discord ID).
388
+ */
389
+ user_identifier: string;
390
+ }
391
+
392
+ export interface AffiliateListParams extends CursorPageParams {
393
+ /**
394
+ * The unique identifier of the company to list affiliates for.
395
+ */
396
+ company_id: string;
397
+
398
+ /**
399
+ * Returns the elements in the list that come before the specified cursor.
400
+ */
401
+ before?: string | null;
402
+
403
+ /**
404
+ * The direction of the sort.
405
+ */
406
+ direction?: Shared.Direction | null;
407
+
408
+ /**
409
+ * Returns the first _n_ elements from the list.
410
+ */
411
+ first?: number | null;
412
+
413
+ /**
414
+ * Returns the last _n_ elements from the list.
415
+ */
416
+ last?: number | null;
417
+
418
+ /**
419
+ * Which columns can be used to sort.
420
+ */
421
+ order?: 'id' | 'created_at' | 'cached_total_referrals' | 'cached_total_rewards' | null;
422
+
423
+ /**
424
+ * Search affiliates by username.
425
+ */
426
+ query?: string | null;
427
+
428
+ /**
429
+ * Statuses for resources
430
+ */
431
+ status?: Status | null;
432
+ }
433
+
434
+ Affiliates.Overrides = Overrides;
435
+
436
+ export declare namespace Affiliates {
437
+ export {
438
+ type Affiliate as Affiliate,
439
+ type Status as Status,
440
+ type AffiliateListResponse as AffiliateListResponse,
441
+ type AffiliateArchiveResponse as AffiliateArchiveResponse,
442
+ type AffiliateUnarchiveResponse as AffiliateUnarchiveResponse,
443
+ type AffiliateListResponsesCursorPage as AffiliateListResponsesCursorPage,
444
+ type AffiliateCreateParams as AffiliateCreateParams,
445
+ type AffiliateListParams as AffiliateListParams,
446
+ };
447
+
448
+ export {
449
+ Overrides as Overrides,
450
+ type AffiliateAppliesToPayments as AffiliateAppliesToPayments,
451
+ type AffiliateAppliesToProducts as AffiliateAppliesToProducts,
452
+ type AffiliateOverrideRoles as AffiliateOverrideRoles,
453
+ type AffiliatePayoutTypes as AffiliatePayoutTypes,
454
+ type AffiliateRevenueBases as AffiliateRevenueBases,
455
+ type OverrideCreateResponse as OverrideCreateResponse,
456
+ type OverrideRetrieveResponse as OverrideRetrieveResponse,
457
+ type OverrideUpdateResponse as OverrideUpdateResponse,
458
+ type OverrideListResponse as OverrideListResponse,
459
+ type OverrideDeleteResponse as OverrideDeleteResponse,
460
+ type OverrideListResponsesCursorPage as OverrideListResponsesCursorPage,
461
+ type OverrideCreateParams as OverrideCreateParams,
462
+ type OverrideRetrieveParams as OverrideRetrieveParams,
463
+ type OverrideUpdateParams as OverrideUpdateParams,
464
+ type OverrideListParams as OverrideListParams,
465
+ type OverrideDeleteParams as OverrideDeleteParams,
466
+ };
467
+ }
@@ -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';