@polar-sh/sdk 0.19.0 → 0.19.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 (140) hide show
  1. package/README.md +9 -0
  2. package/docs/sdks/benefits/README.md +0 -1
  3. package/docs/sdks/customersessions/README.md +85 -0
  4. package/funcs/customerSessionsCreate.d.ts +16 -0
  5. package/funcs/customerSessionsCreate.d.ts.map +1 -0
  6. package/funcs/customerSessionsCreate.js +100 -0
  7. package/funcs/customerSessionsCreate.js.map +1 -0
  8. package/lib/config.d.ts +3 -3
  9. package/lib/config.js +3 -3
  10. package/models/components/benefitcreate.d.ts +4 -4
  11. package/models/components/benefitcreate.d.ts.map +1 -1
  12. package/models/components/benefitcreate.js +6 -6
  13. package/models/components/benefitcreate.js.map +1 -1
  14. package/models/components/benefitcustom.d.ts +1 -1
  15. package/models/components/benefitcustomcreate.d.ts +0 -5
  16. package/models/components/benefitcustomcreate.d.ts.map +1 -1
  17. package/models/components/benefitcustomcreate.js +0 -4
  18. package/models/components/benefitcustomcreate.js.map +1 -1
  19. package/models/components/benefitgithubrepositoryproperties.d.ts +5 -0
  20. package/models/components/benefitgithubrepositoryproperties.d.ts.map +1 -1
  21. package/models/components/benefitgithubrepositoryproperties.js +4 -0
  22. package/models/components/benefitgithubrepositoryproperties.js.map +1 -1
  23. package/models/components/checkout.d.ts +27 -0
  24. package/models/components/checkout.d.ts.map +1 -1
  25. package/models/components/checkout.js +28 -1
  26. package/models/components/checkout.js.map +1 -1
  27. package/models/components/checkoutlinkupdate.d.ts +0 -14
  28. package/models/components/checkoutlinkupdate.d.ts.map +1 -1
  29. package/models/components/checkoutlinkupdate.js.map +1 -1
  30. package/models/components/checkoutpricecreate.d.ts +41 -0
  31. package/models/components/checkoutpricecreate.d.ts.map +1 -1
  32. package/models/components/checkoutpricecreate.js +28 -1
  33. package/models/components/checkoutpricecreate.js.map +1 -1
  34. package/models/components/checkoutproductcreate.d.ts +41 -0
  35. package/models/components/checkoutproductcreate.d.ts.map +1 -1
  36. package/models/components/checkoutproductcreate.js +28 -1
  37. package/models/components/checkoutproductcreate.js.map +1 -1
  38. package/models/components/checkoutupdate.d.ts +38 -11
  39. package/models/components/checkoutupdate.d.ts.map +1 -1
  40. package/models/components/checkoutupdate.js +28 -1
  41. package/models/components/checkoutupdate.js.map +1 -1
  42. package/models/components/customer.d.ts +13 -13
  43. package/models/components/customer.d.ts.map +1 -1
  44. package/models/components/customer.js +16 -16
  45. package/models/components/customer.js.map +1 -1
  46. package/models/components/customersession.d.ts +57 -0
  47. package/models/components/customersession.d.ts.map +1 -0
  48. package/models/components/customersession.js +87 -0
  49. package/models/components/customersession.js.map +1 -0
  50. package/models/components/customersessioncreate.d.ts +35 -0
  51. package/models/components/customersessioncreate.d.ts.map +1 -0
  52. package/models/components/customersessioncreate.js +68 -0
  53. package/models/components/customersessioncreate.js.map +1 -0
  54. package/models/components/customfieldupdatecheckbox.d.ts +0 -14
  55. package/models/components/customfieldupdatecheckbox.d.ts.map +1 -1
  56. package/models/components/customfieldupdatecheckbox.js.map +1 -1
  57. package/models/components/customfieldupdatedate.d.ts +0 -14
  58. package/models/components/customfieldupdatedate.d.ts.map +1 -1
  59. package/models/components/customfieldupdatedate.js.map +1 -1
  60. package/models/components/customfieldupdatenumber.d.ts +0 -14
  61. package/models/components/customfieldupdatenumber.d.ts.map +1 -1
  62. package/models/components/customfieldupdatenumber.js.map +1 -1
  63. package/models/components/customfieldupdateselect.d.ts +0 -14
  64. package/models/components/customfieldupdateselect.d.ts.map +1 -1
  65. package/models/components/customfieldupdateselect.js.map +1 -1
  66. package/models/components/customfieldupdatetext.d.ts +0 -14
  67. package/models/components/customfieldupdatetext.d.ts.map +1 -1
  68. package/models/components/customfieldupdatetext.js.map +1 -1
  69. package/models/components/discountupdate.d.ts +0 -14
  70. package/models/components/discountupdate.d.ts.map +1 -1
  71. package/models/components/discountupdate.js.map +1 -1
  72. package/models/components/index.d.ts +2 -0
  73. package/models/components/index.d.ts.map +1 -1
  74. package/models/components/index.js +2 -0
  75. package/models/components/index.js.map +1 -1
  76. package/models/components/oauth2client.js +2 -2
  77. package/models/components/oauth2client.js.map +1 -1
  78. package/models/components/oauth2clientconfiguration.js +2 -2
  79. package/models/components/oauth2clientconfiguration.js.map +1 -1
  80. package/models/components/oauth2clientconfigurationupdate.js +2 -2
  81. package/models/components/oauth2clientconfigurationupdate.js.map +1 -1
  82. package/models/components/ordersubscription.d.ts +5 -0
  83. package/models/components/ordersubscription.d.ts.map +1 -1
  84. package/models/components/ordersubscription.js +4 -0
  85. package/models/components/ordersubscription.js.map +1 -1
  86. package/models/components/orderuser.d.ts +2 -0
  87. package/models/components/orderuser.d.ts.map +1 -1
  88. package/models/components/orderuser.js +4 -0
  89. package/models/components/orderuser.js.map +1 -1
  90. package/models/components/productupdate.d.ts +0 -14
  91. package/models/components/productupdate.d.ts.map +1 -1
  92. package/models/components/productupdate.js.map +1 -1
  93. package/models/components/scope.d.ts +3 -0
  94. package/models/components/scope.d.ts.map +1 -1
  95. package/models/components/scope.js +1 -0
  96. package/models/components/scope.js.map +1 -1
  97. package/models/components/subscriptionuser.d.ts +2 -0
  98. package/models/components/subscriptionuser.d.ts.map +1 -1
  99. package/models/components/subscriptionuser.js +4 -0
  100. package/models/components/subscriptionuser.js.map +1 -1
  101. package/package.json +1 -1
  102. package/sdk/customersessions.d.ts +12 -0
  103. package/sdk/customersessions.d.ts.map +1 -0
  104. package/sdk/customersessions.js +22 -0
  105. package/sdk/customersessions.js.map +1 -0
  106. package/sdk/sdk.d.ts +3 -0
  107. package/sdk/sdk.d.ts.map +1 -1
  108. package/sdk/sdk.js +5 -0
  109. package/sdk/sdk.js.map +1 -1
  110. package/src/funcs/customerSessionsCreate.ts +132 -0
  111. package/src/lib/config.ts +3 -3
  112. package/src/models/components/benefitcreate.ts +14 -14
  113. package/src/models/components/benefitcustom.ts +1 -1
  114. package/src/models/components/benefitcustomcreate.ts +0 -9
  115. package/src/models/components/benefitgithubrepositoryproperties.ts +9 -0
  116. package/src/models/components/checkout.ts +60 -0
  117. package/src/models/components/checkoutlinkupdate.ts +0 -14
  118. package/src/models/components/checkoutpricecreate.ts +82 -0
  119. package/src/models/components/checkoutproductcreate.ts +82 -0
  120. package/src/models/components/checkoutupdate.ts +79 -11
  121. package/src/models/components/customer.ts +21 -21
  122. package/src/models/components/customersession.ts +126 -0
  123. package/src/models/components/customersessioncreate.ts +81 -0
  124. package/src/models/components/customfieldupdatecheckbox.ts +0 -14
  125. package/src/models/components/customfieldupdatedate.ts +0 -14
  126. package/src/models/components/customfieldupdatenumber.ts +0 -14
  127. package/src/models/components/customfieldupdateselect.ts +0 -14
  128. package/src/models/components/customfieldupdatetext.ts +0 -14
  129. package/src/models/components/discountupdate.ts +0 -14
  130. package/src/models/components/index.ts +2 -0
  131. package/src/models/components/oauth2client.ts +2 -2
  132. package/src/models/components/oauth2clientconfiguration.ts +2 -2
  133. package/src/models/components/oauth2clientconfigurationupdate.ts +2 -2
  134. package/src/models/components/ordersubscription.ts +9 -0
  135. package/src/models/components/orderuser.ts +6 -0
  136. package/src/models/components/productupdate.ts +0 -14
  137. package/src/models/components/scope.ts +1 -0
  138. package/src/models/components/subscriptionuser.ts +6 -0
  139. package/src/sdk/customersessions.ts +27 -0
  140. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,132 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { PolarCore } from "../core.js";
