@usehercules/sdk 1.7.0 → 1.9.0

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 (257) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +17 -16
  3. package/client.d.mts +0 -3
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +0 -3
  6. package/client.d.ts.map +1 -1
  7. package/client.js +2 -15
  8. package/client.js.map +1 -1
  9. package/client.mjs +2 -15
  10. package/client.mjs.map +1 -1
  11. package/internal/qs/formats.d.mts +7 -0
  12. package/internal/qs/formats.d.mts.map +1 -0
  13. package/internal/qs/formats.d.ts +7 -0
  14. package/internal/qs/formats.d.ts.map +1 -0
  15. package/internal/qs/formats.js +13 -0
  16. package/internal/qs/formats.js.map +1 -0
  17. package/internal/qs/formats.mjs +9 -0
  18. package/internal/qs/formats.mjs.map +1 -0
  19. package/internal/qs/index.d.mts +10 -0
  20. package/internal/qs/index.d.mts.map +1 -0
  21. package/internal/qs/index.d.ts +10 -0
  22. package/internal/qs/index.d.ts.map +1 -0
  23. package/internal/qs/index.js +14 -0
  24. package/internal/qs/index.js.map +1 -0
  25. package/internal/qs/index.mjs +10 -0
  26. package/internal/qs/index.mjs.map +1 -0
  27. package/internal/qs/stringify.d.mts +3 -0
  28. package/internal/qs/stringify.d.mts.map +1 -0
  29. package/internal/qs/stringify.d.ts +3 -0
  30. package/internal/qs/stringify.d.ts.map +1 -0
  31. package/internal/qs/stringify.js +277 -0
  32. package/internal/qs/stringify.js.map +1 -0
  33. package/internal/qs/stringify.mjs +274 -0
  34. package/internal/qs/stringify.mjs.map +1 -0
  35. package/internal/qs/types.d.mts +57 -0
  36. package/internal/qs/types.d.mts.map +1 -0
  37. package/internal/qs/types.d.ts +57 -0
  38. package/internal/qs/types.d.ts.map +1 -0
  39. package/internal/qs/types.js +3 -0
  40. package/internal/qs/types.js.map +1 -0
  41. package/internal/qs/types.mjs +2 -0
  42. package/internal/qs/types.mjs.map +1 -0
  43. package/internal/qs/utils.d.mts +15 -0
  44. package/internal/qs/utils.d.mts.map +1 -0
  45. package/internal/qs/utils.d.ts +15 -0
  46. package/internal/qs/utils.d.ts.map +1 -0
  47. package/internal/qs/utils.js +230 -0
  48. package/internal/qs/utils.js.map +1 -0
  49. package/internal/qs/utils.mjs +217 -0
  50. package/internal/qs/utils.mjs.map +1 -0
  51. package/package.json +1 -1
  52. package/resources/beta/beta.d.mts +4 -4
  53. package/resources/beta/beta.d.mts.map +1 -1
  54. package/resources/beta/beta.d.ts +4 -4
  55. package/resources/beta/beta.d.ts.map +1 -1
  56. package/resources/beta/beta.js +4 -4
  57. package/resources/beta/beta.js.map +1 -1
  58. package/resources/beta/beta.mjs +4 -4
  59. package/resources/beta/beta.mjs.map +1 -1
  60. package/resources/beta/commerce/commerce.d.mts +201 -0
  61. package/resources/beta/commerce/commerce.d.mts.map +1 -0
  62. package/resources/beta/commerce/commerce.d.ts +201 -0
  63. package/resources/beta/commerce/commerce.d.ts.map +1 -0
  64. package/resources/beta/{pay/pay.js → commerce/commerce.js} +10 -14
  65. package/resources/beta/commerce/commerce.js.map +1 -0
  66. package/resources/beta/{pay/pay.mjs → commerce/commerce.mjs} +8 -12
  67. package/resources/beta/commerce/commerce.mjs.map +1 -0
  68. package/resources/beta/commerce/coupons.d.mts +334 -0
  69. package/resources/beta/commerce/coupons.d.mts.map +1 -0
  70. package/resources/beta/commerce/coupons.d.ts +334 -0
  71. package/resources/beta/commerce/coupons.d.ts.map +1 -0
  72. package/resources/beta/{pay → commerce}/coupons.js +8 -5
  73. package/resources/beta/commerce/coupons.js.map +1 -0
  74. package/resources/beta/{pay → commerce}/coupons.mjs +8 -5
  75. package/resources/beta/commerce/coupons.mjs.map +1 -0
  76. package/resources/beta/commerce/customers.d.mts +658 -0
  77. package/resources/beta/commerce/customers.d.mts.map +1 -0
  78. package/resources/beta/commerce/customers.d.ts +658 -0
  79. package/resources/beta/commerce/customers.d.ts.map +1 -0
  80. package/resources/beta/{pay → commerce}/customers.js +11 -7
  81. package/resources/beta/commerce/customers.js.map +1 -0
  82. package/resources/beta/{pay → commerce}/customers.mjs +11 -7
  83. package/resources/beta/commerce/customers.mjs.map +1 -0
  84. package/resources/beta/commerce/index.d.mts +5 -0
  85. package/resources/beta/commerce/index.d.mts.map +1 -0
  86. package/resources/beta/commerce/index.d.ts +5 -0
  87. package/resources/beta/commerce/index.d.ts.map +1 -0
  88. package/resources/beta/{pay → commerce}/index.js +3 -5
  89. package/resources/beta/commerce/index.js.map +1 -0
  90. package/resources/beta/{pay → commerce}/index.mjs +1 -2
  91. package/resources/beta/commerce/index.mjs.map +1 -0
  92. package/resources/beta/commerce/products/index.d.mts +4 -0
  93. package/resources/beta/commerce/products/index.d.mts.map +1 -0
  94. package/resources/beta/commerce/products/index.d.ts +4 -0
  95. package/resources/beta/commerce/products/index.d.ts.map +1 -0
  96. package/resources/beta/{pay → commerce}/products/index.js +3 -3
  97. package/resources/beta/commerce/products/index.js.map +1 -0
  98. package/resources/beta/{pay → commerce}/products/index.mjs +1 -1
  99. package/resources/beta/commerce/products/index.mjs.map +1 -0
  100. package/resources/beta/commerce/products/products.d.mts +1082 -0
  101. package/resources/beta/commerce/products/products.d.mts.map +1 -0
  102. package/resources/beta/commerce/products/products.d.ts +1082 -0
  103. package/resources/beta/commerce/products/products.d.ts.map +1 -0
  104. package/resources/beta/{pay → commerce}/products/products.js +16 -12
  105. package/resources/beta/commerce/products/products.js.map +1 -0
  106. package/resources/beta/{pay → commerce}/products/products.mjs +16 -12
  107. package/resources/beta/commerce/products/products.mjs.map +1 -0
  108. package/resources/beta/commerce/products/resources.d.mts +164 -0
  109. package/resources/beta/commerce/products/resources.d.mts.map +1 -0
  110. package/resources/beta/commerce/products/resources.d.ts +164 -0
  111. package/resources/beta/commerce/products/resources.d.ts.map +1 -0
  112. package/resources/beta/commerce/products/resources.js +41 -0
  113. package/resources/beta/commerce/products/resources.js.map +1 -0
  114. package/resources/beta/commerce/products/resources.mjs +37 -0
  115. package/resources/beta/commerce/products/resources.mjs.map +1 -0
  116. package/resources/beta/commerce/products/variants.d.mts +907 -0
  117. package/resources/beta/commerce/products/variants.d.mts.map +1 -0
  118. package/resources/beta/commerce/products/variants.d.ts +907 -0
  119. package/resources/beta/commerce/products/variants.d.ts.map +1 -0
  120. package/resources/beta/{pay → commerce}/products/variants.js +5 -8
  121. package/resources/beta/commerce/products/variants.js.map +1 -0
  122. package/resources/beta/{pay → commerce}/products/variants.mjs +5 -8
  123. package/resources/beta/commerce/products/variants.mjs.map +1 -0
  124. package/resources/beta/commerce/products.d.mts.map +1 -0
  125. package/resources/beta/commerce/products.d.ts.map +1 -0
  126. package/resources/beta/commerce/products.js.map +1 -0
  127. package/resources/beta/commerce/products.mjs.map +1 -0
  128. package/resources/beta/commerce.d.mts +2 -0
  129. package/resources/beta/commerce.d.mts.map +1 -0
  130. package/resources/beta/commerce.d.ts +2 -0
  131. package/resources/beta/commerce.d.ts.map +1 -0
  132. package/resources/beta/{pay.js → commerce.js} +2 -2
  133. package/resources/beta/commerce.js.map +1 -0
  134. package/resources/beta/{pay.mjs → commerce.mjs} +2 -2
  135. package/resources/beta/commerce.mjs.map +1 -0
  136. package/resources/beta/index.d.mts +1 -1
  137. package/resources/beta/index.d.mts.map +1 -1
  138. package/resources/beta/index.d.ts +1 -1
  139. package/resources/beta/index.d.ts.map +1 -1
  140. package/resources/beta/index.js +3 -3
  141. package/resources/beta/index.js.map +1 -1
  142. package/resources/beta/index.mjs +1 -1
  143. package/resources/beta/index.mjs.map +1 -1
  144. package/resources/push-notifications/push-notifications.d.mts +8 -9
  145. package/resources/push-notifications/push-notifications.d.mts.map +1 -1
  146. package/resources/push-notifications/push-notifications.d.ts +8 -9
  147. package/resources/push-notifications/push-notifications.d.ts.map +1 -1
  148. package/resources/push-notifications/push-notifications.js +5 -6
  149. package/resources/push-notifications/push-notifications.js.map +1 -1
  150. package/resources/push-notifications/push-notifications.mjs +5 -6
  151. package/resources/push-notifications/push-notifications.mjs.map +1 -1
  152. package/src/client.ts +2 -17
  153. package/src/internal/qs/LICENSE.md +13 -0
  154. package/src/internal/qs/README.md +3 -0
  155. package/src/internal/qs/formats.ts +10 -0
  156. package/src/internal/qs/index.ts +13 -0
  157. package/src/internal/qs/stringify.ts +385 -0
  158. package/src/internal/qs/types.ts +71 -0
  159. package/src/internal/qs/utils.ts +265 -0
  160. package/src/resources/beta/beta.ts +18 -18
  161. package/src/resources/beta/{pay/pay.ts → commerce/commerce.ts} +82 -85
  162. package/src/resources/beta/commerce/coupons.ts +441 -0
  163. package/src/resources/beta/commerce/customers.ts +842 -0
  164. package/src/resources/beta/commerce/index.ts +47 -0
  165. package/src/resources/beta/commerce/products/index.ts +37 -0
  166. package/src/resources/beta/commerce/products/products.ts +1341 -0
  167. package/src/resources/beta/commerce/products/resources.ts +217 -0
  168. package/src/resources/beta/commerce/products/variants.ts +1120 -0
  169. package/src/resources/beta/{pay.ts → commerce.ts} +1 -1
  170. package/src/resources/beta/index.ts +8 -8
  171. package/src/resources/push-notifications/push-notifications.ts +8 -9
  172. package/src/version.ts +1 -1
  173. package/version.d.mts +1 -1
  174. package/version.d.ts +1 -1
  175. package/version.js +1 -1
  176. package/version.mjs +1 -1
  177. package/resources/beta/pay/coupons.d.mts +0 -156
  178. package/resources/beta/pay/coupons.d.mts.map +0 -1
  179. package/resources/beta/pay/coupons.d.ts +0 -156
  180. package/resources/beta/pay/coupons.d.ts.map +0 -1
  181. package/resources/beta/pay/coupons.js.map +0 -1
  182. package/resources/beta/pay/coupons.mjs.map +0 -1
  183. package/resources/beta/pay/customers.d.mts +0 -160
  184. package/resources/beta/pay/customers.d.mts.map +0 -1
  185. package/resources/beta/pay/customers.d.ts +0 -160
  186. package/resources/beta/pay/customers.d.ts.map +0 -1
  187. package/resources/beta/pay/customers.js.map +0 -1
  188. package/resources/beta/pay/customers.mjs.map +0 -1
  189. package/resources/beta/pay/entitlements.d.mts +0 -76
  190. package/resources/beta/pay/entitlements.d.mts.map +0 -1
  191. package/resources/beta/pay/entitlements.d.ts +0 -76
  192. package/resources/beta/pay/entitlements.d.ts.map +0 -1
  193. package/resources/beta/pay/entitlements.js +0 -41
  194. package/resources/beta/pay/entitlements.js.map +0 -1
  195. package/resources/beta/pay/entitlements.mjs +0 -37
  196. package/resources/beta/pay/entitlements.mjs.map +0 -1
  197. package/resources/beta/pay/index.d.mts +0 -6
  198. package/resources/beta/pay/index.d.mts.map +0 -1
  199. package/resources/beta/pay/index.d.ts +0 -6
  200. package/resources/beta/pay/index.d.ts.map +0 -1
  201. package/resources/beta/pay/index.js.map +0 -1
  202. package/resources/beta/pay/index.mjs.map +0 -1
  203. package/resources/beta/pay/pay.d.mts +0 -206
  204. package/resources/beta/pay/pay.d.mts.map +0 -1
  205. package/resources/beta/pay/pay.d.ts +0 -206
  206. package/resources/beta/pay/pay.d.ts.map +0 -1
  207. package/resources/beta/pay/pay.js.map +0 -1
  208. package/resources/beta/pay/pay.mjs.map +0 -1
  209. package/resources/beta/pay/products/entitlements.d.mts +0 -53
  210. package/resources/beta/pay/products/entitlements.d.mts.map +0 -1
  211. package/resources/beta/pay/products/entitlements.d.ts +0 -53
  212. package/resources/beta/pay/products/entitlements.d.ts.map +0 -1
  213. package/resources/beta/pay/products/entitlements.js +0 -38
  214. package/resources/beta/pay/products/entitlements.js.map +0 -1
  215. package/resources/beta/pay/products/entitlements.mjs +0 -34
  216. package/resources/beta/pay/products/entitlements.mjs.map +0 -1
  217. package/resources/beta/pay/products/index.d.mts +0 -4
  218. package/resources/beta/pay/products/index.d.mts.map +0 -1
  219. package/resources/beta/pay/products/index.d.ts +0 -4
  220. package/resources/beta/pay/products/index.d.ts.map +0 -1
  221. package/resources/beta/pay/products/index.js.map +0 -1
  222. package/resources/beta/pay/products/index.mjs.map +0 -1
  223. package/resources/beta/pay/products/products.d.mts +0 -183
  224. package/resources/beta/pay/products/products.d.mts.map +0 -1
  225. package/resources/beta/pay/products/products.d.ts +0 -183
  226. package/resources/beta/pay/products/products.d.ts.map +0 -1
  227. package/resources/beta/pay/products/products.js.map +0 -1
  228. package/resources/beta/pay/products/products.mjs.map +0 -1
  229. package/resources/beta/pay/products/variants.d.mts +0 -206
  230. package/resources/beta/pay/products/variants.d.mts.map +0 -1
  231. package/resources/beta/pay/products/variants.d.ts +0 -206
  232. package/resources/beta/pay/products/variants.d.ts.map +0 -1
  233. package/resources/beta/pay/products/variants.js.map +0 -1
  234. package/resources/beta/pay/products/variants.mjs.map +0 -1
  235. package/resources/beta/pay/products.d.mts.map +0 -1
  236. package/resources/beta/pay/products.d.ts.map +0 -1
  237. package/resources/beta/pay/products.js.map +0 -1
  238. package/resources/beta/pay/products.mjs.map +0 -1
  239. package/resources/beta/pay.d.mts +0 -2
  240. package/resources/beta/pay.d.mts.map +0 -1
  241. package/resources/beta/pay.d.ts +0 -2
  242. package/resources/beta/pay.d.ts.map +0 -1
  243. package/resources/beta/pay.js.map +0 -1
  244. package/resources/beta/pay.mjs.map +0 -1
  245. package/src/resources/beta/pay/coupons.ts +0 -218
  246. package/src/resources/beta/pay/customers.ts +0 -229
  247. package/src/resources/beta/pay/entitlements.ts +0 -113
  248. package/src/resources/beta/pay/index.ts +0 -46
  249. package/src/resources/beta/pay/products/entitlements.ts +0 -93
  250. package/src/resources/beta/pay/products/index.ts +0 -28
  251. package/src/resources/beta/pay/products/products.ts +0 -280
  252. package/src/resources/beta/pay/products/variants.ts +0 -279
  253. /package/resources/beta/{pay → commerce}/products.d.mts +0 -0
  254. /package/resources/beta/{pay → commerce}/products.d.ts +0 -0
  255. /package/resources/beta/{pay → commerce}/products.js +0 -0
  256. /package/resources/beta/{pay → commerce}/products.mjs +0 -0
  257. /package/src/resources/beta/{pay → commerce}/products.ts +0 -0
