@whop/sdk 0.0.8 → 0.0.10

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 (152) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/client.d.mts +14 -5
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +14 -5
  5. package/client.d.ts.map +1 -1
  6. package/client.js +9 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +9 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/account-links.d.mts +59 -0
  12. package/resources/account-links.d.mts.map +1 -0
  13. package/resources/account-links.d.ts +59 -0
  14. package/resources/account-links.d.ts.map +1 -0
  15. package/resources/account-links.js +27 -0
  16. package/resources/account-links.js.map +1 -0
  17. package/resources/account-links.mjs +23 -0
  18. package/resources/account-links.mjs.map +1 -0
  19. package/resources/app-builds.d.mts +12 -0
  20. package/resources/app-builds.d.mts.map +1 -1
  21. package/resources/app-builds.d.ts +12 -0
  22. package/resources/app-builds.d.ts.map +1 -1
  23. package/resources/apps.d.mts +1 -1
  24. package/resources/apps.d.mts.map +1 -1
  25. package/resources/apps.d.ts +1 -1
  26. package/resources/apps.d.ts.map +1 -1
  27. package/resources/authorized-users.d.mts +8 -0
  28. package/resources/authorized-users.d.mts.map +1 -1
  29. package/resources/authorized-users.d.ts +8 -0
  30. package/resources/authorized-users.d.ts.map +1 -1
  31. package/resources/checkout-configurations.d.mts +8 -0
  32. package/resources/checkout-configurations.d.mts.map +1 -1
  33. package/resources/checkout-configurations.d.ts +8 -0
  34. package/resources/checkout-configurations.d.ts.map +1 -1
  35. package/resources/companies.d.mts +8 -0
  36. package/resources/companies.d.mts.map +1 -1
  37. package/resources/companies.d.ts +8 -0
  38. package/resources/companies.d.ts.map +1 -1
  39. package/resources/disputes.d.mts +8 -0
  40. package/resources/disputes.d.mts.map +1 -1
  41. package/resources/disputes.d.ts +8 -0
  42. package/resources/disputes.d.ts.map +1 -1
  43. package/resources/entries.d.mts +8 -0
  44. package/resources/entries.d.mts.map +1 -1
  45. package/resources/entries.d.ts +8 -0
  46. package/resources/entries.d.ts.map +1 -1
  47. package/resources/experiences.d.mts +8 -0
  48. package/resources/experiences.d.mts.map +1 -1
  49. package/resources/experiences.d.ts +8 -0
  50. package/resources/experiences.d.ts.map +1 -1
  51. package/resources/index.d.mts +5 -2
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +5 -2
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js +7 -1
  56. package/resources/index.js.map +1 -1
  57. package/resources/index.mjs +3 -0
  58. package/resources/index.mjs.map +1 -1
  59. package/resources/invoices.d.mts +8 -0
  60. package/resources/invoices.d.mts.map +1 -1
  61. package/resources/invoices.d.ts +8 -0
  62. package/resources/invoices.d.ts.map +1 -1
  63. package/resources/payment-tokens.d.mts +157 -0
  64. package/resources/payment-tokens.d.mts.map +1 -0
  65. package/resources/payment-tokens.d.ts +157 -0
  66. package/resources/payment-tokens.d.ts.map +1 -0
  67. package/resources/payment-tokens.js +34 -0
  68. package/resources/payment-tokens.js.map +1 -0
  69. package/resources/payment-tokens.mjs +30 -0
  70. package/resources/payment-tokens.mjs.map +1 -0
  71. package/resources/payments.d.mts +256 -2
  72. package/resources/payments.d.mts.map +1 -1
  73. package/resources/payments.d.ts +256 -2
  74. package/resources/payments.d.ts.map +1 -1
  75. package/resources/payments.js +31 -0
  76. package/resources/payments.js.map +1 -1
  77. package/resources/payments.mjs +31 -0
  78. package/resources/payments.mjs.map +1 -1
  79. package/resources/plans.d.mts +9 -11
  80. package/resources/plans.d.mts.map +1 -1
  81. package/resources/plans.d.ts +9 -11
  82. package/resources/plans.d.ts.map +1 -1
  83. package/resources/products.d.mts +8 -26
  84. package/resources/products.d.mts.map +1 -1
  85. package/resources/products.d.ts +8 -26
  86. package/resources/products.d.ts.map +1 -1
  87. package/resources/promo-codes.d.mts +8 -0
  88. package/resources/promo-codes.d.mts.map +1 -1
  89. package/resources/promo-codes.d.ts +8 -0
  90. package/resources/promo-codes.d.ts.map +1 -1
  91. package/resources/refunds.d.mts +8 -0
  92. package/resources/refunds.d.mts.map +1 -1
  93. package/resources/refunds.d.ts +8 -0
  94. package/resources/refunds.d.ts.map +1 -1
  95. package/resources/reviews.d.mts +8 -0
  96. package/resources/reviews.d.mts.map +1 -1
  97. package/resources/reviews.d.ts +8 -0
  98. package/resources/reviews.d.ts.map +1 -1
  99. package/resources/setup-intents.d.mts +359 -0
  100. package/resources/setup-intents.d.mts.map +1 -0
  101. package/resources/setup-intents.d.ts +359 -0
  102. package/resources/setup-intents.d.ts.map +1 -0
  103. package/resources/setup-intents.js +38 -0
  104. package/resources/setup-intents.js.map +1 -0
  105. package/resources/setup-intents.mjs +34 -0
  106. package/resources/setup-intents.mjs.map +1 -0
  107. package/resources/shared.d.mts +50 -0
  108. package/resources/shared.d.mts.map +1 -1
  109. package/resources/shared.d.ts +50 -0
  110. package/resources/shared.d.ts.map +1 -1
  111. package/resources/transfers.d.mts +8 -0
  112. package/resources/transfers.d.mts.map +1 -1
  113. package/resources/transfers.d.ts +8 -0
  114. package/resources/transfers.d.ts.map +1 -1
  115. package/resources/webhooks.d.mts +72 -2
  116. package/resources/webhooks.d.mts.map +1 -1
  117. package/resources/webhooks.d.ts +72 -2
  118. package/resources/webhooks.d.ts.map +1 -1
  119. package/resources/webhooks.js.map +1 -1
  120. package/resources/webhooks.mjs.map +1 -1
  121. package/src/client.ts +56 -1
  122. package/src/resources/account-links.ts +73 -0
  123. package/src/resources/app-builds.ts +15 -0
  124. package/src/resources/apps.ts +1 -0
  125. package/src/resources/authorized-users.ts +10 -0
  126. package/src/resources/checkout-configurations.ts +10 -0
  127. package/src/resources/companies.ts +10 -0
  128. package/src/resources/disputes.ts +10 -0
  129. package/src/resources/entries.ts +10 -0
  130. package/src/resources/experiences.ts +10 -0
  131. package/src/resources/index.ts +21 -0
  132. package/src/resources/invoices.ts +10 -0
  133. package/src/resources/payment-tokens.ts +207 -0
  134. package/src/resources/payments.ts +307 -0
  135. package/src/resources/plans.ts +11 -13
  136. package/src/resources/products.ts +10 -32
  137. package/src/resources/promo-codes.ts +10 -0
  138. package/src/resources/refunds.ts +10 -0
  139. package/src/resources/reviews.ts +10 -0
  140. package/src/resources/setup-intents.ts +435 -0
  141. package/src/resources/shared.ts +59 -0
  142. package/src/resources/transfers.ts +10 -0
  143. package/src/resources/webhooks.ts +91 -0
  144. package/src/version.ts +1 -1
  145. package/version.d.mts +1 -1
  146. package/version.d.mts.map +1 -1
  147. package/version.d.ts +1 -1
  148. package/version.d.ts.map +1 -1
  149. package/version.js +1 -1
  150. package/version.js.map +1 -1
  151. package/version.mjs +1 -1
  152. package/version.mjs.map +1 -1