6
+ import { encodeJSON } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { safeParse } from "../lib/schemas.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 * as components from "../models/components/index.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 { SDKError } from "../models/errors/sdkerror.js";
22
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
+ import { Result } from "../types/fp.js";
24
+
25
+ /**
26
+ * Create Customer Session
27
+ *
28
+ * @remarks
29
+ * Create a customer session.
30
+ */
31
+ export async function customerSessionsCreate(
32
+ client: PolarCore,
33
+ request: components.CustomerSessionCreate,
34
+ options?: RequestOptions,
35
+ ): Promise<
36
+ Result<
37
+ components.CustomerSession,
38
+ | errors.HTTPValidationError
39
+ | SDKError
40
+ | SDKValidationError
41
+ | UnexpectedClientError
42
+ | InvalidRequestError
43
+ | RequestAbortedError
44
+ | RequestTimeoutError
45
+ | ConnectionError
46
+ >
47
+ > {
48
+ const parsed = safeParse(
49
+ request,
50
+ (value) => components.CustomerSessionCreate$outboundSchema.parse(value),
51
+ "Input validation failed",
52
+ );
53
+ if (!parsed.ok) {
54
+ return parsed;
55
+ }
56
+ const payload = parsed.value;
57
+ const body = encodeJSON("body", payload, { explode: true });
58
+
59
+ const path = pathToFunc("/v1/customer-sessions/")();
60
+
61
+ const headers = new Headers({
62
+ "Content-Type": "application/json",
63
+ Accept: "application/json",
64
+ });
65
+
66
+ const secConfig = await extractSecurity(client._options.accessToken);
67
+ const securityInput = secConfig == null ? {} : { accessToken: secConfig };
68
+ const requestSecurity = resolveGlobalSecurity(securityInput);
69
+
70
+ const context = {
71
+ operationID: "customer-sessions:create",
72
+ oAuth2Scopes: [],
73
+
74
+ resolvedSecurity: requestSecurity,
75
+
76
+ securitySource: client._options.accessToken,
77
+ retryConfig: options?.retries
78
+ || client._options.retryConfig
79
+ || { strategy: "none" },
80
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
81
+ };
82
+
83
+ const requestRes = client._createRequest(context, {
84
+ security: requestSecurity,
85
+ method: "POST",
86
+ baseURL: options?.serverURL,
87
+ path: path,
88
+ headers: headers,
89
+ body: body,
90
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
91
+ }, options);
92
+ if (!requestRes.ok) {
93
+ return requestRes;
94
+ }
95
+ const req = requestRes.value;
96
+
97
+ const doResult = await client._do(req, {
98
+ context,
99
+ errorCodes: ["422", "4XX", "5XX"],
100
+ retryConfig: context.retryConfig,
101
+ retryCodes: context.retryCodes,
102
+ });
103
+ if (!doResult.ok) {
104
+ return doResult;
105
+ }
106
+ const response = doResult.value;
107
+
108
+ const responseFields = {
109
+ HttpMeta: { Response: response, Request: req },
110
+ };
111
+
112
+ const [result] = await M.match<
113
+ components.CustomerSession,
114
+ | errors.HTTPValidationError
115
+ | SDKError
116
+ | SDKValidationError
117
+ | UnexpectedClientError
118
+ | InvalidRequestError
119
+ | RequestAbortedError
120
+ | RequestTimeoutError
121
+ | ConnectionError
122
+ >(
123
+ M.json(201, components.CustomerSession$inboundSchema),
124
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
125
+ M.fail(["4XX", "5XX"]),
126
+ )(response, { extraFields: responseFields });
127
+ if (!result.ok) {
128
+ return result;
129
+ }
130
+
131
+ return result;
132
+ }
package/src/lib/config.ts CHANGED
@@ -60,7 +60,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
60
60
  export const SDK_METADATA = {
61
61
  language: "typescript",
62
62
  openapiDocVersion: "0.1.0",
63
- sdkVersion: "0.19.0",
64
- genVersion: "2.480.1",
65
- userAgent: "speakeasy-sdk/typescript 0.19.0 2.480.1 0.1.0 @polar-sh/sdk",
63
+ sdkVersion: "0.19.2",
64
+ genVersion: "2.481.0",
65
+ userAgent: "speakeasy-sdk/typescript 0.19.2 2.481.0 0.1.0 @polar-sh/sdk",
66
66
  } as const;