@@ -0,0 +1,842 @@
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 { CursorIDPage, type CursorIDPageParams, PagePromise } from '../../../core/pagination';
6
+ import { buildHeaders } from '../../../internal/headers';
7
+ import { RequestOptions } from '../../../internal/request-options';
8
+ import { path } from '../../../internal/utils/path';
9
+
10
+ export class Customers extends APIResource {
11
+ /**
12
+ * Creates a new billable customer. A customer represents the entity in your app
13
+ * that will be charged—typically a user, organization, or project. Hercules
14
+ * recommends creating a customer immediately after creating the corresponding
15
+ * entity in your app.
16
+ */
17
+ create(
18
+ body: CustomerCreateParams | null | undefined = {},
19
+ options?: RequestOptions,
20
+ ): APIPromise<CustomerCreateResponse> {
21
+ return this._client.post('/v1/commerce/customers', { body, ...options });
22
+ }
23
+
24
+ /**
25
+ * Updates an existing customer. Use this to modify contact information or billing
26
+ * address. Only provided fields are updated; omitted fields remain unchanged.
27
+ */
28
+ update(
29
+ customerID: string,
30
+ body: CustomerUpdateParams | null | undefined = {},
31
+ options?: RequestOptions,
32
+ ): APIPromise<CustomerUpdateResponse> {
33
+ return this._client.patch(path`/v1/commerce/customers/${customerID}`, { body, ...options });
34
+ }
35
+
36
+ /**
37
+ * Retrieves a paginated list of all customers. Customers are the billable entities
38
+ * in your app—typically users, organizations, or projects.
39
+ */
40
+ list(
41
+ query: CustomerListParams | null | undefined = {},
42
+ options?: RequestOptions,
43
+ ): PagePromise<CustomerListResponsesCursorIDPage, CustomerListResponse> {
44
+ return this._client.getAPIList('/v1/commerce/customers', CursorIDPage<CustomerListResponse>, {
45
+ query,
46
+ ...options,
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Permanently deletes a customer. This also cancels any active subscriptions. This
52
+ * action cannot be undone.
53
+ */
54
+ delete(customerID: string, options?: RequestOptions): APIPromise<void> {
55
+ return this._client.delete(path`/v1/commerce/customers/${customerID}`, {
56
+ ...options,
57
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
58
+ });
59
+ }
60
+
61
+ /**
62
+ * Generates a URL to a hosted billing portal where the customer can view invoices,
63
+ * update payment methods, and manage billing details. Redirect the customer to the
64
+ * returned URL.
65
+ */
66
+ billingPortal(
67
+ customerID: string,
68
+ body: CustomerBillingPortalParams | null | undefined = {},
69
+ options?: RequestOptions,
70
+ ): APIPromise<CustomerBillingPortalResponse> {
71
+ return this._client.post(path`/v1/commerce/customers/${customerID}/billing_portal`, { body, ...options });
72
+ }
73
+
74
+ /**
75
+ * Retrieves a customer by ID. Returns the customer object including contact
76
+ * information, billing address, active subscriptions, recent invoices, and saved
77
+ * payment methods.
78
+ */
79
+ get(customerID: string, options?: RequestOptions): APIPromise<CustomerGetResponse> {
80
+ return this._client.get(path`/v1/commerce/customers/${customerID}`, options);
81
+ }
82
+ }
83
+
84
+ export type CustomerListResponsesCursorIDPage = CursorIDPage<CustomerListResponse>;
85
+
86
+ /**
87
+ * A billable customer. Represents the entity in your app that will be
88
+ * charged—typically a user, organization, or project.
89
+ */
90
+ export interface CustomerCreateResponse {
91
+ /**
92
+ * Unique identifier for the topic subscription
93
+ */
94
+ id: string;
95
+
96
+ /**
97
+ * Timestamp when the customer was created
98
+ */
99
+ created: string;
100
+
101
+ /**
102
+ * The customer's billing address
103
+ */
104
+ address?: CustomerCreateResponse.Address | null;
105
+
106
+ /**
107
+ * The customer's email address for receipts and notifications
108
+ */
109
+ email?: string | null;
110
+
111
+ /**
112
+ * The customer's full name
113
+ */
114
+ name?: string | null;
115
+
116
+ /**
117
+ * The customer's phone number
118
+ */
119
+ phone?: string | null;
120
+ }
121
+
122
+ export namespace CustomerCreateResponse {
123
+ /**
124
+ * The customer's billing address
125
+ */
126
+ export interface Address {
127
+ /**
128
+ * City name
129
+ */
130
+ city?: string | null;
131
+
132
+ /**
133
+ * Two-letter ISO country code
134
+ */
135
+ country?: string | null;
136
+
137
+ /**
138
+ * Street address line 1
139
+ */
140
+ line1?: string | null;
141
+
142
+ /**
143
+ * Street address line 2 (apartment, suite, etc.)
144
+ */
145
+ line2?: string | null;
146
+
147
+ /**
148
+ * Postal or ZIP code
149
+ */
150
+ postal_code?: string | null;
151
+
152
+ /**
153
+ * State, province, or region
154
+ */
155
+ state?: string | null;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * A billable customer. Represents the entity in your app that will be
161
+ * charged—typically a user, organization, or project.
162
+ */
163
+ export interface CustomerUpdateResponse {
164
+ /**
165
+ * Unique identifier for the topic subscription
166
+ */
167
+ id: string;
168
+
169
+ /**
170
+ * Timestamp when the customer was created
171
+ */
172
+ created: string;
173
+
174
+ /**
175
+ * The customer's billing address
176
+ */
177
+ address?: CustomerUpdateResponse.Address | null;
178
+
179
+ /**
180
+ * The customer's email address for receipts and notifications
181
+ */
182
+ email?: string | null;
183
+
184
+ /**
185
+ * The customer's full name
186
+ */
187
+ name?: string | null;
188
+
189
+ /**
190
+ * The customer's phone number
191
+ */
192
+ phone?: string | null;
193
+ }
194
+
195
+ export namespace CustomerUpdateResponse {
196
+ /**
197
+ * The customer's billing address
198
+ */
199
+ export interface Address {
200
+ /**
201
+ * City name
202
+ */
203
+ city?: string | null;
204
+
205
+ /**
206
+ * Two-letter ISO country code
207
+ */
208
+ country?: string | null;
209
+
210
+ /**
211
+ * Street address line 1
212
+ */
213
+ line1?: string | null;
214
+
215
+ /**
216
+ * Street address line 2 (apartment, suite, etc.)
217
+ */
218
+ line2?: string | null;
219
+
220
+ /**
221
+ * Postal or ZIP code
222
+ */
223
+ postal_code?: string | null;
224
+
225
+ /**
226
+ * State, province, or region
227
+ */
228
+ state?: string | null;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * A billable customer. Represents the entity in your app that will be
234
+ * charged—typically a user, organization, or project.
235
+ */
236
+ export interface CustomerListResponse {
237
+ /**
238
+ * Unique identifier for the topic subscription
239
+ */
240
+ id: string;
241
+
242
+ /**
243
+ * Timestamp when the customer was created
244
+ */
245
+ created: string;
246
+
247
+ /**
248
+ * The customer's billing address
249
+ */
250
+ address?: CustomerListResponse.Address | null;
251
+
252
+ /**
253
+ * The customer's email address for receipts and notifications
254
+ */
255
+ email?: string | null;
256
+
257
+ /**
258
+ * The customer's full name
259
+ */
260
+ name?: string | null;
261
+
262
+ /**
263
+ * The customer's phone number
264
+ */
265
+ phone?: string | null;
266
+ }
267
+
268
+ export namespace CustomerListResponse {
269
+ /**
270
+ * The customer's billing address
271
+ */
272
+ export interface Address {
273
+ /**
274
+ * City name
275
+ */
276
+ city?: string | null;
277
+
278
+ /**
279
+ * Two-letter ISO country code
280
+ */
281
+ country?: string | null;
282
+
283
+ /**
284
+ * Street address line 1
285
+ */
286
+ line1?: string | null;
287
+
288
+ /**
289
+ * Street address line 2 (apartment, suite, etc.)
290
+ */
291
+ line2?: string | null;
292
+
293
+ /**
294
+ * Postal or ZIP code
295
+ */
296
+ postal_code?: string | null;
297
+
298
+ /**
299
+ * State, province, or region
300
+ */
301
+ state?: string | null;
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Response containing the billing portal URL
307
+ */
308
+ export interface CustomerBillingPortalResponse {
309
+ /**
310
+ * URL to redirect the customer to for the billing portal
311
+ */
312
+ url: string;
313
+ }
314
+
315
+ /**
316
+ * A billable customer with detailed subscription, invoice, and payment method
317
+ * information.
318
+ */
319
+ export interface CustomerGetResponse {
320
+ /**
321
+ * Unique identifier for the topic subscription
322
+ */
323
+ id: string;
324
+
325
+ /**
326
+ * Timestamp when the customer was created
327
+ */
328
+ created: string;
329
+
330
+ /**
331
+ * The customer's billing address
332
+ */
333
+ address?: CustomerGetResponse.Address | null;
334
+
335
+ /**
336
+ * The customer's email address for receipts and notifications
337
+ */
338
+ email?: string | null;
339
+
340
+ /**
341
+ * Customer's recent invoices (up to 10)
342
+ */
343
+ invoices?: Array<CustomerGetResponse.Invoice>;
344
+
345
+ /**
346
+ * The customer's full name
347
+ */
348
+ name?: string | null;
349
+
350
+ /**
351
+ * Customer's saved payment methods
352
+ */
353
+ payment_methods?: Array<CustomerGetResponse.PaymentMethod>;
354
+
355
+ /**
356
+ * The customer's phone number
357
+ */
358
+ phone?: string | null;
359
+
360
+ /**
361
+ * Customer's active subscriptions
362
+ */
363
+ subscriptions?: Array<CustomerGetResponse.Subscription>;
364
+ }
365
+
366
+ export namespace CustomerGetResponse {
367
+ /**
368
+ * The customer's billing address
369
+ */
370
+ export interface Address {
371
+ /**
372
+ * City name
373
+ */
374
+ city?: string | null;
375
+
376
+ /**
377
+ * Two-letter ISO country code
378
+ */
379
+ country?: string | null;
380
+
381
+ /**
382
+ * Street address line 1
383
+ */
384
+ line1?: string | null;
385
+
386
+ /**
387
+ * Street address line 2 (apartment, suite, etc.)
388
+ */
389
+ line2?: string | null;
390
+
391
+ /**
392
+ * Postal or ZIP code
393
+ */
394
+ postal_code?: string | null;
395
+
396
+ /**
397
+ * State, province, or region
398
+ */
399
+ state?: string | null;
400
+ }
401
+
402
+ /**
403
+ * An invoice for a customer
404
+ */
405
+ export interface Invoice {
406
+ /**
407
+ * Unique identifier for the topic subscription
408
+ */
409
+ id: string;
410
+
411
+ /**
412
+ * Total amount due in cents
413
+ */
414
+ amount_due: number;
415
+
416
+ /**
417
+ * Amount already paid in cents
418
+ */
419
+ amount_paid: number;
420
+
421
+ /**
422
+ * Amount remaining to be paid in cents
423
+ */
424
+ amount_remaining: number;
425
+
426
+ /**
427
+ * Timestamp when the invoice was created
428
+ */
429
+ created: string;
430
+
431
+ /**
432
+ * Currency code (e.g., 'usd')
433
+ */
434
+ currency: string;
435
+
436
+ /**
437
+ * Subtotal before tax in cents
438
+ */
439
+ subtotal: number;
440
+
441
+ /**
442
+ * Total amount in cents
443
+ */
444
+ total: number;
445
+
446
+ /**
447
+ * When the invoice is due
448
+ */
449
+ due_date?: string | null;
450
+
451
+ /**
452
+ * URL to view the invoice online
453
+ */
454
+ hosted_invoice_url?: string | null;
455
+
456
+ /**
457
+ * URL to download the invoice PDF
458
+ */
459
+ invoice_pdf?: string | null;
460
+
461
+ /**
462
+ * Invoice number for display
463
+ */
464
+ number?: string | null;
465
+
466
+ /**
467
+ * When the invoice was paid, if applicable
468
+ */
469
+ paid_at?: string | null;
470
+
471
+ /**
472
+ * End of the billing period
473
+ */
474
+ period_end?: string | null;
475
+
476
+ /**
477
+ * Start of the billing period
478
+ */
479
+ period_start?: string | null;
480
+
481
+ /**
482
+ * Current status of the invoice
483
+ */
484
+ status?: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible' | null;
485
+ }
486
+
487
+ /**
488
+ * A saved payment method for a customer
489
+ */
490
+ export interface PaymentMethod {
491
+ /**
492
+ * Unique identifier for the topic subscription
493
+ */
494
+ id: string;
495
+
496
+ /**
497
+ * Timestamp when the payment method was added
498
+ */
499
+ created: string;
500
+
501
+ /**
502
+ * Whether this is the default payment method
503
+ */
504
+ is_default: boolean;
505
+
506
+ /**
507
+ * Type of payment method
508
+ */
509
+ type: 'card' | 'us_bank_account' | 'sepa_debit' | 'link' | 'other';
510
+
511
+ /**
512
+ * Card details, if payment method is a card
513
+ */
514
+ card?: PaymentMethod.Card | null;
515
+ }
516
+
517
+ export namespace PaymentMethod {
518
+ /**
519
+ * Card details, if payment method is a card
520
+ */
521
+ export interface Card {
522
+ /**
523
+ * Card brand (e.g., 'visa', 'mastercard')
524
+ */
525
+ brand: string;
526
+
527
+ /**
528
+ * Expiration month (1-12)
529
+ */
530
+ exp_month: number;
531
+
532
+ /**
533
+ * Expiration year (4 digits)
534
+ */
535
+ exp_year: number;
536
+
537
+ /**
538
+ * Last 4 digits of the card number
539
+ */
540
+ last4: string;
541
+ }
542
+ }
543
+
544
+ /**
545
+ * A customer subscription to a product
546
+ */
547
+ export interface Subscription {
548
+ /**
549
+ * Unique identifier for the topic subscription
550
+ */
551
+ id: string;
552
+
553
+ /**
554
+ * Whether the subscription will cancel at period end
555
+ */
556
+ cancel_at_period_end: boolean;
557
+
558
+ /**
559
+ * Timestamp when the subscription was created
560
+ */
561
+ created: string;
562
+
563
+ /**
564
+ * End of the current billing period
565
+ */
566
+ current_period_end: string;
567
+
568
+ /**
569
+ * Start of the current billing period
570
+ */
571
+ current_period_start: string;
572
+
573
+ /**
574
+ * The product this subscription is for
575
+ */
576
+ product: Subscription.Product;
577
+
578
+ /**
579
+ * Current status of the subscription
580
+ */
581
+ status:
582
+ | 'active'
583
+ | 'canceled'
584
+ | 'incomplete'
585
+ | 'incomplete_expired'
586
+ | 'past_due'
587
+ | 'paused'
588
+ | 'trialing'
589
+ | 'unpaid';
590
+
591
+ /**
592
+ * When the subscription was canceled, if applicable
593
+ */
594
+ canceled_at?: string | null;
595
+
596
+ /**
597
+ * End of trial period, if applicable
598
+ */
599
+ trial_end?: string | null;
600
+
601
+ /**
602
+ * Start of trial period, if applicable
603
+ */
604
+ trial_start?: string | null;
605
+
606
+ /**
607
+ * The variant (tier/plan) of this subscription, if applicable
608
+ */
609
+ variant?: Subscription.Variant | null;
610
+ }
611
+
612
+ export namespace Subscription {
613
+ /**
614
+ * The product this subscription is for
615
+ */
616
+ export interface Product {
617
+ /**
618
+ * Unique identifier for the topic subscription
619
+ */
620
+ id: string;
621
+
622
+ /**
623
+ * Product name
624
+ */
625
+ name: string;
626
+ }
627
+
628
+ /**
629
+ * The variant (tier/plan) of this subscription, if applicable
630
+ */
631
+ export interface Variant {
632
+ /**
633
+ * Unique identifier for the topic subscription
634
+ */
635
+ id: string;
636
+
637
+ /**
638
+ * Variant name
639
+ */
640
+ name: string;
641
+ }
642
+ }
643
+ }
644
+
645
+ export interface CustomerCreateParams {
646
+ /**
647
+ * Optional custom ID for the customer. Must start with 'cus\_'. If not provided,
648
+ * one will be generated.
649
+ */
650
+ id?: string;
651
+
652
+ /**
653
+ * The customer's billing address
654
+ */
655
+ address?: CustomerCreateParams.Address;
656
+
657
+ /**
658
+ * The customer's email address for receipts and notifications
659
+ */
660
+ email?: string;
661
+
662
+ /**
663
+ * The customer's full name
664
+ */
665
+ name?: string;
666
+
667
+ /**
668
+ * The customer's phone number
669
+ */
670
+ phone?: string;
671
+ }
672
+
673
+ export namespace CustomerCreateParams {
674
+ /**
675
+ * The customer's billing address
676
+ */
677
+ export interface Address {
678
+ /**
679
+ * City name
680
+ */
681
+ city?: string | null;
682
+
683
+ /**
684
+ * Two-letter ISO country code
685
+ */
686
+ country?: string | null;
687
+
688
+ /**
689
+ * Street address line 1
690
+ */
691
+ line1?: string | null;
692
+
693
+ /**
694
+ * Street address line 2 (apartment, suite, etc.)
695
+ */
696
+ line2?: string | null;
697
+
698
+ /**
699
+ * Postal or ZIP code
700
+ */
701
+ postal_code?: string | null;
702
+
703
+ /**
704
+ * State, province, or region
705
+ */
706
+ state?: string | null;
707
+ }
708
+ }
709
+
710
+ export interface CustomerUpdateParams {
711
+ /**
712
+ * The customer's billing address
713
+ */
714
+ address?: CustomerUpdateParams.Address;
715
+
716
+ /**
717
+ * The customer's email address for receipts and notifications
718
+ */
719
+ email?: string;
720
+
721
+ /**
722
+ * The customer's full name
723
+ */
724
+ name?: string;
725
+
726
+ /**
727
+ * The customer's phone number
728
+ */
729
+ phone?: string;
730
+ }
731
+
732
+ export namespace CustomerUpdateParams {
733
+ /**
734
+ * The customer's billing address
735
+ */
736
+ export interface Address {
737
+ /**
738
+ * City name
739
+ */
740
+ city?: string | null;
741
+
742
+ /**
743
+ * Two-letter ISO country code
744
+ */
745
+ country?: string | null;
746
+
747
+ /**
748
+ * Street address line 1
749
+ */
750
+ line1?: string | null;
751
+
752
+ /**
753
+ * Street address line 2 (apartment, suite, etc.)
754
+ */
755
+ line2?: string | null;
756
+
757
+ /**
758
+ * Postal or ZIP code
759
+ */
760
+ postal_code?: string | null;
761
+
762
+ /**
763
+ * State, province, or region
764
+ */
765
+ state?: string | null;
766
+ }
767
+ }
768
+
769
+ export interface CustomerListParams extends CursorIDPageParams {
770
+ /**
771
+ * Filter by creation date. Accepts an object with gt, gte, lt, lte operators using
772
+ * Unix timestamps.
773
+ */
774
+ created?: CustomerListParams.Created;
775
+
776
+ /**
777
+ * Filter by exact email address match.
778
+ */
779
+ email?: string;
780
+
781
+ /**
782
+ * Search query to filter customers. Searches across name, email, and ID fields
783
+ * (case-insensitive).
784
+ */
785
+ query?: string;
786
+
787
+ /**
788
+ * Sort order for customers. Prefix with '-' for descending order. Valid values:
789
+ * name, -name, email, -email, created, -created. Default: -created (newest first).
790
+ */
791
+ sort?: string;
792
+ }
793
+
794
+ export namespace CustomerListParams {
795
+ /**
796
+ * Filter by creation date. Accepts an object with gt, gte, lt, lte operators using
797
+ * Unix timestamps.
798
+ */
799
+ export interface Created {
800
+ /**
801
+ * Greater than (Unix timestamp)
802
+ */
803
+ gt?: number;
804
+
805
+ /**
806
+ * Greater than or equal to (Unix timestamp)
807
+ */
808
+ gte?: number;
809
+
810
+ /**
811
+ * Less than (Unix timestamp)
812
+ */
813
+ lt?: number;
814
+
815
+ /**
816
+ * Less than or equal to (Unix timestamp)
817
+ */
818
+ lte?: number;
819
+ }
820
+ }
821
+
822
+ export interface CustomerBillingPortalParams {
823
+ /**
824
+ * URL to redirect the customer to after they exit the billing portal
825
+ */
826
+ return_url?: string;
827
+ }
828
+
829
+ export declare namespace Customers {
830
+ export {
831
+ type CustomerCreateResponse as CustomerCreateResponse,
832
+ type CustomerUpdateResponse as CustomerUpdateResponse,
833
+ type CustomerListResponse as CustomerListResponse,
834
+ type CustomerBillingPortalResponse as CustomerBillingPortalResponse,
835
+ type CustomerGetResponse as CustomerGetResponse,
836
+ type CustomerListResponsesCursorIDPage as CustomerListResponsesCursorIDPage,
837
+ type CustomerCreateParams as CustomerCreateParams,
838
+ type CustomerUpdateParams as CustomerUpdateParams,
839
+ type CustomerListParams as CustomerListParams,
840
+ type CustomerBillingPortalParams as CustomerBillingPortalParams,
841
+ };
842
+ }