@tirdad/sdk 2.1.47 → 2.1.48

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 (250) hide show
  1. package/esm/funcs/commitments-get-commitment-billing-terms.d.ts +17 -0
  2. package/esm/funcs/commitments-get-commitment-billing-terms.d.ts.map +1 -0
  3. package/esm/funcs/commitments-get-commitment-billing-terms.js +91 -0
  4. package/esm/funcs/commitments-get-commitment-billing-terms.js.map +1 -0
  5. package/esm/funcs/commitments-list-commitment-instalments.d.ts +17 -0
  6. package/esm/funcs/commitments-list-commitment-instalments.d.ts.map +1 -0
  7. package/esm/funcs/commitments-list-commitment-instalments.js +96 -0
  8. package/esm/funcs/commitments-list-commitment-instalments.js.map +1 -0
  9. package/esm/funcs/commitments-preview-commitment-billing-terms.d.ts +17 -0
  10. package/esm/funcs/commitments-preview-commitment-billing-terms.d.ts.map +1 -0
  11. package/esm/funcs/commitments-preview-commitment-billing-terms.js +93 -0
  12. package/esm/funcs/commitments-preview-commitment-billing-terms.js.map +1 -0
  13. package/esm/funcs/commitments-replace-commitment-billing-terms.d.ts +17 -0
  14. package/esm/funcs/commitments-replace-commitment-billing-terms.d.ts.map +1 -0
  15. package/esm/funcs/commitments-replace-commitment-billing-terms.js +93 -0
  16. package/esm/funcs/commitments-replace-commitment-billing-terms.js.map +1 -0
  17. package/esm/funcs/commitments-terminate-commitment.d.ts +1 -1
  18. package/esm/funcs/commitments-terminate-commitment.js +1 -1
  19. package/esm/funcs/commitments-trigger-commitment-instalment.d.ts +17 -0
  20. package/esm/funcs/commitments-trigger-commitment-instalment.d.ts.map +1 -0
  21. package/esm/funcs/commitments-trigger-commitment-instalment.js +98 -0
  22. package/esm/funcs/commitments-trigger-commitment-instalment.js.map +1 -0
  23. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-cancelled.d.ts +17 -0
  24. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-cancelled.d.ts.map +1 -0
  25. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-cancelled.js +69 -0
  26. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-cancelled.js.map +1 -0
  27. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-created.d.ts +17 -0
  28. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-created.d.ts.map +1 -0
  29. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-created.js +69 -0
  30. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-created.js.map +1 -0
  31. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-invoiced.d.ts +17 -0
  32. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-invoiced.d.ts.map +1 -0
  33. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-invoiced.js +69 -0
  34. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-invoiced.js.map +1 -0
  35. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-updated.d.ts +17 -0
  36. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-updated.d.ts.map +1 -0
  37. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-updated.js +69 -0
  38. package/esm/funcs/webhook-events-post-webhook-events-billing-instalment-updated.js.map +1 -0
  39. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-created.d.ts +17 -0
  40. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-created.d.ts.map +1 -0
  41. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-created.js +69 -0
  42. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-created.js.map +1 -0
  43. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-updated.d.ts +17 -0
  44. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-updated.d.ts.map +1 -0
  45. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-updated.js +69 -0
  46. package/esm/funcs/webhook-events-post-webhook-events-billing-terms-updated.js.map +1 -0
  47. package/esm/lib/config.d.ts +2 -2
  48. package/esm/lib/config.js +2 -2
  49. package/esm/sdk/commitments.d.ts +36 -1
  50. package/esm/sdk/commitments.d.ts.map +1 -1
  51. package/esm/sdk/commitments.js +51 -1
  52. package/esm/sdk/commitments.js.map +1 -1
  53. package/esm/sdk/models/billing-term-input.d.ts +67 -0
  54. package/esm/sdk/models/billing-term-input.d.ts.map +1 -0
  55. package/esm/sdk/models/billing-term-input.js +43 -0
  56. package/esm/sdk/models/billing-term-input.js.map +1 -0
  57. package/esm/sdk/models/billing-term-kind.d.ts +12 -0
  58. package/esm/sdk/models/billing-term-kind.d.ts.map +1 -0
  59. package/esm/sdk/models/billing-term-kind.js +13 -0
  60. package/esm/sdk/models/billing-term-kind.js.map +1 -0
  61. package/esm/sdk/models/billing-term-owner-type.d.ts +9 -0
  62. package/esm/sdk/models/billing-term-owner-type.d.ts.map +1 -0
  63. package/esm/sdk/models/billing-term-owner-type.js +10 -0
  64. package/esm/sdk/models/billing-term-owner-type.js.map +1 -0
  65. package/esm/sdk/models/billing-term-split.d.ts +12 -0
  66. package/esm/sdk/models/billing-term-split.d.ts.map +1 -0
  67. package/esm/sdk/models/billing-term-split.js +13 -0
  68. package/esm/sdk/models/billing-term-split.js.map +1 -0
  69. package/esm/sdk/models/billing-term-value-type.d.ts +19 -0
  70. package/esm/sdk/models/billing-term-value-type.d.ts.map +1 -0
  71. package/esm/sdk/models/billing-term-value-type.js +17 -0
  72. package/esm/sdk/models/billing-term-value-type.js.map +1 -0
  73. package/esm/sdk/models/billing-terms-response.d.ts +13 -0
  74. package/esm/sdk/models/billing-terms-response.d.ts.map +1 -0
  75. package/esm/sdk/models/billing-terms-response.js +22 -0
  76. package/esm/sdk/models/billing-terms-response.js.map +1 -0
  77. package/esm/sdk/models/billingterm-instalment.d.ts +43 -0
  78. package/esm/sdk/models/billingterm-instalment.d.ts.map +1 -0
  79. package/esm/sdk/models/billingterm-instalment.js +68 -0
  80. package/esm/sdk/models/billingterm-instalment.js.map +1 -0
  81. package/esm/sdk/models/billingterm-term.d.ts +57 -0
  82. package/esm/sdk/models/billingterm-term.d.ts.map +1 -0
  83. package/esm/sdk/models/billingterm-term.js +65 -0
  84. package/esm/sdk/models/billingterm-term.js.map +1 -0
  85. package/esm/sdk/models/cancellation-fee-input.d.ts +18 -0
  86. package/esm/sdk/models/cancellation-fee-input.d.ts.map +1 -0
  87. package/esm/sdk/models/cancellation-fee-input.js +14 -0
  88. package/esm/sdk/models/cancellation-fee-input.js.map +1 -0
  89. package/esm/sdk/models/cancellation-fee-type.d.ts +16 -0
  90. package/esm/sdk/models/cancellation-fee-type.d.ts.map +1 -0
  91. package/esm/sdk/models/cancellation-fee-type.js +14 -0
  92. package/esm/sdk/models/cancellation-fee-type.js.map +1 -0
  93. package/esm/sdk/models/commitment-response.d.ts +9 -1
  94. package/esm/sdk/models/commitment-response.d.ts.map +1 -1
  95. package/esm/sdk/models/commitment-response.js +7 -1
  96. package/esm/sdk/models/commitment-response.js.map +1 -1
  97. package/esm/sdk/models/create-commitment-request.d.ts +12 -0
  98. package/esm/sdk/models/create-commitment-request.d.ts.map +1 -1
  99. package/esm/sdk/models/create-commitment-request.js +6 -0
  100. package/esm/sdk/models/create-commitment-request.js.map +1 -1
  101. package/esm/sdk/models/get-commitment-billing-terms-op.d.ts +15 -0
  102. package/esm/sdk/models/get-commitment-billing-terms-op.d.ts.map +1 -0
  103. package/esm/sdk/models/get-commitment-billing-terms-op.js +12 -0
  104. package/esm/sdk/models/get-commitment-billing-terms-op.js.map +1 -0
  105. package/esm/sdk/models/get-subscription-v2-op.d.ts +1 -1
  106. package/esm/sdk/models/index.d.ts +24 -0
  107. package/esm/sdk/models/index.d.ts.map +1 -1
  108. package/esm/sdk/models/index.js +24 -0
  109. package/esm/sdk/models/index.js.map +1 -1
  110. package/esm/sdk/models/instalment-bill-trigger.d.ts +12 -0
  111. package/esm/sdk/models/instalment-bill-trigger.d.ts.map +1 -0
  112. package/esm/sdk/models/instalment-bill-trigger.js +13 -0
  113. package/esm/sdk/models/instalment-bill-trigger.js.map +1 -0
  114. package/esm/sdk/models/instalment-delivery.d.ts +12 -0
  115. package/esm/sdk/models/instalment-delivery.d.ts.map +1 -0
  116. package/esm/sdk/models/instalment-delivery.js +13 -0
  117. package/esm/sdk/models/instalment-delivery.js.map +1 -0
  118. package/esm/sdk/models/instalment-kind.d.ts +10 -0
  119. package/esm/sdk/models/instalment-kind.d.ts.map +1 -0
  120. package/esm/sdk/models/instalment-kind.js +11 -0
  121. package/esm/sdk/models/instalment-kind.js.map +1 -0
  122. package/esm/sdk/models/instalment-status.d.ts +11 -0
  123. package/esm/sdk/models/instalment-status.d.ts.map +1 -0
  124. package/esm/sdk/models/instalment-status.js +12 -0
  125. package/esm/sdk/models/instalment-status.js.map +1 -0
  126. package/esm/sdk/models/invoice-billing-reason.d.ts +2 -0
  127. package/esm/sdk/models/invoice-billing-reason.d.ts.map +1 -1
  128. package/esm/sdk/models/invoice-billing-reason.js +2 -0
  129. package/esm/sdk/models/invoice-billing-reason.js.map +1 -1
  130. package/esm/sdk/models/invoice-line-item-response.d.ts +4 -0
  131. package/esm/sdk/models/invoice-line-item-response.d.ts.map +1 -1
  132. package/esm/sdk/models/invoice-line-item-response.js +2 -0
  133. package/esm/sdk/models/invoice-line-item-response.js.map +1 -1
  134. package/esm/sdk/models/list-commitment-instalments-op.d.ts +20 -0
  135. package/esm/sdk/models/list-commitment-instalments-op.d.ts.map +1 -0
  136. package/esm/sdk/models/list-commitment-instalments-op.js +13 -0
  137. package/esm/sdk/models/list-commitment-instalments-op.js.map +1 -0
  138. package/esm/sdk/models/list-instalments-response.d.ts +11 -0
  139. package/esm/sdk/models/list-instalments-response.d.ts.map +1 -0
  140. package/esm/sdk/models/list-instalments-response.js +15 -0
  141. package/esm/sdk/models/list-instalments-response.js.map +1 -0
  142. package/esm/sdk/models/preview-commitment-billing-terms-op.d.ts +21 -0
  143. package/esm/sdk/models/preview-commitment-billing-terms-op.d.ts.map +1 -0
  144. package/esm/sdk/models/preview-commitment-billing-terms-op.js +14 -0
  145. package/esm/sdk/models/preview-commitment-billing-terms-op.js.map +1 -0
  146. package/esm/sdk/models/replace-billing-terms-request.d.ts +13 -0
  147. package/esm/sdk/models/replace-billing-terms-request.d.ts.map +1 -0
  148. package/esm/sdk/models/replace-billing-terms-request.js +18 -0
  149. package/esm/sdk/models/replace-billing-terms-request.js.map +1 -0
  150. package/esm/sdk/models/replace-commitment-billing-terms-op.d.ts +21 -0
  151. package/esm/sdk/models/replace-commitment-billing-terms-op.d.ts.map +1 -0
  152. package/esm/sdk/models/replace-commitment-billing-terms-op.js +14 -0
  153. package/esm/sdk/models/replace-commitment-billing-terms-op.js.map +1 -0
  154. package/esm/sdk/models/subscription-response-v2.d.ts +5 -0
  155. package/esm/sdk/models/subscription-response-v2.d.ts.map +1 -1
  156. package/esm/sdk/models/subscription-response-v2.js +2 -0
  157. package/esm/sdk/models/subscription-response-v2.js.map +1 -1
  158. package/esm/sdk/models/subscription-response.d.ts +5 -0
  159. package/esm/sdk/models/subscription-response.d.ts.map +1 -1
  160. package/esm/sdk/models/subscription-response.js +2 -0
  161. package/esm/sdk/models/subscription-response.js.map +1 -1
  162. package/esm/sdk/models/terminate-commitment-request.d.ts +6 -2
  163. package/esm/sdk/models/terminate-commitment-request.d.ts.map +1 -1
  164. package/esm/sdk/models/terminate-commitment-request.js +2 -1
  165. package/esm/sdk/models/terminate-commitment-request.js.map +1 -1
  166. package/esm/sdk/models/trigger-commitment-instalment-op.d.ts +26 -0
  167. package/esm/sdk/models/trigger-commitment-instalment-op.d.ts.map +1 -0
  168. package/esm/sdk/models/trigger-commitment-instalment-op.js +20 -0
  169. package/esm/sdk/models/trigger-commitment-instalment-op.js.map +1 -0
  170. package/esm/sdk/models/trigger-instalment-request.d.ts +15 -0
  171. package/esm/sdk/models/trigger-instalment-request.d.ts.map +1 -0
  172. package/esm/sdk/models/trigger-instalment-request.js +17 -0
  173. package/esm/sdk/models/trigger-instalment-request.js.map +1 -0
  174. package/esm/sdk/models/update-commitment-request.d.ts +5 -0
  175. package/esm/sdk/models/update-commitment-request.d.ts.map +1 -1
  176. package/esm/sdk/models/update-commitment-request.js +2 -0
  177. package/esm/sdk/models/update-commitment-request.js.map +1 -1
  178. package/esm/sdk/models/webhook-dto-billing-instalment-webhook-payload.d.ts +13 -0
  179. package/esm/sdk/models/webhook-dto-billing-instalment-webhook-payload.d.ts.map +1 -0
  180. package/esm/sdk/models/webhook-dto-billing-instalment-webhook-payload.js +22 -0
  181. package/esm/sdk/models/webhook-dto-billing-instalment-webhook-payload.js.map +1 -0
  182. package/esm/sdk/models/webhook-dto-billing-terms-webhook-payload.d.ts +16 -0
  183. package/esm/sdk/models/webhook-dto-billing-terms-webhook-payload.d.ts.map +1 -0
  184. package/esm/sdk/models/webhook-dto-billing-terms-webhook-payload.js +28 -0
  185. package/esm/sdk/models/webhook-dto-billing-terms-webhook-payload.js.map +1 -0
  186. package/esm/sdk/models/webhook-dto-invoice-line-item.d.ts +1 -0
  187. package/esm/sdk/models/webhook-dto-invoice-line-item.d.ts.map +1 -1
  188. package/esm/sdk/models/webhook-dto-invoice-line-item.js +2 -0
  189. package/esm/sdk/models/webhook-dto-invoice-line-item.js.map +1 -1
  190. package/esm/sdk/models/webhook-event-name.d.ts +6 -0
  191. package/esm/sdk/models/webhook-event-name.d.ts.map +1 -1
  192. package/esm/sdk/models/webhook-event-name.js +6 -0
  193. package/esm/sdk/models/webhook-event-name.js.map +1 -1
  194. package/esm/sdk/webhook-events.d.ts +42 -0
  195. package/esm/sdk/webhook-events.d.ts.map +1 -1
  196. package/esm/sdk/webhook-events.js +60 -0
  197. package/esm/sdk/webhook-events.js.map +1 -1
  198. package/jsr.json +1 -1
  199. package/package.json +1 -1
  200. package/src/funcs/commitments-get-commitment-billing-terms.ts +182 -0
  201. package/src/funcs/commitments-list-commitment-instalments.ts +191 -0
  202. package/src/funcs/commitments-preview-commitment-billing-terms.ts +192 -0
  203. package/src/funcs/commitments-replace-commitment-billing-terms.ts +190 -0
  204. package/src/funcs/commitments-terminate-commitment.ts +1 -1
  205. package/src/funcs/commitments-trigger-commitment-instalment.ts +197 -0
  206. package/src/funcs/webhook-events-post-webhook-events-billing-instalment-cancelled.ts +144 -0
  207. package/src/funcs/webhook-events-post-webhook-events-billing-instalment-created.ts +144 -0
  208. package/src/funcs/webhook-events-post-webhook-events-billing-instalment-invoiced.ts +144 -0
  209. package/src/funcs/webhook-events-post-webhook-events-billing-instalment-updated.ts +144 -0
  210. package/src/funcs/webhook-events-post-webhook-events-billing-terms-created.ts +144 -0
  211. package/src/funcs/webhook-events-post-webhook-events-billing-terms-updated.ts +144 -0
  212. package/src/lib/config.ts +2 -2
  213. package/src/sdk/commitments.ts +101 -1
  214. package/src/sdk/models/billing-term-input.ts +127 -0
  215. package/src/sdk/models/billing-term-kind.ts +24 -0
  216. package/src/sdk/models/billing-term-owner-type.ts +16 -0
  217. package/src/sdk/models/billing-term-split.ts +24 -0
  218. package/src/sdk/models/billing-term-value-type.ts +31 -0
  219. package/src/sdk/models/billing-terms-response.ts +49 -0
  220. package/src/sdk/models/billingterm-instalment.ts +128 -0
  221. package/src/sdk/models/billingterm-term.ts +143 -0
  222. package/src/sdk/models/cancellation-fee-input.ts +40 -0
  223. package/src/sdk/models/cancellation-fee-type.ts +23 -0
  224. package/src/sdk/models/commitment-response.ts +22 -2
  225. package/src/sdk/models/create-commitment-request.ts +23 -0
  226. package/src/sdk/models/get-commitment-billing-terms-op.ts +35 -0
  227. package/src/sdk/models/get-subscription-v2-op.ts +1 -1
  228. package/src/sdk/models/index.ts +24 -0
  229. package/src/sdk/models/instalment-bill-trigger.ts +24 -0
  230. package/src/sdk/models/instalment-delivery.ts +24 -0
  231. package/src/sdk/models/instalment-kind.ts +19 -0
  232. package/src/sdk/models/instalment-status.ts +20 -0
  233. package/src/sdk/models/invoice-billing-reason.ts +2 -0
  234. package/src/sdk/models/invoice-line-item-response.ts +6 -0
  235. package/src/sdk/models/list-commitment-instalments-op.ts +41 -0
  236. package/src/sdk/models/list-instalments-response.ts +35 -0
  237. package/src/sdk/models/preview-commitment-billing-terms-op.ts +46 -0
  238. package/src/sdk/models/replace-billing-terms-request.ts +43 -0
  239. package/src/sdk/models/replace-commitment-billing-terms-op.ts +46 -0
  240. package/src/sdk/models/subscription-response-v2.ts +9 -0
  241. package/src/sdk/models/subscription-response.ts +9 -0
  242. package/src/sdk/models/terminate-commitment-request.ts +11 -3
  243. package/src/sdk/models/trigger-commitment-instalment-op.ts +60 -0
  244. package/src/sdk/models/trigger-instalment-request.ts +41 -0
  245. package/src/sdk/models/update-commitment-request.ts +7 -0
  246. package/src/sdk/models/webhook-dto-billing-instalment-webhook-payload.ts +53 -0
  247. package/src/sdk/models/webhook-dto-billing-terms-webhook-payload.ts +61 -0
  248. package/src/sdk/models/webhook-dto-invoice-line-item.ts +3 -0
  249. package/src/sdk/models/webhook-event-name.ts +6 -0
  250. package/src/sdk/webhook-events.ts +96 -0