@@ -45,11 +45,11 @@ import {
45
45
 
46
46
  export type BenefitCreate =
47
47
  | (BenefitAdsCreate & { type: "ads" })
48
+ | (BenefitCustomCreate & { type: "custom" })
48
49
  | (BenefitDiscordCreate & { type: "discord" })
49
50
  | (BenefitDownloadablesCreate & { type: "downloadables" })
50
51
  | (BenefitGitHubRepositoryCreate & { type: "github_repository" })
51
- | (BenefitLicenseKeysCreate & { type: "license_keys" })
52
- | (BenefitCustomCreate & { type: "custom" });
52
+ | (BenefitLicenseKeysCreate & { type: "license_keys" });
53
53
 
54
54
  /** @internal */
55
55
  export const BenefitCreate$inboundSchema: z.ZodType<
@@ -60,6 +60,11 @@ export const BenefitCreate$inboundSchema: z.ZodType<
60
60
  BenefitAdsCreate$inboundSchema.and(
61
61
  z.object({ type: z.literal("ads") }).transform((v) => ({ type: v.type })),
62
62
  ),
63
+ BenefitCustomCreate$inboundSchema.and(
64
+ z.object({ type: z.literal("custom") }).transform((v) => ({
65
+ type: v.type,
66
+ })),
67
+ ),
63
68
  BenefitDiscordCreate$inboundSchema.and(
64
69
  z.object({ type: z.literal("discord") }).transform((v) => ({
65
70
  type: v.type,
@@ -80,21 +85,16 @@ export const BenefitCreate$inboundSchema: z.ZodType<
80
85
  type: v.type,
81
86
  })),
82
87
  ),
83
- BenefitCustomCreate$inboundSchema.and(
84
- z.object({ type: z.literal("custom") }).transform((v) => ({
85
- type: v.type,
86
- })),
87
- ),
88
88
  ]);
