@metronome/sdk 0.1.0-alpha.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 (284) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +201 -0
  3. package/README.md +313 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +90 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +237 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +868 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +837 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +53 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +143 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +127 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +210 -0
  87. package/index.d.ts +210 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +133 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +105 -0
  92. package/index.mjs.map +1 -0
  93. package/package.json +106 -0
  94. package/resource.d.ts +6 -0
  95. package/resource.d.ts.map +1 -0
  96. package/resource.js +11 -0
  97. package/resource.js.map +1 -0
  98. package/resource.mjs +7 -0
  99. package/resource.mjs.map +1 -0
  100. package/resources/alerts.d.ts +103 -0
  101. package/resources/alerts.d.ts.map +1 -0
  102. package/resources/alerts.js +23 -0
  103. package/resources/alerts.js.map +1 -0
  104. package/resources/alerts.mjs +19 -0
  105. package/resources/alerts.mjs.map +1 -0
  106. package/resources/audit-logs.d.ts +83 -0
  107. package/resources/audit-logs.d.ts.map +1 -0
  108. package/resources/audit-logs.js +18 -0
  109. package/resources/audit-logs.js.map +1 -0
  110. package/resources/audit-logs.mjs +14 -0
  111. package/resources/audit-logs.mjs.map +1 -0
  112. package/resources/billable-metrics.d.ts +236 -0
  113. package/resources/billable-metrics.d.ts.map +1 -0
  114. package/resources/billable-metrics.js +36 -0
  115. package/resources/billable-metrics.js.map +1 -0
  116. package/resources/billable-metrics.mjs +32 -0
  117. package/resources/billable-metrics.mjs.map +1 -0
  118. package/resources/credit-grants.d.ts +469 -0
  119. package/resources/credit-grants.d.ts.map +1 -0
  120. package/resources/credit-grants.js +50 -0
  121. package/resources/credit-grants.js.map +1 -0
  122. package/resources/credit-grants.mjs +46 -0
  123. package/resources/credit-grants.mjs.map +1 -0
  124. package/resources/custom-fields.d.ts +82 -0
  125. package/resources/custom-fields.d.ts.map +1 -0
  126. package/resources/custom-fields.js +66 -0
  127. package/resources/custom-fields.js.map +1 -0
  128. package/resources/custom-fields.mjs +62 -0
  129. package/resources/custom-fields.mjs.map +1 -0
  130. package/resources/customers/alerts.d.ts +146 -0
  131. package/resources/customers/alerts.d.ts.map +1 -0
  132. package/resources/customers/alerts.js +35 -0
  133. package/resources/customers/alerts.js.map +1 -0
  134. package/resources/customers/alerts.mjs +31 -0
  135. package/resources/customers/alerts.mjs.map +1 -0
  136. package/resources/customers/billing-config.d.ts +64 -0
  137. package/resources/customers/billing-config.d.ts.map +1 -0
  138. package/resources/customers/billing-config.js +37 -0
  139. package/resources/customers/billing-config.js.map +1 -0
  140. package/resources/customers/billing-config.mjs +33 -0
  141. package/resources/customers/billing-config.mjs.map +1 -0
  142. package/resources/customers/customers.d.ts +313 -0
  143. package/resources/customers/customers.d.ts.map +1 -0
  144. package/resources/customers/customers.js +116 -0
  145. package/resources/customers/customers.js.map +1 -0
  146. package/resources/customers/customers.mjs +89 -0
  147. package/resources/customers/customers.mjs.map +1 -0
  148. package/resources/customers/index.d.ts +6 -0
  149. package/resources/customers/index.d.ts.map +1 -0
  150. package/resources/customers/index.js +15 -0
  151. package/resources/customers/index.js.map +1 -0
  152. package/resources/customers/index.mjs +7 -0
  153. package/resources/customers/index.mjs.map +1 -0
  154. package/resources/customers/invoices.d.ts +331 -0
  155. package/resources/customers/invoices.d.ts.map +1 -0
  156. package/resources/customers/invoices.js +30 -0
  157. package/resources/customers/invoices.js.map +1 -0
  158. package/resources/customers/invoices.mjs +26 -0
  159. package/resources/customers/invoices.mjs.map +1 -0
  160. package/resources/customers/plans.d.ts +239 -0
  161. package/resources/customers/plans.d.ts.map +1 -0
  162. package/resources/customers/plans.js +41 -0
  163. package/resources/customers/plans.js.map +1 -0
  164. package/resources/customers/plans.mjs +37 -0
  165. package/resources/customers/plans.mjs.map +1 -0
  166. package/resources/dashboards.d.ts +61 -0
  167. package/resources/dashboards.d.ts.map +1 -0
  168. package/resources/dashboards.js +19 -0
  169. package/resources/dashboards.js.map +1 -0
  170. package/resources/dashboards.mjs +15 -0
  171. package/resources/dashboards.mjs.map +1 -0
  172. package/resources/index.d.ts +13 -0
  173. package/resources/index.d.ts.map +1 -0
  174. package/resources/index.js +42 -0
  175. package/resources/index.js.map +1 -0
  176. package/resources/index.mjs +14 -0
  177. package/resources/index.mjs.map +1 -0
  178. package/resources/plans.d.ts +217 -0
  179. package/resources/plans.d.ts.map +1 -0
  180. package/resources/plans.js +36 -0
  181. package/resources/plans.js.map +1 -0
  182. package/resources/plans.mjs +32 -0
  183. package/resources/plans.mjs.map +1 -0
  184. package/resources/services.d.ts +26 -0
  185. package/resources/services.d.ts.map +1 -0
  186. package/resources/services.js +20 -0
  187. package/resources/services.js.map +1 -0
  188. package/resources/services.mjs +16 -0
  189. package/resources/services.mjs.map +1 -0
  190. package/resources/shared.d.ts +540 -0
  191. package/resources/shared.d.ts.map +1 -0
  192. package/resources/shared.js +4 -0
  193. package/resources/shared.js.map +1 -0
  194. package/resources/shared.mjs +3 -0
  195. package/resources/shared.mjs.map +1 -0
  196. package/resources/usage.d.ts +182 -0
  197. package/resources/usage.d.ts.map +1 -0
  198. package/resources/usage.js +41 -0
  199. package/resources/usage.js.map +1 -0
  200. package/resources/usage.mjs +37 -0
  201. package/resources/usage.mjs.map +1 -0
  202. package/resources/webhooks.d.ts +22 -0
  203. package/resources/webhooks.d.ts.map +1 -0
  204. package/resources/webhooks.js +91 -0
  205. package/resources/webhooks.js.map +1 -0
  206. package/resources/webhooks.mjs +87 -0
  207. package/resources/webhooks.mjs.map +1 -0
  208. package/shims/node.d.ts +29 -0
  209. package/shims/node.d.ts.map +1 -0
  210. package/shims/node.js +31 -0
  211. package/shims/node.js.map +1 -0
  212. package/shims/node.mjs +5 -0
  213. package/shims/node.mjs.map +1 -0
  214. package/shims/web.d.ts +26 -0
  215. package/shims/web.d.ts.map +1 -0
  216. package/shims/web.js +31 -0
  217. package/shims/web.js.map +1 -0
  218. package/shims/web.mjs +5 -0
  219. package/shims/web.mjs.map +1 -0
  220. package/src/_shims/MultipartBody.ts +9 -0
  221. package/src/_shims/README.md +46 -0
  222. package/src/_shims/auto/runtime-bun.ts +4 -0
  223. package/src/_shims/auto/runtime-node.ts +4 -0
  224. package/src/_shims/auto/runtime.ts +4 -0
  225. package/src/_shims/auto/types-node.ts +4 -0
  226. package/src/_shims/auto/types.d.ts +101 -0
  227. package/src/_shims/auto/types.js +3 -0
  228. package/src/_shims/auto/types.mjs +3 -0
  229. package/src/_shims/bun-runtime.ts +14 -0
  230. package/src/_shims/index.d.ts +81 -0
  231. package/src/_shims/index.js +13 -0
  232. package/src/_shims/index.mjs +7 -0
  233. package/src/_shims/manual-types.d.ts +12 -0
  234. package/src/_shims/manual-types.js +3 -0
  235. package/src/_shims/manual-types.mjs +3 -0
  236. package/src/_shims/node-runtime.ts +83 -0
  237. package/src/_shims/node-types.d.ts +42 -0
  238. package/src/_shims/node-types.js +3 -0
  239. package/src/_shims/node-types.mjs +3 -0
  240. package/src/_shims/registry.ts +67 -0
  241. package/src/_shims/web-runtime.ts +103 -0
  242. package/src/_shims/web-types.d.ts +83 -0
  243. package/src/_shims/web-types.js +3 -0
  244. package/src/_shims/web-types.mjs +3 -0
  245. package/src/core.ts +1146 -0
  246. package/src/error.ts +146 -0
  247. package/src/index.ts +303 -0
  248. package/src/lib/.keep +4 -0
  249. package/src/resource.ts +11 -0
  250. package/src/resources/alerts.ts +144 -0
  251. package/src/resources/audit-logs.ts +116 -0
  252. package/src/resources/billable-metrics.ts +341 -0
  253. package/src/resources/credit-grants.ts +627 -0
  254. package/src/resources/custom-fields.ts +242 -0
  255. package/src/resources/customers/alerts.ts +214 -0
  256. package/src/resources/customers/billing-config.ts +183 -0
  257. package/src/resources/customers/customers.ts +500 -0
  258. package/src/resources/customers/index.ts +53 -0
  259. package/src/resources/customers/invoices.ts +533 -0
  260. package/src/resources/customers/plans.ts +363 -0
  261. package/src/resources/dashboards.ts +98 -0
  262. package/src/resources/index.ts +90 -0
  263. package/src/resources/plans.ts +333 -0
  264. package/src/resources/services.ts +35 -0
  265. package/src/resources/shared.ts +849 -0
  266. package/src/resources/usage.ts +245 -0
  267. package/src/resources/webhooks.ts +120 -0
  268. package/src/shims/node.ts +50 -0
  269. package/src/shims/web.ts +50 -0
  270. package/src/tsconfig.json +11 -0
  271. package/src/uploads.ts +248 -0
  272. package/src/version.ts +1 -0
  273. package/uploads.d.ts +75 -0
  274. package/uploads.d.ts.map +1 -0
  275. package/uploads.js +165 -0
  276. package/uploads.js.map +1 -0
  277. package/uploads.mjs +152 -0
  278. package/uploads.mjs.map +1 -0
  279. package/version.d.ts +2 -0
  280. package/version.d.ts.map +1 -0
  281. package/version.js +5 -0
  282. package/version.js.map +1 -0
  283. package/version.mjs +2 -0
  284. package/version.mjs.map +1 -0