@@ -0,0 +1,190 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { TirdadCore } from "../core.js";
7
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../sdk/models/http-client-errors.js";
22
+ import * as models from "../sdk/models/index.js";
23
+ import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
24
+ import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
25
+ import { TirdadError } from "../sdk/models/tirdad-error.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Edit billing terms
31
+ *
32
+ * @remarks
33
+ * Replaces the whole set of billing terms of an active commitment. Its scheduled instalments are cancelled and the new terms generate instalments for what the invoiced ones leave of the commitment total; invoiced instalments and their invoices are kept. A term without bill_on or start_date starts at the billing period holding now, or at the commitment start once its term has ended. Returns the new terms with the scheduled and invoiced instalments in billing order.
34
+ */
35
+ export function commitmentsReplaceCommitmentBillingTerms(
36
+ client: TirdadCore,
37
+ id: string,
38
+ body: models.ReplaceBillingTermsRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ models.BillingTermsResponse,
43
+ | models.ErrorsErrorResponse
44
+ | TirdadError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ id,
57
+ body,
58
+ options,
59
+ ));
60
+ }
61
+
62
+ async function $do(
63
+ client: TirdadCore,
64
+ id: string,
65
+ body: models.ReplaceBillingTermsRequest,
66
+ options?: RequestOptions,
67
+ ): Promise<
68
+ [
69
+ Result<
70
+ models.BillingTermsResponse,
71
+ | models.ErrorsErrorResponse
72
+ | TirdadError
73
+ | ResponseValidationError
74
+ | ConnectionError
75
+ | RequestAbortedError
76
+ | RequestTimeoutError
77
+ | InvalidRequestError
78
+ | UnexpectedClientError
79
+ | SDKValidationError
80
+ >,
81
+ APICall,
82
+ ]
83
+ > {
84
+ const input: models.ReplaceCommitmentBillingTermsRequest = {
85
+ id: id,
86
+ body: body,
87
+ };
88
+
89
+ const parsed = safeParse(
90
+ input,
91
+ (value) =>
92
+ z.parse(
93
+ models.ReplaceCommitmentBillingTermsRequest$outboundSchema,
94
+ value,
95
+ ),
96
+ "Input validation failed",
97
+ );
98
+ if (!parsed.ok) {
99
+ return [parsed, { status: "invalid" }];
100
+ }
101
+ const payload = parsed.value;
102
+ const body$ = encodeJSON("body", payload.body, { explode: true });
103
+
104
+ const pathParams = {
105
+ id: encodeSimple("id", payload.id, {
106
+ explode: false,
107
+ charEncoding: "percent",
108
+ }),
109
+ };
110
+ const path = pathToFunc("/commitments/{id}/billing-terms")(pathParams);
111
+
112
+ const headers = new Headers(compactMap({
113
+ "Content-Type": "application/json",
114
+ Accept: "application/json",
115
+ }));
116
+
117
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
118
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
119
+ const requestSecurity = resolveGlobalSecurity(securityInput);
120
+
121
+ const context = {
122
+ options: client._options,
123
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
124
+ operationID: "replaceCommitmentBillingTerms",
125
+ oAuth2Scopes: null,
126
+
127
+ resolvedSecurity: requestSecurity,
128
+
129
+ securitySource: client._options.apiKeyAuth,
130
+ retryConfig: options?.retries
131
+ || client._options.retryConfig
132
+ || { strategy: "none" },
133
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
134
+ };
135
+
136
+ const requestRes = client._createRequest(context, {
137
+ security: requestSecurity,
138
+ method: "PUT",
139
+ baseURL: options?.serverURL,
140
+ path: path,
141
+ headers: headers,
142
+ body: body$,
143
+ userAgent: client._options.userAgent,
144
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
145
+ }, options);
146
+ if (!requestRes.ok) {
147
+ return [requestRes, { status: "invalid" }];
148
+ }
149
+ const req = requestRes.value;
150
+
151
+ const doResult = await client._do(req, {
152
+ context,
153
+ isErrorStatusCode: (statusCode: number) =>
154
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
155
+ retryConfig: context.retryConfig,
156
+ retryCodes: context.retryCodes,
157
+ });
158
+ if (!doResult.ok) {
159
+ return [doResult, { status: "request-error", request: req }];
160
+ }
161
+ const response = doResult.value;
162
+
163
+ const responseFields = {
164
+ HttpMeta: { Response: response, Request: req },
165
+ };
166
+
167
+ const [result] = await M.match<
168
+ models.BillingTermsResponse,
169
+ | models.ErrorsErrorResponse
170
+ | TirdadError
171
+ | ResponseValidationError
172
+ | ConnectionError
173
+ | RequestAbortedError
174
+ | RequestTimeoutError
175
+ | InvalidRequestError
176
+ | UnexpectedClientError
177
+ | SDKValidationError
178
+ >(
179
+ M.json(200, models.BillingTermsResponse$inboundSchema),
180
+ M.jsonErr([400, 404], models.ErrorsErrorResponse$inboundSchema),
181
+ M.jsonErr(500, models.ErrorsErrorResponse$inboundSchema),
182
+ M.fail("4XX"),
183
+ M.fail("5XX"),
184
+ )(response, req, { extraFields: responseFields });
185
+ if (!result.ok) {
186
+ return [result, { status: "complete", request: req, response }];
187
+ }
188
+
189
+ return [result, { status: "complete", request: req, response }];
190
+ }
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
30
30
  * Terminate commitment
