@metronome/sdk 0.1.0-beta.9 → 0.1.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 (286) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/README.md +30 -46
  3. package/_shims/index.d.ts +2 -0
  4. package/_shims/index.js +5 -1
  5. package/_shims/index.mjs +5 -1
  6. package/core.d.ts +19 -5
  7. package/core.d.ts.map +1 -1
  8. package/core.js +23 -14
  9. package/core.js.map +1 -1
  10. package/core.mjs +24 -15
  11. package/core.mjs.map +1 -1
  12. package/index.d.mts +3 -2
  13. package/index.d.ts +3 -2
  14. package/index.d.ts.map +1 -1
  15. package/index.js +6 -3
  16. package/index.js.map +1 -1
  17. package/index.mjs +6 -3
  18. package/index.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/pagination.d.ts +1 -0
  21. package/pagination.d.ts.map +1 -1
  22. package/pagination.js +3 -0
  23. package/pagination.js.map +1 -1
  24. package/pagination.mjs +3 -0
  25. package/pagination.mjs.map +1 -1
  26. package/resource.d.ts +1 -1
  27. package/resource.d.ts.map +1 -1
  28. package/resource.js.map +1 -1
  29. package/resource.mjs.map +1 -1
  30. package/resources/shared.d.ts +473 -37
  31. package/resources/shared.d.ts.map +1 -1
  32. package/resources/v1/alerts.d.ts +26 -2
  33. package/resources/v1/alerts.d.ts.map +1 -1
  34. package/resources/v1/alerts.js +19 -0
  35. package/resources/v1/alerts.js.map +1 -1
  36. package/resources/v1/alerts.mjs +19 -0
  37. package/resources/v1/alerts.mjs.map +1 -1
  38. package/resources/v1/audit-logs.d.ts +8 -0
  39. package/resources/v1/audit-logs.d.ts.map +1 -1
  40. package/resources/v1/audit-logs.js.map +1 -1
  41. package/resources/v1/audit-logs.mjs.map +1 -1
  42. package/resources/v1/billable-metrics.d.ts +58 -3
  43. package/resources/v1/billable-metrics.d.ts.map +1 -1
  44. package/resources/v1/billable-metrics.js +41 -0
  45. package/resources/v1/billable-metrics.js.map +1 -1
  46. package/resources/v1/billable-metrics.mjs +41 -0
  47. package/resources/v1/billable-metrics.mjs.map +1 -1
  48. package/resources/v1/contracts/contracts.d.ts +1478 -102
  49. package/resources/v1/contracts/contracts.d.ts.map +1 -1
  50. package/resources/v1/contracts/contracts.js +180 -3
  51. package/resources/v1/contracts/contracts.js.map +1 -1
  52. package/resources/v1/contracts/contracts.mjs +180 -3
  53. package/resources/v1/contracts/contracts.mjs.map +1 -1
  54. package/resources/v1/contracts/index.d.ts +2 -2
  55. package/resources/v1/contracts/index.d.ts.map +1 -1
  56. package/resources/v1/contracts/index.js.map +1 -1
  57. package/resources/v1/contracts/index.mjs.map +1 -1
  58. package/resources/v1/contracts/named-schedules.d.ts +21 -0
  59. package/resources/v1/contracts/named-schedules.d.ts.map +1 -1
  60. package/resources/v1/contracts/named-schedules.js +21 -0
  61. package/resources/v1/contracts/named-schedules.js.map +1 -1
  62. package/resources/v1/contracts/named-schedules.mjs +21 -0
  63. package/resources/v1/contracts/named-schedules.mjs.map +1 -1
  64. package/resources/v1/contracts/products.d.ts +51 -3
  65. package/resources/v1/contracts/products.d.ts.map +1 -1
  66. package/resources/v1/contracts/products.js +33 -0
  67. package/resources/v1/contracts/products.js.map +1 -1
  68. package/resources/v1/contracts/products.mjs +33 -0
  69. package/resources/v1/contracts/products.mjs.map +1 -1
  70. package/resources/v1/contracts/rate-cards/index.d.ts +1 -1
  71. package/resources/v1/contracts/rate-cards/index.d.ts.map +1 -1
  72. package/resources/v1/contracts/rate-cards/index.js.map +1 -1
  73. package/resources/v1/contracts/rate-cards/index.mjs.map +1 -1
  74. package/resources/v1/contracts/rate-cards/named-schedules.d.ts +25 -0
  75. package/resources/v1/contracts/rate-cards/named-schedules.d.ts.map +1 -1
  76. package/resources/v1/contracts/rate-cards/named-schedules.js +25 -0
  77. package/resources/v1/contracts/rate-cards/named-schedules.js.map +1 -1
  78. package/resources/v1/contracts/rate-cards/named-schedules.mjs +25 -0
  79. package/resources/v1/contracts/rate-cards/named-schedules.mjs.map +1 -1
  80. package/resources/v1/contracts/rate-cards/product-orders.d.ts +30 -0
  81. package/resources/v1/contracts/rate-cards/product-orders.d.ts.map +1 -1
  82. package/resources/v1/contracts/rate-cards/product-orders.js +30 -0
  83. package/resources/v1/contracts/rate-cards/product-orders.js.map +1 -1
  84. package/resources/v1/contracts/rate-cards/product-orders.mjs +30 -0
  85. package/resources/v1/contracts/rate-cards/product-orders.mjs.map +1 -1
  86. package/resources/v1/contracts/rate-cards/rate-cards.d.ts +107 -10
  87. package/resources/v1/contracts/rate-cards/rate-cards.d.ts.map +1 -1
  88. package/resources/v1/contracts/rate-cards/rate-cards.js +71 -0
  89. package/resources/v1/contracts/rate-cards/rate-cards.js.map +1 -1
  90. package/resources/v1/contracts/rate-cards/rate-cards.mjs +71 -0
  91. package/resources/v1/contracts/rate-cards/rate-cards.mjs.map +1 -1
  92. package/resources/v1/contracts/rate-cards/rates.d.ts +102 -14
  93. package/resources/v1/contracts/rate-cards/rates.d.ts.map +1 -1
  94. package/resources/v1/contracts/rate-cards/rates.js +68 -0
  95. package/resources/v1/contracts/rate-cards/rates.js.map +1 -1
  96. package/resources/v1/contracts/rate-cards/rates.mjs +68 -0
  97. package/resources/v1/contracts/rate-cards/rates.mjs.map +1 -1
  98. package/resources/v1/credit-grants.d.ts +77 -2
  99. package/resources/v1/credit-grants.d.ts.map +1 -1
  100. package/resources/v1/credit-grants.js +39 -2
  101. package/resources/v1/credit-grants.js.map +1 -1
  102. package/resources/v1/credit-grants.mjs +39 -2
  103. package/resources/v1/credit-grants.mjs.map +1 -1
  104. package/resources/v1/custom-fields.d.ts +51 -7
  105. package/resources/v1/custom-fields.d.ts.map +1 -1
  106. package/resources/v1/custom-fields.js +35 -0
  107. package/resources/v1/custom-fields.js.map +1 -1
  108. package/resources/v1/custom-fields.mjs +35 -0
  109. package/resources/v1/custom-fields.mjs.map +1 -1
  110. package/resources/v1/customers/alerts.d.ts +28 -0
  111. package/resources/v1/customers/alerts.d.ts.map +1 -1
  112. package/resources/v1/customers/alerts.js +23 -0
  113. package/resources/v1/customers/alerts.js.map +1 -1
  114. package/resources/v1/customers/alerts.mjs +23 -0
  115. package/resources/v1/customers/alerts.mjs.map +1 -1
  116. package/resources/v1/customers/billing-config.d.ts +31 -0
  117. package/resources/v1/customers/billing-config.d.ts.map +1 -1
  118. package/resources/v1/customers/billing-config.js +27 -0
  119. package/resources/v1/customers/billing-config.js.map +1 -1
  120. package/resources/v1/customers/billing-config.mjs +27 -0
  121. package/resources/v1/customers/billing-config.mjs.map +1 -1
  122. package/resources/v1/customers/commits.d.ts +94 -7
  123. package/resources/v1/customers/commits.d.ts.map +1 -1
  124. package/resources/v1/customers/commits.js +56 -1
  125. package/resources/v1/customers/commits.js.map +1 -1
  126. package/resources/v1/customers/commits.mjs +56 -1
  127. package/resources/v1/customers/commits.mjs.map +1 -1
  128. package/resources/v1/customers/credits.d.ts +73 -3
  129. package/resources/v1/customers/credits.d.ts.map +1 -1
  130. package/resources/v1/customers/credits.js +41 -1
  131. package/resources/v1/customers/credits.js.map +1 -1
  132. package/resources/v1/customers/credits.mjs +41 -1
  133. package/resources/v1/customers/credits.mjs.map +1 -1
  134. package/resources/v1/customers/customers.d.ts +186 -9
  135. package/resources/v1/customers/customers.d.ts.map +1 -1
  136. package/resources/v1/customers/customers.js +106 -1
  137. package/resources/v1/customers/customers.js.map +1 -1
  138. package/resources/v1/customers/customers.mjs +106 -1
  139. package/resources/v1/customers/customers.mjs.map +1 -1
  140. package/resources/v1/customers/index.d.ts +1 -1
  141. package/resources/v1/customers/index.d.ts.map +1 -1
  142. package/resources/v1/customers/index.js.map +1 -1
  143. package/resources/v1/customers/index.mjs.map +1 -1
  144. package/resources/v1/customers/invoices.d.ts +144 -52
  145. package/resources/v1/customers/invoices.d.ts.map +1 -1
  146. package/resources/v1/customers/invoices.js +49 -0
  147. package/resources/v1/customers/invoices.js.map +1 -1
  148. package/resources/v1/customers/invoices.mjs +49 -0
  149. package/resources/v1/customers/invoices.mjs.map +1 -1
  150. package/resources/v1/customers/named-schedules.d.ts +21 -0
  151. package/resources/v1/customers/named-schedules.d.ts.map +1 -1
  152. package/resources/v1/customers/named-schedules.js +21 -0
  153. package/resources/v1/customers/named-schedules.js.map +1 -1
  154. package/resources/v1/customers/named-schedules.mjs +21 -0
  155. package/resources/v1/customers/named-schedules.mjs.map +1 -1
  156. package/resources/v1/customers/plans.d.ts +46 -1
  157. package/resources/v1/customers/plans.d.ts.map +1 -1
  158. package/resources/v1/customers/plans.js +43 -0
  159. package/resources/v1/customers/plans.js.map +1 -1
  160. package/resources/v1/customers/plans.mjs +43 -0
  161. package/resources/v1/customers/plans.mjs.map +1 -1
  162. package/resources/v1/dashboards.d.ts +30 -2
  163. package/resources/v1/dashboards.d.ts.map +1 -1
  164. package/resources/v1/dashboards.js +26 -0
  165. package/resources/v1/dashboards.js.map +1 -1
  166. package/resources/v1/dashboards.mjs +26 -0
  167. package/resources/v1/dashboards.mjs.map +1 -1
  168. package/resources/v1/index.d.ts +3 -3
  169. package/resources/v1/index.d.ts.map +1 -1
  170. package/resources/v1/index.js.map +1 -1
  171. package/resources/v1/index.mjs.map +1 -1
  172. package/resources/v1/invoices.d.ts +14 -0
  173. package/resources/v1/invoices.d.ts.map +1 -1
  174. package/resources/v1/invoices.js +14 -0
  175. package/resources/v1/invoices.js.map +1 -1
  176. package/resources/v1/invoices.mjs +14 -0
  177. package/resources/v1/invoices.mjs.map +1 -1
  178. package/resources/v1/plans.d.ts +47 -4
  179. package/resources/v1/plans.d.ts.map +1 -1
  180. package/resources/v1/plans.js +27 -0
  181. package/resources/v1/plans.js.map +1 -1
  182. package/resources/v1/plans.mjs +27 -0
  183. package/resources/v1/plans.mjs.map +1 -1
  184. package/resources/v1/pricing-units.d.ts +8 -0
  185. package/resources/v1/pricing-units.d.ts.map +1 -1
  186. package/resources/v1/pricing-units.js.map +1 -1
  187. package/resources/v1/pricing-units.mjs.map +1 -1
  188. package/resources/v1/services.d.ts +5 -0
  189. package/resources/v1/services.d.ts.map +1 -1
  190. package/resources/v1/services.js +5 -0
  191. package/resources/v1/services.js.map +1 -1
  192. package/resources/v1/services.mjs +5 -0
  193. package/resources/v1/services.mjs.map +1 -1
  194. package/resources/v1/usage.d.ts +161 -3
  195. package/resources/v1/usage.d.ts.map +1 -1
  196. package/resources/v1/usage.js +46 -0
  197. package/resources/v1/usage.js.map +1 -1
  198. package/resources/v1/usage.mjs +46 -0
  199. package/resources/v1/usage.mjs.map +1 -1
  200. package/resources/v1/v1.d.ts +6 -6
  201. package/resources/v1/v1.d.ts.map +1 -1
  202. package/resources/v1/v1.js.map +1 -1
  203. package/resources/v1/v1.mjs.map +1 -1
  204. package/resources/v2/contracts.d.ts +2923 -207
  205. package/resources/v2/contracts.d.ts.map +1 -1
  206. package/resources/v2/contracts.js +90 -2
  207. package/resources/v2/contracts.js.map +1 -1
  208. package/resources/v2/contracts.mjs +90 -2
  209. package/resources/v2/contracts.mjs.map +1 -1
  210. package/resources/webhooks.js +5 -5
  211. package/resources/webhooks.js.map +1 -1
  212. package/resources/webhooks.mjs +5 -5
  213. package/resources/webhooks.mjs.map +1 -1
  214. package/src/_shims/auto/runtime-bun.ts +1 -1
  215. package/src/_shims/auto/runtime-node.ts +1 -1
  216. package/src/_shims/auto/runtime.ts +1 -1
  217. package/src/_shims/auto/types-node.ts +1 -1
  218. package/src/_shims/bun-runtime.ts +2 -2
  219. package/src/_shims/index.d.ts +5 -3
  220. package/src/_shims/index.js +5 -1
  221. package/src/_shims/index.mjs +6 -2
  222. package/src/_shims/node-runtime.ts +3 -3
  223. package/src/_shims/registry.ts +1 -1
  224. package/src/_shims/web-runtime.ts +3 -3
  225. package/src/core.ts +46 -18
  226. package/src/error.ts +1 -1
  227. package/src/index.ts +22 -16
  228. package/src/internal/qs/formats.ts +1 -1
  229. package/src/internal/qs/index.ts +3 -3
  230. package/src/internal/qs/stringify.ts +3 -3
  231. package/src/internal/qs/utils.ts +2 -2
  232. package/src/pagination.ts +5 -1
  233. package/src/resource.ts +2 -2
  234. package/src/resources/index.ts +4 -4
  235. package/src/resources/shared.ts +539 -40
  236. package/src/resources/v1/alerts.ts +29 -5
  237. package/src/resources/v1/audit-logs.ts +12 -4
  238. package/src/resources/v1/billable-metrics.ts +57 -8
  239. package/src/resources/v1/contracts/contracts.ts +1643 -124
  240. package/src/resources/v1/contracts/index.ts +8 -4
  241. package/src/resources/v1/contracts/named-schedules.ts +23 -2
  242. package/src/resources/v1/contracts/products.ts +53 -9
  243. package/src/resources/v1/contracts/rate-cards/index.ts +6 -4
  244. package/src/resources/v1/contracts/rate-cards/named-schedules.ts +27 -2
  245. package/src/resources/v1/contracts/rate-cards/product-orders.ts +33 -3
  246. package/src/resources/v1/contracts/rate-cards/rate-cards.ts +113 -20
  247. package/src/resources/v1/contracts/rate-cards/rates.ts +86 -18
  248. package/src/resources/v1/contracts/rate-cards.ts +1 -1
  249. package/src/resources/v1/contracts.ts +1 -1
  250. package/src/resources/v1/credit-grants.ts +82 -10
  251. package/src/resources/v1/custom-fields.ts +57 -9
  252. package/src/resources/v1/customers/alerts.ts +32 -3
  253. package/src/resources/v1/customers/billing-config.ts +34 -2
  254. package/src/resources/v1/customers/commits.ts +97 -10
  255. package/src/resources/v1/customers/credits.ts +76 -6
  256. package/src/resources/v1/customers/customers.ts +208 -27
  257. package/src/resources/v1/customers/index.ts +10 -8
  258. package/src/resources/v1/customers/invoices.ts +123 -57
  259. package/src/resources/v1/customers/named-schedules.ts +23 -2
  260. package/src/resources/v1/customers/plans.ts +48 -5
  261. package/src/resources/v1/customers.ts +1 -1
  262. package/src/resources/v1/dashboards.ts +30 -4
  263. package/src/resources/v1/index.ts +20 -14
  264. package/src/resources/v1/invoices.ts +16 -2
  265. package/src/resources/v1/plans.ts +45 -10
  266. package/src/resources/v1/pricing-units.ts +12 -4
  267. package/src/resources/v1/services.ts +7 -2
  268. package/src/resources/v1/usage.ts +187 -6
  269. package/src/resources/v1/v1.ts +39 -27
  270. package/src/resources/v1.ts +1 -1
  271. package/src/resources/v2/contracts.ts +3397 -235
  272. package/src/resources/v2/index.ts +2 -2
  273. package/src/resources/v2/v2.ts +3 -3
  274. package/src/resources/v2.ts +1 -1
  275. package/src/resources/webhooks.ts +7 -7
  276. package/src/resources.ts +1 -1
  277. package/src/shims/node.ts +3 -3
  278. package/src/shims/web.ts +3 -3
  279. package/src/uploads.ts +4 -4
  280. package/src/version.ts +1 -1
  281. package/version.d.ts +1 -1
  282. package/version.d.ts.map +1 -1
  283. package/version.js +1 -1
  284. package/version.js.map +1 -1
  285. package/version.mjs +1 -1
  286. package/version.mjs.map +1 -1