89
89
 
90
90
  /** @internal */
91
91
  export type BenefitCreate$Outbound =
92
92
  | (BenefitAdsCreate$Outbound & { type: "ads" })
93
+ | (BenefitCustomCreate$Outbound & { type: "custom" })
93
94
  | (BenefitDiscordCreate$Outbound & { type: "discord" })
94
95
  | (BenefitDownloadablesCreate$Outbound & { type: "downloadables" })
95
96
  | (BenefitGitHubRepositoryCreate$Outbound & { type: "github_repository" })
96
- | (BenefitLicenseKeysCreate$Outbound & { type: "license_keys" })
97
- | (BenefitCustomCreate$Outbound & { type: "custom" });
97
+ | (BenefitLicenseKeysCreate$Outbound & { type: "license_keys" });
98
98
 
99
99
  /** @internal */
100
100
  export const BenefitCreate$outboundSchema: z.ZodType<
@@ -105,6 +105,11 @@ export const BenefitCreate$outboundSchema: z.ZodType<
105
105
  BenefitAdsCreate$outboundSchema.and(
106
106
  z.object({ type: z.literal("ads") }).transform((v) => ({ type: v.type })),
107
107
  ),
108
+ BenefitCustomCreate$outboundSchema.and(
109
+ z.object({ type: z.literal("custom") }).transform((v) => ({
110
+ type: v.type,
111
+ })),
112
+ ),
108
113
  BenefitDiscordCreate$outboundSchema.and(
109
114
  z.object({ type: z.literal("discord") }).transform((v) => ({
110
115
  type: v.type,
@@ -125,11 +130,6 @@ export const BenefitCreate$outboundSchema: z.ZodType<
125
130
  type: v.type,
126
131
  })),
127
132
  ),
128
- BenefitCustomCreate$outboundSchema.and(
129
- z.object({ type: z.literal("custom") }).transform((v) => ({
130
- type: v.type,
131
- })),
132
- ),
133
133
  ]);