package/src/client.ts CHANGED
@@ -20,6 +20,7 @@ import * as Uploads from './core/uploads';
20
20
  import * as API from './resources/index';
21
21
  import { APIPromise } from './core/api-promise';
22
22
  import { AccessTokenCreateParams, AccessTokenCreateResponse, AccessTokens } from './resources/access-tokens';
23
+ import { AccountLinkCreateParams, AccountLinkCreateResponse, AccountLinks } from './resources/account-links';
23
24
  import {
24
25
  AppBuildCreateParams,
25
26
  AppBuildListParams,
@@ -191,9 +192,18 @@ import {
191
192
  NotificationCreateResponse,
192
193
  Notifications,
193
194
  } from './resources/notifications';
195
+ import {
196
+ PaymentTokenListParams,
197
+ PaymentTokenListResponse,
198
+ PaymentTokenListResponsesCursorPage,
199
+ PaymentTokenRetrieveParams,
200
+ PaymentTokenRetrieveResponse,
201
+ PaymentTokens,
202
+ } from './resources/payment-tokens';
194
203
  import {
195
204
  BillingReasons,
196
205
  CardBrands,
206
+ PaymentCreateParams,
197
207
  PaymentListParams,
198
208
  PaymentListResponse,
199
209
  PaymentListResponsesCursorPage,
@@ -254,6 +264,14 @@ import {
254
264
  ReviewStatus,
255
265
  Reviews,
256
266
  } from './resources/reviews';
267
+ import {
268
+ SetupIntent,
269
+ SetupIntentListParams,
270
+ SetupIntentListResponse,
271
+ SetupIntentListResponsesCursorPage,
272
+ SetupIntentStatus,
273
+ SetupIntents,
274
+ } from './resources/setup-intents';
257
275
  import {
258
276
  ShipmentCreateParams,
259
277
  ShipmentListParams,
@@ -300,6 +318,9 @@ import {
300
318
  PaymentSucceededWebhookEvent,
301
319
  RefundCreatedWebhookEvent,
302
320
  RefundUpdatedWebhookEvent,
321
+ SetupIntentCanceledWebhookEvent,
322
+ SetupIntentRequiresActionWebhookEvent,
323
+ SetupIntentSucceededWebhookEvent,
303
324
  UnwrapWebhookEvent,
304
325
  Webhooks,
305
326
  } from './resources/webhooks';
@@ -424,7 +445,7 @@ export class Whop {
424
445
  baseURL: string;
425
446
  maxRetries: number;
426
447
  timeout: number;
427
- logger: Logger | undefined;
448
+ logger: Logger;
428
449
  logLevel: LogLevel | undefined;
429
450
  fetchOptions: MergedRequestInit | undefined;
430
451
 
@@ -1076,6 +1097,9 @@ export class Whop {
1076
1097
  disputes: API.Disputes = new API.Disputes(this);
1077
1098
  refunds: API.Refunds = new API.Refunds(this);
1078
1099
  withdrawals: API.Withdrawals = new API.Withdrawals(this);
1100
+ accountLinks: API.AccountLinks = new API.AccountLinks(this);
1101
+ setupIntents: API.SetupIntents = new API.SetupIntents(this);
1102
+ paymentTokens: API.PaymentTokens = new API.PaymentTokens(this);
1079
1103
  }
1080
1104
 
1081
1105
  Whop.Apps = Apps;
@@ -1114,6 +1138,9 @@ Whop.Notifications = Notifications;
1114
1138
  Whop.Disputes = Disputes;
1115
1139
  Whop.Refunds = Refunds;
1116
1140
  Whop.Withdrawals = Withdrawals;
1141
+ Whop.AccountLinks = AccountLinks;
1142
+ Whop.SetupIntents = SetupIntents;
1143
+ Whop.PaymentTokens = PaymentTokens;
1117
1144
 
1118
1145
  export declare namespace Whop {
1119
1146
  export type RequestOptions = Opts.RequestOptions;
@@ -1171,6 +1198,9 @@ export declare namespace Whop {
1171
1198
  type EntryApprovedWebhookEvent as EntryApprovedWebhookEvent,
1172
1199
  type EntryDeniedWebhookEvent as EntryDeniedWebhookEvent,
1173
1200
  type EntryDeletedWebhookEvent as EntryDeletedWebhookEvent,
1201
+ type SetupIntentRequiresActionWebhookEvent as SetupIntentRequiresActionWebhookEvent,
1202
+ type SetupIntentSucceededWebhookEvent as SetupIntentSucceededWebhookEvent,
1203
+ type SetupIntentCanceledWebhookEvent as SetupIntentCanceledWebhookEvent,
1174
1204
  type CourseLessonInteractionCompletedWebhookEvent as CourseLessonInteractionCompletedWebhookEvent,
1175
1205
  type PaymentSucceededWebhookEvent as PaymentSucceededWebhookEvent,
1176
1206
  type PaymentFailedWebhookEvent as PaymentFailedWebhookEvent,
@@ -1297,6 +1327,7 @@ export declare namespace Whop {
1297
1327
  type PaymentMethodTypes as PaymentMethodTypes,
1298
1328
  type PaymentListResponse as PaymentListResponse,
1299
1329
  type PaymentListResponsesCursorPage as PaymentListResponsesCursorPage,
1330
+ type PaymentCreateParams as PaymentCreateParams,
1300
1331
  type PaymentListParams as PaymentListParams,
1301
1332
  type PaymentRefundParams as PaymentRefundParams,
1302
1333
  };
@@ -1464,6 +1495,30 @@ export declare namespace Whop {
1464
1495
  type WithdrawalListParams as WithdrawalListParams,
1465
1496
  };
1466
1497
 
1498
+ export {
1499
+ AccountLinks as AccountLinks,
1500
+ type AccountLinkCreateResponse as AccountLinkCreateResponse,
1501
+ type AccountLinkCreateParams as AccountLinkCreateParams,
1502
+ };
1503
+
1504
+ export {
1505
+ SetupIntents as SetupIntents,
1506
+ type SetupIntent as SetupIntent,
1507
+ type SetupIntentStatus as SetupIntentStatus,
1508
+ type SetupIntentListResponse as SetupIntentListResponse,
1509
+ type SetupIntentListResponsesCursorPage as SetupIntentListResponsesCursorPage,
1510
+ type SetupIntentListParams as SetupIntentListParams,
1511
+ };
1512
+
1513
+ export {
1514
+ PaymentTokens as PaymentTokens,
1515
+ type PaymentTokenRetrieveResponse as PaymentTokenRetrieveResponse,
1516
+ type PaymentTokenListResponse as PaymentTokenListResponse,
1517
+ type PaymentTokenListResponsesCursorPage as PaymentTokenListResponsesCursorPage,
1518
+ type PaymentTokenRetrieveParams as PaymentTokenRetrieveParams,
1519
+ type PaymentTokenListParams as PaymentTokenListParams,
1520
+ };
1521
+
1467
1522
  export type AccessLevel = API.AccessLevel;
1468
1523
  export type AccessPassType = API.AccessPassType;
1469
1524
  export type App = API.App;
@@ -0,0 +1,73 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class AccountLinks extends APIResource {
8
+ /**
9
+ * Generates a url that a user can be directed to in order to access their
10
+ * sub-merchant account. For example, they can visit the hosted payouts portal or
11
+ * the hosted KYC onboarding flow.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const accountLink = await client.accountLinks.create({
16
+ * company_id: 'biz_xxxxxxxxxxxxxx',
17
+ * refresh_url: 'refresh_url',
18
+ * return_url: 'return_url',
19
+ * use_case: 'account_onboarding',
20
+ * });
21
+ * ```
22
+ */
23
+ create(body: AccountLinkCreateParams, options?: RequestOptions): APIPromise<AccountLinkCreateResponse> {
24
+ return this._client.post('/account_links', { body, ...options });
25
+ }
26
+ }
27
+
28
+ /**
29
+ * An object representing a url that a user can be directed to to access their
30
+ * account.
31
+ */
32
+ export interface AccountLinkCreateResponse {
33
+ /**
34
+ * The expiration timestamp of the url.
35
+ */
36
+ expires_at: string;
37
+
38
+ /**
39
+ * The URL to navigate the user to.
40
+ */
41
+ url: string;
42
+ }
43
+
44
+ export interface AccountLinkCreateParams {
45
+ /**
46
+ * The ID of the Company to generate the url for. The company must be a
47
+ * sub-merchant of the API key's company.
48
+ */
49
+ company_id: string;
50
+
51
+ /**
52
+ * The URL to redirect to if the session expires and needs to be re-authenticated
53
+ * due to the token expiring.
54
+ */
55
+ refresh_url: string;
56
+
57
+ /**
58
+ * The URL to redirect to when the customer wants to return to your site.
59
+ */
60
+ return_url: string;
61
+
62
+ /**
63
+ * The use case for which the link will be used.
64
+ */
65
+ use_case: 'account_onboarding' | 'payouts_portal';
66
+ }
67
+
68
+ export declare namespace AccountLinks {
69
+ export {
70
+ type AccountLinkCreateResponse as AccountLinkCreateResponse,
71
+ type AccountLinkCreateParams as AccountLinkCreateParams,
72
+ };
73
+ }
@@ -166,6 +166,11 @@ export interface AppBuildCreateParams {
166
166
  */
167
167
  platform: Shared.AppBuildPlatforms;
168
168
 
169
+ /**
170
+ * The id of the ai prompt that created this build
171
+ */
172
+ ai_prompt_id?: string | null;
173
+
169
174
  /**
170
175
  * The ID of the app to create a build for. By default the current app from the api
171
176
  * key is used.
@@ -216,6 +221,16 @@ export interface AppBuildListParams extends CursorPageParams {
216
221
  */
217
222
  before?: string | null;
218
223
 
224
+ /**
225
+ * The minimum creation date to filter by
226
+ */
227
+ created_after?: string | null;
228
+
229
+ /**
230
+ * The maximum creation date to filter by
231
+ */
232
+ created_before?: string | null;
233
+
219
234
  /**
220
235
  * Returns the first _n_ elements from the list.
221
236
  */
@@ -365,6 +365,7 @@ export interface AppListParams extends CursorPageParams {
365
365
  order?:
366
366
  | 'discoverable_at'
367
367
  | 'total_installs_last_30_days'
368
+ | 'total_installs_last_7_days'
368
369
  | 'time_spent'
369
370
  | 'time_spent_last_24_hours'
370
371
  | 'daily_active_users'
@@ -146,6 +146,16 @@ export interface AuthorizedUserListParams extends CursorPageParams {
146
146
  */
147
147
  before?: string | null;
148
148
 
149
+ /**
150
+ * The minimum creation date to filter by
151
+ */
152
+ created_after?: string | null;
153
+
154
+ /**
155
+ * The maximum creation date to filter by
156
+ */
157
+ created_before?: string | null;
158
+
149
159
  /**
150
160
  * Returns the first _n_ elements from the list.
151
161
  */
@@ -684,6 +684,16 @@ export interface CheckoutConfigurationListParams extends CursorPageParams {
684
684
  */
685
685
  before?: string | null;
686
686
 
687
+ /**
688
+ * The minimum creation date to filter by
689
+ */
690
+ created_after?: string | null;
691
+
692
+ /**
693
+ * The maximum creation date to filter by
694
+ */
695
+ created_before?: string | null;
696
+
687
697
  /**
688
698
  * The direction of the sort.
689
699
  */
@@ -190,6 +190,16 @@ export interface CompanyListParams extends CursorPageParams {
190
190
  */
191
191
  before?: string | null;
192
192
 
193
+ /**
194
+ * The minimum creation date to filter by
195
+ */
196
+ created_after?: string | null;
197
+
198
+ /**
199
+ * The maximum creation date to filter by
200
+ */
201
+ created_before?: string | null;
202
+
193
203
  /**
194
204
  * The direction of the sort.
195
205
  */
@@ -663,6 +663,16 @@ export interface DisputeListParams extends CursorPageParams {
663
663
  */
664
664
  before?: string | null;
665
665
 
666
+ /**
667
+ * The minimum creation date to filter by
668
+ */
669
+ created_after?: string | null;
670
+
671
+ /**
672
+ * The maximum creation date to filter by
673
+ */
674
+ created_before?: string | null;
675
+
666
676
  /**
667
677
  * The direction of the sort.
668
678
  */
@@ -170,6 +170,16 @@ export interface EntryListParams extends CursorPageParams {
170
170
  */
171
171
  before?: string | null;
172
172
 
173
+ /**
174
+ * The minimum creation date to filter by
175
+ */
176
+ created_after?: string | null;
177
+
178
+ /**
179
+ * The maximum creation date to filter by
180
+ */
181
+ created_before?: string | null;
182
+
173
183
  /**
174
184
  * The direction of the sort.
175
185
  */
@@ -376,6 +376,16 @@ export interface ExperienceListParams extends CursorPageParams {
376
376
  */
377
377
  before?: string | null;
378
378
 
379
+ /**
380
+ * The minimum creation date to filter by
381
+ */
382
+ created_after?: string | null;
383
+
384
+ /**
385
+ * The maximum creation date to filter by
386
+ */
387
+ created_before?: string | null;
388
+
379
389
  /**
380
390
  * Returns the first _n_ elements from the list.
381
391
  */
@@ -2,6 +2,7 @@
2
2
 
3
3
  export * from './shared';
4
4
  export { AccessTokens, type AccessTokenCreateResponse, type AccessTokenCreateParams } from './access-tokens';
5
+ export { AccountLinks, type AccountLinkCreateResponse, type AccountLinkCreateParams } from './account-links';
5
6
  export {
6
7
  AppBuilds,
7
8
  type AppBuildListResponse,
@@ -178,12 +179,21 @@ export {
178
179
  type NotificationCreateResponse,
179
180
  type NotificationCreateParams,
180
181
  } from './notifications';
182
+ export {
183
+ PaymentTokens,
184
+ type PaymentTokenRetrieveResponse,
185
+ type PaymentTokenListResponse,
186
+ type PaymentTokenRetrieveParams,
187
+ type PaymentTokenListParams,
188
+ type PaymentTokenListResponsesCursorPage,
189
+ } from './payment-tokens';
181
190
  export {
182
191
  Payments,
183
192
  type BillingReasons,
184
193
  type CardBrands,
185
194
  type PaymentMethodTypes,
186
195
  type PaymentListResponse,
196
+ type PaymentCreateParams,
187
197
  type PaymentListParams,
188
198
  type PaymentRefundParams,
189
199
  type PaymentListResponsesCursorPage,
@@ -241,6 +251,14 @@ export {
241
251
  type ReviewListParams,
242
252
  type ReviewListResponsesCursorPage,
243
253
  } from './reviews';
254
+ export {
255
+ SetupIntents,
256
+ type SetupIntent,
257
+ type SetupIntentStatus,
258
+ type SetupIntentListResponse,
259
+ type SetupIntentListParams,
260
+ type SetupIntentListResponsesCursorPage,
261
+ } from './setup-intents';
244
262
  export {
245
263
  Shipments,
246
264
  type ShipmentListResponse,
@@ -280,6 +298,9 @@ export {
280
298
  type EntryApprovedWebhookEvent,
281
299
  type EntryDeniedWebhookEvent,
282
300
  type EntryDeletedWebhookEvent,
301
+ type SetupIntentRequiresActionWebhookEvent,
302
+ type SetupIntentSucceededWebhookEvent,
303
+ type SetupIntentCanceledWebhookEvent,
283
304
  type CourseLessonInteractionCompletedWebhookEvent,
284
305
  type PaymentSucceededWebhookEvent,
285
306
  type PaymentFailedWebhookEvent,
@@ -783,6 +783,16 @@ export interface InvoiceListParams extends CursorPageParams {
783
783
  */
784
784
  collection_methods?: Array<Shared.CollectionMethod> | null;
785
785
 
786
+ /**
787
+ * The minimum creation date to filter by
788
+ */
789
+ created_after?: string | null;
790
+
791
+ /**
792
+ * The maximum creation date to filter by
793
+ */
794
+ created_before?: string | null;
795
+
786
796
  /**
787
797
  * The direction of the sort.
788
798
  */
@@ -0,0 +1,207 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as PaymentsAPI from './payments';
5
+ import * as Shared from './shared';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ export class PaymentTokens extends APIResource {
12
+ /**
13
+ * Retrieves a PaymentToken by ID
14
+ *
15
+ * Required permissions:
16
+ *
17
+ * - `member:payment_methods:read`
18
+ */
19
+ retrieve(
20
+ id: string,
21
+ query: PaymentTokenRetrieveParams,
22
+ options?: RequestOptions,
23
+ ): APIPromise<PaymentTokenRetrieveResponse> {
24
+ return this._client.get(path`/payment_tokens/${id}`, { query, ...options });
25
+ }
26
+
27
+ /**
28
+ * Lists PaymentTokens
29
+ *
30
+ * Required permissions:
31
+ *
32
+ * - `member:payment_methods:read`
33
+ */
34
+ list(
35
+ query: PaymentTokenListParams,
36
+ options?: RequestOptions,
37
+ ): PagePromise<PaymentTokenListResponsesCursorPage, PaymentTokenListResponse> {
38
+ return this._client.getAPIList('/payment_tokens', CursorPage<PaymentTokenListResponse>, {
39
+ query,
40
+ ...options,
41
+ });
42
+ }
43
+ }
44
+
45
+ export type PaymentTokenListResponsesCursorPage = CursorPage<PaymentTokenListResponse>;
46
+
47
+ /**
48
+ * A payment token used to process payments.
49
+ */
50
+ export interface PaymentTokenRetrieveResponse {
51
+ /**
52
+ * The ID of the payment token
53
+ */
54
+ id: string;
55
+
56
+ /**
57
+ * The card data associated with the payment token, if its a debit or credit card
58
+ * token.
59
+ */
60
+ card: PaymentTokenRetrieveResponse.Card | null;
61
+
62
+ /**
63
+ * The date and time the payment token was created
64
+ */
65
+ created_at: string;
66
+
67
+ /**
68
+ * The payment method type of the payment token
69
+ */
70
+ payment_method_type: PaymentsAPI.PaymentMethodTypes;
71
+ }
72
+
73
+ export namespace PaymentTokenRetrieveResponse {
74
+ /**
75
+ * The card data associated with the payment token, if its a debit or credit card
76
+ * token.
77
+ */
78
+ export interface Card {
79
+ /**
80
+ * Possible card brands that a payment token can have
81
+ */
82
+ brand: PaymentsAPI.CardBrands | null;
83
+
84
+ /**
85
+ * Card expiration month, like 03 for March.
86
+ */
87
+ exp_month: number | null;
88
+
89
+ /**
90
+ * Card expiration year, like 27 for 2027.
91
+ */
92
+ exp_year: number | null;
93
+
94
+ /**
95
+ * Last four digits of the card.
96
+ */
97
+ last4: string | null;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * A payment token used to process payments.
103
+ */
104
+ export interface PaymentTokenListResponse {
105
+ /**
106
+ * The ID of the payment token
107
+ */
108
+ id: string;
109
+
110
+ /**
111
+ * The card data associated with the payment token, if its a debit or credit card
112
+ * token.
113
+ */
114
+ card: PaymentTokenListResponse.Card | null;
115
+
116
+ /**
117
+ * The date and time the payment token was created
118
+ */
119
+ created_at: string;
120
+
121
+ /**
122
+ * The payment method type of the payment token
123
+ */
124
+ payment_method_type: PaymentsAPI.PaymentMethodTypes;
125
+ }
126
+
127
+ export namespace PaymentTokenListResponse {
128
+ /**
129
+ * The card data associated with the payment token, if its a debit or credit card
130
+ * token.
131
+ */
132
+ export interface Card {
133
+ /**
134
+ * Possible card brands that a payment token can have
135
+ */
136
+ brand: PaymentsAPI.CardBrands | null;
137
+
138
+ /**
139
+ * Card expiration month, like 03 for March.
140
+ */
141
+ exp_month: number | null;
142
+
143
+ /**
144
+ * Card expiration year, like 27 for 2027.
145
+ */
146
+ exp_year: number | null;
147
+
148
+ /**
149
+ * Last four digits of the card.
150
+ */
151
+ last4: string | null;
152
+ }
153
+ }
154
+
155
+ export interface PaymentTokenRetrieveParams {
156
+ /**
157
+ * The ID of the Member associated with the PaymentToken
158
+ */
159
+ member_id: string;
160
+ }
161
+
162
+ export interface PaymentTokenListParams extends CursorPageParams {
163
+ /**
164
+ * The ID of the Member to list payment tokens for
165
+ */
166
+ member_id: string;
167
+
168
+ /**
169
+ * Returns the elements in the list that come before the specified cursor.
170
+ */
171
+ before?: string | null;
172
+
173
+ /**
174
+ * The minimum creation date to filter by
175
+ */
176
+ created_after?: string | null;
177
+
178
+ /**
179
+ * The maximum creation date to filter by
180
+ */
181
+ created_before?: string | null;
182
+
183
+ /**
184
+ * The direction of the sort.
185
+ */
186
+ direction?: Shared.Direction | null;
187
+
188
+ /**
189
+ * Returns the first _n_ elements from the list.
190
+ */
191
+ first?: number | null;
192
+
193
+ /**
194
+ * Returns the last _n_ elements from the list.
195
+ */
196
+ last?: number | null;
197
+ }
198
+
199
+ export declare namespace PaymentTokens {
200
+ export {
201
+ type PaymentTokenRetrieveResponse as PaymentTokenRetrieveResponse,
202
+ type PaymentTokenListResponse as PaymentTokenListResponse,
203
+ type PaymentTokenListResponsesCursorPage as PaymentTokenListResponsesCursorPage,
204
+ type PaymentTokenRetrieveParams as PaymentTokenRetrieveParams,
205
+ type PaymentTokenListParams as PaymentTokenListParams,
206
+ };
207
+ }