From 3c99fff833a28a25326b92996c107878072a97f9 Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Sun, 4 May 2025 16:21:54 -0400 Subject: [PATCH] Update generated code --- deno.json | 5 +- package.json | 2 +- src/adminapi.ts | 1193 ++++++++++++++++++++++++++++++++--- src/adminv1.ts | 626 +++++++++++++++--- src/apiv1.ts | 46 -- src/internal/constants.ts | 6 +- src/userapi.ts | 1260 +++++++++++++++++++++++++++++++++++-- src/userv1.ts | 970 +++++++++++++++++++++++++++- 8 files changed, 3825 insertions(+), 283 deletions(-) diff --git a/deno.json b/deno.json index 4999a49..0c9f08f 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@userhub/sdk", - "version": "0.7.0", + "version": "0.8.0", "exports": "./src/mod.ts", "lint": { "include": ["src/", "test/deno"], @@ -11,6 +11,9 @@ "exclude": ["no-explicit-any", "no-empty-interface"] } }, + "compilerOptions": { + "lib": ["dom", "dom.iterable", "deno.ns"] + }, "publish": { "include": ["LICENSE", "README.md", "deno.json", "src"] } diff --git a/package.json b/package.json index b850e1c..b103b67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@userhub/sdk", - "version": "0.7.0", + "version": "0.8.0", "description": "UserHub JavaScript SDK", "license": "MIT", "author": "UserHub (https://userhub.com/)", diff --git a/src/adminapi.ts b/src/adminapi.ts index ea3614f..d4898db 100644 --- a/src/adminapi.ts +++ b/src/adminapi.ts @@ -13,6 +13,13 @@ export class Client { this.transport = transport; } + /** + * The checkout methods. + */ + public get checkouts(): Checkouts { + return new Checkouts(this.transport); + } + /** * The flow methods. */ @@ -34,6 +41,27 @@ export class Client { return new Organizations(this.transport); } + /** + * The payment method methods. + */ + public get paymentMethods(): PaymentMethods { + return new PaymentMethods(this.transport); + } + + /** + * The pricing methods. + */ + public get pricing(): Pricing { + return new Pricing(this.transport); + } + + /** + * The role methods. + */ + public get roles(): Roles { + return new Roles(this.transport); + } + /** * The subscription methods. */ @@ -49,6 +77,306 @@ export class Client { } } +/** + * The checkout methods. + */ +class Checkouts { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Create a checkout. + */ + async create(input?: CheckoutCreateInput): Promise; + async create(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.create", + method: "POST", + path: "/admin/v1/checkouts", + query: ["submit"], + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Get a checkout. + */ + async get( + checkoutId: string, + input?: Omit, + ): Promise; + async get(input: CheckoutGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.get", + method: "GET", + path: "/admin/v1/checkouts/{checkoutId}", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set plan for a checkout. + */ + async setPlan( + checkoutId: string, + input?: Omit, + ): Promise; + async setPlan(input: CheckoutSetPlanInput): Promise; + async setPlan(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setPlan", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setPlan", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set terms for a checkout. + * + * This is generally used to select a billing cycle for + * the plan. + */ + async setTerms( + checkoutId: string, + input?: Omit, + ): Promise; + async setTerms(input: CheckoutSetTermsInput): Promise; + async setTerms(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setTerms", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setTerms", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set trial settings for a checkout. + */ + async setTrial( + checkoutId: string, + input?: Omit, + ): Promise; + async setTrial(input: CheckoutSetTrialInput): Promise; + async setTrial(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setTrial", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setTrial", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set item quantities for a checkout. + */ + async setItems( + checkoutId: string, + input?: Omit, + ): Promise; + async setItems(input: CheckoutSetItemsInput): Promise; + async setItems(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setItems", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setItems", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set payment method for a checkout. + */ + async setPaymentMethod( + checkoutId: string, + input?: Omit, + ): Promise; + async setPaymentMethod( + input: CheckoutSetPaymentMethodInput, + ): Promise; + async setPaymentMethod(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setPaymentMethod", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setPaymentMethod", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set billing details for a checkout. + */ + async setBillingDetails( + checkoutId: string, + input?: Omit, + ): Promise; + async setBillingDetails( + input: CheckoutSetBillingDetailsInput, + ): Promise; + async setBillingDetails(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setBillingDetails", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setBillingDetails", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Add discount to a checkout. + */ + async addDiscount( + checkoutId: string, + input?: Omit, + ): Promise; + async addDiscount(input: CheckoutAddDiscountInput): Promise; + async addDiscount(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.addDiscount", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:addDiscount", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Remove discount from a checkout. + */ + async removeDiscount( + checkoutId: string, + input: Omit, + ): Promise; + async removeDiscount( + input: CheckoutRemoveDiscountInput, + ): Promise; + async removeDiscount(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.removeDiscount", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:removeDiscount", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Complete payment for a checkout. + */ + async completePayment( + checkoutId: string, + input?: Omit, + ): Promise; + async completePayment( + input: CheckoutCompletePaymentInput, + ): Promise; + async completePayment(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.completePayment", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:completePayment", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Set cancel type for a checkout. + */ + async setCancel( + checkoutId: string, + input?: Omit, + ): Promise; + async setCancel(input: CheckoutSetCancelInput): Promise; + async setCancel(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.setCancel", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:setCancel", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Submit a checkout for processing. + */ + async submit( + checkoutId: string, + input?: Omit, + ): Promise; + async submit(input: CheckoutSubmitInput): Promise; + async submit(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.submit", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:submit", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } + + /** + * Cancel a checkout. + */ + async cancel( + checkoutId: string, + input?: Omit, + ): Promise; + async cancel(input: CheckoutCancelInput): Promise; + async cancel(...args: any[]): Promise { + const req = build({ + call: "admin.checkouts.cancel", + method: "POST", + path: "/admin/v1/checkouts/{checkoutId}:cancel", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Checkout; + } +} + /** * The flow methods. */ @@ -60,7 +388,7 @@ class Flows { } /** - * Lists flows. + * List flows. */ async list(input?: FlowListInput): Promise; async list(...args: any[]): Promise { @@ -107,6 +435,29 @@ class Flows { return res.body as adminv1.Flow; } + /** + * Update a join organization flow. + */ + async updateJoinOrganization( + flowId: string, + input?: Omit, + ): Promise; + async updateJoinOrganization( + input: FlowUpdateJoinOrganizationInput, + ): Promise; + async updateJoinOrganization(...args: any[]): Promise { + const req = build({ + call: "admin.flows.updateJoinOrganization", + method: "PATCH", + path: "/admin/v1/flows/{flowId}:updateJoinOrganization", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Flow; + } + /** * Create a signup flow. * @@ -126,7 +477,7 @@ class Flows { } /** - * Retrieves specified flow. + * Get a flow. */ async get( flowId: string, @@ -147,7 +498,7 @@ class Flows { } /** - * Cancels specified flow. + * Cancel a flow. */ async cancel( flowId: string, @@ -179,7 +530,7 @@ class Invoices { } /** - * Lists invoices. + * List invoices. */ async list(input?: InvoiceListInput): Promise; async list(...args: any[]): Promise { @@ -187,7 +538,14 @@ class Invoices { call: "admin.invoices.list", method: "GET", path: "/admin/v1/invoices", - query: ["organizationId", "userId", "pageSize", "pageToken", "orderBy"], + query: [ + "organizationId", + "userId", + "pageSize", + "pageToken", + "orderBy", + "view", + ], idempotent: true, args, }); @@ -197,7 +555,7 @@ class Invoices { } /** - * Retrieves specified invoice. + * Get an invoice. */ async get( invoiceId: string, @@ -217,6 +575,26 @@ class Invoices { const res = await this.transport.execute(req); return res.body as adminv1.Invoice; } + + /** + * Pay an invoice. + */ + async pay( + invoiceId: string, + input?: Omit, + ): Promise; + async pay(input: InvoicePayInput): Promise; + async pay(...args: any[]): Promise { + const req = build({ + call: "admin.invoices.pay", + method: "POST", + path: "/admin/v1/invoices/{invoiceId}:pay", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Invoice; + } } /** @@ -230,7 +608,7 @@ class Organizations { } /** - * Lists organizations. + * List organizations. */ async list( input?: OrganizationListInput, @@ -258,7 +636,7 @@ class Organizations { } /** - * Creates a new organization. + * Create an organization. */ async create(input?: OrganizationCreateInput): Promise; async create(...args: any[]): Promise { @@ -274,7 +652,7 @@ class Organizations { } /** - * Retrieves specified organization. + * Get an organization. */ async get( organizationId: string, @@ -295,7 +673,7 @@ class Organizations { } /** - * Updates specified organization. + * Update an organization. */ async update( organizationId: string, @@ -317,7 +695,13 @@ class Organizations { } /** - * Marks specified organization for deletion. + * Delete an organization. + * + * This marks the organization for deletion and can be restored during + * a grace period. + * + * To immediately delete an organization, you must also call purge + * organization. */ async delete( organizationId: string, @@ -338,7 +722,7 @@ class Organizations { } /** - * Un-marks specified organization for deletion. + * Restore an organization. */ async undelete( organizationId: string, @@ -361,7 +745,7 @@ class Organizations { } /** - * Hard delete the specified organization. + * Purge a deleted organization. * * The organization must be marked for deletion before it can be purged. */ @@ -385,7 +769,7 @@ class Organizations { } /** - * Connect specified organization to external account. + * Connect an organization to an external account. */ async connect( organizationId: string, @@ -405,7 +789,30 @@ class Organizations { } /** - * Disconnect specified organization from external account. + * Update an organization's external account. + */ + async updateConnection( + organizationId: string, + input: Omit, + ): Promise; + async updateConnection( + input: OrganizationUpdateConnectionInput, + ): Promise; + async updateConnection(...args: any[]): Promise { + const req = build({ + call: "admin.organizations.updateConnection", + method: "PATCH", + path: "/admin/v1/organizations/{organizationId}:updateConnection", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Organization; + } + + /** + * Disconnect an organization from an external account. * * This will delete all the data associated with the connected account, including * payment methods, invoices, and subscriptions. @@ -436,7 +843,7 @@ class Organizations { } /** - * Lists organization members. + * List organization members. */ async listMembers( organizationId: string, @@ -467,7 +874,7 @@ class Organizations { } /** - * Creates a new organization member. + * Create an organization member. */ async addMember( organizationId: string, @@ -487,7 +894,7 @@ class Organizations { } /** - * Retrieves specified organization member. + * Get an organization member. */ async getMember( organizationId: string, @@ -509,7 +916,7 @@ class Organizations { } /** - * Updates specified organization member. + * Update an organization member. */ async updateMember( organizationId: string, @@ -534,7 +941,7 @@ class Organizations { } /** - * Deletes specified organization member. + * Delete an organization member. */ async removeMember( organizationId: string, @@ -557,6 +964,199 @@ class Organizations { } } +/** + * The payment method methods. + */ +class PaymentMethods { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Create a payment method. + */ + async create(input: PaymentMethodCreateInput): Promise; + async create(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.create", + method: "POST", + path: "/admin/v1/paymentMethods", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.PaymentMethod; + } + + /** + * Create a payment method intent. + * + * This can be used with a third-party billing provider API + * to store a payment method. + */ + async createIntent( + input: PaymentMethodCreateIntentInput, + ): Promise; + async createIntent(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.createIntent", + method: "POST", + path: "/admin/v1/paymentMethods:createIntent", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.PaymentMethodIntent; + } + + /** + * Get a payment method. + */ + async get( + paymentMethodId: string, + input?: Omit, + ): Promise; + async get(input: PaymentMethodGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.get", + method: "GET", + path: "/admin/v1/paymentMethods/{paymentMethodId}", + query: ["organizationId", "userId"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.PaymentMethod; + } + + /** + * Update a payment method. + */ + async update( + paymentMethodId: string, + input?: Omit, + ): Promise; + async update(input: PaymentMethodUpdateInput): Promise; + async update(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.update", + method: "PATCH", + path: "/admin/v1/paymentMethods/{paymentMethodId}", + query: ["organizationId", "userId"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.PaymentMethod; + } + + /** + * Set a default payment method for an account. + */ + async setDefault( + paymentMethodId: string, + input?: Omit, + ): Promise; + async setDefault( + input: PaymentMethodSetDefaultInput, + ): Promise; + async setDefault(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.setDefault", + method: "POST", + path: "/admin/v1/paymentMethods/{paymentMethodId}:setDefault", + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.PaymentMethod; + } + + /** + * Delete a payment method. + */ + async delete( + paymentMethodId: string, + input?: Omit, + ): Promise; + async delete(input: PaymentMethodDeleteInput): Promise; + async delete(...args: any[]): Promise { + const req = build({ + call: "admin.payment_methods.delete", + method: "DELETE", + path: "/admin/v1/paymentMethods/{paymentMethodId}", + query: ["organizationId", "userId"], + args, + }); + + const res = await this.transport.execute(req); + return res.body as apiv1.EmptyResponse; + } +} + +/** + * The pricing methods. + */ +class Pricing { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Get pricing. + */ + async get(input?: PricingGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "admin.pricing.get", + method: "GET", + path: "/admin/v1/pricing", + query: ["accountType", "organizationId", "userId"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.Pricing; + } +} + +/** + * The role methods. + */ +class Roles { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * List roles. + */ + async list(input?: RoleListInput): Promise; + async list(...args: any[]): Promise { + const req = build({ + call: "admin.roles.list", + method: "GET", + path: "/admin/v1/roles", + query: ["pageSize", "pageToken", "orderBy"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.ListRolesResponse; + } +} + /** * The subscription methods. */ @@ -568,7 +1168,7 @@ class Subscriptions { } /** - * Lists subscriptions. + * List subscriptions. */ async list( input?: SubscriptionListInput, @@ -597,7 +1197,7 @@ class Subscriptions { } /** - * Retrieves specified subscription. + * Get a subscription. */ async get( subscriptionId: string, @@ -630,7 +1230,7 @@ class Users { } /** - * Lists users. + * List users. */ async list(input?: UserListInput): Promise; async list(...args: any[]): Promise { @@ -656,7 +1256,7 @@ class Users { } /** - * Creates a new user. + * Create a user. */ async create(input?: UserCreateInput): Promise; async create(...args: any[]): Promise { @@ -672,7 +1272,7 @@ class Users { } /** - * Retrieves specified user. + * Get a user. */ async get( userId: string, @@ -693,7 +1293,7 @@ class Users { } /** - * Updates specified user. + * Update a user. */ async update( userId: string, @@ -715,7 +1315,12 @@ class Users { } /** - * Marks specified user for deletion. + * Delete a user. + * + * This marks the user for deletion and can be restored during + * a grace period. + * + * To immediately delete a user, you must also call purge user. */ async delete( userId: string, @@ -735,7 +1340,7 @@ class Users { } /** - * Un-marks specified user for deletion. + * Restore a user. */ async undelete( userId: string, @@ -755,7 +1360,7 @@ class Users { } /** - * Hard delete the specified user. + * Purge a deleted user. * * The user must be marked for deletion before it can be purged. */ @@ -777,7 +1382,7 @@ class Users { } /** - * Connect specified user to external account. + * Connect a user to an external account. */ async connect( userId: string, @@ -797,7 +1402,30 @@ class Users { } /** - * Disconnect specified user from external account. + * Update a user's external account. + */ + async updateConnection( + userId: string, + input: Omit, + ): Promise; + async updateConnection( + input: UserUpdateConnectionInput, + ): Promise; + async updateConnection(...args: any[]): Promise { + const req = build({ + call: "admin.users.updateConnection", + method: "PATCH", + path: "/admin/v1/users/{userId}:updateConnection", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as adminv1.User; + } + + /** + * Disconnect a user from an external account. * * This will delete all the data associated with the connected account, including * payment methods, invoices, and subscriptions. @@ -826,10 +1454,9 @@ class Users { } /** - * Import user from external identity provider if they don't already - * exist. + * Import a user from a user provider. * - * If the user already exists in UserHub, this is a no-op. + * If the user already exists, this is a no-op. */ async importAccount( userId: string, @@ -875,7 +1502,7 @@ class Users { } /** - * Create Portal session. + * Create a Portal session. */ async createPortalSession( userId: string, @@ -900,6 +1527,202 @@ class Users { } } +/** + * The input options for the `checkouts.create` method. + */ +interface CheckoutCreateInput extends RequestOptions { + // The identifier of the organization. + // + // This is required if the user identifier is not specified. + organizationId?: string; + // The identifier of the user. + // + // This is required if the organization identifier is not specified. + userId?: string; + // The type of the checkout. + type?: string; + // The identifier of the plan. + // + // This allows you to specify the currently selected plan. + planId?: string; + // The identifier of the subscriptions. + // + // This allows you to specify a non-default subscription. + subscriptionId?: string; + // The identifier of the connection. + // + // This allows you to specify a non-default billing connection. + connectionId?: string; + + // Attempt to submit checkout if ready and due amount is zero. + submit?: boolean; +} + +/** + * The input options for the `checkouts.get` method. + */ +interface CheckoutGetInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.setPlan` method. + */ +interface CheckoutSetPlanInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the plan. + // + // This is required if completed isn't set to true. + planId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setTerms` method. + */ +interface CheckoutSetTermsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the plan. + // + // This is required if completed isn't set to true. + planId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setTrial` method. + */ +interface CheckoutSetTrialInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // Whether to start, continue, or stop a trial. + type?: string; + // The number of days to trial. + days?: number; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setItems` method. + */ +interface CheckoutSetItemsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The items to update. + items?: adminv1.CheckoutItemInput[]; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setPaymentMethod` method. + */ +interface CheckoutSetPaymentMethodInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the payment method. + // + // This is required if external ID isn't specified or completed + // isn't set to true. + paymentMethodId?: string; + // The external identifier of the payment method to connect. + // + // This is required if payment method ID isn't specified or + // completed isn't set to true. + externalId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setBillingDetails` method. + */ +interface CheckoutSetBillingDetailsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The company or individual's full name. + // + // The maximum length is 200 characters. + fullName?: string; + // The billing details address. + address?: commonv1.Address | null; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.addDiscount` method. + */ +interface CheckoutAddDiscountInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The discount code. + code?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.removeDiscount` method. + */ +interface CheckoutRemoveDiscountInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the checkout discount. + checkoutDiscountId?: string; +} + +/** + * The input options for the `checkouts.completePayment` method. + */ +interface CheckoutCompletePaymentInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.setCancel` method. + */ +interface CheckoutSetCancelInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // Whether to cancel at the end of the billing period or immediately. + type?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.submit` method. + */ +interface CheckoutSubmitInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.cancel` method. + */ +interface CheckoutCancelInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + /** * The input options for the `flows.list` method. */ @@ -931,9 +1754,6 @@ interface FlowListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `createTime desc` orderBy?: string; // The Flow view to return in the results. // @@ -953,7 +1773,7 @@ interface FlowCreateJoinOrganizationInput extends RequestOptions { userId?: string; // The email address of the person to invite. // - // This is required if user is not specified or the user + // This is required if the user is not specified or // does not have an email address. email?: string; // The display name of the person to invite. @@ -975,6 +1795,17 @@ interface FlowCreateJoinOrganizationInput extends RequestOptions { ttl?: string; } +/** + * The input options for the `flows.updateJoinOrganization` method. + */ +interface FlowUpdateJoinOrganizationInput extends RequestOptions { + // The identifier of the flow. + flowId: string; + + // The identifier of the role. + roleId?: string; +} + /** * The input options for the `flows.createSignup` method. */ @@ -1022,11 +1853,11 @@ interface FlowCancelInput extends RequestOptions { interface InvoiceListInput extends RequestOptions { // Filter results by organization identifier. // - // This is required if user identifier is not specified. + // This is required if the user identifier is not specified. organizationId?: string; // Filter results by user identifier. // - // This is required if organization identifier is not specified. + // This is required if the organization identifier is not specified. userId?: string; // The maximum number of invoices to return. The API may return fewer than // this value. @@ -1041,11 +1872,11 @@ interface InvoiceListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `createTime asc` - // - `createTime desc` orderBy?: string; + // The Invoice view to return in the results. + // + // This defaults to the `BASIC` view. + view?: string; } /** @@ -1061,6 +1892,23 @@ interface InvoiceGetInput extends RequestOptions { userId?: string; } +/** + * The input options for the `invoices.pay` method. + */ +interface InvoicePayInput extends RequestOptions { + // The identifier of the invoice. + invoiceId: string; + + // Restrict by organization identifier. + organizationId?: string; + // Restrict by user identifier. + userId?: string; + // The identifier of the payment method. + // + // The default payment method will be used if not specified. + paymentMethodId?: string; +} + /** * The input options for the `organizations.list` method. */ @@ -1094,13 +1942,6 @@ interface OrganizationListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `displayName asc` - // - `email asc` - // - `signupTime desc` - // - `createTime desc` - // - `deleteTime desc` orderBy?: string; // Whether to show deleted organizations. showDeleted?: boolean; @@ -1258,6 +2099,41 @@ interface OrganizationConnectInput extends RequestOptions { externalId?: string; } +/** + * The input options for the `organizations.updateConnection` method. + */ +interface OrganizationUpdateConnectionInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + + // The system-assigned identifier for the connection of the external account. + connectionId?: string; + // The human-readable display name of the external account. + // + // The maximum length is 200 characters. + // + // This might be further restricted by the external provider. + displayName?: string; + // The email address of the external account. + // + // The maximum length is 320 characters. + // + // This might be further restricted by the external provider. + email?: string; + // Whether the external account's email address has been verified. + emailVerified?: boolean; + // The E164 phone number for the external account (e.g. `+12125550123`). + phoneNumber?: string; + // Whether the external account's phone number has been verified. + phoneNumberVerified?: boolean; + // The default ISO-4217 currency code for the external account (e.g. `USD`). + currencyCode?: string; + // The billing address for the external account. + address?: commonv1.Address | null; + // Whether the external account is disabled. + disabled?: boolean; +} + /** * The input options for the `organizations.disconnect` method. */ @@ -1310,11 +2186,6 @@ interface OrganizationListMembersInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `displayName asc` - // - `email asc` - // - `createTime desc` orderBy?: string; } @@ -1367,6 +2238,165 @@ interface OrganizationRemoveMemberInput extends RequestOptions { userId: string; } +/** + * The input options for the `paymentMethods.create` method. + */ +interface PaymentMethodCreateInput extends RequestOptions { + // The identifier of the organization. + // + // This is required if the user identifier not specified. + organizationId?: string; + // The identifier of the user. + // + // This is required if the organization identifier not specified. + userId?: string; + // The identifier of the connection. + connectionId?: string; + // The external identifier of the payment method to connect. + externalId?: string; + // Whether to set the payment method as the default. + // + // This defaults to true. + default?: boolean; +} + +/** + * The input options for the `paymentMethods.createIntent` method. + */ +interface PaymentMethodCreateIntentInput extends RequestOptions { + // The identifier of the organization. + // + // This is required if the user identifier is not specified. + organizationId?: string; + // The identifier of the user. + // + // This is required if the organization identifier is not not + // specified. + userId?: string; + // The identifier of the connection. + connectionId?: string; +} + +/** + * The input options for the `paymentMethods.get` method. + */ +interface PaymentMethodGetInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; + + // The identifier of the organization. + // + // Optionally restrict update to payment methods owned by + // this organization. + organizationId?: string; + // The identifier of the user. + // + // Optionally restrict update to payment methods owned by + // this user. + userId?: string; +} + +/** + * The input options for the `paymentMethods.update` method. + */ +interface PaymentMethodUpdateInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; + + // The full name of the owner of the payment method (e.g. `Jane Doe`). + fullName?: string; + // The address for the payment method. + address?: commonv1.Address | null; + // The card expiration year (e.g. `2030`). + expYear?: number; + // The card expiration month (e.g. `12`). + expMonth?: number; + + // The identifier of the organization. + // + // Optionally restrict update to payment methods owned by + // this organization. + organizationId?: string; + // The identifier of the user. + // + // Optionally restrict update to payment methods owned by + // this user. + userId?: string; +} + +/** + * The input options for the `paymentMethods.setDefault` method. + */ +interface PaymentMethodSetDefaultInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; + + // The identifier of the organization. + // + // Optionally restrict set default to payment methods owned by + // this organization. + organizationId?: string; + // The identifier of the user. + // + // Optionally restrict set default to payment methods owned by + // this user. + userId?: string; +} + +/** + * The input options for the `paymentMethods.delete` method. + */ +interface PaymentMethodDeleteInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; + + // The identifier of the organization. + // + // Optionally restrict delete to payment methods owned by + // this organization. + organizationId?: string; + // The identifier of the user. + // + // Optionally restrict delete to payment methods owned by + // this user. + userId?: string; +} + +/** + * The input options for the `pricing.get` method. + */ +interface PricingGetInput extends RequestOptions { + // Whether to get pricing for users or organizations. + // + // This is not required if either user ID or organization ID is specified + // and will default to user if no options are specified. + accountType?: string; + // Show pricing for specified organization. + organizationId?: string; + // Show pricing for the specified user. + userId?: string; +} + +/** + * The input options for the `roles.list` method. + */ +interface RoleListInput extends RequestOptions { + // The maximum number of roles to return. The API may return fewer than + // this value. + // + // If unspecified, at most 20 roles will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + pageSize?: number; + // A page token, received from a previous list roles call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to list roles must match + // the call that provided the page token. + pageToken?: string; + // A comma-separated list of fields to order by. + orderBy?: string; +} + /** * The input options for the `subscriptions.list` method. */ @@ -1396,11 +2426,6 @@ interface SubscriptionListInput extends RequestOptions { // A comma-separated list of fields to order by. // // This is only supported when either `organizationId` or `userId` is specified. - // - // Supports: - // - `active desc` - // - `createTime desc` - // - `startTime desc` orderBy?: string; // The Subscription view to return in the results. // @@ -1454,13 +2479,6 @@ interface UserListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `displayName asc` - // - `email asc` - // - `signupTime desc` - // - `createTime desc` - // - `deleteTime desc` orderBy?: string; // Whether to show deleted users. showDeleted?: boolean; @@ -1618,6 +2636,41 @@ interface UserConnectInput extends RequestOptions { externalId?: string; } +/** + * The input options for the `users.updateConnection` method. + */ +interface UserUpdateConnectionInput extends RequestOptions { + // The identifier of the user. + userId: string; + + // The system-assigned identifier for the connection of the external account. + connectionId?: string; + // The human-readable display name of the external account. + // + // The maximum length is 200 characters. + // + // This might be further restricted by the external provider. + displayName?: string; + // The email address of the external account. + // + // The maximum length is 320 characters. + // + // This might be further restricted by the external provider. + email?: string; + // Whether the external account's email address has been verified. + emailVerified?: boolean; + // The E164 phone number for the external account (e.g. `+12125550123`). + phoneNumber?: string; + // Whether the external account's phone number has been verified. + phoneNumberVerified?: boolean; + // The default ISO-4217 currency code for the external account (e.g. `USD`). + currencyCode?: string; + // The billing address for the external account. + address?: commonv1.Address | null; + // Whether the external account is disabled. + disabled?: boolean; +} + /** * The input options for the `users.disconnect` method. */ @@ -1678,8 +2731,6 @@ interface UserCreatePortalSessionInput extends RequestOptions { // // Examples: // * `/{accountId}` - the billing dashboard - // * `/{accountId}/checkout` - start a checkout - // * `/{accountId}/checkout/` - start a checkout with a specified plan // * `/{accountId}/cancel` - cancel current plan // * `/{accountId}/members` - manage organization members // * `/{accountId}/invite` - invite a user to an organization diff --git a/src/adminv1.ts b/src/adminv1.ts index 136181a..02aadc3 100644 --- a/src/adminv1.ts +++ b/src/adminv1.ts @@ -68,14 +68,6 @@ export interface AccountConnection { * The payment methods for connections that support it. */ paymentMethods?: PaymentMethod[]; - /** - * The last time the account was pulled from the connection. - */ - pullTime?: Date | null; - /** - * The last time the account was pushed to the connection. - */ - pushTime?: Date | null; /** * The creation time of the account connection. */ @@ -86,6 +78,56 @@ export interface AccountConnection { updateTime: Date; } +/** + * AccountConnection input parameters. + */ +export interface AccountConnectionInput { + /** + * The system-assigned identifier for the connection of the external account. + */ + connectionId: string; + /** + * The human-readable display name of the external account. + * + * The maximum length is 200 characters. + * + * This might be further restricted by the external provider. + */ + displayName?: string; + /** + * The email address of the external account. + * + * The maximum length is 320 characters. + * + * This might be further restricted by the external provider. + */ + email?: string; + /** + * Whether the external account's email address has been verified. + */ + emailVerified?: boolean; + /** + * The E164 phone number for the external account (e.g. `+12125550123`). + */ + phoneNumber?: string; + /** + * Whether the external account's phone number has been verified. + */ + phoneNumberVerified?: boolean; + /** + * The default ISO-4217 currency code for the external account (e.g. `USD`). + */ + currencyCode?: string; + /** + * The billing address for the external account. + */ + address?: commonv1.Address | null; + /** + * Whether the external account is disabled. + */ + disabled?: boolean; +} + /** * The account view of the subscription. */ @@ -226,12 +268,6 @@ export interface CardPaymentMethod { * The brand of the card (e.g. `VISA`). */ brand?: string; - /** - * The expiration date of the card. - * - * @deprecated Use `expYear` and `expMonth` instead. - */ - expiration?: CardPaymentMethodExpiration | null; /** * The last for digits of the card. */ @@ -251,17 +287,325 @@ export interface CardPaymentMethod { } /** - * The expiration date for the card. + * The checkout. */ -export interface CardPaymentMethodExpiration { +export interface Checkout { /** - * The expiration year. + * The system-assigned identifier of the checkout. */ - year?: number; + id: string; /** - * The expiration month. + * The type of checkout. + */ + type: string; + /** + * The state of the checkout. + */ + state: string; + /** + * The checkout error. + */ + error?: apiv1.Status | null; + /** + * The currently selected currency code. + */ + currencyCode: string; + /** + * The plans available for checkout. + */ + plans?: Plan[]; + /** + * The payment method for the checkout. + */ + paymentMethod?: PaymentMethod | null; + /** + * The company or individual's full name. + */ + fullName?: string; + /** + * The billing address. + */ + address?: commonv1.Address | null; + /** + * The steps required to complete the checkout. + */ + steps?: CheckoutStep[]; + /** + * The products included in the checkout. + */ + items?: CheckoutItem[]; + /** + * The discounts applied to the checkout. + */ + discounts?: CheckoutDiscount[]; + /** + * The subtotal amount for the checkout. + * + * This includes item-level discounts. + */ + subtotalAmount?: string; + /** + * The top-level discount amount. + * + * This does not include item level discounts. + */ + discountAmount?: string; + /** + * The tax amount for the checkout. + * + * This is for rendering purposes only and is + * not the reported tax amount. + */ + taxAmount?: string; + /** + * The total amount for the checkout. + */ + totalAmount?: string; + /** + * The amount applied to the checkout from the balance. + * + * A negative amount means a debit from the account balance. + * A positive amount means a credit to the account balance. + */ + balanceAppliedAmount?: string; + /** + * The total amount minus any credits automatically + * associated with the invoice. + */ + dueAmount?: string; + /** + * The normal total recurring amount. + * + * This does not include any time-limited discounts. + */ + renewAmount?: string; +} + +/** + * The cancel step details. + */ +export interface CheckoutCancelStep { + /** + * The type of cancellation. + */ + type?: string; +} + +/** + * The complete payment step details. + */ +export interface CheckoutCompletePaymentStep { + /** + * The payment intent for the checkout. + */ + paymentIntent?: PaymentIntent | null; +} + +/** + * The discount. + */ +export interface CheckoutDiscount { + /** + * The checkout discount identifier. + */ + id: string; + /** + * The discount code. + */ + code?: string; +} + +/** + * Checkout input parameters. + */ +export interface CheckoutInput { + /** + * The identifier of the organization. + * + * This is required if the user identifier is not specified. + */ + organizationId?: string; + /** + * The identifier of the user. + * + * This is required if the organization identifier is not specified. + */ + userId?: string; + /** + * The type of the checkout. + */ + type?: string; + /** + * The identifier of the plan. + * + * This allows you to specify the currently selected plan. + */ + planId?: string; + /** + * The identifier of the subscriptions. + * + * This allows you to specify a non-default subscription. + */ + subscriptionId?: string; + /** + * The identifier of the connection. + * + * This allows you to specify a non-default billing connection. + */ + connectionId?: string; +} + +/** + * The checkout item. + */ +export interface CheckoutItem { + /** + * The item identifier. + */ + id: string; + /** + * The display name for the item. + */ + displayName: string; + /** + * The input type of the item. + */ + inputType: string; + /** + * The type of the item. + */ + type?: string; + /** + * The unit for the item. + */ + unit?: string; + /** + * The price for the item. + */ + price?: Price | null; + /** + * The quantity for the item. + */ + quantity?: number; + /** + * The minimum quantity allowed. + * + * This will only be set when quantity is settable. + */ + minQuantity?: number; + /** + * The maximum quantity allowed. + * + * This will only be set when the quantity is settable and there is a + * discrete (non-infinity) maximum. + */ + maxQuantity?: number; + /** + * The quantity at which the plan will renew. + * + * This will only be set when different from quantity and the + * subscription is set to renew. + */ + renewQuantity?: number; + /** + * The minimum renew quantity allowed. + * + * This will only be set when renew quantity is settable. + */ + minRenewQuantity?: number; + /** + * The maximum renew quantity allowed. + * + * This will only be set when the new quantity is settable and there is a + * discrete (non-infinity) maximum. + */ + maxRenewQuantity?: number; + /** + * The billing period for the item. + */ + period?: commonv1.Period | null; + /** + * The subtotal amount at checkout. + */ + subtotalAmount?: string; + /** + * The item-level discount amount at checkout. + */ + discountAmount?: string; + /** + * The normal recurring amount. + * + * This does not include any time-limited discounts. + */ + renewAmount?: string; + /** + * Whether this is a preview-only item. + * + * Preview-only items are generally prorations or other pending + * charges or credits. */ - month?: number; + preview?: boolean; + /** + * The item identifier for which you can group this item. + * + * This allows you to group credits and other preview items + * with the related plan, seat, or add-on item. + */ + groupItemId?: string; +} + +/** + * Checkout item input. + */ +export interface CheckoutItemInput { + /** + * The identifier of the item. + */ + id: string; + /** + * The quantity for the item. + */ + quantity?: number; +} + +/** + * The checkout step. + */ +export interface CheckoutStep { + /** + * The type of step. + */ + type: string; + /** + * The state of the step. + */ + state: string; + /** + * The trial step details. + */ + trial?: CheckoutTrialStep | null; + /** + * The cancel step details. + */ + cancel?: CheckoutCancelStep | null; + /** + * The complete payment step details. + */ + completePayment?: CheckoutCompletePaymentStep | null; +} + +/** + * The trial step details. + */ +export interface CheckoutTrialStep { + /** + * Whether to start or continue a trial. + */ + type?: string; + /** + * The number of days in the trial. + */ + days?: number; } /** @@ -308,18 +652,6 @@ export interface Connection { * The connection providers. */ providers: ConnectionProvider[]; - /** - * The connection view. - */ - view: string; - /** - * The creation time of the connection. - */ - createTime: Date; - /** - * The last update time of the connection. - */ - updateTime: Date; /** * The Amazon Cognito connection data. */ @@ -348,6 +680,18 @@ export interface Connection { * The webhooks configuration data. */ webhook?: WebhookConnection | null; + /** + * The connection view. + */ + view: string; + /** + * The creation time of the connection. + */ + createTime: Date; + /** + * The last update time of the connection. + */ + updateTime: Date; } /** @@ -474,6 +818,14 @@ export interface Flow { * This is only populated on create. */ secret?: string; + /** + * The join organization flow type specific data. + */ + joinOrganization?: JoinOrganizationFlow | null; + /** + * The signup flow type specific data + */ + signup?: SignupFlow | null; /** * The flow view. */ @@ -486,14 +838,6 @@ export interface Flow { * The last update time of the flow. */ updateTime: Date; - /** - * The join organization flow type specific data. - */ - joinOrganization?: JoinOrganizationFlow | null; - /** - * The signup flow type specific data - */ - signup?: SignupFlow | null; } /** @@ -627,9 +971,9 @@ export interface Invoice { */ changes?: InvoiceChange[]; /** - * The last time the invoice was pulled from the connection. + * The invoice view. */ - pullTime?: Date | null; + view: string; /** * The creation time of the invoice. */ @@ -872,6 +1216,27 @@ export interface ListOrganizationsResponse { previousPageToken?: string; } +/** + * Response message for ListRoles. + */ +export interface ListRolesResponse { + /** + * The list of roles. + */ + roles: Role[]; + /** + * A token, which can be sent as `pageToken` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + nextPageToken?: string; + /** + * A token, which can be sent as `pageToken` to retrieve the previous page. + * If this field is absent, there are no preceding pages. If this field is + * an empty string then the previous page is the first result. + */ + previousPageToken?: string; +} + /** * Response message for ListSubscriptions. */ @@ -938,6 +1303,10 @@ export interface Member { * has not been assigned a seat. */ seat?: AccountSubscriptionSeat | null; + /** + * The member view. + */ + view: string; /** * The creation time of the membership. */ @@ -1252,9 +1621,13 @@ export interface PaymentMethod { */ lastPaymentError?: apiv1.Status | null; /** - * The last time the payment method was pulled from the connection. + * Card payment method (e.g. Visa credit card). + */ + card?: CardPaymentMethod | null; + /** + * The payment method view. */ - pullTime?: Date | null; + view: string; /** * The creation time of the payment method connection. */ @@ -1263,10 +1636,38 @@ export interface PaymentMethod { * The last update time of the payment method connection. */ updateTime: Date; +} + +/** + * Payment method input parameters. + */ +export interface PaymentMethodInput { /** - * Card payment method (e.g. Visa credit card). + * The full name of the owner of the payment method (e.g. `Jane Doe`). */ - card?: CardPaymentMethod | null; + fullName?: string; + /** + * The address for the payment method. + */ + address?: commonv1.Address | null; + /** + * The card expiration year (e.g. `2030`). + */ + expYear?: number; + /** + * The card expiration month (e.g. `12`). + */ + expMonth?: number; +} + +/** + * Configuration for setting up a payment method. + */ +export interface PaymentMethodIntent { + /** + * A Stripe Setup Intent. + */ + stripe?: StripePaymentMethodIntent | null; } /** @@ -1281,6 +1682,10 @@ export interface Plan { * The status of the plan. */ state: string; + /** + * The client defined unique identifier of the plan. + */ + uniqueId?: string; /** * The name of the plan. */ @@ -1298,15 +1703,15 @@ export interface Plan { /** * The currency code for the plan (e.g. `USD`). */ - currencyCode: string; + currencyCode?: string; /** * The billing interval for the plan. */ - billingInterval: commonv1.Interval; + interval?: commonv1.Interval | null; /** * The revision for the plan. */ - revision: PlanRevision; + revision?: PlanRevision | null; /** * Whether this is the current plan for the subscription. * @@ -1352,7 +1757,7 @@ export interface Plan { } /** - * The products which the plan includes. + * The products included in the plan. */ export interface PlanItem { /** @@ -1364,7 +1769,7 @@ export interface PlanItem { */ product: Product; /** - * The price associated with them item. + * The price associated with the item. */ price: Price; } @@ -1398,7 +1803,7 @@ export interface PlanRevision { /** * The tag for the revision. * - * This will only be set in checkout for plans set using a tag. + * This is only set in checkout for plans selected using a tag. */ tag?: string; } @@ -1489,19 +1894,23 @@ export interface Price { */ product?: Product | null; /** - * The archived status of the price. - * - * It determines if the price can be used. + * The price is dependent on the quantity. */ - archived?: boolean; + empty?: PriceEmptyPrice | null; + /** + * The price is fixed per quantity. + */ + fixed?: PriceFixedPrice | null; /** - * The last time the price was pulled from the connection. + * The price is dependent on the quantity. */ - pullTime?: Date | null; + tiered?: PriceTieredPrice | null; /** - * The last time the price was pushed to the connection. + * The archived status of the price. + * + * It determines if the price can be used. */ - pushTime?: Date | null; + archived?: boolean; /** * The price view. */ @@ -1514,18 +1923,6 @@ export interface Price { * The last update time of the price. */ updateTime: Date; - /** - * The price is dependent on the quantity. - */ - empty?: PriceEmptyPrice | null; - /** - * The price is fixed per quantity. - */ - fixed?: PriceFixedPrice | null; - /** - * The price is dependent on the quantity. - */ - tiered?: PriceTieredPrice | null; } /** @@ -1595,6 +1992,16 @@ export interface PriceTransformQuantity { round: string; } +/** + * The plans available in checkout. + */ +export interface Pricing { + /** + * The list of plans. + */ + plans: Plan[]; +} + /** * Product describes a service a tenant provides. */ @@ -1676,14 +2083,6 @@ export interface ProductConnection { * The code that best describes the reason for the state. */ stateReason?: string; - /** - * The last time the product was pulled from the connection. - */ - pullTime?: Date | null; - /** - * The last time the product was pushed to the connection. - */ - pushTime?: Date | null; /** * The creation time of the product connection. */ @@ -1752,6 +2151,10 @@ export interface Role { * The archived status of the role. */ archived?: boolean; + /** + * The role view. + */ + view: string; /** * The creation time of the role. */ @@ -1826,6 +2229,28 @@ export interface StripePaymentIntent { clientSecret: string; } +/** + * A Stripe Setup Intent. + */ +export interface StripePaymentMethodIntent { + /** + * The Stripe account ID (e.g. `acct_1LcUvxQYGbxD2SPK`) + */ + accountId: string; + /** + * Whether the Stripe Setup Intent was created in live mode. + */ + live: boolean; + /** + * The Stripe Setup Intent client secret. + */ + clientSecret: string; + /** + * The Stripe.js Payment Element options. + */ + paymentElementOptions?: Record; +} + /** * The representation of an activated plan. */ @@ -1874,6 +2299,13 @@ export interface Subscription { * Whether the subscription is scheduled to be canceled * at the end of the current billing period. */ + renewCanceled?: boolean; + /** + * Whether the subscription is scheduled to be canceled + * at the end of the current billing period. + * + * @deprecated Use `renewCanceled` instead. + */ cancelPeriodEnd?: boolean; /** * The anchor time for the billing cycle. @@ -1897,30 +2329,16 @@ export interface Subscription { currentPeriod?: SubscriptionCurrentPeriod | null; /** * The organization owner of the subscription. - * - * The ID field of this object must be populated if - * if user isn't specified. */ organization?: Organization | null; /** * The user owner of the subscription. - * - * The ID field of this object must be populated if - * if organization isn't specified. */ user?: User | null; /** * Whether the subscription is the default for the account. */ default?: boolean; - /** - * The last time the subscription was pulled from the connection. - */ - pullTime?: Date | null; - /** - * The last time the subscription was pushed to the connection. - */ - pushTime?: Date | null; /** * The subscription view. */ @@ -1993,13 +2411,13 @@ export interface SubscriptionSeatInfo { * This might be less than the total quantity while a subscription change * is pending or if the subscription is over-provisioned. */ - currentPeriodQuantity?: number; + currentQuantity?: number; /** - * The number of seats scheduled to appear on the next invoice. + * The number of seats expected at renewal. * - * This will only be set when different from current period quantity. + * This will only be set when different from current quantity. */ - nextPeriodQuantity?: number; + renewQuantity?: number; /** * The number of seats currently assigned. */ @@ -2019,7 +2437,7 @@ export interface SubscriptionSeatInfo { */ availableQuantity?: number; /** - * The total number of seats for the current period. + * The total number of seats associated with the subscription. */ totalQuantity?: number; } @@ -2053,6 +2471,16 @@ export interface SubscriptionTrial { remainingDays?: number; } +/** + * Input message for UpdateJoinOrganizationFlow. + */ +export interface UpdateJoinOrganizationFlowInput { + /** + * The identifier of the role. + */ + roleId?: string; +} + /** * Individual account. */ diff --git a/src/apiv1.ts b/src/apiv1.ts index eab460a..eb67d34 100644 --- a/src/apiv1.ts +++ b/src/apiv1.ts @@ -5,52 +5,6 @@ */ export interface EmptyResponse {} -/** - * The field view options.. - */ -export interface FieldView { - /** - * Whether the field is included in the view. - * - * THis overrides the message default. - */ - include?: string; - /** - * Whether the field is excluded from the view. - * - * THis overrides the message default. - */ - exclude?: string; - /** - * The referenced type's view. - */ - type?: string; -} - -/** - * The message view options. - */ -export interface MessageView { - /** - * Whether all fields are included in the view by default. - */ - include?: string; - /** - * Whether all fields are excluded from the view by default. - */ - exclude?: string; -} - -/** - * Operations metadata. - */ -export interface OperationInfo { - /** - * The message name of the primary return type for this operation. - */ - responseType?: string; -} - /** * The full API error. */ diff --git a/src/internal/constants.ts b/src/internal/constants.ts index b63d8ba..caf2da3 100644 --- a/src/internal/constants.ts +++ b/src/internal/constants.ts @@ -1,9 +1,9 @@ // Code generated. DO NOT EDIT. export const API_BASE_URL = "https://api.userhub.com"; -export const API_VERSION = "2022-11-15"; -export const USER_AGENT = "UserHub-JavaScript/0.7.0"; -export const VERSION = "0.7.0"; +export const API_VERSION = "2025-05-01"; +export const USER_AGENT = "UserHub-JavaScript/0.8.0"; +export const VERSION = "0.8.0"; export const AUTH_HEADER = "Authorization"; export const API_KEY_HEADER = "UserHub-Api-Key"; diff --git a/src/userapi.ts b/src/userapi.ts index b06728b..d2e282e 100644 --- a/src/userapi.ts +++ b/src/userapi.ts @@ -1,5 +1,6 @@ // Code generated. DO NOT EDIT. import type * as apiv1 from "./apiv1.ts"; +import type * as commonv1 from "./commonv1.ts"; import { build } from "./internal/http.ts"; import { Transport } from "./internal/transport.ts"; import type { RequestOptions } from "./request.ts"; @@ -12,6 +13,20 @@ export class Client { this.transport = transport; } + /** + * The billing account methods. + */ + public get billingAccount(): BillingAccount { + return new BillingAccount(this.transport); + } + + /** + * The checkout methods. + */ + public get checkouts(): Checkouts { + return new Checkouts(this.transport); + } + /** * The flow methods. */ @@ -33,6 +48,27 @@ export class Client { return new Organizations(this.transport); } + /** + * The payment method methods. + */ + public get paymentMethods(): PaymentMethods { + return new PaymentMethods(this.transport); + } + + /** + * The pricing methods. + */ + public get pricing(): Pricing { + return new Pricing(this.transport); + } + + /** + * The role methods. + */ + public get roles(): Roles { + return new Roles(this.transport); + } + /** * The Portal session. */ @@ -41,6 +77,315 @@ export class Client { } } +/** + * The billing account methods. + */ +class BillingAccount { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Get the default billing account. + */ + async get(input?: BillingAccountGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "user.billing_account.get", + method: "GET", + path: "/user/v1/billingAccount", + query: ["organizationId"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.BillingAccount; + } + + /** + * Update the default billing account. + */ + async update( + input?: BillingAccountUpdateInput, + ): Promise; + async update(...args: any[]): Promise { + const req = build({ + call: "user.billing_account.update", + method: "PATCH", + path: "/user/v1/billingAccount", + query: ["organizationId"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.BillingAccount; + } +} + +/** + * The checkout methods. + */ +class Checkouts { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Create a new checkout. + */ + async create(input?: CheckoutCreateInput): Promise; + async create(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.create", + method: "POST", + path: "/user/v1/checkouts", + query: ["submit"], + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Get a checkout. + */ + async get( + checkoutId: string, + input?: Omit, + ): Promise; + async get(input: CheckoutGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.get", + method: "GET", + path: "/user/v1/checkouts/{checkoutId}", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Set plan for a checkout. + */ + async setPlan( + checkoutId: string, + input?: Omit, + ): Promise; + async setPlan(input: CheckoutSetPlanInput): Promise; + async setPlan(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.setPlan", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:setPlan", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Set terms for a checkout. + * + * This is generally used to select a billing cycle for + * the plan. + */ + async setTerms( + checkoutId: string, + input?: Omit, + ): Promise; + async setTerms(input: CheckoutSetTermsInput): Promise; + async setTerms(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.setTerms", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:setTerms", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Set item quantities for a checkout. + */ + async setItems( + checkoutId: string, + input?: Omit, + ): Promise; + async setItems(input: CheckoutSetItemsInput): Promise; + async setItems(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.setItems", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:setItems", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Set payment method for a checkout. + */ + async setPaymentMethod( + checkoutId: string, + input?: Omit, + ): Promise; + async setPaymentMethod( + input: CheckoutSetPaymentMethodInput, + ): Promise; + async setPaymentMethod(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.setPaymentMethod", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:setPaymentMethod", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Set billing details for a checkout. + */ + async setBillingDetails( + checkoutId: string, + input?: Omit, + ): Promise; + async setBillingDetails( + input: CheckoutSetBillingDetailsInput, + ): Promise; + async setBillingDetails(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.setBillingDetails", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:setBillingDetails", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Add discount to a checkout. + */ + async addDiscount( + checkoutId: string, + input?: Omit, + ): Promise; + async addDiscount(input: CheckoutAddDiscountInput): Promise; + async addDiscount(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.addDiscount", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:addDiscount", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Remove discount from a checkout. + */ + async removeDiscount( + checkoutId: string, + input: Omit, + ): Promise; + async removeDiscount( + input: CheckoutRemoveDiscountInput, + ): Promise; + async removeDiscount(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.removeDiscount", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:removeDiscount", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Complete payment for a checkout. + */ + async completePayment( + checkoutId: string, + input?: Omit, + ): Promise; + async completePayment( + input: CheckoutCompletePaymentInput, + ): Promise; + async completePayment(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.completePayment", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:completePayment", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Submit a checkout for processing. + */ + async submit( + checkoutId: string, + input?: Omit, + ): Promise; + async submit(input: CheckoutSubmitInput): Promise; + async submit(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.submit", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:submit", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } + + /** + * Cancel a checkout. + */ + async cancel( + checkoutId: string, + input?: Omit, + ): Promise; + async cancel(input: CheckoutCancelInput): Promise; + async cancel(...args: any[]): Promise { + const req = build({ + call: "user.checkouts.cancel", + method: "POST", + path: "/user/v1/checkouts/{checkoutId}:cancel", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Checkout; + } +} + /** * The flow methods. */ @@ -52,7 +397,7 @@ class Flows { } /** - * Lists flows. + * List flows. */ async list(input?: FlowListInput): Promise; async list(...args: any[]): Promise { @@ -78,7 +423,7 @@ class Flows { } /** - * Creates a join organization flow. + * Create a new join organization flow. * * This invites a person to join an organization. */ @@ -98,7 +443,30 @@ class Flows { } /** - * Creates a signup flow. + * Update a join organization flow. + */ + async updateJoinOrganization( + flowId: string, + input?: Omit, + ): Promise; + async updateJoinOrganization( + input: FlowUpdateJoinOrganizationInput, + ): Promise; + async updateJoinOrganization(...args: any[]): Promise { + const req = build({ + call: "user.flows.updateJoinOrganization", + method: "PATCH", + path: "/user/v1/flows/{flowId}:updateJoinOrganization", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Flow; + } + + /** + * Create a new signup flow. * * This invites a person to join the app. */ @@ -116,7 +484,7 @@ class Flows { } /** - * Retrieves specified flow. + * Get a flow. */ async get( flowId: string, @@ -137,7 +505,7 @@ class Flows { } /** - * Consume the flow. + * Consume a flow. * * This accepts the flow (e.g. for a join organization flow it will * accept the invitation and add the member to the organization). @@ -160,7 +528,7 @@ class Flows { } /** - * Cancels specified flow. + * Cancel a flow. * * This cancels the flow and hides it from the user. */ @@ -194,7 +562,7 @@ class Invoices { } /** - * Lists invoices. + * List invoices. */ async list(input?: InvoiceListInput): Promise; async list(...args: any[]): Promise { @@ -212,7 +580,7 @@ class Invoices { } /** - * Retrieves specified invoice. + * Get an invoice. */ async get( invoiceId: string, @@ -231,6 +599,26 @@ class Invoices { const res = await this.transport.execute(req); return res.body as userv1.Invoice; } + + /** + * Pay an invoice. + */ + async pay( + invoiceId: string, + input?: Omit, + ): Promise; + async pay(input: InvoicePayInput): Promise; + async pay(...args: any[]): Promise { + const req = build({ + call: "user.invoices.pay", + method: "POST", + path: "/user/v1/invoices/{invoiceId}:pay", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Invoice; + } } /** @@ -244,7 +632,7 @@ class Organizations { } /** - * Lists organizations. + * List organizations. */ async list( input?: OrganizationListInput, @@ -264,7 +652,7 @@ class Organizations { } /** - * Creates a new organization. + * Create a new organization. */ async create(input?: OrganizationCreateInput): Promise; async create(...args: any[]): Promise { @@ -280,7 +668,7 @@ class Organizations { } /** - * Retrieves specified organization. + * Get an organization. */ async get( organizationId: string, @@ -301,7 +689,7 @@ class Organizations { } /** - * Updates specified organization. + * Update an organization. */ async update( organizationId: string, @@ -322,61 +710,420 @@ class Organizations { } /** - * Delete specified organization. + * List organization members. */ - async delete( + async listMembers( organizationId: string, - input?: Omit, - ): Promise; - async delete(input: OrganizationDeleteInput): Promise; - async delete(...args: any[]): Promise { + input?: Omit, + ): Promise; + async listMembers( + input: OrganizationListMembersInput, + ): Promise; + async listMembers(...args: any[]): Promise { const req = build({ - call: "user.organizations.delete", - method: "DELETE", - path: "/user/v1/organizations/{organizationId}", + call: "user.organizations.listMembers", + method: "GET", + path: "/user/v1/organizations/{organizationId}/members", + query: ["pageSize", "pageToken", "orderBy"], + idempotent: true, args, }); const res = await this.transport.execute(req); - return res.body as apiv1.EmptyResponse; + return res.body as userv1.ListMembersResponse; } /** - * Leave organization. - * - * This allows a user to remove themselves from an organization - * without have permission to manage the organization. + * Get an organization member. */ - async leave( + async getMember( organizationId: string, - input?: Omit, - ): Promise; - async leave(input: OrganizationLeaveInput): Promise; - async leave(...args: any[]): Promise { + userId: string, + input?: Omit, + ): Promise; + async getMember(input: OrganizationGetMemberInput): Promise; + async getMember(...args: any[]): Promise { const req = build({ - call: "user.organizations.leave", - method: "DELETE", - path: "/user/v1/organizations/{organizationId}:leave", + call: "user.organizations.getMember", + method: "GET", + path: "/user/v1/organizations/{organizationId}/members/{userId}", + idempotent: true, args, }); const res = await this.transport.execute(req); - return res.body as apiv1.EmptyResponse; + return res.body as userv1.Member; } -} -/** - * The Portal session. - */ -class Session { - private readonly transport: Transport; + /** + * Update an organization member. + */ + async updateMember( + organizationId: string, + userId: string, + input?: Omit, + ): Promise; + async updateMember( + input: OrganizationUpdateMemberInput, + ): Promise; + async updateMember(...args: any[]): Promise { + const req = build({ + call: "user.organizations.updateMember", + method: "PATCH", + path: "/user/v1/organizations/{organizationId}/members/{userId}", + idempotent: true, + args, + }); - constructor(transport: Transport) { - this.transport = transport; + const res = await this.transport.execute(req); + return res.body as userv1.Member; } /** - * Get the current session details. + * Assign a seat to an organization member. + * + * This will automatically purchase additional seats if none + * are available and the plan has just-in-time seat provisioning + * enabled. + */ + async assignMemberSeat( + organizationId: string, + userId: string, + input?: Omit< + OrganizationAssignMemberSeatInput, + "organizationId" | "userId" + >, + ): Promise; + async assignMemberSeat( + input: OrganizationAssignMemberSeatInput, + ): Promise; + async assignMemberSeat(...args: any[]): Promise { + const req = build({ + call: "user.organizations.assignMemberSeat", + method: "POST", + path: "/user/v1/organizations/{organizationId}/members/{userId}:assignSeat", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Member; + } + + /** + * Unassign a seat from an organization member. + */ + async unassignMemberSeat( + organizationId: string, + userId: string, + input?: Omit< + OrganizationUnassignMemberSeatInput, + "organizationId" | "userId" + >, + ): Promise; + async unassignMemberSeat( + input: OrganizationUnassignMemberSeatInput, + ): Promise; + async unassignMemberSeat(...args: any[]): Promise { + const req = build({ + call: "user.organizations.unassignMemberSeat", + method: "POST", + path: "/user/v1/organizations/{organizationId}/members/{userId}:unassignSeat", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Member; + } + + /** + * Remove a member from an organization. + */ + async removeMember( + organizationId: string, + userId: string, + input?: Omit, + ): Promise; + async removeMember( + input: OrganizationRemoveMemberInput, + ): Promise; + async removeMember(...args: any[]): Promise { + const req = build({ + call: "user.organizations.removeMember", + method: "DELETE", + path: "/user/v1/organizations/{organizationId}/members/{userId}", + args, + }); + + const res = await this.transport.execute(req); + return res.body as apiv1.EmptyResponse; + } + + /** + * Delete an organization. + */ + async delete( + organizationId: string, + input?: Omit, + ): Promise; + async delete(input: OrganizationDeleteInput): Promise; + async delete(...args: any[]): Promise { + const req = build({ + call: "user.organizations.delete", + method: "DELETE", + path: "/user/v1/organizations/{organizationId}", + args, + }); + + const res = await this.transport.execute(req); + return res.body as apiv1.EmptyResponse; + } + + /** + * Leave an organization. + * + * This allows a user to remove themselves from an organization + * without have permission to manage the organization. + */ + async leave( + organizationId: string, + input?: Omit, + ): Promise; + async leave(input: OrganizationLeaveInput): Promise; + async leave(...args: any[]): Promise { + const req = build({ + call: "user.organizations.leave", + method: "DELETE", + path: "/user/v1/organizations/{organizationId}:leave", + args, + }); + + const res = await this.transport.execute(req); + return res.body as apiv1.EmptyResponse; + } +} + +/** + * The payment method methods. + */ +class PaymentMethods { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * List payment methods for an account. + */ + async list( + input?: PaymentMethodListInput, + ): Promise; + async list(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.list", + method: "GET", + path: "/user/v1/paymentMethods", + query: ["organizationId", "pageSize", "pageToken"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.ListPaymentMethodsResponse; + } + + /** + * Create a new payment method. + */ + async create(input: PaymentMethodCreateInput): Promise; + async create(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.create", + method: "POST", + path: "/user/v1/paymentMethods", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.PaymentMethod; + } + + /** + * Create a new payment method intent. + * + * This can be used with a third-party billing provider to + * store a payment method. + */ + async createIntent( + input?: PaymentMethodCreateIntentInput, + ): Promise; + async createIntent(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.createIntent", + method: "POST", + path: "/user/v1/paymentMethods:createIntent", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.PaymentMethodIntent; + } + + /** + * Get a payment method. + */ + async get( + paymentMethodId: string, + input?: Omit, + ): Promise; + async get(input: PaymentMethodGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.get", + method: "GET", + path: "/user/v1/paymentMethods/{paymentMethodId}", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.PaymentMethod; + } + + /** + * Update a payment method. + */ + async update( + paymentMethodId: string, + input?: Omit, + ): Promise; + async update(input: PaymentMethodUpdateInput): Promise; + async update(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.update", + method: "PATCH", + path: "/user/v1/paymentMethods/{paymentMethodId}", + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.PaymentMethod; + } + + /** + * Set a default payment method for an account. + */ + async setDefault( + paymentMethodId: string, + input?: Omit, + ): Promise; + async setDefault( + input: PaymentMethodSetDefaultInput, + ): Promise; + async setDefault(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.setDefault", + method: "POST", + path: "/user/v1/paymentMethods/{paymentMethodId}:setDefault", + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.PaymentMethod; + } + + /** + * Delete a payment method. + */ + async delete( + paymentMethodId: string, + input?: Omit, + ): Promise; + async delete(input: PaymentMethodDeleteInput): Promise; + async delete(...args: any[]): Promise { + const req = build({ + call: "user.payment_methods.delete", + method: "DELETE", + path: "/user/v1/paymentMethods/{paymentMethodId}", + args, + }); + + const res = await this.transport.execute(req); + return res.body as apiv1.EmptyResponse; + } +} + +/** + * The pricing methods. + */ +class Pricing { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Get pricing. + */ + async get(input?: PricingGetInput): Promise; + async get(...args: any[]): Promise { + const req = build({ + call: "user.pricing.get", + method: "GET", + path: "/user/v1/pricing", + query: ["accountType", "organizationId", "public"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.Pricing; + } +} + +/** + * The role methods. + */ +class Roles { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * List roles. + */ + async list(input?: RoleListInput): Promise; + async list(...args: any[]): Promise { + const req = build({ + call: "user.roles.list", + method: "GET", + path: "/user/v1/roles", + query: ["pageSize", "pageToken", "orderBy"], + idempotent: true, + args, + }); + + const res = await this.transport.execute(req); + return res.body as userv1.ListRolesResponse; + } +} + +/** + * The Portal session. + */ +class Session { + private readonly transport: Transport; + + constructor(transport: Transport) { + this.transport = transport; + } + + /** + * Get details about the current session. */ async get(input?: SessionGetInput): Promise; async get(...args: any[]): Promise { @@ -393,7 +1140,7 @@ class Session { } /** - * Exchange an ID token from your IdP for an access token. + * Exchange an ID token from an IdP for an access token. */ async exchangeToken( input: SessionExchangeTokenInput, @@ -413,7 +1160,7 @@ class Session { } /** - * Create Portal session. + * Create a new Portal session. */ async createPortal( input?: SessionCreatePortalInput, @@ -433,6 +1180,199 @@ class Session { } } +/** + * The input options for the `billingAccount.get` method. + */ +interface BillingAccountGetInput extends RequestOptions { + // The identifier of the organization. + // + // If not specified the billing account for the user is returned. + organizationId?: string; +} + +/** + * The input options for the `billingAccount.update` method. + */ +interface BillingAccountUpdateInput extends RequestOptions { + // The human-readable display name of the billing account. + // + // The maximum length is 200 characters. + // + // This might be further restricted by the billing provider. + displayName?: string; + // The email address of the billing account. + // + // The maximum length is 320 characters. + // + // This might be further restricted by the billing provider. + email?: string; + // The E164 phone number of the billing account (e.g. `+12125550123`). + phoneNumber?: string; + // The address for the billing account. + address?: commonv1.Address | null; + + // The identifier of the organization. + // + // If not specified the billing account for the user is used. + organizationId?: string; +} + +/** + * The input options for the `checkouts.create` method. + */ +interface CheckoutCreateInput extends RequestOptions { + // The identifier of the organization. + // + // This must be provided for organization checkouts. + organizationId?: string; + // The type of the checkout. + type?: string; + // The identifier of the plan. + // + // This allows you to specify the currently selected plan. + planId?: string; + + // Attempt to submit checkout if ready and due amount is zero. + submit?: boolean; +} + +/** + * The input options for the `checkouts.get` method. + */ +interface CheckoutGetInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.setPlan` method. + */ +interface CheckoutSetPlanInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the plan. + // + // This is required if completed isn't set to true. + planId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setTerms` method. + */ +interface CheckoutSetTermsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the plan. + // + // This is required if completed isn't set to true. + planId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setItems` method. + */ +interface CheckoutSetItemsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The items to update. + items?: userv1.CheckoutItemInput[]; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setPaymentMethod` method. + */ +interface CheckoutSetPaymentMethodInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the payment method. + // + // This is required if external ID isn't specified or completed + // isn't set to true. + paymentMethodId?: string; + // The external identifier of the payment method to connect. + // + // This is required if payment method ID isn't specified or + // completed isn't set to true. + externalId?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.setBillingDetails` method. + */ +interface CheckoutSetBillingDetailsInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The company or individual's full name. + // + // The maximum length is 200 characters. + fullName?: string; + // The billing details address. + address?: commonv1.Address | null; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.addDiscount` method. + */ +interface CheckoutAddDiscountInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The discount code. + code?: string; + // Mark the step completed if it is optional. + completed?: boolean; +} + +/** + * The input options for the `checkouts.removeDiscount` method. + */ +interface CheckoutRemoveDiscountInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; + + // The identifier of the checkout discount. + checkoutDiscountId?: string; +} + +/** + * The input options for the `checkouts.completePayment` method. + */ +interface CheckoutCompletePaymentInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.submit` method. + */ +interface CheckoutSubmitInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + +/** + * The input options for the `checkouts.cancel` method. + */ +interface CheckoutCancelInput extends RequestOptions { + // The identifier of the checkout. + checkoutId: string; +} + /** * The input options for the `flows.list` method. */ @@ -464,9 +1404,6 @@ interface FlowListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `createTime desc` orderBy?: string; } @@ -491,6 +1428,17 @@ interface FlowCreateJoinOrganizationInput extends RequestOptions { roleId?: string; } +/** + * The input options for the `flows.updateJoinOrganization` method. + */ +interface FlowUpdateJoinOrganizationInput extends RequestOptions { + // The identifier of the flow. + flowId: string; + + // The identifier of the role. + roleId?: string; +} + /** * The input options for the `flows.createSignup` method. */ @@ -549,10 +1497,6 @@ interface InvoiceListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `createTime asc` - // - `createTime desc` orderBy?: string; } @@ -564,6 +1508,14 @@ interface InvoiceGetInput extends RequestOptions { invoiceId: string; } +/** + * The input options for the `invoices.pay` method. + */ +interface InvoicePayInput extends RequestOptions { + // The identifier of the invoice. + invoiceId: string; +} + /** * The input options for the `organizations.list` method. */ @@ -581,10 +1533,6 @@ interface OrganizationListInput extends RequestOptions { // the call that provided the page token. pageToken?: string; // A comma-separated list of fields to order by. - // - // Supports: - // - `displayName asc` - // - `email asc` orderBy?: string; } @@ -651,6 +1599,82 @@ interface OrganizationUpdateInput extends RequestOptions { flowId?: string; } +/** + * The input options for the `organizations.listMembers` method. + */ +interface OrganizationListMembersInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + + // The maximum number of members to return. The API may return fewer than + // this value. + // + // If unspecified, at most 20 members will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + pageSize?: number; + // A page token, received from a previous list members call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to list members must match + // the call that provided the page token. + pageToken?: string; + // A comma-separated list of fields to order by. + orderBy?: string; +} + +/** + * The input options for the `organizations.getMember` method. + */ +interface OrganizationGetMemberInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + // The identifier of the user. + userId: string; +} + +/** + * The input options for the `organizations.updateMember` method. + */ +interface OrganizationUpdateMemberInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + // The identifier of the user. + userId: string; + + // The identifier of the role. + roleId?: string; +} + +/** + * The input options for the `organizations.assignMemberSeat` method. + */ +interface OrganizationAssignMemberSeatInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + // The identifier of the user. + userId: string; +} + +/** + * The input options for the `organizations.unassignMemberSeat` method. + */ +interface OrganizationUnassignMemberSeatInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + // The identifier of the user. + userId: string; +} + +/** + * The input options for the `organizations.removeMember` method. + */ +interface OrganizationRemoveMemberInput extends RequestOptions { + // The identifier of the organization. + organizationId: string; + // The identifier of the user. + userId: string; +} + /** * The input options for the `organizations.delete` method. */ @@ -667,6 +1691,128 @@ interface OrganizationLeaveInput extends RequestOptions { organizationId: string; } +/** + * The input options for the `paymentMethods.list` method. + */ +interface PaymentMethodListInput extends RequestOptions { + // Show results for specified organization. + // + // If this is not provided the user's individual subscription(s) + // will be returned. + organizationId?: string; + // The maximum number of payment methods to return. The API may return fewer than + // this value. + // + // If unspecified, at most 20 payment methods will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + pageSize?: number; + // A page token, received from a previous list payment methods call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to list payment methods must match + // the call that provided the page token. + pageToken?: string; +} + +/** + * The input options for the `paymentMethods.create` method. + */ +interface PaymentMethodCreateInput extends RequestOptions { + // The identifier of the organization. + organizationId?: string; + // The external identifier of the payment method to connect. + externalId?: string; +} + +/** + * The input options for the `paymentMethods.createIntent` method. + */ +interface PaymentMethodCreateIntentInput extends RequestOptions { + // The identifier of the organization. + organizationId?: string; +} + +/** + * The input options for the `paymentMethods.get` method. + */ +interface PaymentMethodGetInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; +} + +/** + * The input options for the `paymentMethods.update` method. + */ +interface PaymentMethodUpdateInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; + + // The full name of the owner of the payment method (e.g. `Jane Doe`). + fullName?: string; + // The address for the payment method. + address?: commonv1.Address | null; + // The card expiration year (e.g. `2030`). + expYear?: number; + // The card expiration month (e.g. `12`). + expMonth?: number; +} + +/** + * The input options for the `paymentMethods.setDefault` method. + */ +interface PaymentMethodSetDefaultInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; +} + +/** + * The input options for the `paymentMethods.delete` method. + */ +interface PaymentMethodDeleteInput extends RequestOptions { + // The identifier of the payment method. + paymentMethodId: string; +} + +/** + * The input options for the `pricing.get` method. + */ +interface PricingGetInput extends RequestOptions { + // Whether to get pricing for users or organizations. + // + // This is not required if organization ID is specified + // and will default to user if no options are specified. + accountType?: string; + // Show pricing for specified organization. + // + // If this and account type are not specified, it will default to + // the requesting user for authenticated requests. + organizationId?: string; + // Always get the current public pricing. + // + // For unauthenticated requests, this is always true. + public?: boolean; +} + +/** + * The input options for the `roles.list` method. + */ +interface RoleListInput extends RequestOptions { + // The maximum number of roles to return. The API may return fewer than + // this value. + // + // If unspecified, at most 20 roles will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + pageSize?: number; + // A page token, received from a previous list roles call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to list roles must match + // the call that provided the page token. + pageToken?: string; + // A comma-separated list of fields to order by. + orderBy?: string; +} + /** * The input options for the `session.get` method. */ diff --git a/src/userv1.ts b/src/userv1.ts index c164f2c..03f177d 100644 --- a/src/userv1.ts +++ b/src/userv1.ts @@ -1,4 +1,5 @@ // Code generated. DO NOT EDIT. +import type * as apiv1 from "./apiv1.ts"; import type * as commonv1 from "./commonv1.ts"; /** @@ -38,6 +39,10 @@ export interface AccountSubscriptionPlan { * The identifier of the plan. */ id: string; + /** + * The client defined unique identifier of the plan. + */ + uniqueId?: string; /** * The human-readable display name of the plan. */ @@ -58,6 +63,394 @@ export interface AccountSubscriptionSeat { product?: Product | null; } +/** + * The billing account for an organization or user. + */ +export interface BillingAccount { + /** + * The status of the billing account. + */ + state?: string; + /** + * The human-readable display name of the billing account. + */ + displayName?: string; + /** + * The email address of the billing account. + */ + email?: string; + /** + * The E164 phone number for the billing account (e.g. `+12125550123`). + */ + phoneNumber?: string; + /** + * The billing address for the billing account. + */ + address?: commonv1.Address | null; + /** + * The ISO-4217 currency code for the billing account (e.g. `USD`). + */ + currencyCode?: string; + /** + * The balance amount for the account. + * + * A negative value indicates an amount which will be subtracted from the next + * invoice (credit). + * + * A positive value indicates an amount which will be added to the next + * invoice (debt). + */ + balanceAmount?: string; + /** + * The available checkouts. + */ + checkouts?: BillingAccountCheckout[]; + /** + * The default and latest 10 payment methods for the account. + */ + paymentMethods?: PaymentMethod[]; + /** + * The subscription for the account. + */ + subscription?: Subscription | null; +} + +/** + * The discount. + */ +export interface BillingAccountCheckout { + /** + * The type of checkout. + */ + type: string; +} + +/** + * BillingAccountInput input parameters. + */ +export interface BillingAccountInput { + /** + * The human-readable display name of the billing account. + * + * The maximum length is 200 characters. + * + * This might be further restricted by the billing provider. + */ + displayName?: string; + /** + * The email address of the billing account. + * + * The maximum length is 320 characters. + * + * This might be further restricted by the billing provider. + */ + email?: string; + /** + * The E164 phone number of the billing account (e.g. `+12125550123`). + */ + phoneNumber?: string; + /** + * The address for the billing account. + */ + address?: commonv1.Address | null; +} + +/** + * A card payment method (e.g. credit, debit, etc...). + */ +export interface CardPaymentMethod { + /** + * The brand of the card (e.g. `VISA`). + */ + brand?: string; + /** + * The expiration year. + */ + expYear?: number; + /** + * The expiration month. + */ + expMonth?: number; + /** + * The last for digits of the card. + */ + last4?: string; + /** + * The funding method for the card (e.g. `DEBIT`) + */ + fundingType?: string; +} + +/** + * The checkout. + */ +export interface Checkout { + /** + * The system-assigned identifier of the checkout. + */ + id: string; + /** + * The type of checkout. + */ + type: string; + /** + * The state of the checkout. + */ + state: string; + /** + * The checkout error. + */ + error?: apiv1.Status | null; + /** + * The currently selected currency code. + */ + currencyCode: string; + /** + * The plans available for checkout. + */ + plans?: Plan[]; + /** + * The payment method for the checkout. + */ + paymentMethod?: PaymentMethod | null; + /** + * The company or individual's full name. + */ + fullName?: string; + /** + * The billing address. + */ + address?: commonv1.Address | null; + /** + * The steps required to complete the checkout. + */ + steps?: CheckoutStep[]; + /** + * The products included in the checkout. + */ + items?: CheckoutItem[]; + /** + * The discounts applied to the checkout. + */ + discounts?: CheckoutDiscount[]; + /** + * The subtotal amount for the checkout. + * + * This includes item-level discounts. + */ + subtotalAmount?: string; + /** + * The top-level discount amount. + * + * This does not include item level discounts. + */ + discountAmount?: string; + /** + * The tax amount for the checkout. + * + * This is for rendering purposes only and is + * not the reported tax amount. + */ + taxAmount?: string; + /** + * The total amount for the checkout. + */ + totalAmount?: string; + /** + * The amount applied to the checkout from the balance. + * + * A negative amount means a debit from the account balance. + * A positive amount means a credit to the account balance. + */ + balanceAppliedAmount?: string; + /** + * The total amount minus any credits automatically + * associated with the invoice. + */ + dueAmount?: string; + /** + * The normal total recurring amount. + * + * This does not include any time-limited discounts. + */ + renewAmount?: string; +} + +/** + * The complete payment step details. + */ +export interface CheckoutCompletePaymentStep { + /** + * The payment intent for the checkout. + */ + paymentIntent?: PaymentIntent | null; +} + +/** + * The discount. + */ +export interface CheckoutDiscount { + /** + * The checkout discount identifier. + */ + id: string; + /** + * The discount code. + */ + code?: string; +} + +/** + * Checkout input parameters. + */ +export interface CheckoutInput { + /** + * The identifier of the organization. + * + * This must be provided for organization checkouts. + */ + organizationId?: string; + /** + * The type of the checkout. + */ + type?: string; + /** + * The identifier of the plan. + * + * This allows you to specify the currently selected plan. + */ + planId?: string; +} + +/** + * The checkout item. + */ +export interface CheckoutItem { + /** + * The item identifier. + */ + id: string; + /** + * The display name for the item. + */ + displayName: string; + /** + * The input type of the item. + */ + inputType: string; + /** + * The type of the item. + */ + type?: string; + /** + * The unit for the item. + */ + unit?: string; + /** + * The price for the item. + */ + price?: Price | null; + /** + * The quantity for the item. + */ + quantity?: number; + /** + * The minimum quantity allowed. + * + * This will only be set when quantity is settable. + */ + minQuantity?: number; + /** + * The maximum quantity allowed. + * + * This will only be set when the quantity is settable and there is a + * discrete (non-infinity) maximum. + */ + maxQuantity?: number; + /** + * The quantity at which the plan will renew. + * + * This will only be set when different from quantity and the + * subscription is set to renew. + */ + renewQuantity?: number; + /** + * The minimum renew quantity allowed. + * + * This will only be set when renew quantity is settable. + */ + minRenewQuantity?: number; + /** + * The maximum renew quantity allowed. + * + * This will only be set when the new quantity is settable and there is a + * discrete (non-infinity) maximum. + */ + maxRenewQuantity?: number; + /** + * The billing period for the item. + */ + period?: commonv1.Period | null; + /** + * The subtotal amount at checkout. + */ + subtotalAmount?: string; + /** + * The item-level discount amount at checkout. + */ + discountAmount?: string; + /** + * The item-level normal recurring amount. + */ + renewAmount?: string; + /** + * Whether this is a preview-only item. + * + * Preview-only items are generally prorations or other pending + * charges or credits. + */ + preview?: boolean; + /** + * The item identifier for which you can group this item. + * + * This allows you to group credits and other preview items + * with the related plan, seat, or add-on item. + */ + groupItemId?: string; +} + +/** + * Checkout item input. + */ +export interface CheckoutItemInput { + /** + * The identifier of the item. + */ + id: string; + /** + * The quantity for the item. + */ + quantity?: number; +} + +/** + * The checkout step. + */ +export interface CheckoutStep { + /** + * The type of step. + */ + type: string; + /** + * The state of the step. + */ + state: string; + /** + * The complete payment step details. + */ + completePayment?: CheckoutCompletePaymentStep | null; +} + /** * Response message for CreatePortalSession. */ @@ -438,13 +831,13 @@ export interface ListInvoicesResponse { } /** - * Response message for ListOrganizations. + * Response message for ListMembers. */ -export interface ListOrganizationsResponse { +export interface ListMembersResponse { /** - * The list of organizations. + * The list of members. */ - organizations?: Organization[]; + members?: Member[]; /** * A token, which can be sent as `pageToken` to retrieve the next page. * If this field is omitted, there are no subsequent pages. @@ -459,7 +852,106 @@ export interface ListOrganizationsResponse { } /** - * A user's membership in an organization. + * Response message for ListOrganizations. + */ +export interface ListOrganizationsResponse { + /** + * The list of organizations. + */ + organizations?: Organization[]; + /** + * A token, which can be sent as `pageToken` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + nextPageToken?: string; + /** + * A token, which can be sent as `pageToken` to retrieve the previous page. + * If this field is absent, there are no preceding pages. If this field is + * an empty string then the previous page is the first result. + */ + previousPageToken?: string; +} + +/** + * Response message for ListPaymentMethods. + */ +export interface ListPaymentMethodsResponse { + /** + * The list of payment methods. + */ + paymentMethods: PaymentMethod[]; + /** + * A token, which can be sent as `pageToken` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + nextPageToken?: string; + /** + * A token, which can be sent as `pageToken` to retrieve the previous page. + * If this field is absent, there are no preceding pages. If this field is + * an empty string then the previous page is the first result. + */ + previousPageToken?: string; +} + +/** + * Response message for ListRoles. + */ +export interface ListRolesResponse { + /** + * The list of roles. + */ + roles: Role[]; + /** + * A token, which can be sent as `pageToken` to retrieve the next page. + * If this field is omitted, there are no subsequent pages. + */ + nextPageToken?: string; + /** + * A token, which can be sent as `pageToken` to retrieve the previous page. + * If this field is absent, there are no preceding pages. If this field is + * an empty string then the previous page is the first result. + */ + previousPageToken?: string; +} + +/** + * A member of an organization. + */ +export interface Member { + /** + * The user. + */ + user: User; + /** + * The user's role within the organization. + */ + role: Role; + /** + * The seat assigned to the member. + * + * This will be absent if there is no active + * subscription for the organization or the user + * has not been assigned a seat. + */ + seat?: AccountSubscriptionSeat | null; +} + +/** + * Member input parameters. + */ +export interface MemberInput { + /** + * The identifier of the user. + */ + userId?: string; + /** + * The identifier of the role. + */ + roleId?: string; +} + +/** + * A user's membership in an organization. * * This is the user view, see Member for the organizational * view. @@ -563,6 +1055,243 @@ export interface PaymentIntent { stripe?: StripePaymentIntent | null; } +/** + * A link to an external payment method (e.g. credit card, bank account). + */ +export interface PaymentMethod { + /** + * The system-assigned identifier of the payment method. + */ + id?: string; + /** + * The payment method type. + */ + type: string; + /** + * A human-readable description of the payment method. + * + * This can be used to show a description of the payment method + * when the type is UNKNOWN or not explicitly handled. + */ + displayName?: string; + /** + * The full name of the owner of the payment method. + */ + fullName?: string; + /** + * The address for the payment method. + */ + address?: commonv1.Address | null; + /** + * Whether the payment method is the default for the account. + */ + default?: boolean; + /** + * The last payment error. + * + * This will be unset if the payment method is updated + * or if a payment succeeds. + */ + lastPaymentError?: apiv1.Status | null; + /** + * Card payment method (e.g. Visa credit card). + */ + card?: CardPaymentMethod | null; + /** + * The creation time of the payment method connection. + */ + createTime: Date; + /** + * The last update time of the payment method connection. + */ + updateTime: Date; +} + +/** + * Payment method input parameters. + */ +export interface PaymentMethodInput { + /** + * The full name of the owner of the payment method (e.g. `Jane Doe`). + */ + fullName?: string; + /** + * The address for the payment method. + */ + address?: commonv1.Address | null; + /** + * The card expiration year (e.g. `2030`). + */ + expYear?: number; + /** + * The card expiration month (e.g. `12`). + */ + expMonth?: number; +} + +/** + * Configuration for setting up a payment method. + */ +export interface PaymentMethodIntent { + /** + * A Stripe Setup Intent. + */ + stripe?: StripePaymentMethodIntent | null; +} + +/** + * The plan. + */ +export interface Plan { + /** + * The system-assigned identifier of the plan. + */ + id: string; + /** + * The status of the plan. + */ + state: string; + /** + * The client defined unique identifier of the plan. + */ + uniqueId?: string; + /** + * The name of the plan. + */ + displayName: string; + /** + * The description of the plan. + */ + description?: string; + /** + * The tier for the plan. + * + * This is only available in checkout and pricing. + */ + tier?: string; + /** + * The currency code for the plan (e.g. `USD`). + */ + currencyCode?: string; + /** + * The billing interval for the plan. + */ + interval?: commonv1.Interval | null; + /** + * The revision for the plan. + */ + revision?: PlanRevision | null; + /** + * Whether this is the current plan for the subscription. + * + * This is only set in checkout. + */ + current?: boolean; + /** + * Whether this is the selected plan. + * + * This is only set in checkout. + */ + selected?: boolean; + /** + * Whether this is the default term for the plan. + */ + default?: boolean; + /** + * The trial settings. + * + * For authenticated requests, this will only be set for accounts that + * are eligible for a new trial. + */ + trial?: PlanTrial | null; + /** + * Whether the change is considered an upgrade or + * a downgrade. + * + * This is only set in checkout. + */ + changePath?: string; + /** + * The savings for the plan. + * + * The savings are in comparison to the plan in the revision with the + * shortest billing interval (normally monthly). + */ + savings?: PlanSavings | null; + /** + * The items associated with plan. + */ + items?: PlanItem[]; +} + +/** + * The products included in the plan. + */ +export interface PlanItem { + /** + * The plan item type. + */ + type: string; + /** + * The product associated with the item. + */ + product: Product; + /** + * The price associated with the item. + */ + price: Price; +} + +/** + * The revision information for the plan. + */ +export interface PlanRevision { + /** + * The system-assigned identifier of the plan revision. + */ + id: string; + /** + * Whether this is the current revision for the subscription. + * + * This is only set in checkout. + */ + current?: boolean; + /** + * Whether this is the selected revision. + * + * This is only set in checkout. + */ + selected?: boolean; + /** + * Whether this is the latest revision for the plan. + * + * This is only set for a current or selected plan in checkout. + */ + latest?: boolean; +} + +/** + * The savings for the plan. + */ +export interface PlanSavings { + /** + * The percentage savings (1-100). + * + * This percentage is rounded down. + */ + percentage?: number; +} + +/** + * The trial details. + */ +export interface PlanTrial { + /** + * The number of days in the trial. + */ + days: number; +} + /** * Price for a product. */ @@ -655,6 +1384,16 @@ export interface PriceTransformQuantity { round: string; } +/** + * The plans available in checkout. + */ +export interface Pricing { + /** + * The list of plans. + */ + plans: Plan[]; +} + /** * The product. */ @@ -786,6 +1525,227 @@ export interface StripePaymentIntent { clientSecret: string; } +/** + * A Stripe Setup Intent. + */ +export interface StripePaymentMethodIntent { + /** + * The Stripe account ID (e.g. `acct_1LcUvxQYGbxD2SPK`) + */ + accountId: string; + /** + * Whether the Stripe Setup Intent was created in live mode. + */ + live: boolean; + /** + * The Stripe Setup Intent client secret. + */ + clientSecret: string; + /** + * The Stripe.js Payment Element options. + */ + paymentElementOptions?: Record; +} + +/** + * The user's or organization's subscription. + */ +export interface Subscription { + /** + * The system-assigned identifier of the subscription. + */ + id: string; + /** + * The status of the subscription. + */ + state: string; + /** + * The currency code for the subscription (e.g. `USD`). + */ + currencyCode?: string; + /** + * The subscription items. + */ + plan?: Plan | null; + /** + * The payment method. + */ + paymentMethod?: PaymentMethod | null; + /** + * The subscription is scheduled to be canceled at the end of the + * current billing period. + */ + renewCanceled?: boolean; + /** + * The subscription is scheduled to be canceled at the end of the + * current billing period. + * + * @deprecated Use `renewCanceled` instead. + */ + cancelPeriodEnd?: boolean; + /** + * The time the subscription started. + */ + startTime?: Date | null; + /** + * The time the subscription ends/ended. + */ + endTime?: Date | null; + /** + * The trial information for the subscription. + */ + trial?: SubscriptionTrial | null; + /** + * The current billing period for the subscription. + */ + currentPeriod?: SubscriptionCurrentPeriod | null; + /** + * The subscription items. + */ + items?: SubscriptionItem[]; + /** + * The information about the various seats available in + * the subscription. + */ + seats?: SubscriptionSeatInfo[]; + /** + * The creation time of the subscription. + */ + createTime: Date; + /** + * The last update time of the subscription. + */ + updateTime: Date; +} + +/** + * Information about the current billing period. + */ +export interface SubscriptionCurrentPeriod { + /** + * The time the current billing period started. + */ + startTime?: Date | null; + /** + * The time the current billing period ends. + */ + endTime?: Date | null; +} + +/** + * The subscription items. + */ +export interface SubscriptionItem { + /** + * The identifier of the item. + */ + id: string; + /** + * The details of the associated product. + */ + product: Product; + /** + * The details of the associated price. + */ + price?: Price | null; + /** + * The quantity for the item. + */ + quantity: number; +} + +/** + * The subscription seat. + */ +export interface SubscriptionSeatInfo { + /** + * Whether a seat can be assigned or reserved. + */ + state?: string; + /** + * The code that best describes the reason for the state. + */ + stateReason?: string; + /** + * The subscription item product. + */ + product?: Product | null; + /** + * The number of seats expected to be invoiced for the current billing period. + * + * This might be less than the total quantity while a subscription change + * is pending or if the subscription is over-provisioned. + */ + currentQuantity?: number; + /** + * The number of seats expected at renewal. + * + * This will only be set when different from current quantity. + */ + renewQuantity?: number; + /** + * The number of seats currently assigned. + */ + assignedQuantity?: number; + /** + * The number of seats not assigned. + */ + unassignedQuantity?: number; + /** + * The number of seats currently reserved because of pending invitations. + * + * These can be made available by cancelling outstanding invitations. + */ + reservedQuantity?: number; + /** + * The number of seats which can be assigned or reserved. + */ + availableQuantity?: number; + /** + * The total number of seats associated with the subscription. + */ + totalQuantity?: number; +} + +/** + * The trial information for the subscription. + */ +export interface SubscriptionTrial { + /** + * The time the trial started. + */ + startTime?: Date | null; + /** + * The time the trial ended/ends. + */ + endTime?: Date | null; + /** + * The number of days in the trial. + * + * This number is rounded to the nearest whole number + * of days. + */ + days?: number; + /** + * The number of days remaining in the trial. + * + * This number is rounded down, so will generally be + * less than days. It will be zero on the last day + * of the trial and null when the trial expires. + */ + remainingDays?: number; +} + +/** + * Input message for UpdateJoinOrganizationFlow. + */ +export interface UpdateJoinOrganizationFlowInput { + /** + * The identifier of the role. + */ + roleId?: string; +} + /** * Individual account. */