134
134
 
135
135
  /**
@@ -62,7 +62,7 @@ export type BenefitCustom = {
62
62
  */
63
63
  properties: BenefitCustomProperties;
64
64
  /**
65
- * Whether the benefit is taxable.
65
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
66
66
  */
67
67
  isTaxApplicable: boolean;
68
68
  };
@@ -35,10 +35,6 @@ export type BenefitCustomCreate = {
35
35
  * The ID of the organization owning the benefit. **Required unless you use an organization token.**
36
36
  */
37
37
  organizationId?: string | null | undefined;
38
- /**
39
- * Whether the benefit is taxable.
40
- */
41
- isTaxApplicable: boolean;
42
38
  /**
43
39
  * Properties for creating a benefit of type `custom`.
44
40
  */
@@ -75,12 +71,10 @@ export const BenefitCustomCreate$inboundSchema: z.ZodType<
75
71
  type: z.literal("custom").optional(),
76
72
  description: z.string(),
77
73
  organization_id: z.nullable(z.string()).optional(),
78
- is_tax_applicable: z.boolean(),
79
74
  properties: BenefitCustomCreateProperties$inboundSchema,
80
75
  }).transform((v) => {
81
76
  return remap$(v, {
82
77
  "organization_id": "organizationId",
83
- "is_tax_applicable": "isTaxApplicable",
84
78
  });
85
79
  });
86
80
 
@@ -89,7 +83,6 @@ export type BenefitCustomCreate$Outbound = {
89
83
  type: "custom";
90
84
  description: string;
91
85
  organization_id?: string | null | undefined;
92
- is_tax_applicable: boolean;
93
86
  properties: BenefitCustomCreateProperties$Outbound;
94
87
  };
95
88
 
@@ -102,12 +95,10 @@ export const BenefitCustomCreate$outboundSchema: z.ZodType<
102
95
  type: z.literal("custom").default("custom"),
103
96
  description: z.string(),
104
97
  organizationId: z.nullable(z.string()).optional(),
105
- isTaxApplicable: z.boolean(),
106
98
  properties: BenefitCustomCreateProperties$outboundSchema,
107
99
  }).transform((v) => {
108
100
  return remap$(v, {
109
101
  organizationId: "organization_id",
110
- isTaxApplicable: "is_tax_applicable",
111
102
  });
112
103
  });
113
104
 
@@ -40,6 +40,10 @@ export type BenefitGitHubRepositoryProperties = {
40
40
  * The permission level to grant. Read more about roles and their permissions on [GitHub documentation](https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization#permissions-for-each-role).
41
41
  */
42
42
  permission: Permission;
43
+ /**
44
+ * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
45
+ */
46
+ repositoryId?: string | null | undefined;
43
47
  };
44
48
 
45
49
  /** @internal */
@@ -70,10 +74,12 @@ export const BenefitGitHubRepositoryProperties$inboundSchema: z.ZodType<
70
74
  repository_owner: z.string(),
71
75
  repository_name: z.string(),
72
76
  permission: Permission$inboundSchema,
77
+ repository_id: z.nullable(z.string()).optional(),
73
78
  }).transform((v) => {
74
79
  return remap$(v, {
75
80
  "repository_owner": "repositoryOwner",
76
81
  "repository_name": "repositoryName",
82
+ "repository_id": "repositoryId",
77
83
  });
78
84
  });
79
85
 
@@ -82,6 +88,7 @@ export type BenefitGitHubRepositoryProperties$Outbound = {
82
88
  repository_owner: string;
83
89
  repository_name: string;
84
90
  permission: string;
91
+ repository_id?: string | null | undefined;
85
92
  };
86
93
 
87
94
  /** @internal */
@@ -93,10 +100,12 @@ export const BenefitGitHubRepositoryProperties$outboundSchema: z.ZodType<
93
100
  repositoryOwner: z.string(),
94
101
  repositoryName: z.string(),
95
102
  permission: Permission$outboundSchema,
103
+ repositoryId: z.nullable(z.string()).optional(),
96
104
  }).transform((v) => {
97
105
  return remap$(v, {
98
106
  repositoryOwner: "repository_owner",
99
107
  repositoryName: "repository_name",
108
+ repositoryId: "repository_id",
100
109
  });
101
110
  });
102
111
 
