shoal-web-sdk 1.0.126 → 1.0.127
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/dist/sdk/billing/@tanstack/react-query.gen.d.ts +8 -1
- package/dist/sdk/billing/@tanstack/react-query.gen.js +20 -1
- package/dist/sdk/billing/sdk.gen.d.ts +8 -1
- package/dist/sdk/billing/sdk.gen.js +22 -0
- package/dist/sdk/billing/types.gen.d.ts +53 -0
- package/dist/sdk/billing/zod.gen.d.ts +55 -0
- package/dist/sdk/billing/zod.gen.js +22 -1
- package/dist/tanstack-codegen/generated/billing.d.ts +9 -1
- package/dist/tanstack-codegen/generated/billing.js +20 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
2
|
import { type Options } from '../sdk.gen';
|
|
3
|
-
import type { CancelSubscriptionData, CancelSubscriptionError, CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, CreateSubscriptionData, CreateSubscriptionError, CreateSubscriptionResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetCustomerData, GetInvoicesData, GetPlansData, GetUsageData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
|
|
3
|
+
import type { CancelSubscriptionData, CancelSubscriptionError, CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, CreateSubscriptionData, CreateSubscriptionError, CreateSubscriptionResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetCustomerData, GetInvoicesData, GetPlansData, GetUsageData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, UpdateBillingAddressData, UpdateBillingAddressError, UpdateBillingAddressResponse, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
|
|
4
4
|
export type QueryKey<TOptions extends Options> = [
|
|
5
5
|
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
|
6
6
|
_id: string;
|
|
@@ -110,6 +110,13 @@ export declare const cancelSubscriptionMutation: (options?: Partial<Options<Canc
|
|
|
110
110
|
*
|
|
111
111
|
*/
|
|
112
112
|
export declare const createSubscriptionMutation: (options?: Partial<Options<CreateSubscriptionData>>) => UseMutationOptions<CreateSubscriptionResponse, CreateSubscriptionError, Options<CreateSubscriptionData>>;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the billing address on the Stripe customer.
|
|
115
|
+
*
|
|
116
|
+
* Stripe Tax uses the customer's address to work out their tax location. The address is validated immediately, so an address Stripe cannot use for tax is rejected instead of leaving the customer with an unknown tax location.
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
export declare const updateBillingAddressMutation: (options?: Partial<Options<UpdateBillingAddressData>>) => UseMutationOptions<UpdateBillingAddressResponse, UpdateBillingAddressError, Options<UpdateBillingAddressData>>;
|
|
113
120
|
/**
|
|
114
121
|
* Creates a Stripe SetupIntent.
|
|
115
122
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
import { client } from '../client.gen';
|
|
4
|
-
import { cancelSubscription, createSetupIntent, createSubscription, deletePaymentMethod, getCustomer, getInvoices, getPlans, getUsage, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
|
|
4
|
+
import { cancelSubscription, createSetupIntent, createSubscription, deletePaymentMethod, getCustomer, getInvoices, getPlans, getUsage, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, updateBillingAddress, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
|
|
5
5
|
const createQueryKey = (id, options, infinite, tags) => {
|
|
6
6
|
const params = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl };
|
|
7
7
|
if (infinite) {
|
|
@@ -134,6 +134,25 @@ export const createSubscriptionMutation = (options) => {
|
|
|
134
134
|
};
|
|
135
135
|
return mutationOptions;
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Sets the billing address on the Stripe customer.
|
|
139
|
+
*
|
|
140
|
+
* Stripe Tax uses the customer's address to work out their tax location. The address is validated immediately, so an address Stripe cannot use for tax is rejected instead of leaving the customer with an unknown tax location.
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
export const updateBillingAddressMutation = (options) => {
|
|
144
|
+
const mutationOptions = {
|
|
145
|
+
mutationFn: async (fnOptions) => {
|
|
146
|
+
const { data } = await updateBillingAddress({
|
|
147
|
+
...options,
|
|
148
|
+
...fnOptions,
|
|
149
|
+
throwOnError: true
|
|
150
|
+
});
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return mutationOptions;
|
|
155
|
+
};
|
|
137
156
|
/**
|
|
138
157
|
* Creates a Stripe SetupIntent.
|
|
139
158
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client, Options as Options2, TDataShape } from './client';
|
|
2
|
-
import type { CancelSubscriptionData, CancelSubscriptionErrors, CancelSubscriptionResponses, CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, CreateSubscriptionData, CreateSubscriptionErrors, CreateSubscriptionResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetCustomerData, GetCustomerErrors, GetCustomerResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, GetUsageData, GetUsageErrors, GetUsageResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
|
|
2
|
+
import type { CancelSubscriptionData, CancelSubscriptionErrors, CancelSubscriptionResponses, CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, CreateSubscriptionData, CreateSubscriptionErrors, CreateSubscriptionResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetCustomerData, GetCustomerErrors, GetCustomerResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, GetUsageData, GetUsageErrors, GetUsageResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, UpdateBillingAddressData, UpdateBillingAddressErrors, UpdateBillingAddressResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -43,6 +43,13 @@ export declare const cancelSubscription: <ThrowOnError extends boolean = false>(
|
|
|
43
43
|
*
|
|
44
44
|
*/
|
|
45
45
|
export declare const createSubscription: <ThrowOnError extends boolean = false>(options: Options<CreateSubscriptionData, ThrowOnError>) => import("./client").RequestResult<CreateSubscriptionResponses, CreateSubscriptionErrors, ThrowOnError, "fields">;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the billing address on the Stripe customer.
|
|
48
|
+
*
|
|
49
|
+
* Stripe Tax uses the customer's address to work out their tax location. The address is validated immediately, so an address Stripe cannot use for tax is rejected instead of leaving the customer with an unknown tax location.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare const updateBillingAddress: <ThrowOnError extends boolean = false>(options: Options<UpdateBillingAddressData, ThrowOnError>) => import("./client").RequestResult<UpdateBillingAddressResponses, UpdateBillingAddressErrors, ThrowOnError, "fields">;
|
|
46
53
|
/**
|
|
47
54
|
* Creates a Stripe SetupIntent.
|
|
48
55
|
*
|
|
@@ -104,6 +104,28 @@ export const createSubscription = (options) => {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Sets the billing address on the Stripe customer.
|
|
109
|
+
*
|
|
110
|
+
* Stripe Tax uses the customer's address to work out their tax location. The address is validated immediately, so an address Stripe cannot use for tax is rejected instead of leaving the customer with an unknown tax location.
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
export const updateBillingAddress = (options) => {
|
|
114
|
+
return (options.client ?? client).put({
|
|
115
|
+
security: [
|
|
116
|
+
{
|
|
117
|
+
scheme: 'bearer',
|
|
118
|
+
type: 'http'
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
url: '/api/v1/billing-address/{org}',
|
|
122
|
+
...options,
|
|
123
|
+
headers: {
|
|
124
|
+
'Content-Type': 'application/json',
|
|
125
|
+
...options.headers
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
107
129
|
/**
|
|
108
130
|
* Creates a Stripe SetupIntent.
|
|
109
131
|
*
|
|
@@ -96,6 +96,18 @@ export type CreateSubscriptionRequest = {
|
|
|
96
96
|
plan: string;
|
|
97
97
|
billingInterval: BillingInterval;
|
|
98
98
|
};
|
|
99
|
+
export type BillingAddress = {
|
|
100
|
+
name: string;
|
|
101
|
+
line1: string;
|
|
102
|
+
line2?: string;
|
|
103
|
+
city: string;
|
|
104
|
+
state: string;
|
|
105
|
+
postalCode: string;
|
|
106
|
+
/**
|
|
107
|
+
* Two-letter ISO 3166-1 country code.
|
|
108
|
+
*/
|
|
109
|
+
country: string;
|
|
110
|
+
};
|
|
99
111
|
export type SetupIntentResponse = {
|
|
100
112
|
readonly clientSecret: string;
|
|
101
113
|
};
|
|
@@ -156,6 +168,10 @@ export type CustomerResponse = {
|
|
|
156
168
|
readonly paymentMethods: Array<PaymentMethodSummary>;
|
|
157
169
|
readonly estimatedCreditBalanceUSD: unknown;
|
|
158
170
|
readonly upcomingInvoiceTotalCents?: number;
|
|
171
|
+
/**
|
|
172
|
+
* The address Stripe Tax uses for the customer's tax location. Null when none is set.
|
|
173
|
+
*/
|
|
174
|
+
billingAddress?: BillingAddress;
|
|
159
175
|
};
|
|
160
176
|
export type UsageInfoResponse = {
|
|
161
177
|
meters: {
|
|
@@ -478,6 +494,43 @@ export type CreateSubscriptionResponses = {
|
|
|
478
494
|
201: SubscriptionResponse;
|
|
479
495
|
};
|
|
480
496
|
export type CreateSubscriptionResponse = CreateSubscriptionResponses[keyof CreateSubscriptionResponses];
|
|
497
|
+
export type UpdateBillingAddressData = {
|
|
498
|
+
body: BillingAddress;
|
|
499
|
+
path: {
|
|
500
|
+
/**
|
|
501
|
+
* Kinde organisation id.
|
|
502
|
+
*/
|
|
503
|
+
org: string;
|
|
504
|
+
};
|
|
505
|
+
query?: never;
|
|
506
|
+
url: '/api/v1/billing-address/{org}';
|
|
507
|
+
};
|
|
508
|
+
export type UpdateBillingAddressErrors = {
|
|
509
|
+
/**
|
|
510
|
+
* Invalid request body, or Stripe could not use the address as a tax location
|
|
511
|
+
*/
|
|
512
|
+
400: _Error;
|
|
513
|
+
/**
|
|
514
|
+
* Unauthorised user
|
|
515
|
+
*/
|
|
516
|
+
401: _Error;
|
|
517
|
+
/**
|
|
518
|
+
* Account not found
|
|
519
|
+
*/
|
|
520
|
+
404: _Error;
|
|
521
|
+
/**
|
|
522
|
+
* Internal error
|
|
523
|
+
*/
|
|
524
|
+
500: _Error;
|
|
525
|
+
};
|
|
526
|
+
export type UpdateBillingAddressError = UpdateBillingAddressErrors[keyof UpdateBillingAddressErrors];
|
|
527
|
+
export type UpdateBillingAddressResponses = {
|
|
528
|
+
/**
|
|
529
|
+
* The billing address was updated
|
|
530
|
+
*/
|
|
531
|
+
204: void;
|
|
532
|
+
};
|
|
533
|
+
export type UpdateBillingAddressResponse = UpdateBillingAddressResponses[keyof UpdateBillingAddressResponses];
|
|
481
534
|
export type CreateSetupIntentData = {
|
|
482
535
|
body?: never;
|
|
483
536
|
path: {
|
|
@@ -1959,6 +1959,15 @@ export declare const zCreateSubscriptionRequest: z.ZodObject<{
|
|
|
1959
1959
|
annual: "annual";
|
|
1960
1960
|
}>;
|
|
1961
1961
|
}, z.core.$strip>;
|
|
1962
|
+
export declare const zBillingAddress: z.ZodObject<{
|
|
1963
|
+
name: z.ZodString;
|
|
1964
|
+
line1: z.ZodString;
|
|
1965
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
1966
|
+
city: z.ZodString;
|
|
1967
|
+
state: z.ZodString;
|
|
1968
|
+
postalCode: z.ZodString;
|
|
1969
|
+
country: z.ZodString;
|
|
1970
|
+
}, z.core.$strip>;
|
|
1962
1971
|
export declare const zSetupIntentResponse: z.ZodObject<{
|
|
1963
1972
|
clientSecret: z.ZodReadonly<z.ZodString>;
|
|
1964
1973
|
}, z.core.$strip>;
|
|
@@ -2919,6 +2928,15 @@ export declare const zCustomerResponse: z.ZodObject<{
|
|
|
2919
2928
|
}, z.core.$strip>>>;
|
|
2920
2929
|
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodUnknown>;
|
|
2921
2930
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
2931
|
+
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
2932
|
+
name: z.ZodString;
|
|
2933
|
+
line1: z.ZodString;
|
|
2934
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
2935
|
+
city: z.ZodString;
|
|
2936
|
+
state: z.ZodString;
|
|
2937
|
+
postalCode: z.ZodString;
|
|
2938
|
+
country: z.ZodString;
|
|
2939
|
+
}, z.core.$strip>>;
|
|
2922
2940
|
}, z.core.$strip>;
|
|
2923
2941
|
export declare const zUsagePoint: z.ZodObject<{
|
|
2924
2942
|
date: z.ZodISODateTime;
|
|
@@ -5249,6 +5267,15 @@ export declare const zGetCustomerResponse: z.ZodObject<{
|
|
|
5249
5267
|
}, z.core.$strip>>>;
|
|
5250
5268
|
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodUnknown>;
|
|
5251
5269
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
5270
|
+
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
5271
|
+
name: z.ZodString;
|
|
5272
|
+
line1: z.ZodString;
|
|
5273
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
5274
|
+
city: z.ZodString;
|
|
5275
|
+
state: z.ZodString;
|
|
5276
|
+
postalCode: z.ZodString;
|
|
5277
|
+
country: z.ZodString;
|
|
5278
|
+
}, z.core.$strip>>;
|
|
5252
5279
|
}, z.core.$strip>;
|
|
5253
5280
|
export declare const zGetUsageData: z.ZodObject<{
|
|
5254
5281
|
body: z.ZodOptional<z.ZodNever>;
|
|
@@ -6555,6 +6582,25 @@ export declare const zCreateSubscriptionResponse: z.ZodObject<{
|
|
|
6555
6582
|
status: z.ZodReadonly<z.ZodString>;
|
|
6556
6583
|
clientSecret: z.ZodOptional<z.ZodReadonly<z.ZodString>>;
|
|
6557
6584
|
}, z.core.$strip>;
|
|
6585
|
+
export declare const zUpdateBillingAddressData: z.ZodObject<{
|
|
6586
|
+
body: z.ZodObject<{
|
|
6587
|
+
name: z.ZodString;
|
|
6588
|
+
line1: z.ZodString;
|
|
6589
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
6590
|
+
city: z.ZodString;
|
|
6591
|
+
state: z.ZodString;
|
|
6592
|
+
postalCode: z.ZodString;
|
|
6593
|
+
country: z.ZodString;
|
|
6594
|
+
}, z.core.$strip>;
|
|
6595
|
+
path: z.ZodObject<{
|
|
6596
|
+
org: z.ZodString;
|
|
6597
|
+
}, z.core.$strip>;
|
|
6598
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
6599
|
+
}, z.core.$strip>;
|
|
6600
|
+
/**
|
|
6601
|
+
* The billing address was updated
|
|
6602
|
+
*/
|
|
6603
|
+
export declare const zUpdateBillingAddressResponse: z.ZodVoid;
|
|
6558
6604
|
export declare const zCreateSetupIntentData: z.ZodObject<{
|
|
6559
6605
|
body: z.ZodOptional<z.ZodNever>;
|
|
6560
6606
|
path: z.ZodObject<{
|
|
@@ -7242,6 +7288,15 @@ export declare const zM2mGetCustomerResponse: z.ZodObject<{
|
|
|
7242
7288
|
}, z.core.$strip>>>;
|
|
7243
7289
|
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodUnknown>;
|
|
7244
7290
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
7291
|
+
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
7292
|
+
name: z.ZodString;
|
|
7293
|
+
line1: z.ZodString;
|
|
7294
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
7295
|
+
city: z.ZodString;
|
|
7296
|
+
state: z.ZodString;
|
|
7297
|
+
postalCode: z.ZodString;
|
|
7298
|
+
country: z.ZodString;
|
|
7299
|
+
}, z.core.$strip>>;
|
|
7245
7300
|
}, z.core.$strip>;
|
|
7246
7301
|
export declare const zM2mCreateCustomerData: z.ZodObject<{
|
|
7247
7302
|
body: z.ZodObject<{
|
|
@@ -121,6 +121,15 @@ export const zCreateSubscriptionRequest = z.object({
|
|
|
121
121
|
plan: z.string(),
|
|
122
122
|
billingInterval: zBillingInterval
|
|
123
123
|
});
|
|
124
|
+
export const zBillingAddress = z.object({
|
|
125
|
+
name: z.string(),
|
|
126
|
+
line1: z.string(),
|
|
127
|
+
line2: z.optional(z.string()),
|
|
128
|
+
city: z.string(),
|
|
129
|
+
state: z.string(),
|
|
130
|
+
postalCode: z.string(),
|
|
131
|
+
country: z.string()
|
|
132
|
+
});
|
|
124
133
|
export const zSetupIntentResponse = z.object({
|
|
125
134
|
clientSecret: z.string().readonly()
|
|
126
135
|
});
|
|
@@ -186,7 +195,8 @@ export const zCustomerResponse = z.object({
|
|
|
186
195
|
seats: z.int().readonly(),
|
|
187
196
|
paymentMethods: z.array(zPaymentMethodSummary).readonly(),
|
|
188
197
|
estimatedCreditBalanceUSD: z.unknown().readonly(),
|
|
189
|
-
upcomingInvoiceTotalCents: z.optional(z.int().readonly())
|
|
198
|
+
upcomingInvoiceTotalCents: z.optional(z.int().readonly()),
|
|
199
|
+
billingAddress: z.optional(zBillingAddress)
|
|
190
200
|
});
|
|
191
201
|
export const zUsagePoint = z.object({
|
|
192
202
|
date: z.iso.datetime(),
|
|
@@ -349,6 +359,17 @@ export const zCreateSubscriptionData = z.object({
|
|
|
349
359
|
* The subscription was created
|
|
350
360
|
*/
|
|
351
361
|
export const zCreateSubscriptionResponse = zSubscriptionResponse;
|
|
362
|
+
export const zUpdateBillingAddressData = z.object({
|
|
363
|
+
body: zBillingAddress,
|
|
364
|
+
path: z.object({
|
|
365
|
+
org: z.string()
|
|
366
|
+
}),
|
|
367
|
+
query: z.optional(z.never())
|
|
368
|
+
});
|
|
369
|
+
/**
|
|
370
|
+
* The billing address was updated
|
|
371
|
+
*/
|
|
372
|
+
export const zUpdateBillingAddressResponse = z.void();
|
|
352
373
|
export const zCreateSetupIntentData = z.object({
|
|
353
374
|
body: z.optional(z.never()),
|
|
354
375
|
path: z.object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation } from "@tanstack/react-query";
|
|
2
2
|
import { GetSuccessResponse } from "../util";
|
|
3
|
-
import { GetCustomerData, GetUsageData, GetPlansData, UpdatePlanData, UpdatePlanResponses, CancelSubscriptionData, CancelSubscriptionResponses, CreateSubscriptionData, CreateSubscriptionResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
|
|
3
|
+
import { GetCustomerData, GetUsageData, GetPlansData, UpdatePlanData, UpdatePlanResponses, CancelSubscriptionData, CancelSubscriptionResponses, CreateSubscriptionData, CreateSubscriptionResponses, UpdateBillingAddressData, UpdateBillingAddressResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
|
|
4
4
|
export declare const useGetCustomer: (options: Omit<GetCustomerData, "url"> & {
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
}) => {
|
|
@@ -646,6 +646,14 @@ export declare const useCreateSubscription: (config?: {
|
|
|
646
646
|
data: import("../../sdk/billing/types.gen").SubscriptionResponse | undefined;
|
|
647
647
|
headers: Record<string, string>;
|
|
648
648
|
}, unknown, Omit<CreateSubscriptionData, "url">, unknown>;
|
|
649
|
+
export declare const useUpdateBillingAddress: (config?: {
|
|
650
|
+
onSuccess?: (data: GetSuccessResponse<UpdateBillingAddressResponses>, headers: Record<string, string>) => void;
|
|
651
|
+
onError?: Parameters<typeof useMutation>["0"]["onError"];
|
|
652
|
+
retry?: boolean;
|
|
653
|
+
}) => import("@tanstack/react-query").UseMutationResult<{
|
|
654
|
+
data: void | undefined;
|
|
655
|
+
headers: Record<string, string>;
|
|
656
|
+
}, unknown, Omit<UpdateBillingAddressData, "url">, unknown>;
|
|
649
657
|
export declare const useCreateSetupIntent: (config?: {
|
|
650
658
|
onSuccess?: (data: GetSuccessResponse<CreateSetupIntentResponses>, headers: Record<string, string>) => void;
|
|
651
659
|
onError?: Parameters<typeof useMutation>["0"]["onError"];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { isPromise, headersToObject } from "../util";
|
|
4
4
|
import { useToken } from "../../provider/token-provider";
|
|
5
|
-
import { getCustomer, getUsage, getPlans, updatePlan, cancelSubscription, createSubscription, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
|
|
5
|
+
import { getCustomer, getUsage, getPlans, updatePlan, cancelSubscription, createSubscription, updateBillingAddress, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
|
|
6
6
|
export const useGetCustomer = (options) => {
|
|
7
7
|
const token = useToken();
|
|
8
8
|
let { enabled, ...rest } = options || { enabled: true };
|
|
@@ -126,6 +126,25 @@ export const useCreateSubscription = (config) => {
|
|
|
126
126
|
retry: config?.retry
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
|
+
export const useUpdateBillingAddress = (config) => {
|
|
130
|
+
const token = useToken();
|
|
131
|
+
const queryClient = useQueryClient();
|
|
132
|
+
const opts = { throwOnError: true, url: "/api/v1/billing-address/{org}" };
|
|
133
|
+
const funcer = async (options) => {
|
|
134
|
+
const auth = isPromise(token) ? (await token) || "" : token || "";
|
|
135
|
+
const res = await updateBillingAddress({ ...opts, ...options, auth });
|
|
136
|
+
return { data: res.data, headers: headersToObject(res.response.headers) };
|
|
137
|
+
};
|
|
138
|
+
return useMutation({
|
|
139
|
+
mutationFn: funcer,
|
|
140
|
+
onSuccess: (res, options, c, ctx) => {
|
|
141
|
+
queryClient.invalidateQueries({ queryKey: ["api", "v1", "billing-address", options?.path?.org] });
|
|
142
|
+
config?.onSuccess && config.onSuccess(res.data, res.headers);
|
|
143
|
+
},
|
|
144
|
+
onError: config?.onError,
|
|
145
|
+
retry: config?.retry
|
|
146
|
+
});
|
|
147
|
+
};
|
|
129
148
|
export const useCreateSetupIntent = (config) => {
|
|
130
149
|
const token = useToken();
|
|
131
150
|
const queryClient = useQueryClient();
|