@@ -0,0 +1,627 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import { isRequestOptions } from "../core";
6
+ import * as CreditGrantsAPI from "./credit-grants";
7
+ import * as Shared from "./shared";
8
+
9
+ export class CreditGrants extends APIResource {
10
+ /**
11
+ * Create a new credit grant
12
+ */
13
+ create(
14
+ body: CreditGrantCreateParams,
15
+ options?: Core.RequestOptions,
16
+ ): Core.APIPromise<CreditGrantCreateResponse> {
17
+ return this._client.post('/credits/createGrant', { body, ...options });
18
+ }
19
+
20
+ /**
21
+ * List credit grants. This list does not included voided grants.
22
+ */
23
+ list(
24
+ params?: CreditGrantListParams,
25
+ options?: Core.RequestOptions,
26
+ ): Core.APIPromise<CreditGrantListResponse>;
27
+ list(options?: Core.RequestOptions): Core.APIPromise<CreditGrantListResponse>;
28
+ list(
29
+ params: CreditGrantListParams | Core.RequestOptions = {},
30
+ options?: Core.RequestOptions,
31
+ ): Core.APIPromise<CreditGrantListResponse> {
32
+ if (isRequestOptions(params)) {
33
+ return this.list({}, params);
34
+ }
35
+ const { limit, next_page, ...body } = params;
36
+ return this._client.post('/credits/listGrants', { query: { limit, next_page }, body, ...options });
37
+ }
38
+
39
+ /**
40
+ * Edit an existing credit grant
41
+ */
42
+ edit(body: CreditGrantEditParams, options?: Core.RequestOptions): Core.APIPromise<CreditGrantEditResponse> {
43
+ return this._client.post('/credits/editGrant', { body, ...options });
44
+ }
45
+
46
+ /**
47
+ * List all pricing units (known in the API by the legacy term "credit types").
48
+ */
49
+ listCreditTypes(
50
+ query?: CreditGrantListCreditTypesParams,
51
+ options?: Core.RequestOptions,
52
+ ): Core.APIPromise<CreditGrantListCreditTypesResponse>;
53
+ listCreditTypes(options?: Core.RequestOptions): Core.APIPromise<CreditGrantListCreditTypesResponse>;
54
+ listCreditTypes(
55
+ query: CreditGrantListCreditTypesParams | Core.RequestOptions = {},
56
+ options?: Core.RequestOptions,
57
+ ): Core.APIPromise<CreditGrantListCreditTypesResponse> {
58
+ if (isRequestOptions(query)) {
59
+ return this.listCreditTypes({}, query);
60
+ }
61
+ return this._client.get('/credit-types/list', { query, ...options });
62
+ }
63
+
64
+ /**
65
+ * Fetches a list of credit ledger entries. Returns lists of ledgers per customer.
66
+ * Ledger entries are returned in reverse chronological order. Ledger entries
67
+ * associated with voided credit grants are not included.
68
+ */
69
+ listEntries(
70
+ params?: CreditGrantListEntriesParams,
71
+ options?: Core.RequestOptions,
72
+ ): Core.APIPromise<CreditGrantListEntriesResponse>;
73
+ listEntries(options?: Core.RequestOptions): Core.APIPromise<CreditGrantListEntriesResponse>;
74
+ listEntries(
75
+ params: CreditGrantListEntriesParams | Core.RequestOptions = {},
76
+ options?: Core.RequestOptions,
77
+ ): Core.APIPromise<CreditGrantListEntriesResponse> {
78
+ if (isRequestOptions(params)) {
79
+ return this.listEntries({}, params);
80
+ }
81
+ const { next_page, ...body } = params;
82
+ return this._client.post('/credits/listEntries', { query: { next_page }, body, ...options });
83
+ }
84
+
85
+ /**
86
+ * Void a credit grant
87
+ */
88
+ void(body: CreditGrantVoidParams, options?: Core.RequestOptions): Core.APIPromise<CreditGrantVoidResponse> {
89
+ return this._client.post('/credits/voidGrant', { body, ...options });
90
+ }
91
+ }
92
+
93
+ export interface CreditLedgerEntry {
94
+ /**
95
+ * an amount representing the change to the customer's credit balance
96
+ */
97
+ amount: number;
98
+
99
+ created_by: string;
100
+
101
+ /**
102
+ * the credit grant this entry is related to
103
+ */
104
+ credit_grant_id: string;
105
+
106
+ effective_at: string;
107
+
108
+ reason: string;
109
+
110
+ /**
111
+ * the running balance for this credit type at the time of the ledger entry,
112
+ * including all preceding charges
113
+ */
114
+ running_balance: number;
115
+
116
+ /**
117
+ * if this entry is a deduction, the Metronome ID of the invoice where the credit
118
+ * deduction was consumed; if this entry is a grant, the Metronome ID of the
119
+ * invoice where the grant's paid_amount was charged
120
+ */
121
+ invoice_id?: string | null;
122
+ }
123
+
124
+ export interface RolloverAmountMaxAmount {
125
+ /**
126
+ * Rollover up to a fixed amount of the original credit grant amount.
127
+ */
128
+ type: 'MAX_AMOUNT';
129
+
130
+ /**
131
+ * The maximum amount to rollover.
132
+ */
133
+ value: number;
134
+ }
135
+
136
+ export interface RolloverAmountMaxPercentage {
137
+ /**
138
+ * Rollover up to a percentage of the original credit grant amount.
139
+ */
140
+ type: 'MAX_PERCENTAGE';
141
+
142
+ /**
143
+ * The maximum percentage (0-1) of the original credit grant to rollover.
144
+ */
145
+ value: number;
146
+ }
147
+
148
+ export interface CreditGrantCreateResponse {
149
+ data: Shared.ID;
150
+ }
151
+
152
+ export interface CreditGrantListResponse {
153
+ data: Array<CreditGrantListResponse.Data>;
154
+
155
+ next_page: string | null;
156
+ }
157
+
158
+ export namespace CreditGrantListResponse {
159
+ export interface Data {
160
+ /**
161
+ * the Metronome ID of the credit grant
162
+ */
163
+ id: string;
164
+
165
+ /**
166
+ * The effective balance of the grant as of the end of the customer's current
167
+ * billing period. Expiration deductions will be included only if the grant expires
168
+ * before the end of the current billing period.
169
+ */
170
+ balance: Data.Balance;
171
+
172
+ custom_fields: Record<string, string>;
173
+
174
+ /**
175
+ * the Metronome ID of the customer
176
+ */
177
+ customer_id: string;
178
+
179
+ deductions: Array<CreditGrantsAPI.CreditLedgerEntry>;
180
+
181
+ effective_at: string;
182
+
183
+ expires_at: string;
184
+
185
+ /**
186
+ * the amount of credits initially granted
187
+ */
188
+ grant_amount: Data.GrantAmount;
189
+
190
+ name: string;
191
+
192
+ /**
193
+ * the amount paid for this credit grant
194
+ */
195
+ paid_amount: Data.PaidAmount;
196
+
197
+ pending_deductions: Array<CreditGrantsAPI.CreditLedgerEntry>;
198
+
199
+ priority: number;
200
+
201
+ credit_grant_type?: string | null;
202
+
203
+ /**
204
+ * the Metronome ID of the invoice with the purchase charge for this credit grant,
205
+ * if applicable
206
+ */
207
+ invoice_id?: string | null;
208
+
209
+ /**
210
+ * The products which these credits will be applied to. (If unspecified, the
211
+ * credits will be applied to charges for all products.)
212
+ */
213
+ products?: Array<Data.Product>;
214
+
215
+ reason?: string | null;
216
+
217
+ /**
218
+ * Prevents the creation of duplicates. If a request to create a record is made
219
+ * with a previously used uniqueness key, a new record will not be created and the
220
+ * request will fail with a 409 error.
221
+ */
222
+ uniqueness_key?: string | null;
223
+ }
224
+
225
+ export namespace Data {
226
+ /**
227
+ * The effective balance of the grant as of the end of the customer's current
228
+ * billing period. Expiration deductions will be included only if the grant expires
229
+ * before the end of the current billing period.
230
+ */
231
+ export interface Balance {
232
+ /**
233
+ * The end_date of the customer's current billing period.
234
+ */
235
+ effective_at: string;
236
+
237
+ /**
238
+ * The grant's current balance including all posted deductions. If the grant has
239
+ * expired, this amount will be 0.
240
+ */
241
+ excluding_pending: number;
242
+
243
+ /**
244
+ * The grant's current balance including all posted and pending deductions. If the
245
+ * grant expires before the end of the customer's current billing period, this
246
+ * amount will be 0.
247
+ */
248
+ including_pending: number;
249
+ }
250
+
251
+ /**
252
+ * the amount of credits initially granted
253
+ */
254
+ export interface GrantAmount {
255
+ amount: number;
256
+
257
+ /**
258
+ * the credit type for the amount granted
259
+ */
260
+ credit_type: Shared.CreditType;
261
+ }
262
+
263
+ /**
264
+ * the amount paid for this credit grant
265
+ */
266
+ export interface PaidAmount {
267
+ amount: number;
268
+
269
+ /**
270
+ * the credit type for the amount paid
271
+ */
272
+ credit_type: Shared.CreditType;
273
+ }
274
+
275
+ export interface Product {
276
+ id: string;
277
+
278
+ name: string;
279
+ }
280
+ }
281
+ }
282
+
283
+ export interface CreditGrantEditResponse {
284
+ data: Shared.ID;
285
+ }
286
+
287
+ export interface CreditGrantListCreditTypesResponse {
288
+ data: Array<CreditGrantListCreditTypesResponse.Data>;
289
+
290
+ next_page: string | null;
291
+ }
292
+
293
+ export namespace CreditGrantListCreditTypesResponse {
294
+ export interface Data {
295
+ id?: string;
296
+
297
+ is_currency?: boolean;
298
+
299
+ name?: string;
300
+ }
301
+ }
302
+
303
+ export interface CreditGrantListEntriesResponse {
304
+ data: Array<CreditGrantListEntriesResponse.Data>;
305
+
306
+ next_page: string | null;
307
+ }
308
+
309
+ export namespace CreditGrantListEntriesResponse {
310
+ export interface Data {
311
+ customer_id: string;
312
+
313
+ ledgers: Array<Data.Ledger>;
314
+ }
315
+
316
+ export namespace Data {
317
+ export interface Ledger {
318
+ credit_type: Shared.CreditType;
319
+
320
+ /**
321
+ * the effective balances at the end of the specified time window
322
+ */
323
+ ending_balance: Ledger.EndingBalance;
324
+
325
+ entries: Array<CreditGrantsAPI.CreditLedgerEntry>;
326
+
327
+ pending_entries: Array<CreditGrantsAPI.CreditLedgerEntry>;
328
+
329
+ starting_balance: Ledger.StartingBalance;
330
+ }
331
+
332
+ export namespace Ledger {
333
+ /**
334
+ * the effective balances at the end of the specified time window
335
+ */
336
+ export interface EndingBalance {
337
+ /**
338
+ * the ending_before request parameter (if supplied) or the current billing
339
+ * period's end date
340
+ */
341
+ effective_at: string;
342
+
343
+ /**
344
+ * the ending balance, including the balance of all grants that have not expired
345
+ * before the effective_at date and deductions that happened before the
346
+ * effective_at date
347
+ */
348
+ excluding_pending: number;
349
+
350
+ /**
351
+ * the excluding_pending balance plus any pending invoice deductions and
352
+ * expirations that will happen by the effective_at date
353
+ */
354
+ including_pending: number;
355
+ }
356
+
357
+ export interface StartingBalance {
358
+ /**
359
+ * the starting_on request parameter (if supplied) or the first credit grant's
360
+ * effective_at date
361
+ */
362
+ effective_at: string;
363
+
364
+ /**
365
+ * the starting balance, including all posted grants, deductions, and expirations
366
+ * that happened at or before the effective_at timestamp
367
+ */
368
+ excluding_pending: number;
369
+
370
+ /**
371
+ * the excluding_pending balance plus any pending activity that has not been posted
372
+ * at the time of the query
373
+ */
374
+ including_pending: number;
375
+ }
376
+ }
377
+ }
378
+ }
379
+
380
+ export interface CreditGrantVoidResponse {
381
+ data: Shared.ID;
382
+ }
383
+
384
+ export interface CreditGrantCreateParams {
385
+ /**
386
+ * the Metronome ID of the customer
387
+ */
388
+ customer_id: string;
389
+
390
+ /**
391
+ * The credit grant will only apply to billing periods that end before this
392
+ * timestamp.
393
+ */
394
+ expires_at: string;
395
+
396
+ /**
397
+ * the amount of credits granted
398
+ */
399
+ grant_amount: CreditGrantCreateParams.GrantAmount;
400
+
401
+ /**
402
+ * the name of the credit grant as it will appear on invoices
403
+ */
404
+ name: string;
405
+
406
+ /**
407
+ * the amount paid for this credit grant
408
+ */
409
+ paid_amount: CreditGrantCreateParams.PaidAmount;
410
+
411
+ priority: number;
412
+
413
+ credit_grant_type?: string;
414
+
415
+ /**
416
+ * Custom fields to attach to the credit grant.
417
+ */
418
+ custom_fields?: Record<string, string>;
419
+
420
+ /**
421
+ * The credit grant will only apply to billing periods that end at or after this
422
+ * timestamp.
423
+ */
424
+ effective_at?: string;
425
+
426
+ /**
427
+ * The date to issue an invoice for the paid_amount.
428
+ */
429
+ invoice_date?: string;
430
+
431
+ /**
432
+ * The product(s) which these credits will be applied to. (If unspecified, the
433
+ * credits will be applied to charges for all products.). The array ordering
434
+ * specified here will be used to determine the order in which credits will be
435
+ * applied to invoice line items
436
+ */
437
+ product_ids?: Array<string>;
438
+
439
+ reason?: string;
440
+
441
+ /**
442
+ * Configure a rollover for this credit grant so if it expires it rolls over a
443
+ * configured amount to a new credit grant. This feature is currently opt-in only.
444
+ * Contact Metronome to be added to the beta.
445
+ */
446
+ rollover_settings?: CreditGrantCreateParams.RolloverSettings;
447
+
448
+ /**
449
+ * Prevents the creation of duplicates. If a request to create a record is made
450
+ * with a previously used uniqueness key, a new record will not be created and the
451
+ * request will fail with a 409 error.
452
+ */
453
+ uniqueness_key?: string;
454
+ }
455
+
456
+ export namespace CreditGrantCreateParams {
457
+ /**
458
+ * the amount of credits granted
459
+ */
460
+ export interface GrantAmount {
461
+ amount: number;
462
+
463
+ credit_type_id: string;
464
+ }
465
+
466
+ /**
467
+ * the amount paid for this credit grant
468
+ */
469
+ export interface PaidAmount {
470
+ amount: number;
471
+
472
+ credit_type_id: string;
473
+ }
474
+
475
+ /**
476
+ * Configure a rollover for this credit grant so if it expires it rolls over a
477
+ * configured amount to a new credit grant. This feature is currently opt-in only.
478
+ * Contact Metronome to be added to the beta.
479
+ */
480
+ export interface RolloverSettings {
481
+ /**
482
+ * The date to expire the rollover credits.
483
+ */
484
+ expires_at: string;
485
+
486
+ /**
487
+ * The priority to give the rollover credit grant that gets created when a rollover
488
+ * happens.
489
+ */
490
+ priority: number;
491
+
492
+ /**
493
+ * Specify how much to rollover to the rollover credit grant
494
+ */
495
+ rollover_amount: CreditGrantsAPI.RolloverAmountMaxPercentage | CreditGrantsAPI.RolloverAmountMaxAmount;
496
+ }
497
+ }
498
+
499
+ export interface CreditGrantListParams {
500
+ /**
501
+ * Query param: Max number of results that should be returned
502
+ */
503
+ limit?: number;
504
+
505
+ /**
506
+ * Query param: Cursor that indicates where the next page of results should start.
507
+ */
508
+ next_page?: string;
509
+
510
+ /**
511
+ * Body param: An array of credit grant IDs. If this is specified, neither
512
+ * credit_type_ids nor customer_ids may be specified.
513
+ */
514
+ credit_grant_ids?: Array<string>;
515
+
516
+ /**
517
+ * Body param: An array of credit type IDs. This must not be specified if
518
+ * credit_grant_ids is specified.
519
+ */
520
+ credit_type_ids?: Array<string>;
521
+
522
+ /**
523
+ * Body param: An array of Metronome customer IDs. This must not be specified if
524
+ * credit_grant_ids is specified.
525
+ */
526
+ customer_ids?: Array<string>;
527
+
528
+ /**
529
+ * Body param: Only return credit grants that are effective before this timestamp
530
+ * (exclusive).
531
+ */
532
+ effective_before?: string;
533
+
534
+ /**
535
+ * Body param: Only return credit grants that expire at or after this timestamp.
536
+ */
537
+ not_expiring_before?: string;
538
+ }
539
+
540
+ export interface CreditGrantEditParams {
541
+ /**
542
+ * the ID of the credit grant
543
+ */
544
+ id: string;
545
+
546
+ /**
547
+ * the updated expiration date for the credit grant
548
+ */
549
+ expires_at?: string;
550
+
551
+ /**
552
+ * the updated name for the credit grant
553
+ */
554
+ name?: string;
555
+ }
556
+
557
+ export interface CreditGrantListCreditTypesParams {
558
+ /**
559
+ * Max number of results that should be returned
560
+ */
561
+ limit?: number;
562
+
563
+ /**
564
+ * Cursor that indicates where the next page of results should start.
565
+ */
566
+ next_page?: string;
567
+ }
568
+
569
+ export interface CreditGrantListEntriesParams {
570
+ /**
571
+ * Query param: Cursor that indicates where the next page of results should start.
572
+ */
573
+ next_page?: string;
574
+
575
+ /**
576
+ * Body param: A list of Metronome credit type IDs to fetch ledger entries for. If
577
+ * absent, ledger entries for all credit types will be returned.
578
+ */
579
+ credit_type_ids?: Array<string>;
580
+
581
+ /**
582
+ * Body param: A list of Metronome customer IDs to fetch ledger entries for. If
583
+ * absent, ledger entries for all customers will be returned.
584
+ */
585
+ customer_ids?: Array<string>;
586
+
587
+ /**
588
+ * Body param: If supplied, ledger entries will only be returned with an
589
+ * effective_at before this time. This timestamp must not be in the future. If no
590
+ * timestamp is supplied, all entries up to the start of the customer's next
591
+ * billing period will be returned.
592
+ */
593
+ ending_before?: string;
594
+
595
+ /**
596
+ * Body param: If supplied, only ledger entries effective at or after this time
597
+ * will be returned.
598
+ */
599
+ starting_on?: string;
600
+ }
601
+
602
+ export interface CreditGrantVoidParams {
603
+ id: string;
604
+
605
+ /**
606
+ * If true, void the purchase invoice associated with the grant
607
+ */
608
+ void_credit_purchase_invoice?: boolean;
609
+ }
610
+
611
+ export namespace CreditGrants {
612
+ export import CreditLedgerEntry = CreditGrantsAPI.CreditLedgerEntry;
613
+ export import RolloverAmountMaxAmount = CreditGrantsAPI.RolloverAmountMaxAmount;
614
+ export import RolloverAmountMaxPercentage = CreditGrantsAPI.RolloverAmountMaxPercentage;
615
+ export import CreditGrantCreateResponse = CreditGrantsAPI.CreditGrantCreateResponse;
616
+ export import CreditGrantListResponse = CreditGrantsAPI.CreditGrantListResponse;
617
+ export import CreditGrantEditResponse = CreditGrantsAPI.CreditGrantEditResponse;
618
+ export import CreditGrantListCreditTypesResponse = CreditGrantsAPI.CreditGrantListCreditTypesResponse;
619
+ export import CreditGrantListEntriesResponse = CreditGrantsAPI.CreditGrantListEntriesResponse;
620
+ export import CreditGrantVoidResponse = CreditGrantsAPI.CreditGrantVoidResponse;
621
+ export import CreditGrantCreateParams = CreditGrantsAPI.CreditGrantCreateParams;
622
+ export import CreditGrantListParams = CreditGrantsAPI.CreditGrantListParams;
623
+ export import CreditGrantEditParams = CreditGrantsAPI.CreditGrantEditParams;
624
+ export import CreditGrantListCreditTypesParams = CreditGrantsAPI.CreditGrantListCreditTypesParams;
625
+ export import CreditGrantListEntriesParams = CreditGrantsAPI.CreditGrantListEntriesParams;
626
+ export import CreditGrantVoidParams = CreditGrantsAPI.CreditGrantVoidParams;
627
+ }