@@ -1,12 +1,45 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../../resource';
4
- import * as Core from '../../../core';
5
- import * as Shared from '../../shared';
3
+ import { APIResource } from "../../../resource.js";
4
+ import * as Core from "../../../core.js";
5
+ import * as Shared from "../../shared.js";
6
6
 
7
7
  export class Commits extends APIResource {
8
8
  /**
9
9
  * Create a new commit at the customer level.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const commit = await client.v1.customers.commits.create({
14
+ * access_schedule: {
15
+ * credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',
16
+ * schedule_items: [
17
+ * {
18
+ * amount: 1000,
19
+ * starting_at: '2020-01-01T00:00:00.000Z',
20
+ * ending_before: '2020-02-01T00:00:00.000Z',
21
+ * },
22
+ * ],
23
+ * },
24
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
25
+ * priority: 100,
26
+ * product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',
27
+ * type: 'prepaid',
28
+ * invoice_contract_id:
29
+ * 'e57d6929-c2f1-4796-a9a8-63cedefe848d',
30
+ * invoice_schedule: {
31
+ * credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',
32
+ * schedule_items: [
33
+ * {
34
+ * unit_price: 10000000,
35
+ * quantity: 1,
36
+ * timestamp: '2020-03-01T00:00:00.000Z',
37
+ * },
38
+ * ],
39
+ * },
40
+ * name: 'My Commit',
41
+ * });
42
+ * ```
10
43
  */
11
44
  create(body: CommitCreateParams, options?: Core.RequestOptions): Core.APIPromise<CommitCreateResponse> {
12
45
  return this._client.post('/v1/contracts/customerCommits/create', { body, ...options });
@@ -14,13 +47,35 @@ export class Commits extends APIResource {
14
47
 
15
48
  /**
16
49
  * List commits.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const commits = await client.v1.customers.commits.list({
54
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
55
+ * commit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
56
+ * include_ledgers: true,
57
+ * });
58
+ * ```
17
59
  */
18
60
  list(body: CommitListParams, options?: Core.RequestOptions): Core.APIPromise<CommitListResponse> {
19
61
  return this._client.post('/v1/contracts/customerCommits/list', { body, ...options });
20
62
  }
21
63
 
22
64
  /**
23
- * Update the end date of a PREPAID commit
65
+ * Pull forward the end date of a prepaid commit. Use the "edit a commit" endpoint
66
+ * to extend the end date of a prepaid commit, or to make other edits to the
67
+ * commit.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const response =
72
+ * await client.v1.customers.commits.updateEndDate({
73
+ * commit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
74
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
75
+ * access_ending_before: '2020-01-01T00:00:00.000Z',
76
+ * invoices_ending_before: '2020-01-01T00:00:00.000Z',
77
+ * });
78
+ * ```
24
79
  */
25
80
  updateEndDate(
26
81
  body: CommitUpdateEndDateParams,
@@ -74,18 +129,20 @@ export interface CommitCreateParams {
74
129
  applicable_contract_ids?: Array<string>;
75
130
 
76
131
  /**
77
- * Which products the commit applies to. If both applicable_product_ids and
78
- * applicable_product_tags are not provided, the commit applies to all products.
132
+ * Which products the commit applies to. If applicable_product_ids,
133
+ * applicable_product_tags or specifiers are not provided, the commit applies to
134
+ * all products.
79
135
  */
80
136
  applicable_product_ids?: Array<string>;
81
137
 
82
138
  /**
83
- * Which tags the commit applies to. If both applicable_product_ids and
84
- * applicable_product_tags are not provided, the commit applies to all products.
139
+ * Which tags the commit applies to. If applicable_product_ids,
140
+ * applicable_product_tags or specifiers are not provided, the commit applies to
141
+ * all products.
85
142
  */
86
143
  applicable_product_tags?: Array<string>;
87
144
 
88
- custom_fields?: Record<string, string>;
145
+ custom_fields?: { [key: string]: string };
89
146
 
90
147
  /**
91
148
  * Used only in UI/API. It is not exposed to end customers.
@@ -124,6 +181,14 @@ export interface CommitCreateParams {
124
181
  */
125
182
  salesforce_opportunity_id?: string;
126
183
 
184
+ /**
185
+ * List of filters that determine what kind of customer usage draws down a commit
186
+ * or credit. A customer's usage needs to meet the condition of at least one of the
187
+ * specifiers to contribute to a commit's or credit's drawdown. This field cannot
188
+ * be used together with `applicable_product_ids` or `applicable_product_tags`.
189
+ */
190
+ specifiers?: Array<CommitCreateParams.Specifier>;
191
+
127
192
  /**
128
193
  * Prevents the creation of duplicates. If a request to create a commit or credit
129
194
  * is made with a uniqueness key that was previously used to create a commit or
@@ -259,6 +324,23 @@ export namespace CommitCreateParams {
259
324
  unit_price?: number;
260
325
  }
261
326
  }
327
+
328
+ export interface Specifier {
329
+ presentation_group_values?: { [key: string]: string };
330
+
331
+ pricing_group_values?: { [key: string]: string };
332
+
333
+ /**
334
+ * If provided, the specifier will only apply to the product with the specified ID.
335
+ */
336
+ product_id?: string;
337
+
338
+ /**
339
+ * If provided, the specifier will only apply to products with all the specified
340
+ * tags.
341
+ */
342
+ product_tags?: Array<string>;
343
+ }
262
344
  }
263
345
 
264
346
  export interface CommitListParams {
@@ -277,7 +359,7 @@ export interface CommitListParams {
277
359
  effective_before?: string;
278
360
 
279
361
  /**
280
- * Include commits from archived contracts.
362
+ * Include archived commits and commits from archived contracts.
281
363
  */
282
364
  include_archived?: boolean;
283
365
 
@@ -298,6 +380,11 @@ export interface CommitListParams {
298
380
  */
299
381
  include_ledgers?: boolean;
300
382
 
383
+ /**
384
+ * The maximum number of commits to return. Defaults to 25.
385
+ */
386
+ limit?: number;
387
+
301
388
  /**
302
389
  * The next page token from a previous response.
303
390
  */
@@ -1,12 +1,32 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../../resource';
4
- import * as Core from '../../../core';
5
- import * as Shared from '../../shared';
3
+ import { APIResource } from "../../../resource.js";
4
+ import * as Core from "../../../core.js";
5
+ import * as Shared from "../../shared.js";
6
6
 
7
7
  export class Credits extends APIResource {
8
8
  /**
9
9
  * Create a new credit at the customer level.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const credit = await client.v1.customers.credits.create({
14
+ * access_schedule: {
15
+ * credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',
16
+ * schedule_items: [
17
+ * {
18
+ * amount: 1000,
19
+ * starting_at: '2020-01-01T00:00:00.000Z',
20
+ * ending_before: '2020-02-01T00:00:00.000Z',
21
+ * },
22
+ * ],
23
+ * },
24
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
25
+ * priority: 100,
26
+ * product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',
27
+ * name: 'My Credit',
28
+ * });
29
+ * ```
10
30
  */
11
31
  create(body: CreditCreateParams, options?: Core.RequestOptions): Core.APIPromise<CreditCreateResponse> {
12
32
  return this._client.post('/v1/contracts/customerCredits/create', { body, ...options });
@@ -14,13 +34,33 @@ export class Credits extends APIResource {
14
34
 
15
35
  /**
16
36
  * List credits.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const credits = await client.v1.customers.credits.list({
41
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
42
+ * credit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
43
+ * include_ledgers: true,
44
+ * });
45
+ * ```
17
46
  */
18
47
  list(body: CreditListParams, options?: Core.RequestOptions): Core.APIPromise<CreditListResponse> {
19
48
  return this._client.post('/v1/contracts/customerCredits/list', { body, ...options });
20
49
  }
21
50
 
22
51
  /**
23
- * Update the end date of a credit
52
+ * Pull forward the end date of a credit. Use the "edit a credit" endpoint to
53
+ * extend the end date of a credit, or to make other edits to the credit.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const response =
58
+ * await client.v1.customers.credits.updateEndDate({
59
+ * access_ending_before: '2020-01-01T00:00:00.000Z',
60
+ * credit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
61
+ * customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
62
+ * });
63
+ * ```
24
64
  */
25
65
  updateEndDate(
26
66
  body: CreditUpdateEndDateParams,
@@ -78,7 +118,7 @@ export interface CreditCreateParams {
78
118
  */
79
119
  applicable_product_tags?: Array<string>;
80
120
 
81
- custom_fields?: Record<string, string>;
121
+ custom_fields?: { [key: string]: string };
82
122
 
83
123
  /**
84
124
  * Used only in UI/API. It is not exposed to end customers.
@@ -102,6 +142,14 @@ export interface CreditCreateParams {
102
142
  */
103
143
  salesforce_opportunity_id?: string;
104
144
 
145
+ /**
146
+ * List of filters that determine what kind of customer usage draws down a commit
147
+ * or credit. A customer's usage needs to meet the condition of at least one of the
148
+ * specifiers to contribute to a commit's or credit's drawdown. This field cannot
149
+ * be used together with `applicable_product_ids` or `applicable_product_tags`.
150
+ */
151
+ specifiers?: Array<CreditCreateParams.Specifier>;
152
+
105
153
  /**
106
154
  * Prevents the creation of duplicates. If a request to create a commit or credit
107
155
  * is made with a uniqueness key that was previously used to create a commit or
@@ -139,6 +187,23 @@ export namespace CreditCreateParams {
139
187
  starting_at: string;
140
188
  }
141
189
  }
190
+
191
+ export interface Specifier {
192
+ presentation_group_values?: { [key: string]: string };
193
+
194
+ pricing_group_values?: { [key: string]: string };
195
+
196
+ /**
197
+ * If provided, the specifier will only apply to the product with the specified ID.
198
+ */
199
+ product_id?: string;
200
+
201
+ /**
202
+ * If provided, the specifier will only apply to products with all the specified
203
+ * tags.
204
+ */
205
+ product_tags?: Array<string>;
206
+ }
142
207
  }
143
208
 
144
209
  export interface CreditListParams {
@@ -157,7 +222,7 @@ export interface CreditListParams {
157
222
  effective_before?: string;
158
223
 
159
224
  /**
160
- * Include credits from archived contracts.
225
+ * Include archived credits and credits from archived contracts.
161
226
  */
162
227
  include_archived?: boolean;
163
228
 
@@ -178,6 +243,11 @@ export interface CreditListParams {
178
243
  */
179
244
  include_ledgers?: boolean;
180
245
 
246
+ /**
247
+ * The maximum number of commits to return. Defaults to 25.
248
+ */
249
+ limit?: number;
250
+
181
251
  /**
182
252
  * The next page token from a previous response.
183
253
  */