@paygentic/sdk 0.7.1 → 0.7.2

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 (193) hide show
  1. package/README.md +13 -3
  2. package/dist/commonjs/funcs/invoicesV2List.js +1 -0
  3. package/dist/commonjs/funcs/invoicesV2List.js.map +1 -1
  4. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  5. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js +127 -0
  7. package/dist/commonjs/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  8. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts +19 -0
  9. package/dist/commonjs/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/profitabilityGetProfitability.js +127 -0
  11. package/dist/commonjs/funcs/profitabilityGetProfitability.js.map +1 -0
  12. package/dist/commonjs/lib/config.d.ts +2 -2
  13. package/dist/commonjs/lib/config.js +2 -2
  14. package/dist/commonjs/models/index.d.ts +4 -0
  15. package/dist/commonjs/models/index.d.ts.map +1 -1
  16. package/dist/commonjs/models/index.js +4 -0
  17. package/dist/commonjs/models/index.js.map +1 -1
  18. package/dist/commonjs/models/offsetpagination.d.ts +4 -4
  19. package/dist/commonjs/models/offsetpagination.d.ts.map +1 -1
  20. package/dist/commonjs/models/offsetpagination.js +3 -3
  21. package/dist/commonjs/models/offsetpagination.js.map +1 -1
  22. package/dist/commonjs/models/operations/createplan.d.ts +5 -0
  23. package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
  24. package/dist/commonjs/models/operations/createplan.js +2 -0
  25. package/dist/commonjs/models/operations/createplan.js.map +1 -1
  26. package/dist/commonjs/models/operations/getprofitability.d.ts +55 -0
  27. package/dist/commonjs/models/operations/getprofitability.d.ts.map +1 -0
  28. package/dist/commonjs/models/operations/getprofitability.js +64 -0
  29. package/dist/commonjs/models/operations/getprofitability.js.map +1 -0
  30. package/dist/commonjs/models/operations/getrevenue.d.ts +4 -4
  31. package/dist/commonjs/models/operations/getrevenue.d.ts.map +1 -1
  32. package/dist/commonjs/models/operations/getrevenue.js +4 -5
  33. package/dist/commonjs/models/operations/getrevenue.js.map +1 -1
  34. package/dist/commonjs/models/operations/index.d.ts +2 -0
  35. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  36. package/dist/commonjs/models/operations/index.js +2 -0
  37. package/dist/commonjs/models/operations/index.js.map +1 -1
  38. package/dist/commonjs/models/operations/listinvoices.d.ts +9 -0
  39. package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
  40. package/dist/commonjs/models/operations/listinvoices.js +2 -0
  41. package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
  42. package/dist/commonjs/models/operations/listpaymentsessions.d.ts +36 -10
  43. package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
  44. package/dist/commonjs/models/operations/listpaymentsessions.js +19 -4
  45. package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
  46. package/dist/commonjs/models/operations/updateplan.d.ts +5 -0
  47. package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
  48. package/dist/commonjs/models/operations/updateplan.js +2 -0
  49. package/dist/commonjs/models/operations/updateplan.js.map +1 -1
  50. package/dist/commonjs/models/paymentsession.d.ts +68 -0
  51. package/dist/commonjs/models/paymentsession.d.ts.map +1 -0
  52. package/dist/commonjs/models/paymentsession.js +78 -0
  53. package/dist/commonjs/models/paymentsession.js.map +1 -0
  54. package/dist/commonjs/models/plan.d.ts +4 -0
  55. package/dist/commonjs/models/plan.d.ts.map +1 -1
  56. package/dist/commonjs/models/plan.js +1 -0
  57. package/dist/commonjs/models/plan.js.map +1 -1
  58. package/dist/commonjs/models/profitabilityrow.d.ts +38 -0
  59. package/dist/commonjs/models/profitabilityrow.d.ts.map +1 -0
  60. package/dist/commonjs/models/profitabilityrow.js +57 -0
  61. package/dist/commonjs/models/profitabilityrow.js.map +1 -0
  62. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts +26 -0
  63. package/dist/commonjs/models/profitabilitysummaryresponse.d.ts.map +1 -0
  64. package/dist/commonjs/models/profitabilitysummaryresponse.js +54 -0
  65. package/dist/commonjs/models/profitabilitysummaryresponse.js.map +1 -0
  66. package/dist/commonjs/models/profitabilitytrend.d.ts +17 -0
  67. package/dist/commonjs/models/profitabilitytrend.d.ts.map +1 -0
  68. package/dist/commonjs/models/profitabilitytrend.js +51 -0
  69. package/dist/commonjs/models/profitabilitytrend.js.map +1 -0
  70. package/dist/commonjs/models/purchasegrantresponse.d.ts +4 -4
  71. package/dist/commonjs/models/purchasegrantresponse.d.ts.map +1 -1
  72. package/dist/commonjs/models/purchasegrantresponse.js +6 -6
  73. package/dist/commonjs/models/purchasegrantresponse.js.map +1 -1
  74. package/dist/commonjs/sdk/paymentsessions.d.ts +12 -0
  75. package/dist/commonjs/sdk/paymentsessions.d.ts.map +1 -0
  76. package/dist/commonjs/sdk/paymentsessions.js +22 -0
  77. package/dist/commonjs/sdk/paymentsessions.js.map +1 -0
  78. package/dist/commonjs/sdk/profitability.d.ts +13 -0
  79. package/dist/commonjs/sdk/profitability.d.ts.map +1 -0
  80. package/dist/commonjs/sdk/profitability.js +22 -0
  81. package/dist/commonjs/sdk/profitability.js.map +1 -0
  82. package/dist/commonjs/sdk/sdk.d.ts +6 -0
  83. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  84. package/dist/commonjs/sdk/sdk.js +8 -0
  85. package/dist/commonjs/sdk/sdk.js.map +1 -1
  86. package/dist/esm/funcs/invoicesV2List.js +1 -0
  87. package/dist/esm/funcs/invoicesV2List.js.map +1 -1
  88. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts +18 -0
  89. package/dist/esm/funcs/paymentSessionsListPaymentSessions.d.ts.map +1 -0
  90. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js +91 -0
  91. package/dist/esm/funcs/paymentSessionsListPaymentSessions.js.map +1 -0
  92. package/dist/esm/funcs/profitabilityGetProfitability.d.ts +19 -0
  93. package/dist/esm/funcs/profitabilityGetProfitability.d.ts.map +1 -0
  94. package/dist/esm/funcs/profitabilityGetProfitability.js +91 -0
  95. package/dist/esm/funcs/profitabilityGetProfitability.js.map +1 -0
  96. package/dist/esm/lib/config.d.ts +2 -2
  97. package/dist/esm/lib/config.js +2 -2
  98. package/dist/esm/models/index.d.ts +4 -0
  99. package/dist/esm/models/index.d.ts.map +1 -1
  100. package/dist/esm/models/index.js +4 -0
  101. package/dist/esm/models/index.js.map +1 -1
  102. package/dist/esm/models/offsetpagination.d.ts +4 -4
  103. package/dist/esm/models/offsetpagination.d.ts.map +1 -1
  104. package/dist/esm/models/offsetpagination.js +3 -3
  105. package/dist/esm/models/offsetpagination.js.map +1 -1
  106. package/dist/esm/models/operations/createplan.d.ts +5 -0
  107. package/dist/esm/models/operations/createplan.d.ts.map +1 -1
  108. package/dist/esm/models/operations/createplan.js +2 -0
  109. package/dist/esm/models/operations/createplan.js.map +1 -1
  110. package/dist/esm/models/operations/getprofitability.d.ts +55 -0
  111. package/dist/esm/models/operations/getprofitability.d.ts.map +1 -0
  112. package/dist/esm/models/operations/getprofitability.js +27 -0
  113. package/dist/esm/models/operations/getprofitability.js.map +1 -0
  114. package/dist/esm/models/operations/getrevenue.d.ts +4 -4
  115. package/dist/esm/models/operations/getrevenue.d.ts.map +1 -1
  116. package/dist/esm/models/operations/getrevenue.js +3 -4
  117. package/dist/esm/models/operations/getrevenue.js.map +1 -1
  118. package/dist/esm/models/operations/index.d.ts +2 -0
  119. package/dist/esm/models/operations/index.d.ts.map +1 -1
  120. package/dist/esm/models/operations/index.js +2 -0
  121. package/dist/esm/models/operations/index.js.map +1 -1
  122. package/dist/esm/models/operations/listinvoices.d.ts +9 -0
  123. package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
  124. package/dist/esm/models/operations/listinvoices.js +2 -0
  125. package/dist/esm/models/operations/listinvoices.js.map +1 -1
  126. package/dist/esm/models/operations/listpaymentsessions.d.ts +36 -10
  127. package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
  128. package/dist/esm/models/operations/listpaymentsessions.js +18 -3
  129. package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
  130. package/dist/esm/models/operations/updateplan.d.ts +5 -0
  131. package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
  132. package/dist/esm/models/operations/updateplan.js +2 -0
  133. package/dist/esm/models/operations/updateplan.js.map +1 -1
  134. package/dist/esm/models/paymentsession.d.ts +68 -0
  135. package/dist/esm/models/paymentsession.d.ts.map +1 -0
  136. package/dist/esm/models/paymentsession.js +41 -0
  137. package/dist/esm/models/paymentsession.js.map +1 -0
  138. package/dist/esm/models/plan.d.ts +4 -0
  139. package/dist/esm/models/plan.d.ts.map +1 -1
  140. package/dist/esm/models/plan.js +1 -0
  141. package/dist/esm/models/plan.js.map +1 -1
  142. package/dist/esm/models/profitabilityrow.d.ts +38 -0
  143. package/dist/esm/models/profitabilityrow.d.ts.map +1 -0
  144. package/dist/esm/models/profitabilityrow.js +20 -0
  145. package/dist/esm/models/profitabilityrow.js.map +1 -0
  146. package/dist/esm/models/profitabilitysummaryresponse.d.ts +26 -0
  147. package/dist/esm/models/profitabilitysummaryresponse.d.ts.map +1 -0
  148. package/dist/esm/models/profitabilitysummaryresponse.js +17 -0
  149. package/dist/esm/models/profitabilitysummaryresponse.js.map +1 -0
  150. package/dist/esm/models/profitabilitytrend.d.ts +17 -0
  151. package/dist/esm/models/profitabilitytrend.d.ts.map +1 -0
  152. package/dist/esm/models/profitabilitytrend.js +14 -0
  153. package/dist/esm/models/profitabilitytrend.js.map +1 -0
  154. package/dist/esm/models/purchasegrantresponse.d.ts +4 -4
  155. package/dist/esm/models/purchasegrantresponse.d.ts.map +1 -1
  156. package/dist/esm/models/purchasegrantresponse.js +4 -4
  157. package/dist/esm/models/purchasegrantresponse.js.map +1 -1
  158. package/dist/esm/sdk/paymentsessions.d.ts +12 -0
  159. package/dist/esm/sdk/paymentsessions.d.ts.map +1 -0
  160. package/dist/esm/sdk/paymentsessions.js +18 -0
  161. package/dist/esm/sdk/paymentsessions.js.map +1 -0
  162. package/dist/esm/sdk/profitability.d.ts +13 -0
  163. package/dist/esm/sdk/profitability.d.ts.map +1 -0
  164. package/dist/esm/sdk/profitability.js +18 -0
  165. package/dist/esm/sdk/profitability.js.map +1 -0
  166. package/dist/esm/sdk/sdk.d.ts +6 -0
  167. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  168. package/dist/esm/sdk/sdk.js +8 -0
  169. package/dist/esm/sdk/sdk.js.map +1 -1
  170. package/jsr.json +1 -1
  171. package/package.json +1 -1
  172. package/src/funcs/invoicesV2List.ts +1 -0
  173. package/src/funcs/paymentSessionsListPaymentSessions.ts +183 -0
  174. package/src/funcs/profitabilityGetProfitability.ts +184 -0
  175. package/src/lib/config.ts +2 -2
  176. package/src/models/index.ts +4 -0
  177. package/src/models/offsetpagination.ts +7 -7
  178. package/src/models/operations/createplan.ts +7 -0
  179. package/src/models/operations/getprofitability.ts +85 -0
  180. package/src/models/operations/getrevenue.ts +7 -6
  181. package/src/models/operations/index.ts +2 -0
  182. package/src/models/operations/listinvoices.ts +11 -0
  183. package/src/models/operations/listpaymentsessions.ts +43 -12
  184. package/src/models/operations/updateplan.ts +7 -0
  185. package/src/models/paymentsession.ts +109 -0
  186. package/src/models/plan.ts +7 -0
  187. package/src/models/profitabilityrow.ts +68 -0
  188. package/src/models/profitabilitysummaryresponse.ts +53 -0
  189. package/src/models/profitabilitytrend.ts +39 -0
  190. package/src/models/purchasegrantresponse.ts +12 -9
  191. package/src/sdk/paymentsessions.ts +27 -0
  192. package/src/sdk/profitability.ts +28 -0
  193. package/src/sdk/sdk.ts +12 -0
