@polar-sh/sdk 1.0.0-alpha.12 → 1.0.0-alpha.13
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.
- package/README.md +4 -2
- package/dist/2026-04/index.d.cts +36 -36
- package/dist/2026-04/index.d.mts +36 -36
- package/dist/2026-04/services/benefit_grants.cjs +3 -3
- package/dist/2026-04/services/benefit_grants.cjs.map +1 -1
- package/dist/2026-04/services/benefit_grants.d.cts +3 -3
- package/dist/2026-04/services/benefit_grants.d.mts +3 -3
- package/dist/2026-04/services/benefit_grants.mjs +3 -3
- package/dist/2026-04/services/benefit_grants.mjs.map +1 -1
- package/dist/2026-04/services/benefits.cjs +6 -6
- package/dist/2026-04/services/benefits.cjs.map +1 -1
- package/dist/2026-04/services/benefits.d.cts +5 -5
- package/dist/2026-04/services/benefits.d.mts +5 -5
- package/dist/2026-04/services/benefits.mjs +5 -5
- package/dist/2026-04/services/benefits.mjs.map +1 -1
- package/dist/2026-04/services/checkout_links.cjs +3 -3
- package/dist/2026-04/services/checkout_links.cjs.map +1 -1
- package/dist/2026-04/services/checkout_links.d.cts +3 -3
- package/dist/2026-04/services/checkout_links.d.mts +3 -3
- package/dist/2026-04/services/checkout_links.mjs +3 -3
- package/dist/2026-04/services/checkout_links.mjs.map +1 -1
- package/dist/2026-04/services/checkouts.cjs +3 -3
- package/dist/2026-04/services/checkouts.cjs.map +1 -1
- package/dist/2026-04/services/checkouts.d.cts +3 -3
- package/dist/2026-04/services/checkouts.d.mts +3 -3
- package/dist/2026-04/services/checkouts.mjs +3 -3
- package/dist/2026-04/services/checkouts.mjs.map +1 -1
- package/dist/2026-04/services/custom_fields.cjs +3 -3
- package/dist/2026-04/services/custom_fields.cjs.map +1 -1
- package/dist/2026-04/services/custom_fields.d.cts +3 -3
- package/dist/2026-04/services/custom_fields.d.mts +3 -3
- package/dist/2026-04/services/custom_fields.mjs +3 -3
- package/dist/2026-04/services/custom_fields.mjs.map +1 -1
- package/dist/2026-04/services/customer_meters.cjs +3 -3
- package/dist/2026-04/services/customer_meters.cjs.map +1 -1
- package/dist/2026-04/services/customer_meters.d.cts +3 -3
- package/dist/2026-04/services/customer_meters.d.mts +3 -3
- package/dist/2026-04/services/customer_meters.mjs +3 -3
- package/dist/2026-04/services/customer_meters.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/benefit_grants.cjs +3 -3
- package/dist/2026-04/services/customer_portal/benefit_grants.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/benefit_grants.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/benefit_grants.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/benefit_grants.mjs +3 -3
- package/dist/2026-04/services/customer_portal/benefit_grants.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/customer_meters.cjs +3 -3
- package/dist/2026-04/services/customer_portal/customer_meters.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/customer_meters.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/customer_meters.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/customer_meters.mjs +3 -3
- package/dist/2026-04/services/customer_portal/customer_meters.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/customers.cjs +3 -3
- package/dist/2026-04/services/customer_portal/customers.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/customers.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/customers.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/customers.mjs +3 -3
- package/dist/2026-04/services/customer_portal/customers.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/downloadables.cjs +3 -3
- package/dist/2026-04/services/customer_portal/downloadables.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/downloadables.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/downloadables.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/downloadables.mjs +3 -3
- package/dist/2026-04/services/customer_portal/downloadables.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/index.d.cts +10 -10
- package/dist/2026-04/services/customer_portal/index.d.mts +10 -10
- package/dist/2026-04/services/customer_portal/license_keys.cjs +3 -3
- package/dist/2026-04/services/customer_portal/license_keys.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/license_keys.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/license_keys.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/license_keys.mjs +3 -3
- package/dist/2026-04/services/customer_portal/license_keys.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/members.cjs +3 -3
- package/dist/2026-04/services/customer_portal/members.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/members.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/members.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/members.mjs +3 -3
- package/dist/2026-04/services/customer_portal/members.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/orders.cjs +3 -3
- package/dist/2026-04/services/customer_portal/orders.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/orders.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/orders.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/orders.mjs +3 -3
- package/dist/2026-04/services/customer_portal/orders.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/seats.cjs +3 -3
- package/dist/2026-04/services/customer_portal/seats.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/seats.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/seats.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/seats.mjs +3 -3
- package/dist/2026-04/services/customer_portal/seats.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/subscriptions.cjs +3 -3
- package/dist/2026-04/services/customer_portal/subscriptions.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/subscriptions.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/subscriptions.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/subscriptions.mjs +3 -3
- package/dist/2026-04/services/customer_portal/subscriptions.mjs.map +1 -1
- package/dist/2026-04/services/customer_portal/wallets.cjs +3 -3
- package/dist/2026-04/services/customer_portal/wallets.cjs.map +1 -1
- package/dist/2026-04/services/customer_portal/wallets.d.cts +3 -3
- package/dist/2026-04/services/customer_portal/wallets.d.mts +3 -3
- package/dist/2026-04/services/customer_portal/wallets.mjs +3 -3
- package/dist/2026-04/services/customer_portal/wallets.mjs.map +1 -1
- package/dist/2026-04/services/customers/index.cjs +9 -9
- package/dist/2026-04/services/customers/index.cjs.map +1 -1
- package/dist/2026-04/services/customers/index.d.cts +7 -7
- package/dist/2026-04/services/customers/index.d.mts +7 -7
- package/dist/2026-04/services/customers/index.mjs +7 -7
- package/dist/2026-04/services/customers/index.mjs.map +1 -1
- package/dist/2026-04/services/discounts.cjs +3 -3
- package/dist/2026-04/services/discounts.cjs.map +1 -1
- package/dist/2026-04/services/discounts.d.cts +3 -3
- package/dist/2026-04/services/discounts.d.mts +3 -3
- package/dist/2026-04/services/discounts.mjs +3 -3
- package/dist/2026-04/services/discounts.mjs.map +1 -1
- package/dist/2026-04/services/disputes.cjs +3 -3
- package/dist/2026-04/services/disputes.cjs.map +1 -1
- package/dist/2026-04/services/disputes.d.cts +3 -3
- package/dist/2026-04/services/disputes.d.mts +3 -3
- package/dist/2026-04/services/disputes.mjs +3 -3
- package/dist/2026-04/services/disputes.mjs.map +1 -1
- package/dist/2026-04/services/event_types.cjs +3 -3
- package/dist/2026-04/services/event_types.cjs.map +1 -1
- package/dist/2026-04/services/event_types.d.cts +3 -3
- package/dist/2026-04/services/event_types.d.mts +3 -3
- package/dist/2026-04/services/event_types.mjs +3 -3
- package/dist/2026-04/services/event_types.mjs.map +1 -1
- package/dist/2026-04/services/events.cjs +3 -3
- package/dist/2026-04/services/events.cjs.map +1 -1
- package/dist/2026-04/services/events.d.cts +3 -3
- package/dist/2026-04/services/events.d.mts +3 -3
- package/dist/2026-04/services/events.mjs +3 -3
- package/dist/2026-04/services/events.mjs.map +1 -1
- package/dist/2026-04/services/files.cjs +3 -3
- package/dist/2026-04/services/files.cjs.map +1 -1
- package/dist/2026-04/services/files.d.cts +3 -3
- package/dist/2026-04/services/files.d.mts +3 -3
- package/dist/2026-04/services/files.mjs +3 -3
- package/dist/2026-04/services/files.mjs.map +1 -1
- package/dist/2026-04/services/license_keys.cjs +3 -3
- package/dist/2026-04/services/license_keys.cjs.map +1 -1
- package/dist/2026-04/services/license_keys.d.cts +3 -3
- package/dist/2026-04/services/license_keys.d.mts +3 -3
- package/dist/2026-04/services/license_keys.mjs +3 -3
- package/dist/2026-04/services/license_keys.mjs.map +1 -1
- package/dist/2026-04/services/members.cjs +3 -3
- package/dist/2026-04/services/members.cjs.map +1 -1
- package/dist/2026-04/services/members.d.cts +3 -3
- package/dist/2026-04/services/members.d.mts +3 -3
- package/dist/2026-04/services/members.mjs +3 -3
- package/dist/2026-04/services/members.mjs.map +1 -1
- package/dist/2026-04/services/meters.cjs +3 -3
- package/dist/2026-04/services/meters.cjs.map +1 -1
- package/dist/2026-04/services/meters.d.cts +3 -3
- package/dist/2026-04/services/meters.d.mts +3 -3
- package/dist/2026-04/services/meters.mjs +3 -3
- package/dist/2026-04/services/meters.mjs.map +1 -1
- package/dist/2026-04/services/orders.cjs +3 -3
- package/dist/2026-04/services/orders.cjs.map +1 -1
- package/dist/2026-04/services/orders.d.cts +3 -3
- package/dist/2026-04/services/orders.d.mts +3 -3
- package/dist/2026-04/services/orders.mjs +3 -3
- package/dist/2026-04/services/orders.mjs.map +1 -1
- package/dist/2026-04/services/organizations.cjs +3 -3
- package/dist/2026-04/services/organizations.cjs.map +1 -1
- package/dist/2026-04/services/organizations.d.cts +3 -3
- package/dist/2026-04/services/organizations.d.mts +3 -3
- package/dist/2026-04/services/organizations.mjs +3 -3
- package/dist/2026-04/services/organizations.mjs.map +1 -1
- package/dist/2026-04/services/payments.cjs +3 -3
- package/dist/2026-04/services/payments.cjs.map +1 -1
- package/dist/2026-04/services/payments.d.cts +3 -3
- package/dist/2026-04/services/payments.d.mts +3 -3
- package/dist/2026-04/services/payments.mjs +3 -3
- package/dist/2026-04/services/payments.mjs.map +1 -1
- package/dist/2026-04/services/products.cjs +3 -3
- package/dist/2026-04/services/products.cjs.map +1 -1
- package/dist/2026-04/services/products.d.cts +3 -3
- package/dist/2026-04/services/products.d.mts +3 -3
- package/dist/2026-04/services/products.mjs +3 -3
- package/dist/2026-04/services/products.mjs.map +1 -1
- package/dist/2026-04/services/refunds.cjs +3 -3
- package/dist/2026-04/services/refunds.cjs.map +1 -1
- package/dist/2026-04/services/refunds.d.cts +3 -3
- package/dist/2026-04/services/refunds.d.mts +3 -3
- package/dist/2026-04/services/refunds.mjs +3 -3
- package/dist/2026-04/services/refunds.mjs.map +1 -1
- package/dist/2026-04/services/subscriptions.cjs +3 -3
- package/dist/2026-04/services/subscriptions.cjs.map +1 -1
- package/dist/2026-04/services/subscriptions.d.cts +3 -3
- package/dist/2026-04/services/subscriptions.d.mts +3 -3
- package/dist/2026-04/services/subscriptions.mjs +3 -3
- package/dist/2026-04/services/subscriptions.mjs.map +1 -1
- package/dist/2026-04/services/webhooks.cjs +6 -6
- package/dist/2026-04/services/webhooks.cjs.map +1 -1
- package/dist/2026-04/services/webhooks.d.cts +5 -5
- package/dist/2026-04/services/webhooks.d.mts +5 -5
- package/dist/2026-04/services/webhooks.mjs +5 -5
- package/dist/2026-04/services/webhooks.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ declare const listCustomers: (client: ClientBase) => (query?: {
|
|
|
23
23
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
24
24
|
* @throws {HTTPValidationError} Validation Error
|
|
25
25
|
*/
|
|
26
|
-
declare const
|
|
26
|
+
declare const iterListCustomers: (client: ClientBase) => (query?: {
|
|
27
27
|
organization_id?: string | string[] | null;
|
|
28
28
|
email?: string | null;
|
|
29
29
|
query?: string | null;
|
|
@@ -67,7 +67,7 @@ declare const listPaymentMethodsCustomers: (client: ClientBase) => (id: string,
|
|
|
67
67
|
* @throws {ResourceNotFound} Customer not found.
|
|
68
68
|
* @throws {HTTPValidationError} Validation Error
|
|
69
69
|
*/
|
|
70
|
-
declare const
|
|
70
|
+
declare const iterListPaymentMethodsCustomers: (client: ClientBase) => (id: string, query?: {
|
|
71
71
|
page?: number;
|
|
72
72
|
limit?: number;
|
|
73
73
|
}) => AsyncGenerator<PaymentMethod>;
|
|
@@ -89,7 +89,7 @@ declare const listPaymentMethodsExternalCustomers: (client: ClientBase) => (exte
|
|
|
89
89
|
* @throws {ResourceNotFound} Customer not found.
|
|
90
90
|
* @throws {HTTPValidationError} Validation Error
|
|
91
91
|
*/
|
|
92
|
-
declare const
|
|
92
|
+
declare const iterListPaymentMethodsExternalCustomers: (client: ClientBase) => (external_id: string, query?: {
|
|
93
93
|
page?: number;
|
|
94
94
|
limit?: number;
|
|
95
95
|
}) => AsyncGenerator<PaymentMethod>;
|
|
@@ -128,7 +128,7 @@ declare function createCustomersService(client: ClientBase): {
|
|
|
128
128
|
page?: number;
|
|
129
129
|
limit?: number;
|
|
130
130
|
}) => Promise<ListResourcePaymentMethod>;
|
|
131
|
-
|
|
131
|
+
iterList: (query?: {
|
|
132
132
|
organization_id?: string | string[] | null;
|
|
133
133
|
email?: string | null;
|
|
134
134
|
query?: string | null;
|
|
@@ -138,11 +138,11 @@ declare function createCustomersService(client: ClientBase): {
|
|
|
138
138
|
sorting?: CustomerSortProperty[] | null;
|
|
139
139
|
metadata?: MetadataQuery;
|
|
140
140
|
}) => AsyncGenerator<Customer>;
|
|
141
|
-
|
|
141
|
+
iterListPaymentMethods: (id: string, query?: {
|
|
142
142
|
page?: number;
|
|
143
143
|
limit?: number;
|
|
144
144
|
}) => AsyncGenerator<PaymentMethod>;
|
|
145
|
-
|
|
145
|
+
iterListPaymentMethodsExternal: (external_id: string, query?: {
|
|
146
146
|
page?: number;
|
|
147
147
|
limit?: number;
|
|
148
148
|
}) => AsyncGenerator<PaymentMethod>;
|
|
@@ -159,5 +159,5 @@ declare function createCustomersService(client: ClientBase): {
|
|
|
159
159
|
};
|
|
160
160
|
type Customers = ReturnType<typeof createCustomersService>;
|
|
161
161
|
//#endregion
|
|
162
|
-
export { Customers, createCustomers, createCustomersService, deleteCustomers, deleteExternalCustomers, exportCustomers, getCustomers, getExternalCustomers, getStateCustomers, getStateExternalCustomers,
|
|
162
|
+
export { Customers, createCustomers, createCustomersService, deleteCustomers, deleteExternalCustomers, exportCustomers, getCustomers, getExternalCustomers, getStateCustomers, getStateExternalCustomers, iterListCustomers, iterListPaymentMethodsCustomers, iterListPaymentMethodsExternalCustomers, listCustomers, listPaymentMethodsCustomers, listPaymentMethodsExternalCustomers, updateCustomers, updateExternalCustomers };
|
|
163
163
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -43,7 +43,7 @@ const listCustomers = (client) => {
|
|
|
43
43
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
44
44
|
* @throws {HTTPValidationError} Validation Error
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
46
|
+
const iterListCustomers = (client) => {
|
|
47
47
|
return async function* (query) {
|
|
48
48
|
let page;
|
|
49
49
|
page = query?.page ?? 1;
|
|
@@ -372,7 +372,7 @@ const listPaymentMethodsCustomers = (client) => {
|
|
|
372
372
|
* @throws {ResourceNotFound} Customer not found.
|
|
373
373
|
* @throws {HTTPValidationError} Validation Error
|
|
374
374
|
*/
|
|
375
|
-
const
|
|
375
|
+
const iterListPaymentMethodsCustomers = (client) => {
|
|
376
376
|
return async function* (id, query) {
|
|
377
377
|
let page;
|
|
378
378
|
page = query?.page ?? 1;
|
|
@@ -433,7 +433,7 @@ const listPaymentMethodsExternalCustomers = (client) => {
|
|
|
433
433
|
* @throws {ResourceNotFound} Customer not found.
|
|
434
434
|
* @throws {HTTPValidationError} Validation Error
|
|
435
435
|
*/
|
|
436
|
-
const
|
|
436
|
+
const iterListPaymentMethodsExternalCustomers = (client) => {
|
|
437
437
|
return async function* (external_id, query) {
|
|
438
438
|
let page;
|
|
439
439
|
page = query?.page ?? 1;
|
|
@@ -466,13 +466,13 @@ function createCustomersService(client) {
|
|
|
466
466
|
getStateExternal: getStateExternalCustomers(client),
|
|
467
467
|
listPaymentMethods: listPaymentMethodsCustomers(client),
|
|
468
468
|
listPaymentMethodsExternal: listPaymentMethodsExternalCustomers(client),
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
469
|
+
iterList: iterListCustomers(client),
|
|
470
|
+
iterListPaymentMethods: iterListPaymentMethodsCustomers(client),
|
|
471
|
+
iterListPaymentMethodsExternal: iterListPaymentMethodsExternalCustomers(client),
|
|
472
472
|
members: createMembersService(client)
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
475
|
//#endregion
|
|
476
|
-
export { createCustomers, createCustomersService, deleteCustomers, deleteExternalCustomers, exportCustomers, getCustomers, getExternalCustomers, getStateCustomers, getStateExternalCustomers,
|
|
476
|
+
export { createCustomers, createCustomersService, deleteCustomers, deleteExternalCustomers, exportCustomers, getCustomers, getExternalCustomers, getStateCustomers, getStateExternalCustomers, iterListCustomers, iterListPaymentMethodsCustomers, iterListPaymentMethodsExternalCustomers, listCustomers, listPaymentMethodsCustomers, listPaymentMethodsExternalCustomers, updateCustomers, updateExternalCustomers };
|
|
477
477
|
|
|
478
478
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/2026-04/services/customers/index.ts"],"sourcesContent":["import type { ClientBase } from \"../../../base\";\nimport type {\n Customer,\n CustomerCreate,\n CustomerSortProperty,\n CustomerState,\n CustomerUpdate,\n CustomerUpdateExternalID,\n ListResourceCustomer,\n ListResourcePaymentMethod,\n MetadataQuery,\n PaymentMethod,\n} from \"../../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../../errors\";\nimport { createMembersService } from \"./members\";\n\nexport const listCustomers = (client: ClientBase) => {\n /**\n * List customers.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceCustomer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n email?: string | null;\n query?: string | null;\n active?: boolean | null;\n page?: number;\n limit?: number;\n sorting?: CustomerSortProperty[] | null;\n metadata?: MetadataQuery;\n }): Promise<ListResourceCustomer> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n email: query?.email,\n query: query?.query,\n active: query?.active,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n metadata: query?.metadata,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceCustomer>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List customers.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Customer>} A generator that yields items of type Customer.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterlistCustomers = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n email?: string | null;\n query?: string | null;\n active?: boolean | null;\n page?: number;\n limit?: number;\n sorting?: CustomerSortProperty[] | null;\n metadata?: MetadataQuery;\n }): AsyncGenerator<Customer> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listCustomers(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const createCustomers = (client: ClientBase) => {\n /**\n * Create a customer.\n *\n * **Scopes**: `customers:write`\n *\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (body: CustomerCreate): Promise<Customer> => {\n const pathParams = {};\n const queryParams = {};\n const request = client.buildRequest(\"POST\", \"/v1/customers/\", pathParams, queryParams, body);\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const exportCustomers = (client: ClientBase) => {\n /**\n * Export customers as a CSV file.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {string}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: { organization_id?: string | string[] | null }): Promise<string> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/export\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<string>(response, \"text\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const getCustomers = (client: ClientBase) => {\n /**\n * Get a customer by ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Customer> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteCustomers = (client: ClientBase) => {\n /**\n * Delete a customer.\n *\n * This action cannot be undone and will immediately:\n * - Cancel any active subscriptions for the customer\n * - Revoke all their benefits\n * - Clear any `external_id`\n *\n * Use it only in the context of deleting a user within your\n * own service. Otherwise, use more granular API endpoints to cancel\n * a specific subscription or revoke certain benefits.\n *\n * Note: The customers information will nonetheless be retained for historic\n * orders and subscriptions.\n *\n * Set `anonymize=true` to also anonymize PII for GDPR compliance.\n *\n * **Scopes**: `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n id: string,\n query?: {\n anonymize?: boolean;\n },\n ): Promise<void> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {\n anonymize: query?.anonymize,\n };\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateCustomers = (client: ClientBase) => {\n /**\n * Update a customer.\n *\n * **Scopes**: `customers:write`\n *\n * @param id - The customer ID.\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string, body: CustomerUpdate): Promise<Customer> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getExternalCustomers = (client: ClientBase) => {\n /**\n * Get a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string): Promise<Customer> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteExternalCustomers = (client: ClientBase) => {\n /**\n * Delete a customer by external ID.\n *\n * Immediately cancels any active subscriptions and revokes any active benefits.\n *\n * Set `anonymize=true` to also anonymize PII for GDPR compliance.\n *\n * **Scopes**: `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n external_id: string,\n query?: {\n anonymize?: boolean;\n },\n ): Promise<void> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {\n anonymize: query?.anonymize,\n };\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateExternalCustomers = (client: ClientBase) => {\n /**\n * Update a customer by external ID.\n *\n * **Scopes**: `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string, body: CustomerUpdateExternalID): Promise<Customer> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getStateCustomers = (client: ClientBase) => {\n /**\n * Get a customer state by ID.\n *\n * The customer state includes information about\n * the customer's active subscriptions and benefits.\n *\n * It's the ideal endpoint to use when you need to get a full overview\n * of a customer's status.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @returns {CustomerState}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<CustomerState> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}/state\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<CustomerState>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getStateExternalCustomers = (client: ClientBase) => {\n /**\n * Get a customer state by external ID.\n *\n * The customer state includes information about\n * the customer's active subscriptions and benefits.\n *\n * It's the ideal endpoint to use when you need to get a full overview\n * of a customer's status.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @returns {CustomerState}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string): Promise<CustomerState> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}/state\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<CustomerState>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const listPaymentMethodsCustomers = (client: ClientBase) => {\n /**\n * Get saved payment methods of a customer.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {ListResourcePaymentMethod}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): Promise<ListResourcePaymentMethod> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}/payment-methods\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourcePaymentMethod>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * Get saved payment methods of a customer.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {AsyncGenerator<PaymentMethod>} A generator that yields items of type PaymentMethod.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterlistPaymentMethodsCustomers = (client: ClientBase) => {\n return async function* (\n id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): AsyncGenerator<PaymentMethod> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listPaymentMethodsCustomers(client)(id, { ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const listPaymentMethodsExternalCustomers = (client: ClientBase) => {\n /**\n * Get saved payment methods of a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {ListResourcePaymentMethod}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n external_id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): Promise<ListResourcePaymentMethod> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}/payment-methods\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourcePaymentMethod>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * Get saved payment methods of a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {AsyncGenerator<PaymentMethod>} A generator that yields items of type PaymentMethod.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterlistPaymentMethodsExternalCustomers = (client: ClientBase) => {\n return async function* (\n external_id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): AsyncGenerator<PaymentMethod> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listPaymentMethodsExternalCustomers(client)(external_id, {\n ...query,\n page,\n limit,\n });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\n\nexport function createCustomersService(client: ClientBase) {\n return {\n list: listCustomers(client),\n create: createCustomers(client),\n export: exportCustomers(client),\n get: getCustomers(client),\n delete: deleteCustomers(client),\n update: updateCustomers(client),\n getExternal: getExternalCustomers(client),\n deleteExternal: deleteExternalCustomers(client),\n updateExternal: updateExternalCustomers(client),\n getState: getStateCustomers(client),\n getStateExternal: getStateExternalCustomers(client),\n listPaymentMethods: listPaymentMethodsCustomers(client),\n listPaymentMethodsExternal: listPaymentMethodsExternalCustomers(client),\n iterlist: iterlistCustomers(client),\n iterlistPaymentMethods: iterlistPaymentMethodsCustomers(client),\n iterlistPaymentMethodsExternal: iterlistPaymentMethodsExternalCustomers(client),\n members: createMembersService(client),\n };\n}\n\nexport type Customers = ReturnType<typeof createCustomersService>;\n"],"mappings":";;;AAiBA,MAAa,iBAAiB,WAAuB;;;;;;;;;;;;;CAanD,OAAO,OAAO,UASuB;EACnC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;GACzC,UAAU,OAAO;EACnB;EACA,MAAM,UAAU,OAAO,aACrB,OACA,kBACA,YACA,aACA,KAAA,CACF;EACA,MAAM,WAA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,gBAAgB,MAAM;EAC9B,QAAQ,gBAAgB,MAAM;EAC9B,KAAK,aAAa,MAAM;EACxB,QAAQ,gBAAgB,MAAM;EAC9B,QAAQ,gBAAgB,MAAM;EAC9B,aAAa,qBAAqB,MAAM;EACxC,gBAAgB,wBAAwB,MAAM;EAC9C,gBAAgB,wBAAwB,MAAM;EAC9C,UAAU,kBAAkB,MAAM;EAClC,kBAAkB,0BAA0B,MAAM;EAClD,oBAAoB,4BAA4B,MAAM;EACtD,4BAA4B,oCAAoC,MAAM;EACtE,UAAU,kBAAkB,MAAM;EAClC,wBAAwB,gCAAgC,MAAM;EAC9D,gCAAgC,wCAAwC,MAAM;EAC9E,SAAS,qBAAqB,MAAM;CACtC;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/2026-04/services/customers/index.ts"],"sourcesContent":["import type { ClientBase } from \"../../../base\";\nimport type {\n Customer,\n CustomerCreate,\n CustomerSortProperty,\n CustomerState,\n CustomerUpdate,\n CustomerUpdateExternalID,\n ListResourceCustomer,\n ListResourcePaymentMethod,\n MetadataQuery,\n PaymentMethod,\n} from \"../../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../../errors\";\nimport { createMembersService } from \"./members\";\n\nexport const listCustomers = (client: ClientBase) => {\n /**\n * List customers.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceCustomer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n email?: string | null;\n query?: string | null;\n active?: boolean | null;\n page?: number;\n limit?: number;\n sorting?: CustomerSortProperty[] | null;\n metadata?: MetadataQuery;\n }): Promise<ListResourceCustomer> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n email: query?.email,\n query: query?.query,\n active: query?.active,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n metadata: query?.metadata,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceCustomer>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List customers.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Customer>} A generator that yields items of type Customer.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListCustomers = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n email?: string | null;\n query?: string | null;\n active?: boolean | null;\n page?: number;\n limit?: number;\n sorting?: CustomerSortProperty[] | null;\n metadata?: MetadataQuery;\n }): AsyncGenerator<Customer> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listCustomers(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const createCustomers = (client: ClientBase) => {\n /**\n * Create a customer.\n *\n * **Scopes**: `customers:write`\n *\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (body: CustomerCreate): Promise<Customer> => {\n const pathParams = {};\n const queryParams = {};\n const request = client.buildRequest(\"POST\", \"/v1/customers/\", pathParams, queryParams, body);\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const exportCustomers = (client: ClientBase) => {\n /**\n * Export customers as a CSV file.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param query - Query parameters\n * @returns {string}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: { organization_id?: string | string[] | null }): Promise<string> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/export\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<string>(response, \"text\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const getCustomers = (client: ClientBase) => {\n /**\n * Get a customer by ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Customer> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteCustomers = (client: ClientBase) => {\n /**\n * Delete a customer.\n *\n * This action cannot be undone and will immediately:\n * - Cancel any active subscriptions for the customer\n * - Revoke all their benefits\n * - Clear any `external_id`\n *\n * Use it only in the context of deleting a user within your\n * own service. Otherwise, use more granular API endpoints to cancel\n * a specific subscription or revoke certain benefits.\n *\n * Note: The customers information will nonetheless be retained for historic\n * orders and subscriptions.\n *\n * Set `anonymize=true` to also anonymize PII for GDPR compliance.\n *\n * **Scopes**: `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n id: string,\n query?: {\n anonymize?: boolean;\n },\n ): Promise<void> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {\n anonymize: query?.anonymize,\n };\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateCustomers = (client: ClientBase) => {\n /**\n * Update a customer.\n *\n * **Scopes**: `customers:write`\n *\n * @param id - The customer ID.\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string, body: CustomerUpdate): Promise<Customer> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/customers/{id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getExternalCustomers = (client: ClientBase) => {\n /**\n * Get a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string): Promise<Customer> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteExternalCustomers = (client: ClientBase) => {\n /**\n * Delete a customer by external ID.\n *\n * Immediately cancels any active subscriptions and revokes any active benefits.\n *\n * Set `anonymize=true` to also anonymize PII for GDPR compliance.\n *\n * **Scopes**: `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n external_id: string,\n query?: {\n anonymize?: boolean;\n },\n ): Promise<void> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {\n anonymize: query?.anonymize,\n };\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateExternalCustomers = (client: ClientBase) => {\n /**\n * Update a customer by external ID.\n *\n * **Scopes**: `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param body - Request body\n * @returns {Customer}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string, body: CustomerUpdateExternalID): Promise<Customer> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/customers/external/{external_id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Customer>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getStateCustomers = (client: ClientBase) => {\n /**\n * Get a customer state by ID.\n *\n * The customer state includes information about\n * the customer's active subscriptions and benefits.\n *\n * It's the ideal endpoint to use when you need to get a full overview\n * of a customer's status.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @returns {CustomerState}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<CustomerState> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}/state\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<CustomerState>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const getStateExternalCustomers = (client: ClientBase) => {\n /**\n * Get a customer state by external ID.\n *\n * The customer state includes information about\n * the customer's active subscriptions and benefits.\n *\n * It's the ideal endpoint to use when you need to get a full overview\n * of a customer's status.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @returns {CustomerState}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (external_id: string): Promise<CustomerState> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}/state\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<CustomerState>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const listPaymentMethodsCustomers = (client: ClientBase) => {\n /**\n * Get saved payment methods of a customer.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {ListResourcePaymentMethod}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): Promise<ListResourcePaymentMethod> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/{id}/payment-methods\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourcePaymentMethod>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * Get saved payment methods of a customer.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param id - The customer ID.\n * @param query - Query parameters\n * @returns {AsyncGenerator<PaymentMethod>} A generator that yields items of type PaymentMethod.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListPaymentMethodsCustomers = (client: ClientBase) => {\n return async function* (\n id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): AsyncGenerator<PaymentMethod> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listPaymentMethodsCustomers(client)(id, { ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const listPaymentMethodsExternalCustomers = (client: ClientBase) => {\n /**\n * Get saved payment methods of a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {ListResourcePaymentMethod}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (\n external_id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): Promise<ListResourcePaymentMethod> => {\n const pathParams = {\n external_id: external_id,\n };\n const queryParams = {\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/customers/external/{external_id}/payment-methods\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourcePaymentMethod>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * Get saved payment methods of a customer by external ID.\n *\n * **Scopes**: `customers:read` `customers:write`\n *\n * @param external_id - The customer external ID.\n * @param query - Query parameters\n * @returns {AsyncGenerator<PaymentMethod>} A generator that yields items of type PaymentMethod.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Customer not found.\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListPaymentMethodsExternalCustomers = (client: ClientBase) => {\n return async function* (\n external_id: string,\n query?: {\n page?: number;\n limit?: number;\n },\n ): AsyncGenerator<PaymentMethod> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listPaymentMethodsExternalCustomers(client)(external_id, {\n ...query,\n page,\n limit,\n });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\n\nexport function createCustomersService(client: ClientBase) {\n return {\n list: listCustomers(client),\n create: createCustomers(client),\n export: exportCustomers(client),\n get: getCustomers(client),\n delete: deleteCustomers(client),\n update: updateCustomers(client),\n getExternal: getExternalCustomers(client),\n deleteExternal: deleteExternalCustomers(client),\n updateExternal: updateExternalCustomers(client),\n getState: getStateCustomers(client),\n getStateExternal: getStateExternalCustomers(client),\n listPaymentMethods: listPaymentMethodsCustomers(client),\n listPaymentMethodsExternal: listPaymentMethodsExternalCustomers(client),\n iterList: iterListCustomers(client),\n iterListPaymentMethods: iterListPaymentMethodsCustomers(client),\n iterListPaymentMethodsExternal: iterListPaymentMethodsExternalCustomers(client),\n members: createMembersService(client),\n };\n}\n\nexport type Customers = ReturnType<typeof createCustomersService>;\n"],"mappings":";;;AAiBA,MAAa,iBAAiB,WAAuB;;;;;;;;;;;;;CAanD,OAAO,OAAO,UASuB;EACnC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;GACzC,UAAU,OAAO;EACnB;EACA,MAAM,UAAU,OAAO,aACrB,OACA,kBACA,YACA,aACA,KAAA,CACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAoC,UAAU,QAAQ,EAClE,KAAK,oBACP,CAAC;CACH;AACF;;;;;;;;;;;;;AAaA,MAAa,qBAAqB,WAAuB;CACvD,OAAO,iBAAiB,OASK;EAC3B,IAAI;EACJ,OAAO,OAAO,QAAQ;EACtB,IAAI;EACJ,QAAQ,OAAO;EAEf,OAAO,MAAM;GACX,MAAM,WAAW,MAAM,cAAc,MAAM,CAAC,CAAC;IAAE,GAAG;IAAO;IAAM;GAAM,CAAC;GACtE,KAAK,MAAM,QAAQ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BAAwB,gCAAgC,MAAM;EAC9D,gCAAgC,wCAAwC,MAAM;EAC9E,SAAS,qBAAqB,MAAM;CACtC;AACF"}
|
|
@@ -40,7 +40,7 @@ const listDiscounts = (client) => {
|
|
|
40
40
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
41
41
|
* @throws {HTTPValidationError} Validation Error
|
|
42
42
|
*/
|
|
43
|
-
const
|
|
43
|
+
const iterListDiscounts = (client) => {
|
|
44
44
|
return async function* (query) {
|
|
45
45
|
let page;
|
|
46
46
|
page = query?.page ?? 1;
|
|
@@ -157,7 +157,7 @@ function createDiscountsService(client) {
|
|
|
157
157
|
get: getDiscounts(client),
|
|
158
158
|
delete: deleteDiscounts(client),
|
|
159
159
|
update: updateDiscounts(client),
|
|
160
|
-
|
|
160
|
+
iterList: iterListDiscounts(client)
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
//#endregion
|
|
@@ -165,7 +165,7 @@ exports.createDiscounts = createDiscounts;
|
|
|
165
165
|
exports.createDiscountsService = createDiscountsService;
|
|
166
166
|
exports.deleteDiscounts = deleteDiscounts;
|
|
167
167
|
exports.getDiscounts = getDiscounts;
|
|
168
|
-
exports.
|
|
168
|
+
exports.iterListDiscounts = iterListDiscounts;
|
|
169
169
|
exports.listDiscounts = listDiscounts;
|
|
170
170
|
exports.updateDiscounts = updateDiscounts;
|
|
171
171
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discounts.cjs","names":["HTTPValidationError","ResourceNotFound"],"sources":["../../../src/2026-04/services/discounts.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type {\n Discount,\n DiscountCreate,\n DiscountSortProperty,\n DiscountUpdate,\n ListResourceDiscount,\n} from \"../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDiscounts = (client: ClientBase) => {\n /**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDiscount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): Promise<ListResourceDiscount> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n query: query?.query,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDiscount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Discount>} A generator that yields items of type Discount.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const
|
|
1
|
+
{"version":3,"file":"discounts.cjs","names":["HTTPValidationError","ResourceNotFound"],"sources":["../../../src/2026-04/services/discounts.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type {\n Discount,\n DiscountCreate,\n DiscountSortProperty,\n DiscountUpdate,\n ListResourceDiscount,\n} from \"../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDiscounts = (client: ClientBase) => {\n /**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDiscount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): Promise<ListResourceDiscount> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n query: query?.query,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDiscount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Discount>} A generator that yields items of type Discount.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListDiscounts = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): AsyncGenerator<Discount> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listDiscounts(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const createDiscounts = (client: ClientBase) => {\n /**\n * Create a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param body - Request body\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (body: DiscountCreate): Promise<Discount> => {\n const pathParams = {};\n const queryParams = {};\n const request = client.buildRequest(\"POST\", \"/v1/discounts/\", pathParams, queryParams, body);\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const getDiscounts = (client: ClientBase) => {\n /**\n * Get a discount by ID.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param id - The discount ID.\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Discount> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteDiscounts = (client: ClientBase) => {\n /**\n * Delete a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param id - The discount ID.\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<void> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateDiscounts = (client: ClientBase) => {\n /**\n * Update a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param id - The discount ID.\n * @param body - Request body\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string, body: DiscountUpdate): Promise<Discount> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n\nexport function createDiscountsService(client: ClientBase) {\n return {\n list: listDiscounts(client),\n create: createDiscounts(client),\n get: getDiscounts(client),\n delete: deleteDiscounts(client),\n update: updateDiscounts(client),\n iterList: iterListDiscounts(client),\n };\n}\n\nexport type Discounts = ReturnType<typeof createDiscountsService>;\n"],"mappings":";;;AAWA,MAAa,iBAAiB,WAAuB;;;;;;;;;;;;;CAanD,OAAO,OAAO,UAMuB;EACnC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,OAAO,OAAO;GACd,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;EAC3C;EACA,MAAM,UAAU,OAAO,aACrB,OACA,kBACA,YACA,aACA,KAAA,CACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAoC,UAAU,QAAQ,EAClE,KAAKA,eAAAA,oBACP,CAAC;CACH;AACF;;;;;;;;;;;;;AAaA,MAAa,qBAAqB,WAAuB;CACvD,OAAO,iBAAiB,OAMK;EAC3B,IAAI;EACJ,OAAO,OAAO,QAAQ;EACtB,IAAI;EACJ,QAAQ,OAAO;EAEf,OAAO,MAAM;GACX,MAAM,WAAW,MAAM,cAAc,MAAM,CAAC,CAAC;IAAE,GAAG;IAAO;IAAM;GAAM,CAAC;GACtE,KAAK,MAAM,QAAQ,SAAS,OAC1B,MAAM;GAER,IAAI,QAAQ,SAAS,WAAW,UAC9B;GAEF;EACF;CACF;AACF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AAc,MAAM;EAC1B,QAAQ,gBAAgB,MAAM;EAC9B,KAAK,aAAa,MAAM;EACxB,QAAQ,gBAAgB,MAAM;EAC9B,QAAQ,gBAAgB,MAAM;EAC9B,UAAU,kBAAkB,MAAM;CACpC;AACF"}
|
|
@@ -20,7 +20,7 @@ declare const listDiscounts: (client: ClientBase) => (query?: {
|
|
|
20
20
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
21
21
|
* @throws {HTTPValidationError} Validation Error
|
|
22
22
|
*/
|
|
23
|
-
declare const
|
|
23
|
+
declare const iterListDiscounts: (client: ClientBase) => (query?: {
|
|
24
24
|
organization_id?: string | string[] | null;
|
|
25
25
|
query?: string | null;
|
|
26
26
|
page?: number;
|
|
@@ -43,7 +43,7 @@ declare function createDiscountsService(client: ClientBase): {
|
|
|
43
43
|
get: (id: string) => Promise<Discount>;
|
|
44
44
|
delete: (id: string) => Promise<void>;
|
|
45
45
|
update: (id: string, body: DiscountUpdate) => Promise<Discount>;
|
|
46
|
-
|
|
46
|
+
iterList: (query?: {
|
|
47
47
|
organization_id?: string | string[] | null;
|
|
48
48
|
query?: string | null;
|
|
49
49
|
page?: number;
|
|
@@ -53,5 +53,5 @@ declare function createDiscountsService(client: ClientBase): {
|
|
|
53
53
|
};
|
|
54
54
|
type Discounts = ReturnType<typeof createDiscountsService>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { Discounts, createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts,
|
|
56
|
+
export { Discounts, createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts, iterListDiscounts, listDiscounts, updateDiscounts };
|
|
57
57
|
//# sourceMappingURL=discounts.d.cts.map
|
|
@@ -20,7 +20,7 @@ declare const listDiscounts: (client: ClientBase) => (query?: {
|
|
|
20
20
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
21
21
|
* @throws {HTTPValidationError} Validation Error
|
|
22
22
|
*/
|
|
23
|
-
declare const
|
|
23
|
+
declare const iterListDiscounts: (client: ClientBase) => (query?: {
|
|
24
24
|
organization_id?: string | string[] | null;
|
|
25
25
|
query?: string | null;
|
|
26
26
|
page?: number;
|
|
@@ -43,7 +43,7 @@ declare function createDiscountsService(client: ClientBase): {
|
|
|
43
43
|
get: (id: string) => Promise<Discount>;
|
|
44
44
|
delete: (id: string) => Promise<void>;
|
|
45
45
|
update: (id: string, body: DiscountUpdate) => Promise<Discount>;
|
|
46
|
-
|
|
46
|
+
iterList: (query?: {
|
|
47
47
|
organization_id?: string | string[] | null;
|
|
48
48
|
query?: string | null;
|
|
49
49
|
page?: number;
|
|
@@ -53,5 +53,5 @@ declare function createDiscountsService(client: ClientBase): {
|
|
|
53
53
|
};
|
|
54
54
|
type Discounts = ReturnType<typeof createDiscountsService>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { Discounts, createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts,
|
|
56
|
+
export { Discounts, createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts, iterListDiscounts, listDiscounts, updateDiscounts };
|
|
57
57
|
//# sourceMappingURL=discounts.d.mts.map
|
|
@@ -39,7 +39,7 @@ const listDiscounts = (client) => {
|
|
|
39
39
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
40
40
|
* @throws {HTTPValidationError} Validation Error
|
|
41
41
|
*/
|
|
42
|
-
const
|
|
42
|
+
const iterListDiscounts = (client) => {
|
|
43
43
|
return async function* (query) {
|
|
44
44
|
let page;
|
|
45
45
|
page = query?.page ?? 1;
|
|
@@ -156,10 +156,10 @@ function createDiscountsService(client) {
|
|
|
156
156
|
get: getDiscounts(client),
|
|
157
157
|
delete: deleteDiscounts(client),
|
|
158
158
|
update: updateDiscounts(client),
|
|
159
|
-
|
|
159
|
+
iterList: iterListDiscounts(client)
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
//#endregion
|
|
163
|
-
export { createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts,
|
|
163
|
+
export { createDiscounts, createDiscountsService, deleteDiscounts, getDiscounts, iterListDiscounts, listDiscounts, updateDiscounts };
|
|
164
164
|
|
|
165
165
|
//# sourceMappingURL=discounts.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discounts.mjs","names":[],"sources":["../../../src/2026-04/services/discounts.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type {\n Discount,\n DiscountCreate,\n DiscountSortProperty,\n DiscountUpdate,\n ListResourceDiscount,\n} from \"../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDiscounts = (client: ClientBase) => {\n /**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDiscount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): Promise<ListResourceDiscount> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n query: query?.query,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDiscount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Discount>} A generator that yields items of type Discount.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const
|
|
1
|
+
{"version":3,"file":"discounts.mjs","names":[],"sources":["../../../src/2026-04/services/discounts.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type {\n Discount,\n DiscountCreate,\n DiscountSortProperty,\n DiscountUpdate,\n ListResourceDiscount,\n} from \"../models\";\n\nimport { HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDiscounts = (client: ClientBase) => {\n /**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDiscount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): Promise<ListResourceDiscount> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n query: query?.query,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDiscount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List discounts.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Discount>} A generator that yields items of type Discount.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListDiscounts = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n query?: string | null;\n page?: number;\n limit?: number;\n sorting?: DiscountSortProperty[] | null;\n }): AsyncGenerator<Discount> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listDiscounts(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const createDiscounts = (client: ClientBase) => {\n /**\n * Create a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param body - Request body\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (body: DiscountCreate): Promise<Discount> => {\n const pathParams = {};\n const queryParams = {};\n const request = client.buildRequest(\"POST\", \"/v1/discounts/\", pathParams, queryParams, body);\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\nexport const getDiscounts = (client: ClientBase) => {\n /**\n * Get a discount by ID.\n *\n * **Scopes**: `discounts:read` `discounts:write`\n *\n * @param id - The discount ID.\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Discount> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const deleteDiscounts = (client: ClientBase) => {\n /**\n * Delete a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param id - The discount ID.\n * @returns {void}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<void> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"DELETE\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<void>(response, \"none\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const updateDiscounts = (client: ClientBase) => {\n /**\n * Update a discount.\n *\n * **Scopes**: `discounts:write`\n *\n * @param id - The discount ID.\n * @param body - Request body\n * @returns {Discount}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Discount not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string, body: DiscountUpdate): Promise<Discount> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"PATCH\",\n \"/v1/discounts/{id}\",\n pathParams,\n queryParams,\n body,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Discount>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\n\nexport function createDiscountsService(client: ClientBase) {\n return {\n list: listDiscounts(client),\n create: createDiscounts(client),\n get: getDiscounts(client),\n delete: deleteDiscounts(client),\n update: updateDiscounts(client),\n iterList: iterListDiscounts(client),\n };\n}\n\nexport type Discounts = ReturnType<typeof createDiscountsService>;\n"],"mappings":";;AAWA,MAAa,iBAAiB,WAAuB;;;;;;;;;;;;;CAanD,OAAO,OAAO,UAMuB;EACnC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,OAAO,OAAO;GACd,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;EAC3C;EACA,MAAM,UAAU,OAAO,aACrB,OACA,kBACA,YACA,aACA,KAAA,CACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;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AAC;CACH;AACF;AACA,MAAa,mBAAmB,WAAuB;;;;;;;;;;;;;;;CAerD,OAAO,OAAO,IAAY,SAA4C;EACpE,MAAM,aAAa,EACb,GACN;EAEA,MAAM,UAAU,OAAO,aACrB,SACA,sBACA,YACA,CAAU,GACV,IACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAwB,UAAU,QAAQ;GACtD,KAAK;GACL,KAAK;EACP,CAAC;CACH;AACF;AAEA,SAAgB,uBAAuB,QAAoB;CACzD,OAAO;EACL,MAAM,cAAc,MAAM;EAC1B,QAAQ,gBAAgB,MAAM;EAC9B,KAAK,aAAa,MAAM;EACxB,QAAQ,gBAAgB,MAAM;EAC9B,QAAQ,gBAAgB,MAAM;EAC9B,UAAU,kBAAkB,MAAM;CACpC;AACF"}
|
|
@@ -41,7 +41,7 @@ const listDisputes = (client) => {
|
|
|
41
41
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
42
42
|
* @throws {HTTPValidationError} Validation Error
|
|
43
43
|
*/
|
|
44
|
-
const
|
|
44
|
+
const iterListDisputes = (client) => {
|
|
45
45
|
return async function* (query) {
|
|
46
46
|
let page;
|
|
47
47
|
page = query?.page ?? 1;
|
|
@@ -117,14 +117,14 @@ function createDisputesService(client) {
|
|
|
117
117
|
list: listDisputes(client),
|
|
118
118
|
get: getDisputes(client),
|
|
119
119
|
accept: acceptDisputes(client),
|
|
120
|
-
|
|
120
|
+
iterList: iterListDisputes(client)
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
//#endregion
|
|
124
124
|
exports.acceptDisputes = acceptDisputes;
|
|
125
125
|
exports.createDisputesService = createDisputesService;
|
|
126
126
|
exports.getDisputes = getDisputes;
|
|
127
|
-
exports.
|
|
127
|
+
exports.iterListDisputes = iterListDisputes;
|
|
128
128
|
exports.listDisputes = listDisputes;
|
|
129
129
|
|
|
130
130
|
//# sourceMappingURL=disputes.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disputes.cjs","names":["HTTPValidationError","ResourceNotFound","DisputeNotOpenError"],"sources":["../../../src/2026-04/services/disputes.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type { Dispute, DisputeSortProperty, DisputeStatus, ListResourceDispute } from \"../models\";\n\nimport { DisputeNotOpenError, HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDisputes = (client: ClientBase) => {\n /**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): Promise<ListResourceDispute> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n order_id: query?.order_id,\n status: query?.status,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\"GET\", \"/v1/disputes/\", pathParams, queryParams, undefined);\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDispute>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Dispute>} A generator that yields items of type Dispute.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const
|
|
1
|
+
{"version":3,"file":"disputes.cjs","names":["HTTPValidationError","ResourceNotFound","DisputeNotOpenError"],"sources":["../../../src/2026-04/services/disputes.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type { Dispute, DisputeSortProperty, DisputeStatus, ListResourceDispute } from \"../models\";\n\nimport { DisputeNotOpenError, HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDisputes = (client: ClientBase) => {\n /**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): Promise<ListResourceDispute> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n order_id: query?.order_id,\n status: query?.status,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\"GET\", \"/v1/disputes/\", pathParams, queryParams, undefined);\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDispute>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Dispute>} A generator that yields items of type Dispute.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListDisputes = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): AsyncGenerator<Dispute> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listDisputes(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const getDisputes = (client: ClientBase) => {\n /**\n * Get a dispute by ID.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param id - The dispute ID.\n * @returns {Dispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Dispute not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Dispute> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/disputes/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Dispute>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const acceptDisputes = (client: ClientBase) => {\n /**\n * Accept a dispute, conceding the chargeback.\n *\n * Closes the dispute with the processor (settling it as `lost`) and records\n * the merchant's decision on the dispute's support case.\n *\n * **Scopes**: `disputes:write`\n *\n * @param id - The dispute ID.\n * @returns {Dispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Dispute not found.\n * @throws {DisputeNotOpenError} Conflict\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Dispute> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"POST\",\n \"/v1/disputes/{id}/accept\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Dispute>(response, \"json\", {\n 404: ResourceNotFound,\n 409: DisputeNotOpenError,\n 422: HTTPValidationError,\n });\n };\n};\n\nexport function createDisputesService(client: ClientBase) {\n return {\n list: listDisputes(client),\n get: getDisputes(client),\n accept: acceptDisputes(client),\n iterList: iterListDisputes(client),\n };\n}\n\nexport type Disputes = ReturnType<typeof createDisputesService>;\n"],"mappings":";;;AAKA,MAAa,gBAAgB,WAAuB;;;;;;;;;;;;;CAalD,OAAO,OAAO,UAOsB;EAClC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,UAAU,OAAO;GACjB,QAAQ,OAAO;GACf,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;EAC3C;EACA,MAAM,UAAU,OAAO,aAAa,OAAO,iBAAiB,YAAY,aAAa,KAAA,CAAS;EAC9F,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAmC,UAAU,QAAQ,EACjE,KAAKA,eAAAA,oBACP,CAAC;CACH;AACF;;;;;;;;;;;;;AAaA,MAAa,oBAAoB,WAAuB;CACtD,OAAO,iBAAiB,OAOI;EAC1B,IAAI;EACJ,OAAO,OAAO,QAAQ;EACtB,IAAI;EACJ,QAAQ,OAAO;EAEf,OAAO,MAAM;GACX,MAAM,WAAW,MAAM,aAAa,MAAM,CAAC,CAAC;IAAE,GAAG;IAAO;IAAM;GAAM,CAAC;GACrE,KAAK,MAAM,QAAQ,SAAS,OAC1B,MAAM;GAER,IAAI,QAAQ,SAAS,WAAW,UAC9B;GAEF;EACF;CACF;AACF;AACA,MAAa,eAAe,WAAuB;;;;;;;;;;;;;;CAcjD,OAAO,OAAO,OAAiC;EAC7C,MAAM,aAAa,EACb,GACN;EAEA,MAAM,UAAU,OAAO,aACrB,OACA,qBACA,YACA,CAAU,GACV,KAAA,CACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAuB,UAAU,QAAQ;GACrD,KAAKC,eAAAA;GACL,KAAKD,eAAAA;EACP,CAAC;CACH;AACF;AACA,MAAa,kBAAkB,WAAuB;;;;;;;;;;;;;;;;;;CAkBpD,OAAO,OAAO,OAAiC;EAC7C,MAAM,aAAa,EACb,GACN;EAEA,MAAM,UAAU,OAAO,aACrB,QACA,4BACA,YACA,CAAU,GACV,KAAA,CACF;EACA,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAuB,UAAU,QAAQ;GACrD,KAAKC,eAAAA;GACL,KAAKC,eAAAA;GACL,KAAKF,eAAAA;EACP,CAAC;CACH;AACF;AAEA,SAAgB,sBAAsB,QAAoB;CACxD,OAAO;EACL,MAAM,aAAa,MAAM;EACzB,KAAK,YAAY,MAAM;EACvB,QAAQ,eAAe,MAAM;EAC7B,UAAU,iBAAiB,MAAM;CACnC;AACF"}
|
|
@@ -21,7 +21,7 @@ declare const listDisputes: (client: ClientBase) => (query?: {
|
|
|
21
21
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
22
22
|
* @throws {HTTPValidationError} Validation Error
|
|
23
23
|
*/
|
|
24
|
-
declare const
|
|
24
|
+
declare const iterListDisputes: (client: ClientBase) => (query?: {
|
|
25
25
|
organization_id?: string | string[] | null;
|
|
26
26
|
order_id?: string | string[] | null;
|
|
27
27
|
status?: DisputeStatus | DisputeStatus[] | null;
|
|
@@ -42,7 +42,7 @@ declare function createDisputesService(client: ClientBase): {
|
|
|
42
42
|
}) => Promise<ListResourceDispute>;
|
|
43
43
|
get: (id: string) => Promise<Dispute>;
|
|
44
44
|
accept: (id: string) => Promise<Dispute>;
|
|
45
|
-
|
|
45
|
+
iterList: (query?: {
|
|
46
46
|
organization_id?: string | string[] | null;
|
|
47
47
|
order_id?: string | string[] | null;
|
|
48
48
|
status?: DisputeStatus | DisputeStatus[] | null;
|
|
@@ -53,5 +53,5 @@ declare function createDisputesService(client: ClientBase): {
|
|
|
53
53
|
};
|
|
54
54
|
type Disputes = ReturnType<typeof createDisputesService>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { Disputes, acceptDisputes, createDisputesService, getDisputes,
|
|
56
|
+
export { Disputes, acceptDisputes, createDisputesService, getDisputes, iterListDisputes, listDisputes };
|
|
57
57
|
//# sourceMappingURL=disputes.d.cts.map
|
|
@@ -21,7 +21,7 @@ declare const listDisputes: (client: ClientBase) => (query?: {
|
|
|
21
21
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
22
22
|
* @throws {HTTPValidationError} Validation Error
|
|
23
23
|
*/
|
|
24
|
-
declare const
|
|
24
|
+
declare const iterListDisputes: (client: ClientBase) => (query?: {
|
|
25
25
|
organization_id?: string | string[] | null;
|
|
26
26
|
order_id?: string | string[] | null;
|
|
27
27
|
status?: DisputeStatus | DisputeStatus[] | null;
|
|
@@ -42,7 +42,7 @@ declare function createDisputesService(client: ClientBase): {
|
|
|
42
42
|
}) => Promise<ListResourceDispute>;
|
|
43
43
|
get: (id: string) => Promise<Dispute>;
|
|
44
44
|
accept: (id: string) => Promise<Dispute>;
|
|
45
|
-
|
|
45
|
+
iterList: (query?: {
|
|
46
46
|
organization_id?: string | string[] | null;
|
|
47
47
|
order_id?: string | string[] | null;
|
|
48
48
|
status?: DisputeStatus | DisputeStatus[] | null;
|
|
@@ -53,5 +53,5 @@ declare function createDisputesService(client: ClientBase): {
|
|
|
53
53
|
};
|
|
54
54
|
type Disputes = ReturnType<typeof createDisputesService>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { Disputes, acceptDisputes, createDisputesService, getDisputes,
|
|
56
|
+
export { Disputes, acceptDisputes, createDisputesService, getDisputes, iterListDisputes, listDisputes };
|
|
57
57
|
//# sourceMappingURL=disputes.d.mts.map
|
|
@@ -40,7 +40,7 @@ const listDisputes = (client) => {
|
|
|
40
40
|
* @throws {PolarServerError} When the server returns a 5xx error
|
|
41
41
|
* @throws {HTTPValidationError} Validation Error
|
|
42
42
|
*/
|
|
43
|
-
const
|
|
43
|
+
const iterListDisputes = (client) => {
|
|
44
44
|
return async function* (query) {
|
|
45
45
|
let page;
|
|
46
46
|
page = query?.page ?? 1;
|
|
@@ -116,10 +116,10 @@ function createDisputesService(client) {
|
|
|
116
116
|
list: listDisputes(client),
|
|
117
117
|
get: getDisputes(client),
|
|
118
118
|
accept: acceptDisputes(client),
|
|
119
|
-
|
|
119
|
+
iterList: iterListDisputes(client)
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
|
-
export { acceptDisputes, createDisputesService, getDisputes,
|
|
123
|
+
export { acceptDisputes, createDisputesService, getDisputes, iterListDisputes, listDisputes };
|
|
124
124
|
|
|
125
125
|
//# sourceMappingURL=disputes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disputes.mjs","names":[],"sources":["../../../src/2026-04/services/disputes.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type { Dispute, DisputeSortProperty, DisputeStatus, ListResourceDispute } from \"../models\";\n\nimport { DisputeNotOpenError, HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDisputes = (client: ClientBase) => {\n /**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): Promise<ListResourceDispute> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n order_id: query?.order_id,\n status: query?.status,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\"GET\", \"/v1/disputes/\", pathParams, queryParams, undefined);\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDispute>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Dispute>} A generator that yields items of type Dispute.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const
|
|
1
|
+
{"version":3,"file":"disputes.mjs","names":[],"sources":["../../../src/2026-04/services/disputes.ts"],"sourcesContent":["import type { ClientBase } from \"../../base\";\nimport type { Dispute, DisputeSortProperty, DisputeStatus, ListResourceDispute } from \"../models\";\n\nimport { DisputeNotOpenError, HTTPValidationError, ResourceNotFound } from \"../errors\";\n\nexport const listDisputes = (client: ClientBase) => {\n /**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {ListResourceDispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\n return async (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): Promise<ListResourceDispute> => {\n const pathParams = {};\n const queryParams = {\n organization_id: query?.organization_id,\n order_id: query?.order_id,\n status: query?.status,\n page: query?.page ?? 1,\n limit: query?.limit ?? 10,\n sorting: query?.sorting ?? [\"-created_at\"],\n };\n const request = client.buildRequest(\"GET\", \"/v1/disputes/\", pathParams, queryParams, undefined);\n const response = await client.sendRequest(request);\n return client.parseResponse<ListResourceDispute>(response, \"json\", {\n 422: HTTPValidationError,\n });\n };\n};\n/**\n * List disputes.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param query - Query parameters\n * @returns {AsyncGenerator<Dispute>} A generator that yields items of type Dispute.\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {HTTPValidationError} Validation Error\n */\nexport const iterListDisputes = (client: ClientBase) => {\n return async function* (query?: {\n organization_id?: string | string[] | null;\n order_id?: string | string[] | null;\n status?: DisputeStatus | DisputeStatus[] | null;\n page?: number;\n limit?: number;\n sorting?: DisputeSortProperty[] | null;\n }): AsyncGenerator<Dispute> {\n let page: number;\n page = query?.page ?? 1;\n let limit: number | undefined;\n limit = query?.limit;\n\n while (true) {\n const response = await listDisputes(client)({ ...query, page, limit });\n for (const item of response.items) {\n yield item;\n }\n if (page >= response.pagination.max_page) {\n break;\n }\n page++;\n }\n };\n};\nexport const getDisputes = (client: ClientBase) => {\n /**\n * Get a dispute by ID.\n *\n * **Scopes**: `disputes:read` `disputes:write`\n *\n * @param id - The dispute ID.\n * @returns {Dispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Dispute not found.\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Dispute> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"GET\",\n \"/v1/disputes/{id}\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Dispute>(response, \"json\", {\n 404: ResourceNotFound,\n 422: HTTPValidationError,\n });\n };\n};\nexport const acceptDisputes = (client: ClientBase) => {\n /**\n * Accept a dispute, conceding the chargeback.\n *\n * Closes the dispute with the processor (settling it as `lost`) and records\n * the merchant's decision on the dispute's support case.\n *\n * **Scopes**: `disputes:write`\n *\n * @param id - The dispute ID.\n * @returns {Dispute}\n * @throws {PolarNetworkError} When a network error occurs\n * @throws {PolarRateLimitError} When the rate limit is exceeded\n * @throws {PolarServerError} When the server returns a 5xx error\n * @throws {ResourceNotFound} Dispute not found.\n * @throws {DisputeNotOpenError} Conflict\n * @throws {HTTPValidationError} Validation Error\n */\n return async (id: string): Promise<Dispute> => {\n const pathParams = {\n id: id,\n };\n const queryParams = {};\n const request = client.buildRequest(\n \"POST\",\n \"/v1/disputes/{id}/accept\",\n pathParams,\n queryParams,\n undefined,\n );\n const response = await client.sendRequest(request);\n return client.parseResponse<Dispute>(response, \"json\", {\n 404: ResourceNotFound,\n 409: DisputeNotOpenError,\n 422: HTTPValidationError,\n });\n };\n};\n\nexport function createDisputesService(client: ClientBase) {\n return {\n list: listDisputes(client),\n get: getDisputes(client),\n accept: acceptDisputes(client),\n iterList: iterListDisputes(client),\n };\n}\n\nexport type Disputes = ReturnType<typeof createDisputesService>;\n"],"mappings":";;AAKA,MAAa,gBAAgB,WAAuB;;;;;;;;;;;;;CAalD,OAAO,OAAO,UAOsB;EAClC,MAAM,aAAa,CAAC;EACpB,MAAM,cAAc;GAClB,iBAAiB,OAAO;GACxB,UAAU,OAAO;GACjB,QAAQ,OAAO;GACf,MAAM,OAAO,QAAQ;GACrB,OAAO,OAAO,SAAS;GACvB,SAAS,OAAO,WAAW,CAAC,aAAa;EAC3C;EACA,MAAM,UAAU,OAAO,aAAa,OAAO,iBAAiB,YAAY,aAAa,KAAA,CAAS;EAC9F,MAAM,WAAW,MAAM,OAAO,YAAY,OAAO;EACjD,OAAO,OAAO,cAAmC,UAAU,QAAQ,EACjE,KAAK,oBACP,CAAC;CACH;AACF;;;;;;;;;;;;;AAaA,MAAa,oBAAoB,WAAuB;CACtD,OAAO,iBAAiB,OAOI;EAC1B,IAAI;EACJ,OAAO,OAAO,QAAQ;EACtB,IAAI;EACJ,QAAQ,OAAO;EAEf,OAAO,MAAM;GACX,MAAM,WAAW,MAAM,aAAa,MAAM,CAAC,CAAC;IAAE,GAAG;IAAO;IAAM;GAAM,CAAC;GACrE,KAAK,MAAM,QAAQ,SAAS,OAC1B,MAAM;GAER,IAAI,QAAQ,SAAS,WAAW,UAC9B;GAEF;EACF;CAC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