/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { customersCreateCustomer } from "../funcs/customers-create-customer.js"; import { customersDeleteCustomer } from "../funcs/customers-delete-customer.js"; import { customersGetCustomerByExternalId } from "../funcs/customers-get-customer-by-external-id.js"; import { customersGetCustomerEntitlementsByExternalID } from "../funcs/customers-get-customer-entitlements-by-external-id.js"; import { customersGetCustomerEntitlements } from "../funcs/customers-get-customer-entitlements.js"; import { customersGetCustomerUpcomingGrants } from "../funcs/customers-get-customer-upcoming-grants.js"; import { customersGetCustomerUsageSummary } from "../funcs/customers-get-customer-usage-summary.js"; import { customersGetCustomer } from "../funcs/customers-get-customer.js"; import { customersGetSubscriptionsForCustomer } from "../funcs/customers-get-subscriptions-for-customer.js"; import { customersQueryCustomer } from "../funcs/customers-query-customer.js"; import { customersUpdateCustomer } from "../funcs/customers-update-customer.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import { unwrapAsync } from "../types/fp.js"; import * as models from "./models/index.js"; export class Customers extends ClientSDK { /** * Update customer * * @remarks * Use when updating customer details (e.g. name, email, or metadata). Identify by id or external_customer_id. */ async updateCustomer( body: models.UpdateCustomerRequest, id?: string | undefined, externalCustomerId?: string | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(customersUpdateCustomer( this, body, id, externalCustomerId, options, )); } /** * Create customer * * @remarks * Use when onboarding a new billing customer (e.g. sign-up or CRM sync). Ideal for linking via external_customer_id to your app's user id. */ async createCustomer( request: models.CreateCustomerRequest, options?: RequestOptions, ): Promise { return unwrapAsync(customersCreateCustomer( this, request, options, )); } /** * Get customer by external ID * * @remarks * Use when resolving a customer by your app's id (e.g. from your user table). Ideal for integrations that key by external id. */ async getCustomerByExternalId( externalId: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomerByExternalId( this, externalId, options, )); } /** * Get customer entitlements by external ID * * @remarks * Use when checking entitlements by your app's customer id (e.g. feature gating at the edge). Supports optional filters (feature_ids, subscription_ids). */ async getCustomerEntitlementsByExternalID( externalId: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomerEntitlementsByExternalID( this, externalId, options, )); } /** * Get subscriptions for customer by external ID * * @remarks * Returns all subscriptions for a customer looked up by external_id, with line-item meters and entitlements attached (no pagination). */ async getSubscriptionsForCustomer( externalId: string, expand?: string | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetSubscriptionsForCustomer( this, externalId, expand, options, )); } /** * Query customers * * @remarks * Use when listing or searching customers (e.g. admin CRM or reporting). Returns a paginated list; supports filtering and sorting. */ async queryCustomer( request: models.CustomerFilter, options?: RequestOptions, ): Promise { return unwrapAsync(customersQueryCustomer( this, request, options, )); } /** * Get customer usage summary * * @remarks * Use when showing a customer's usage (e.g. portal or overage alerts). Identify by customer_id or customer_lookup_key; supports filters. */ async getCustomerUsageSummary( request?: models.GetCustomerUsageSummaryRequest | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomerUsageSummary( this, request, options, )); } /** * Get customer * * @remarks * Use when you need to load a single customer (e.g. for a billing portal or to attach a subscription). */ async getCustomer( id: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomer( this, id, options, )); } /** * Delete customer * * @remarks * Use when removing a customer (e.g. GDPR or churn). Returns 204 No Content on success. */ async deleteCustomer( id: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersDeleteCustomer( this, id, options, )); } /** * Get customer entitlements * * @remarks * Use when checking what a customer can access (e.g. feature gating or usage limits). Supports optional filters (feature_ids, subscription_ids). */ async getCustomerEntitlements( id: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomerEntitlements( this, id, options, )); } /** * Get upcoming credit grant applications * * @remarks * Use when showing upcoming or pending credits for a customer (e.g. in a portal or for forecasting). */ async getCustomerUpcomingGrants( id: string, options?: RequestOptions, ): Promise { return unwrapAsync(customersGetCustomerUpcomingGrants( this, id, options, )); } }