31
31
  *
32
32
  * @remarks
33
- * Ends a commitment early, effective at the given time or now.
33
+ * Ends a commitment immediately. effective_at defaults to now and cannot be in the future. Under billing terms, its scheduled instalments are cancelled, and those already due by effective_at are billed together as one settlement; later instalments are not billed and nothing is refunded. The settlement and a fixed cancellation fee, when given, are billed together on one one-off invoice.
34
34
  */
35
35
  export function commitmentsTerminateCommitment(
36
36
  client: TirdadCore,
@@ -0,0 +1,197 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { TirdadCore } from "../core.js";
7
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../sdk/models/http-client-errors.js";
22
+ import * as models from "../sdk/models/index.js";
23
+ import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
24
+ import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
25
+ import { TirdadError } from "../sdk/models/tirdad-error.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Trigger instalment
31
+ *
32
+ * @remarks
33
+ * Bills a manual instalment of an active commitment on bill_on, now by default, which must fall within the commitment term. The instalment goes on the first subscription invoice at or after that date, or on its own invoice once due when its instalment_invoicing, the term's or else the commitment's, is separate_invoice. Either way it waits while the subscription is trialing or paused. Until it is triggered, a manual instalment waits at the end of the term, and bill_on can only move earlier; edit the billing terms to bill it later.
34
+ */
35
+ export function commitmentsTriggerCommitmentInstalment(
36
+ client: TirdadCore,
37
+ id: string,
38
+ instalmentId: string,
39
+ body?: models.TriggerInstalmentRequest | undefined,
40
+ options?: RequestOptions,
41
+ ): APIPromise<
42
+ Result<
43
+ models.BillingtermInstalment,
44
+ | models.ErrorsErrorResponse
45
+ | TirdadError
46
+ | ResponseValidationError
47
+ | ConnectionError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | InvalidRequestError
51
+ | UnexpectedClientError
52
+ | SDKValidationError
53
+ >
54
+ > {
55
+ return new APIPromise($do(
56
+ client,
57
+ id,
58
+ instalmentId,
59
+ body,
60
+ options,
61
+ ));
62
+ }
63
+
64
+ async function $do(
65
+ client: TirdadCore,
66
+ id: string,
67
+ instalmentId: string,
68
+ body?: models.TriggerInstalmentRequest | undefined,
69
+ options?: RequestOptions,
70
+ ): Promise<
71
+ [
72
+ Result<
73
+ models.BillingtermInstalment,
74
+ | models.ErrorsErrorResponse
75
+ | TirdadError
76
+ | ResponseValidationError
77
+ | ConnectionError
78
+ | RequestAbortedError
79
+ | RequestTimeoutError
80
+ | InvalidRequestError
81
+ | UnexpectedClientError
82
+ | SDKValidationError
83
+ >,
84
+ APICall,
85
+ ]
86
+ > {
87
+ const input: models.TriggerCommitmentInstalmentRequest = {
88
+ id: id,
89
+ instalmentId: instalmentId,
90
+ body: body,
91
+ };
92
+
93
+ const parsed = safeParse(
94
+ input,
95
+ (value) =>
96
+ z.parse(models.TriggerCommitmentInstalmentRequest$outboundSchema, value),
97
+ "Input validation failed",
98
+ );
99
+ if (!parsed.ok) {
100
+ return [parsed, { status: "invalid" }];
101
+ }
102
+ const payload = parsed.value;
103
+ const body$ = encodeJSON("body", payload.body, { explode: true });
104
+
105
+ const pathParams = {
106
+ id: encodeSimple("id", payload.id, {
107
+ explode: false,
108
+ charEncoding: "percent",
109
+ }),
110
+ instalment_id: encodeSimple("instalment_id", payload.instalment_id, {
111
+ explode: false,
112
+ charEncoding: "percent",
113
+ }),
114
+ };
115
+ const path = pathToFunc(
116
+ "/commitments/{id}/instalments/{instalment_id}/trigger",
117
+ )(pathParams);
118
+
119
+ const headers = new Headers(compactMap({
120
+ "Content-Type": "application/json",
121
+ Accept: "application/json",
122
+ }));
123
+
124
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
125
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
126
+ const requestSecurity = resolveGlobalSecurity(securityInput);
127
+
128
+ const context = {
129
+ options: client._options,
130
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
131
+ operationID: "triggerCommitmentInstalment",
132
+ oAuth2Scopes: null,
133
+
134
+ resolvedSecurity: requestSecurity,
135
+
136
+ securitySource: client._options.apiKeyAuth,
137
+ retryConfig: options?.retries
138
+ || client._options.retryConfig
139
+ || { strategy: "none" },
140
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
141
+ };
142
+
143
+ const requestRes = client._createRequest(context, {
144
+ security: requestSecurity,
145
+ method: "POST",
146
+ baseURL: options?.serverURL,
147
+ path: path,
148
+ headers: headers,
149
+ body: body$,
150
+ userAgent: client._options.userAgent,
151
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
152
+ }, options);
153
+ if (!requestRes.ok) {
154
+ return [requestRes, { status: "invalid" }];
155
+ }
156
+ const req = requestRes.value;
157
+
158
+ const doResult = await client._do(req, {
159
+ context,
160
+ isErrorStatusCode: (statusCode: number) =>
161
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
162
+ retryConfig: context.retryConfig,
163
+ retryCodes: context.retryCodes,
164
+ });
165
+ if (!doResult.ok) {
166
+ return [doResult, { status: "request-error", request: req }];
167
+ }
168
+ const response = doResult.value;
169
+
170
+ const responseFields = {
171
+ HttpMeta: { Response: response, Request: req },
172
+ };
173
+
174
+ const [result] = await M.match<
175
+ models.BillingtermInstalment,
176
+ | models.ErrorsErrorResponse
177
+ | TirdadError
178
+ | ResponseValidationError
179
+ | ConnectionError
180
+ | RequestAbortedError
181
+ | RequestTimeoutError
182
+ | InvalidRequestError
183
+ | UnexpectedClientError
184
+ | SDKValidationError
185
+ >(
186
+ M.json(200, models.BillingtermInstalment$inboundSchema),
187
+ M.jsonErr([400, 404], models.ErrorsErrorResponse$inboundSchema),
188
+ M.jsonErr(500, models.ErrorsErrorResponse$inboundSchema),
189
+ M.fail("4XX"),
190
+ M.fail("5XX"),
191
+ )(response, req, { extraFields: responseFields });
192
+ if (!result.ok) {
193
+ return [result, { status: "complete", request: req, response }];
194
+ }
195
+
196
+ return [result, { status: "complete", request: req, response }];
197
+ }
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { TirdadCore } from "../core.js";
6
+ import { matchStatusCode } from "../lib/http.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { RequestOptions } from "../lib/sdks.js";
10
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
11
+ import { pathToFunc } from "../lib/url.js";
12
+ import {
13
+ ConnectionError,
14
+ InvalidRequestError,
15
+ RequestAbortedError,
16
+ RequestTimeoutError,
17
+ UnexpectedClientError,
18
+ } from "../sdk/models/http-client-errors.js";
19
+ import * as models from "../sdk/models/index.js";
20
+ import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
21
+ import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
22
+ import { TirdadError } from "../sdk/models/tirdad-error.js";
23
+ import { APICall, APIPromise } from "../types/async.js";
24
+ import { Result } from "../types/fp.js";
25
+
26
+ /**
27
+ * billing_instalment.cancelled
28
+ *
29
+ * @remarks
30
+ * Fired when a billing instalment is cancelled. Doc-only for parsing.
31
+ */
32
+ export function webhookEventsPostWebhookEventsBillingInstalmentCancelled(
33
+ client: TirdadCore,
34
+ options?: RequestOptions,
35
+ ): APIPromise<
36
+ Result<
37
+ models.WebhookDtoBillingInstalmentWebhookPayload,
38
+ | TirdadError
39
+ | ResponseValidationError
40
+ | ConnectionError
41
+ | RequestAbortedError
42
+ | RequestTimeoutError
43
+ | InvalidRequestError
44
+ | UnexpectedClientError
45
+ | SDKValidationError
46
+ >
47
+ > {
48
+ return new APIPromise($do(
49
+ client,
50
+ options,
51
+ ));
52
+ }
53
+
54
+ async function $do(
55
+ client: TirdadCore,
56
+ options?: RequestOptions,
57
+ ): Promise<
58
+ [
59
+ Result<
60
+ models.WebhookDtoBillingInstalmentWebhookPayload,
61
+ | TirdadError
62
+ | ResponseValidationError
63
+ | ConnectionError
64
+ | RequestAbortedError
65
+ | RequestTimeoutError
66
+ | InvalidRequestError
67
+ | UnexpectedClientError
68
+ | SDKValidationError
69
+ >,
70
+ APICall,
71
+ ]
72
+ > {
73
+ const path = pathToFunc("/webhook-events/billing_instalment.cancelled")();
74
+
75
+ const headers = new Headers(compactMap({
76
+ Accept: "application/json",
77
+ }));
78
+
79
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
80
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
81
+ const requestSecurity = resolveGlobalSecurity(securityInput);
82
+
83
+ const context = {
84
+ options: client._options,
85
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
86
+ operationID: "post_/webhook-events/billing_instalment.cancelled",
87
+ oAuth2Scopes: null,
88
+
89
+ resolvedSecurity: requestSecurity,
90
+
91
+ securitySource: client._options.apiKeyAuth,
92
+ retryConfig: options?.retries
93
+ || client._options.retryConfig
94
+ || { strategy: "none" },
95
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
96
+ };
97
+
98
+ const requestRes = client._createRequest(context, {
99
+ security: requestSecurity,
100
+ method: "POST",
101
+ baseURL: options?.serverURL,
102
+ path: path,
103
+ headers: headers,
104
+ userAgent: client._options.userAgent,
105
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
106
+ }, options);
107
+ if (!requestRes.ok) {
108
+ return [requestRes, { status: "invalid" }];
109
+ }
110
+ const req = requestRes.value;
111
+
112
+ const doResult = await client._do(req, {
113
+ context,
114
+ isErrorStatusCode: (statusCode: number) =>
115
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
116
+ retryConfig: context.retryConfig,
117
+ retryCodes: context.retryCodes,
118
+ });
119
+ if (!doResult.ok) {
120
+ return [doResult, { status: "request-error", request: req }];
121
+ }
122
+ const response = doResult.value;
123
+
124
+ const [result] = await M.match<
125
+ models.WebhookDtoBillingInstalmentWebhookPayload,
126
+ | TirdadError
127
+ | ResponseValidationError
128
+ | ConnectionError
129
+ | RequestAbortedError
130
+ | RequestTimeoutError
131
+ | InvalidRequestError
132
+ | UnexpectedClientError
133
+ | SDKValidationError
134
+ >(
135
+ M.json(200, models.WebhookDtoBillingInstalmentWebhookPayload$inboundSchema),
136
+ M.fail("4XX"),
137
+ M.fail("5XX"),
138
+ )(response, req);
139
+ if (!result.ok) {
140
+ return [result, { status: "complete", request: req, response }];
141
+ }
142
+
143
+ return [result, { status: "complete", request: req, response }];
144
+ }
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { TirdadCore } from "../core.js";
6
+ import { matchStatusCode } from "../lib/http.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { RequestOptions } from "../lib/sdks.js";
10
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
11
+ import { pathToFunc } from "../lib/url.js";
12
+ import {
13
+ ConnectionError,
14
+ InvalidRequestError,
15
+ RequestAbortedError,
16
+ RequestTimeoutError,
17
+ UnexpectedClientError,
18
+ } from "../sdk/models/http-client-errors.js";
19
+ import * as models from "../sdk/models/index.js";
20
+ import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
21
+ import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
22
+ import { TirdadError } from "../sdk/models/tirdad-error.js";
23
+ import { APICall, APIPromise } from "../types/async.js";
24
+ import { Result } from "../types/fp.js";
25
+
26
+ /**
27
+ * billing_instalment.created
28
+ *
29
+ * @remarks
30
+ * Fired when a billing instalment is scheduled for an entity (like a commitment). Doc-only for parsing.
31
+ */
32
+ export function webhookEventsPostWebhookEventsBillingInstalmentCreated(
33
+ client: TirdadCore,
34
+ options?: RequestOptions,
35
+ ): APIPromise<
36
+ Result<
37
+ models.WebhookDtoBillingInstalmentWebhookPayload,
38
+ | TirdadError
39
+ | ResponseValidationError
40
+ | ConnectionError
41
+ | RequestAbortedError
42
+ | RequestTimeoutError
43
+ | InvalidRequestError
44
+ | UnexpectedClientError
45
+ | SDKValidationError
46
+ >
47
+ > {
48
+ return new APIPromise($do(
49
+ client,
50
+ options,
51
+ ));
52
+ }
53
+
54
+ async function $do(
55
+ client: TirdadCore,
56
+ options?: RequestOptions,
57
+ ): Promise<
58
+ [
59
+ Result<
60
+ models.WebhookDtoBillingInstalmentWebhookPayload,
61
+ | TirdadError
62
+ | ResponseValidationError
63
+ | ConnectionError
64
+ | RequestAbortedError
65
+ | RequestTimeoutError
66
+ | InvalidRequestError
67
+ | UnexpectedClientError
68
+ | SDKValidationError
69
+ >,
70
+ APICall,
71
+ ]
72
+ > {
73
+ const path = pathToFunc("/webhook-events/billing_instalment.created")();
74
+
75
+ const headers = new Headers(compactMap({
76
+ Accept: "application/json",
77
+ }));
78
+
79
+ const secConfig = await extractSecurity(client._options.apiKeyAuth);
80
+ const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
81
+ const requestSecurity = resolveGlobalSecurity(securityInput);
82
+
83
+ const context = {
84
+ options: client._options,
85
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
86
+ operationID: "post_/webhook-events/billing_instalment.created",
87
+ oAuth2Scopes: null,
88
+
89
+ resolvedSecurity: requestSecurity,
90
+
91
+ securitySource: client._options.apiKeyAuth,
92
+ retryConfig: options?.retries
93
+ || client._options.retryConfig
94
+ || { strategy: "none" },
95
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
96
+ };
97
+
98
+ const requestRes = client._createRequest(context, {
99
+ security: requestSecurity,
100
+ method: "POST",
101
+ baseURL: options?.serverURL,
102
+ path: path,
103
+ headers: headers,
104
+ userAgent: client._options.userAgent,
105
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
106
+ }, options);
107
+ if (!requestRes.ok) {
108
+ return [requestRes, { status: "invalid" }];
109
+ }
110
+ const req = requestRes.value;
111
+
112
+ const doResult = await client._do(req, {
113
+ context,
114
+ isErrorStatusCode: (statusCode: number) =>
115
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
116
+ retryConfig: context.retryConfig,
117
+ retryCodes: context.retryCodes,
118
+ });
119
+ if (!doResult.ok) {
120
+ return [doResult, { status: "request-error", request: req }];
121
+ }
122
+ const response = doResult.value;
123
+
124
+ const [result] = await M.match<
125
+ models.WebhookDtoBillingInstalmentWebhookPayload,
126
+ | TirdadError
127
+ | ResponseValidationError
128
+ | ConnectionError
129
+ | RequestAbortedError
130
+ | RequestTimeoutError
131
+ | InvalidRequestError
132
+ | UnexpectedClientError
133
+ | SDKValidationError
134
+ >(
135
+ M.json(200, models.WebhookDtoBillingInstalmentWebhookPayload$inboundSchema),
136
+ M.fail("4XX"),
137
+ M.fail("5XX"),
138
+ )(response, req);
139
+ if (!result.ok) {
140
+ return [result, { status: "complete", request: req, response }];
141
+ }
142
+
143
+ return [result, { status: "complete", request: req, response }];
144
+ }