@@ -76,6 +76,8 @@ export type CheckoutDiscount =
76
76
  | CheckoutDiscountPercentageRepeatDuration
77
77
  | CheckoutDiscountFixedRepeatDuration;
78
78
 
79
+ export type CustomerMetadata = string | number | boolean;
80
+
79
81
  /**
80
82
  * Checkout session data retrieved using an access token.
81
83
  */
@@ -192,6 +194,7 @@ export type Checkout = {
192
194
  | null;
193
195
  subscriptionId: string | null;
194
196
  attachedCustomFields: Array<AttachedCustomField>;
197
+ customerMetadata: { [k: string]: string | number | boolean };
195
198
  };
196
199
 
197
200
  /** @internal */
@@ -400,6 +403,54 @@ export function checkoutDiscountFromJSON(
400
403
  );
401
404
  }
402
405
 
406
+ /** @internal */
407
+ export const CustomerMetadata$inboundSchema: z.ZodType<
408
+ CustomerMetadata,
409
+ z.ZodTypeDef,
410
+ unknown
411
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
412
+
413
+ /** @internal */
414
+ export type CustomerMetadata$Outbound = string | number | boolean;
415
+
416
+ /** @internal */
417
+ export const CustomerMetadata$outboundSchema: z.ZodType<
418
+ CustomerMetadata$Outbound,
419
+ z.ZodTypeDef,
420
+ CustomerMetadata
421
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
422
+
423
+ /**
424
+ * @internal
425
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
426
+ */
427
+ export namespace CustomerMetadata$ {
428
+ /** @deprecated use `CustomerMetadata$inboundSchema` instead. */
429
+ export const inboundSchema = CustomerMetadata$inboundSchema;
430
+ /** @deprecated use `CustomerMetadata$outboundSchema` instead. */
431
+ export const outboundSchema = CustomerMetadata$outboundSchema;
432
+ /** @deprecated use `CustomerMetadata$Outbound` instead. */
433
+ export type Outbound = CustomerMetadata$Outbound;
434
+ }
435
+
436
+ export function customerMetadataToJSON(
437
+ customerMetadata: CustomerMetadata,
438
+ ): string {
439
+ return JSON.stringify(
440
+ CustomerMetadata$outboundSchema.parse(customerMetadata),
441
+ );
442
+ }
443
+
444
+ export function customerMetadataFromJSON(
445
+ jsonString: string,
446
+ ): SafeParseResult<CustomerMetadata, SDKValidationError> {
447
+ return safeParse(
448
+ jsonString,
449
+ (x) => CustomerMetadata$inboundSchema.parse(JSON.parse(x)),
450
+ `Failed to parse 'CustomerMetadata' from JSON`,
451
+ );
452
+ }
453
+
403
454
  /** @internal */
404
455
  export const Checkout$inboundSchema: z.ZodType<
405
456
  Checkout,
@@ -456,6 +507,9 @@ export const Checkout$inboundSchema: z.ZodType<
456
507
  ),
457
508
  subscription_id: z.nullable(z.string()),
458
509
  attached_custom_fields: z.array(AttachedCustomField$inboundSchema),
510
+ customer_metadata: z.record(
511
+ z.union([z.string(), z.number().int(), z.boolean()]),
512
+ ),
459
513
  }).transform((v) => {
460
514
  return remap$(v, {
461
515
  "created_at": "createdAt",
@@ -488,6 +542,7 @@ export const Checkout$inboundSchema: z.ZodType<
488
542
  "product_price": "productPrice",
489
543
  "subscription_id": "subscriptionId",
490
544
  "attached_custom_fields": "attachedCustomFields",
545
+ "customer_metadata": "customerMetadata",
491
546
  });
492
547
  });
493
548
 
@@ -536,6 +591,7 @@ export type Checkout$Outbound = {
536
591
  | null;
537
592
  subscription_id: string | null;
538
593
  attached_custom_fields: Array<AttachedCustomField$Outbound>;
594
+ customer_metadata: { [k: string]: string | number | boolean };
539
595
  };
540
596
 
541
597
  /** @internal */
@@ -592,6 +648,9 @@ export const Checkout$outboundSchema: z.ZodType<
592
648
  ),
593
649
  subscriptionId: z.nullable(z.string()),
594
650
  attachedCustomFields: z.array(AttachedCustomField$outboundSchema),