@@ -0,0 +1,183 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { PaygenticCore } from "../core.js";
6
+ import { encodeFormQuery } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { PaygenticError } from "../models/errors/paygenticerror.js";
22
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * List
30
+ *
31
+ * @remarks
32
+ * List payment sessions for the authenticated merchant with optional filters. Supports filtering by subscriptionId, customerId, status, and entityType. When subscriptionId is provided the result includes both the subscription's own activation session (entityType='subscription') and any session attached to invoices for that subscription (entityType='invoice').
33
+ */
34
+ export function paymentSessionsListPaymentSessions(
35
+ client: PaygenticCore,
36
+ request?: operations.ListPaymentSessionsRequest | undefined,
37
+ options?: RequestOptions,
38
+ ): APIPromise<
39
+ Result<
40
+ operations.ListPaymentSessionsResponse,
41
+ | errors.ErrorT
42
+ | PaygenticError
43
+ | ResponseValidationError
44
+ | ConnectionError
45
+ | RequestAbortedError
46
+ | RequestTimeoutError
47
+ | InvalidRequestError
48
+ | UnexpectedClientError
49
+ | SDKValidationError
50
+ >
51
+ > {
52
+ return new APIPromise($do(
53
+ client,
54
+ request,
55
+ options,
56
+ ));
57
+ }
58
+
59
+ async function $do(
60
+ client: PaygenticCore,
61
+ request?: operations.ListPaymentSessionsRequest | undefined,
62
+ options?: RequestOptions,
63
+ ): Promise<
64
+ [
65
+ Result<
66
+ operations.ListPaymentSessionsResponse,
67
+ | errors.ErrorT
68
+ | PaygenticError
69
+ | ResponseValidationError
70
+ | ConnectionError
71
+ | RequestAbortedError
72
+ | RequestTimeoutError
73
+ | InvalidRequestError
74
+ | UnexpectedClientError
75
+ | SDKValidationError
76
+ >,
77
+ APICall,
78
+ ]
79
+ > {
80
+ const parsed = safeParse(
81
+ request,
82
+ (value) =>
83
+ operations.ListPaymentSessionsRequest$outboundSchema.optional().parse(
84
+ value,
85
+ ),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = null;
93
+
94
+ const path = pathToFunc("/v0/paymentSessions")();
95
+
96
+ const query = encodeFormQuery({
97
+ "customerId": payload?.customerId,
98
+ "entityType": payload?.entityType,
99
+ "limit": payload?.limit,
100
+ "merchantId": payload?.merchantId,
101
+ "offset": payload?.offset,
102
+ "status": payload?.status,
103
+ "subscriptionId": payload?.subscriptionId,
104
+ });
105
+
106
+ const headers = new Headers(compactMap({
107
+ Accept: "application/json",
108
+ }));
109
+
110
+ const secConfig = await extractSecurity(client._options.bearerAuth);
111
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
112
+ const requestSecurity = resolveGlobalSecurity(securityInput);
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "listPaymentSessions",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: requestSecurity,
121
+
122
+ securitySource: client._options.bearerAuth,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "GET",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ query: query,
136
+ body: body,
137
+ userAgent: client._options.userAgent,
138
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
139
+ }, options);
140
+ if (!requestRes.ok) {
141
+ return [requestRes, { status: "invalid" }];
142
+ }
143
+ const req = requestRes.value;
144
+
145
+ const doResult = await client._do(req, {
146
+ context,
147
+ errorCodes: ["401", "403", "4XX", "500", "5XX"],
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ operations.ListPaymentSessionsResponse,
162
+ | errors.ErrorT
163
+ | PaygenticError
164
+ | ResponseValidationError
165
+ | ConnectionError
166
+ | RequestAbortedError
167
+ | RequestTimeoutError
168
+ | InvalidRequestError
169
+ | UnexpectedClientError
170
+ | SDKValidationError
171
+ >(
172
+ M.json(200, operations.ListPaymentSessionsResponse$inboundSchema),
173
+ M.jsonErr([401, 403], errors.ErrorT$inboundSchema),
174
+ M.jsonErr(500, errors.ErrorT$inboundSchema),
175
+ M.fail("4XX"),
176
+ M.fail("5XX"),
177
+ )(response, req, { extraFields: responseFields });
178
+ if (!result.ok) {
179
+ return [result, { status: "complete", request: req, response }];
180
+ }
181
+
182
+ return [result, { status: "complete", request: req, response }];
183
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { PaygenticCore } from "../core.js";
6
+ import { encodeFormQuery } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { PaygenticError } from "../models/errors/paygenticerror.js";
22
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as models from "../models/index.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Get profitability summary
31
+ *
32
+ * @remarks
33
+ * Returns a per-customer profitability summary for a merchant over a date range. Each row aggregates revenue (from issued + paid invoices), cost (from metered cost discovery), profit, and margin. Customers are ranked by profit descending and capped at topN; the remainder is rolled into a single self-consistent 'Other' row whose revenue, cost, and profit reflect the same set of customers. Rows are inner-joined against the merchant's customer list, so orphaned meter subjects from deleted or unknown customers are dropped.
34
+ */
35
+ export function profitabilityGetProfitability(
36
+ client: PaygenticCore,
37
+ request: operations.GetProfitabilityRequest,
38
+ options?: RequestOptions,
39
+ ): APIPromise<
40
+ Result<
41
+ models.ProfitabilitySummaryResponse,
42
+ | errors.BadRequest
43
+ | errors.ErrorT
44
+ | PaygenticError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: PaygenticCore,
63
+ request: operations.GetProfitabilityRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ models.ProfitabilitySummaryResponse,
69
+ | errors.BadRequest
70
+ | errors.ErrorT
71
+ | PaygenticError
72
+ | ResponseValidationError
73
+ | ConnectionError
74
+ | RequestAbortedError
75
+ | RequestTimeoutError
76
+ | InvalidRequestError
77
+ | UnexpectedClientError
78
+ | SDKValidationError
79
+ >,
80
+ APICall,
81
+ ]
82
+ > {
83
+ const parsed = safeParse(
84
+ request,
85
+ (value) => operations.GetProfitabilityRequest$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = null;
93
+
94
+ const path = pathToFunc("/v0/profitability")();
95
+
96
+ const query = encodeFormQuery({
97
+ "bucketWidth": payload.bucketWidth,
98
+ "currency": payload.currency,
99
+ "from": payload.from,
100
+ "merchantId": payload.merchantId,
101
+ "to": payload.to,
102
+ "topN": payload.topN,
103
+ });
104
+
105
+ const headers = new Headers(compactMap({
106
+ Accept: "application/json",
107
+ }));
108
+
109
+ const secConfig = await extractSecurity(client._options.bearerAuth);
110
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
111
+ const requestSecurity = resolveGlobalSecurity(securityInput);
112
+
113
+ const context = {
114
+ options: client._options,
115
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
116
+ operationID: "getProfitability",
117
+ oAuth2Scopes: null,
118
+
119
+ resolvedSecurity: requestSecurity,
120
+
121
+ securitySource: client._options.bearerAuth,
122
+ retryConfig: options?.retries
123
+ || client._options.retryConfig
124
+ || { strategy: "none" },
125
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
126
+ };
127
+
128
+ const requestRes = client._createRequest(context, {
129
+ security: requestSecurity,
130
+ method: "GET",
131
+ baseURL: options?.serverURL,
132
+ path: path,
133
+ headers: headers,
134
+ query: query,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ errorCodes: ["400", "401", "403", "4XX", "500", "5XX"],
147
+ retryConfig: context.retryConfig,
148
+ retryCodes: context.retryCodes,
149
+ });
150
+ if (!doResult.ok) {
151
+ return [doResult, { status: "request-error", request: req }];
152
+ }
153
+ const response = doResult.value;
154
+
155
+ const responseFields = {
156
+ HttpMeta: { Response: response, Request: req },
157
+ };
158
+
159
+ const [result] = await M.match<
160
+ models.ProfitabilitySummaryResponse,
161
+ | errors.BadRequest
162
+ | errors.ErrorT
163
+ | PaygenticError
164
+ | ResponseValidationError
165
+ | ConnectionError
166
+ | RequestAbortedError
167
+ | RequestTimeoutError
168
+ | InvalidRequestError
169
+ | UnexpectedClientError
170
+ | SDKValidationError
171
+ >(
172
+ M.json(200, models.ProfitabilitySummaryResponse$inboundSchema),
173
+ M.jsonErr(400, errors.BadRequest$inboundSchema),
174
+ M.jsonErr([401, 403], errors.ErrorT$inboundSchema),
175
+ M.jsonErr(500, errors.ErrorT$inboundSchema),
176
+ M.fail("4XX"),
177
+ M.fail("5XX"),
178
+ )(response, req, { extraFields: responseFields });
179
+ if (!result.ok) {
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
182
+
183
+ return [result, { status: "complete", request: req, response }];
184
+ }
package/src/lib/config.ts CHANGED
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
65
65
  export const SDK_METADATA = {
66
66
  language: "typescript",
67
67
  openapiDocVersion: "0.1.0",
68
- sdkVersion: "0.7.1",
68
+ sdkVersion: "0.7.2",
69
69
  genVersion: "2.879.13",
70
- userAgent: "speakeasy-sdk/typescript 0.7.1 2.879.13 0.1.0 @paygentic/sdk",
70
+ userAgent: "speakeasy-sdk/typescript 0.7.2 2.879.13 0.1.0 @paygentic/sdk",
71
71
  } as const;
@@ -40,6 +40,7 @@ export * from "./meterevent.js";
40
40
  export * from "./metereventlist.js";
41
41
  export * from "./offsetpagination.js";
42
42
  export * from "./payment.js";
43
+ export * from "./paymentsession.js";
43
44
  export * from "./paymentsummary.js";
44
45
  export * from "./plan.js";
45
46
  export * from "./price.js";
@@ -47,6 +48,9 @@ export * from "./pricefeature.js";
47
48
  export * from "./pricefeatureinput.js";
48
49
  export * from "./pricepropertiesunion.js";
49
50
  export * from "./product.js";
51
+ export * from "./profitabilityrow.js";
52
+ export * from "./profitabilitysummaryresponse.js";
53
+ export * from "./profitabilitytrend.js";
50
54
  export * from "./purchasegrantrequest.js";
51
55
  export * from "./purchasegrantresponse.js";
52
56
  export * from "./revenuesummaryresponse.js";
@@ -12,17 +12,17 @@ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
12
12
  */
13
13
  export type OffsetPagination = {
14
14
  /**
15
- * Number of items returned in the current page.
15
+ * Requested page size.
16
16
  */
17
- limit?: number | undefined;
17
+ limit: number;
18
18
  /**
19
19
  * Number of items skipped.
20
20
  */
21
- offset?: number | undefined;
21
+ offset: number;
22
22
  /**
23
23
  * Total number of items available.
24
24
  */
25
- total?: number | undefined;
25
+ total: number;
26
26
  };
27
27
 
28
28
  /** @internal */
@@ -31,9 +31,9 @@ export const OffsetPagination$inboundSchema: z.ZodType<
31
31
  z.ZodTypeDef,
32
32
  unknown
33
33
  > = z.object({
34
- limit: z.number().int().optional(),
35
- offset: z.number().int().optional(),
36
- total: z.number().int().optional(),
34
+ limit: z.number().int(),
35
+ offset: z.number().int(),
36
+ total: z.number().int(),
37
37
  });
38
38
 
39
39
  export function offsetPaginationFromJSON(
@@ -121,6 +121,10 @@ export type CreatePlanRequest = {
121
121
  * Billing engine version. 0 = legacy fee-schedule billing (Legacy), 1 = line-item billing with metered usage support (Standard).
122
122
  */
123
123
  billingVersion?: BillingVersion | undefined;
124
+ /**
125
+ * ISO 8601 datetime reference point for billing period alignment. Must be in the past or present. When set, subscriptions created under this plan align their first billing period to the next recurrence of this anchor.
126
+ */
127
+ billingAnchor?: Date | null | undefined;
124
128
  };
125
129
 
126
130
  /** @internal */
@@ -160,6 +164,7 @@ export type CreatePlanRequest$Outbound = {
160
164
  renewalReminderEnabled: boolean;
161
165
  renewalReminderDays: number;
162
166
  billingVersion: number;
167
+ billingAnchor?: string | null | undefined;
163
168
  };
164
169
 
165
170
  /** @internal */
@@ -183,6 +188,8 @@ export const CreatePlanRequest$outboundSchema: z.ZodType<
183
188
  renewalReminderEnabled: z.boolean().default(true),
184
189
  renewalReminderDays: z.number().int().default(3),
185
190
  billingVersion: BillingVersion$outboundSchema.default(0),
191
+ billingAnchor: z.nullable(z.date().transform(v => v.toISOString()))
192
+ .optional(),
186
193
  });
187
194
 
188
195
  export function createPlanRequestToJSON(
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { ClosedEnum } from "../../types/enums.js";
7
+
8
+ /**
9
+ * Time bucket granularity for the per-customer revenue trend. When omitted, the server picks a reasonable bucket from the window length.
10
+ */
11
+ export const GetProfitabilityBucketWidth = {
12
+ Hour: "hour",
13
+ Day: "day",
14
+ Week: "week",
15
+ } as const;
16
+ /**
17
+ * Time bucket granularity for the per-customer revenue trend. When omitted, the server picks a reasonable bucket from the window length.
18
+ */
19
+ export type GetProfitabilityBucketWidth = ClosedEnum<
20
+ typeof GetProfitabilityBucketWidth
21
+ >;
22
+
23
+ export type GetProfitabilityRequest = {
24
+ /**
25
+ * Merchant whose customers to summarize
26
+ */
27
+ merchantId: string;
28
+ /**
29
+ * Start of the time range (ISO 8601 format)
30
+ */
31
+ from: Date;
32
+ /**
33
+ * End of the time range (ISO 8601 format)
34
+ */
35
+ to: Date;
36
+ /**
37
+ * Number of top customers (by profit) to return individually. The rest are rolled into a single 'Other' row.
38
+ */
39
+ topN?: number | undefined;
40
+ /**
41
+ * ISO 4217 currency code to scope the summary. Defaults to the merchant's primary currency.
42
+ */
43
+ currency?: string | undefined;
44
+ /**
45
+ * Time bucket granularity for the per-customer revenue trend. When omitted, the server picks a reasonable bucket from the window length.
46
+ */
47
+ bucketWidth?: GetProfitabilityBucketWidth | undefined;
48
+ };
49
+
50
+ /** @internal */
51
+ export const GetProfitabilityBucketWidth$outboundSchema: z.ZodNativeEnum<
52
+ typeof GetProfitabilityBucketWidth
53
+ > = z.nativeEnum(GetProfitabilityBucketWidth);
54
+
55
+ /** @internal */
56
+ export type GetProfitabilityRequest$Outbound = {
57
+ merchantId: string;
58
+ from: string;
59
+ to: string;
60
+ topN: number;
61
+ currency?: string | undefined;
62
+ bucketWidth: string;
63
+ };
64
+
65
+ /** @internal */
66
+ export const GetProfitabilityRequest$outboundSchema: z.ZodType<
67
+ GetProfitabilityRequest$Outbound,
68
+ z.ZodTypeDef,
69
+ GetProfitabilityRequest
70
+ > = z.object({
71
+ merchantId: z.string(),
72
+ from: z.date().transform(v => v.toISOString()),
73
+ to: z.date().transform(v => v.toISOString()),
74
+ topN: z.number().int().default(10),
75
+ currency: z.string().optional(),
76
+ bucketWidth: GetProfitabilityBucketWidth$outboundSchema.default("day"),
77
+ });
78
+
79
+ export function getProfitabilityRequestToJSON(
80
+ getProfitabilityRequest: GetProfitabilityRequest,
81
+ ): string {
82
+ return JSON.stringify(
83
+ GetProfitabilityRequest$outboundSchema.parse(getProfitabilityRequest),
84
+ );
85
+ }
@@ -8,7 +8,7 @@ import { ClosedEnum } from "../../types/enums.js";
8
8
  /**
9
9
  * Time bucket granularity for trend data
10
10
  */
11
- export const BucketWidth = {
11
+ export const GetRevenueBucketWidth = {
12
12
  Hour: "hour",
13
13
  Day: "day",
14
14
  Week: "week",
@@ -16,7 +16,7 @@ export const BucketWidth = {
16
16
  /**
17
17
  * Time bucket granularity for trend data
18
18
  */
19
- export type BucketWidth = ClosedEnum<typeof BucketWidth>;
19
+ export type GetRevenueBucketWidth = ClosedEnum<typeof GetRevenueBucketWidth>;
20
20
 
21
21
  /**
22
22
  * Group invoice data by dimension. Allowed values: 'plan' (max 5 groups, top 4 + 'other' when exceeding), 'customer' (max 25 groups, top 24 + 'other' when exceeding, sorted by revenue descending), 'currency' (one entry per currency, primary currency first then alphabetical). Note: groupBy values are mutually exclusive — combining them returns a 400 error. When groupBy=currency is active, top-level netRevenue, invoices, and payments fields are omitted; currencyBreakdown is the sole data source.
@@ -43,7 +43,7 @@ export type GetRevenueRequest = {
43
43
  /**
44
44
  * Time bucket granularity for trend data
45
45
  */
46
- bucketWidth?: BucketWidth | undefined;
46
+ bucketWidth?: GetRevenueBucketWidth | undefined;
47
47
  /**
48
48
  * Filter by merchant ID. At least one of merchantId, subscriptionIds, or customerId must be provided.
49
49
  */
@@ -67,8 +67,9 @@ export type GetRevenueRequest = {
67
67
  };
68
68
 
69
69
  /** @internal */
70
- export const BucketWidth$outboundSchema: z.ZodNativeEnum<typeof BucketWidth> = z
71
- .nativeEnum(BucketWidth);
70
+ export const GetRevenueBucketWidth$outboundSchema: z.ZodNativeEnum<
71
+ typeof GetRevenueBucketWidth
72
+ > = z.nativeEnum(GetRevenueBucketWidth);
72
73
 
73
74
  /** @internal */
74
75
  export const GroupBy$outboundSchema: z.ZodNativeEnum<typeof GroupBy> = z
@@ -94,7 +95,7 @@ export const GetRevenueRequest$outboundSchema: z.ZodType<
94
95
  > = z.object({
95
96
  startTime: z.date().transform(v => v.toISOString()),
96
97
  endTime: z.date().transform(v => v.toISOString()),
97
- bucketWidth: BucketWidth$outboundSchema.default("day"),
98
+ bucketWidth: GetRevenueBucketWidth$outboundSchema.default("day"),
98
99
  merchantId: z.string().optional(),
99
100
  customerId: z.string().optional(),
100
101
  subscriptionIds: z.array(z.string()).optional(),
@@ -45,6 +45,7 @@ export * from "./getpayment.js";
45
45
  export * from "./getplan.js";
46
46
  export * from "./getprice.js";
47
47
  export * from "./getproduct.js";
48
+ export * from "./getprofitability.js";
48
49
  export * from "./getrevenue.js";
49
50
  export * from "./getsource.js";
50
51
  export * from "./getsourcerule.js";
@@ -64,6 +65,7 @@ export * from "./listfees.js";
64
65
  export * from "./listinvoices.js";
65
66
  export * from "./listlineitems.js";
66
67
  export * from "./listpayments.js";
68
+ export * from "./listpaymentsessions.js";
67
69
  export * from "./listplans.js";
68
70
  export * from "./listprices.js";
69
71
  export * from "./listproducts.js";
@@ -46,6 +46,10 @@ export type ListInvoicesRequest = {
46
46
  * Maximum number of invoices to return
47
47
  */
48
48
  limit?: number | undefined;
49
+ /**
50
+ * Number of invoices to skip for pagination
51
+ */
52
+ offset?: number | undefined;
49
53
  /**
50
54
  * Filter for invoices ready for processing (platform only)
51
55
  */
@@ -75,6 +79,10 @@ export type ListInvoicesObject = ClosedEnum<typeof ListInvoicesObject>;
75
79
  export type ListInvoicesResponse = {
76
80
  object: ListInvoicesObject;
77
81
  data: Array<models.Invoice>;
82
+ /**
83
+ * Offset-based pagination response.
84
+ */
85
+ pagination?: models.OffsetPagination | undefined;
78
86
  };
79
87
 
80
88
  /** @internal */
@@ -89,6 +97,7 @@ export const ListInvoicesStatus$outboundSchema: z.ZodNativeEnum<
89
97
  /** @internal */
90
98
  export type ListInvoicesRequest$Outbound = {
91
99
  limit: number;
100
+ offset: number;
92
101
  nextActionAt?: string | undefined;
93
102
  status?: string | undefined;
94
103
  subscriptionId?: string | undefined;
@@ -102,6 +111,7 @@ export const ListInvoicesRequest$outboundSchema: z.ZodType<
102
111
  ListInvoicesRequest
103
112
  > = z.object({
104
113
  limit: z.number().int().default(10),
114
+ offset: z.number().int().default(0),
105
115
  nextActionAt: NextActionAt$outboundSchema.optional(),
106
116
  status: ListInvoicesStatus$outboundSchema.optional(),
107
117
  subscriptionId: z.string().optional(),
@@ -129,6 +139,7 @@ export const ListInvoicesResponse$inboundSchema: z.ZodType<
129
139
  > = z.object({
130
140
  object: ListInvoicesObject$inboundSchema,
131
141
  data: z.array(models.Invoice$inboundSchema),
142
+ pagination: models.OffsetPagination$inboundSchema.optional(),
132
143
  });
133
144
 
134
145
  export function listInvoicesResponseFromJSON(