651
+ customerMetadata: z.record(
652
+ z.union([z.string(), z.number().int(), z.boolean()]),
653
+ ),
595
654
  }).transform((v) => {
596
655
  return remap$(v, {
597
656
  createdAt: "created_at",
@@ -624,6 +683,7 @@ export const Checkout$outboundSchema: z.ZodType<
624
683
  productPrice: "product_price",
625
684
  subscriptionId: "subscription_id",
626
685
  attachedCustomFields: "attached_custom_fields",
686
+ customerMetadata: "customer_metadata",
627
687
  });
628
688
  });
629
689
 
@@ -14,20 +14,6 @@ export type CheckoutLinkUpdateMetadata = string | number | boolean;
14
14
  * Schema to update an existing checkout link.
15
15
  */
16
16
  export type CheckoutLinkUpdate = {
17
- /**
18
- * Key-value object allowing you to store additional information.
19
- *
20
- * @remarks
21
- *
22
- * The key must be a string with a maximum length of **40 characters**.
23
- * The value must be either:
24
- *
25
- * * A string with a maximum length of **500 characters**
26
- * * An integer
27
- * * A boolean
28
- *
29
- * You can store up to **50 key-value pairs**.
30
- */
31
17
  metadata?: { [k: string]: string | number | boolean } | null | undefined;
32
18
  label?: string | null | undefined;
33
19
  /**
@@ -35,6 +35,8 @@ export type CheckoutPriceCreatePaymentProcessor = ClosedEnum<
35
35
  typeof CheckoutPriceCreatePaymentProcessor
36
36
  >;
37
37
 
38
+ export type CheckoutPriceCreateCustomerMetadata = string | number | boolean;
39
+
38
40
  /**
39
41
  * Create a new checkout session from a product price.
40
42
  *
@@ -85,6 +87,21 @@ export type CheckoutPriceCreate = {
85
87
  customerIpAddress?: string | null | undefined;
86
88
  customerBillingAddress?: Address | null | undefined;
87
89
  customerTaxId?: string | null | undefined;
90
+ /**
91
+ * Key-value object allowing you to store additional information that'll be copied to the created customer.
92
+ *
93
+ * @remarks
94
+ *
95
+ * The key must be a string with a maximum length of **40 characters**.
96
+ * The value must be either:
97
+ *
98
+ * * A string with a maximum length of **500 characters**
99
+ * * An integer
100
+ * * A boolean
101
+ *
102
+ * You can store up to **50 key-value pairs**.
103
+ */
104
+ customerMetadata?: { [k: string]: string | number | boolean } | undefined;
88
105
  /**
89
106
  * ID of a subscription to upgrade. It must be on a free pricing. If checkout is successful, metadata set on this checkout will be copied to the subscription, and existing keys will be overwritten.
90
107
  */
@@ -228,6 +245,62 @@ export namespace CheckoutPriceCreatePaymentProcessor$ {
228
245
  CheckoutPriceCreatePaymentProcessor$outboundSchema;
229
246
  }
230
247
 
248
+ /** @internal */
249
+ export const CheckoutPriceCreateCustomerMetadata$inboundSchema: z.ZodType<
250
+ CheckoutPriceCreateCustomerMetadata,
251
+ z.ZodTypeDef,
252
+ unknown
253
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
254
+
255
+ /** @internal */
256
+ export type CheckoutPriceCreateCustomerMetadata$Outbound =
257
+ | string
258
+ | number
259
+ | boolean;
260
+
261
+ /** @internal */
262
+ export const CheckoutPriceCreateCustomerMetadata$outboundSchema: z.ZodType<
263
+ CheckoutPriceCreateCustomerMetadata$Outbound,
264
+ z.ZodTypeDef,
265
+ CheckoutPriceCreateCustomerMetadata
266
+ > = z.union([z.string(), z.number().int(), z.boolean()]);
267
+
268
+ /**
269
+ * @internal
270
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
271
+ */
272
+ export namespace CheckoutPriceCreateCustomerMetadata$ {
273
+ /** @deprecated use `CheckoutPriceCreateCustomerMetadata$inboundSchema` instead. */
274
+ export const inboundSchema =
275
+ CheckoutPriceCreateCustomerMetadata$inboundSchema;
276
+ /** @deprecated use `CheckoutPriceCreateCustomerMetadata$outboundSchema` instead. */
277
+ export const outboundSchema =
278
+ CheckoutPriceCreateCustomerMetadata$outboundSchema;
279
+ /** @deprecated use `CheckoutPriceCreateCustomerMetadata$Outbound` instead. */
280
+ export type Outbound = CheckoutPriceCreateCustomerMetadata$Outbound;
281
+ }
282
+
283
+ export function checkoutPriceCreateCustomerMetadataToJSON(
284
+ checkoutPriceCreateCustomerMetadata: CheckoutPriceCreateCustomerMetadata,
285
+ ): string {
286
+ return JSON.stringify(
287
+ CheckoutPriceCreateCustomerMetadata$outboundSchema.parse(
288
+ checkoutPriceCreateCustomerMetadata,
289
+ ),
290
+ );
291
+ }
292
+
293
+ export function checkoutPriceCreateCustomerMetadataFromJSON(
294
+ jsonString: string,
295
+ ): SafeParseResult<CheckoutPriceCreateCustomerMetadata, SDKValidationError> {
296
+ return safeParse(
297
+ jsonString,
298
+ (x) =>
299
+ CheckoutPriceCreateCustomerMetadata$inboundSchema.parse(JSON.parse(x)),
300
+ `Failed to parse 'CheckoutPriceCreateCustomerMetadata' from JSON`,
301
+ );
302
+ }
303
+
231
304
  /** @internal */
232
305
  export const CheckoutPriceCreate$inboundSchema: z.ZodType<
233
306
  CheckoutPriceCreate,
@@ -249,6 +322,9 @@ export const CheckoutPriceCreate$inboundSchema: z.ZodType<
249
322
  customer_ip_address: z.nullable(z.string()).optional(),
250
323
  customer_billing_address: z.nullable(Address$inboundSchema).optional(),
251
324
  customer_tax_id: z.nullable(z.string()).optional(),
325
+ customer_metadata: z.record(
326
+ z.union([z.string(), z.number().int(), z.boolean()]),
327
+ ).optional(),
252
328
  subscription_id: z.nullable(z.string()).optional(),
253
329
  success_url: z.nullable(z.string()).optional(),
254
330
  embed_origin: z.nullable(z.string()).optional(),
@@ -265,6 +341,7 @@ export const CheckoutPriceCreate$inboundSchema: z.ZodType<
265
341
  "customer_ip_address": "customerIpAddress",
266
342
  "customer_billing_address": "customerBillingAddress",
267
343
  "customer_tax_id": "customerTaxId",
344
+ "customer_metadata": "customerMetadata",
268
345
  "subscription_id": "subscriptionId",
269
346
  "success_url": "successUrl",
270
347
  "embed_origin": "embedOrigin",
@@ -286,6 +363,7 @@ export type CheckoutPriceCreate$Outbound = {
286
363
  customer_ip_address?: string | null | undefined;
287
364
  customer_billing_address?: Address$Outbound | null | undefined;
288
365
  customer_tax_id?: string | null | undefined;
366
+ customer_metadata?: { [k: string]: string | number | boolean } | undefined;
289
367
  subscription_id?: string | null | undefined;
290
368
  success_url?: string | null | undefined;
291
369
  embed_origin?: string | null | undefined;
@@ -313,6 +391,9 @@ export const CheckoutPriceCreate$outboundSchema: z.ZodType<
313
391
  customerIpAddress: z.nullable(z.string()).optional(),
314
392
  customerBillingAddress: z.nullable(Address$outboundSchema).optional(),
315
393
  customerTaxId: z.nullable(z.string()).optional(),
394
+ customerMetadata: z.record(
395
+ z.union([z.string(), z.number().int(), z.boolean()]),
396
+ ).optional(),
316
397
  subscriptionId: z.nullable(z.string()).optional(),
317
398
  successUrl: z.nullable(z.string()).optional(),
318
399
  embedOrigin: z.nullable(z.string()).optional(),
@@ -329,6 +410,7 @@ export const CheckoutPriceCreate$outboundSchema: z.ZodType<
329
410
  customerIpAddress: "customer_ip_address",
330
411
  customerBillingAddress: "customer_billing_address",
331
412
  customerTaxId: "customer_tax_id",
413
+ customerMetadata: "customer_metadata",
332
414
  subscriptionId: "subscription_id",
333
415
  successUrl: "success_url",
334
416
  embedOrigin: "embed_origin",