import { transformResponse } from './utils.js';
/**
 * Customers
 * Manage customer subscription lifecycles and plan assignments.
 */
export class Customers {
    client;
    apps;
    entitlementsV1;
    entitlements;
    stripe;
    constructor(client) {
        this.client = client;
        this.apps = new CustomerApps(client);
        this.entitlementsV1 = new CustomerEntitlements(client);
        this.entitlements = new CustomerEntitlementsV2(client);
        this.stripe = new CustomerStripe(client);
    }
    /**
     * Create a customer
     * @param customer - The customer to create
     * @param signal - An optional abort signal
     * @returns The created customer
     */
    async create(customer, options) {
        const resp = await this.client.POST('/api/v1/customers', {
            body: customer,
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get a customer by ID
     * @param customerIdOrKey - The ID or Key of the customer
     * @param signal - An optional abort signal
     * @returns The customer
     */
    async get(customerIdOrKey, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}', {
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Update a customer
     * @param customerIdOrKey - The ID or Key of the customer
     * @param customer - The customer to update
     * @param signal - An optional abort signal
     * @returns The updated customer
     */
    async update(customerIdOrKey, customer, options) {
        const resp = await this.client.PUT('/api/v1/customers/{customerIdOrKey}', {
            body: customer,
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Delete a customer
     * @param customerIdOrKey - The ID or Key of the customer
     * @param signal - An optional abort signal
     * @returns The deleted customer
     */
    async delete(customerIdOrKey, options) {
        const resp = await this.client.DELETE('/api/v1/customers/{customerIdOrKey}', {
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List customers
     * @param signal - An optional abort signal
     * @returns The list of customers
     */
    async list(query, options) {
        const resp = await this.client.GET('/api/v1/customers', {
            params: {
                query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get customer access
     * @param customerIdOrKey - The ID or Key of the customer
     * @param options - Optional request options
     * @returns The customer access information
     */
    async getAccess(customerIdOrKey, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/access', {
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List customer subscriptions
     * @param customerIdOrKey - The ID or key of the customer
     * @param query - The query parameters
     * @param signal - An optional abort signal
     * @returns The list of customer subscriptions
     */
    async listSubscriptions(customerIdOrKey, query, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/subscriptions', {
            params: { path: { customerIdOrKey }, query },
            ...options,
        });
        return transformResponse(resp);
    }
}
/**
 * Customer Apps
 * Manage customer apps.
 */
export class CustomerApps {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Upsert customer app data
     * @param customerIdOrKey - The ID or Key of the customer
     * @param appData - The app data to upsert
     * @param signal - An optional abort signal
     * @returns The upserted app data
     */
    async upsert(customerIdOrKey, appData, options) {
        const resp = await this.client.PUT('/api/v1/customers/{customerIdOrKey}/apps', {
            body: appData,
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List customer app data
     * @param customerIdOrKey - The ID or key of the customer
     * @param query - The query parameters
     * @param signal - An optional abort signal
     * @returns The list of customer app data
     */
    async list(customerIdOrKey, query, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/apps', {
            params: {
                path: { customerIdOrKey },
                query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Delete customer app data
     * @param customerIdOrKey - The ID or key of the customer
     * @param appId - The ID of the app
     * @param signal - An optional abort signal
     * @returns The deleted customer app data
     */
    async delete(customerIdOrKey, appId, options) {
        const resp = await this.client.DELETE('/api/v1/customers/{customerIdOrKey}/apps/{appId}', {
            params: { path: { appId, customerIdOrKey } },
            ...options,
        });
        return transformResponse(resp);
    }
}
/**
 * Customer Stripe
 * Manage customer Stripe data.
 */
export class CustomerStripe {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Upsert customer stripe app data
     * @param customerIdOrKey - The ID or Key of the customer
     * @param appData - The app data to upsert
     * @param signal - An optional abort signal
     * @returns The upserted customer stripe app data
     */
    async upsert(customerIdOrKey, stripeAppData, options) {
        const resp = await this.client.PUT('/api/v1/customers/{customerIdOrKey}/stripe', {
            body: stripeAppData,
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get customer stripe app data
     * @param customerIdOrKey - The ID or key of the customer
     * @param query - The query parameters
     * @param signal - An optional abort signal
     * @returns The customer stripe app data
     */
    async get(customerIdOrKey, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/stripe', {
            params: {
                path: { customerIdOrKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Create a Stripe customer portal session
     * @param customerIdOrKey - The ID or Key of the customer
     * @param params - The parameters for creating a Stripe customer portal session
     * @param signal - An optional abort signal
     * @returns The Stripe customer portal session
     */
    async createPortalSession(customerIdOrKey, params, options) {
        const resp = await this.client.POST('/api/v1/customers/{customerIdOrKey}/stripe/portal', {
            body: params,
            params: {
                path: {
                    customerIdOrKey,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
}
/**
 * Customer Entitlements
 */
export class CustomerEntitlements {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Get the value of an entitlement for a customer
     * @param customerIdOrKey - The ID or Key of the customer
     * @param featureKey - The key of the feature
     * @param signal - An optional abort signal
     * @returns The value of the entitlement
     */
    async value(customerIdOrKey, featureKey, options) {
        const resp = await this.client.GET('/api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/value', {
            params: { path: { customerIdOrKey, featureKey } },
            ...options,
        });
        return transformResponse(resp);
    }
}
/**
 * Customer Entitlements V2
 */
export class CustomerEntitlementsV2 {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * List all entitlements for a customer
     * @param customerIdOrKey - The ID or Key of the customer
     * @param options - Request options including query parameters
     * @returns List of customer entitlements
     */
    async list(customerIdOrKey, options) {
        const resp = await this.client.GET('/api/v2/customers/{customerIdOrKey}/entitlements', {
            params: {
                path: { customerIdOrKey },
                query: options?.query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Create a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlement - The entitlement data to create
     * @param options - Request options
     * @returns The created entitlement
     */
    async create(customerIdOrKey, entitlement, options) {
        const resp = await this.client.POST('/api/v2/customers/{customerIdOrKey}/entitlements', {
            body: entitlement,
            params: {
                path: { customerIdOrKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get a specific customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param options - Request options
     * @returns The entitlement
     */
    async get(customerIdOrKey, entitlementIdOrFeatureKey, options) {
        const resp = await this.client.GET('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}', {
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Delete a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param options - Request options
     * @returns The deletion response
     */
    async delete(customerIdOrKey, entitlementIdOrFeatureKey, options) {
        const resp = await this.client.DELETE('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}', {
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Override a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param entitlement - The new entitlement data
     * @param options - Request options
     * @returns The overridden entitlement
     */
    async override(customerIdOrKey, entitlementIdOrFeatureKey, entitlement, options) {
        const resp = await this.client.PUT('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/override', {
            body: entitlement,
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List grants for a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param options - Request options including query parameters
     * @returns List of entitlement grants
     */
    async listGrants(customerIdOrKey, entitlementIdOrFeatureKey, options) {
        const resp = await this.client.GET('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants', {
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
                query: options?.query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Create a grant for a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param grant - The grant data to create
     * @param options - Request options
     * @returns The created grant
     */
    async createGrant(customerIdOrKey, entitlementIdOrFeatureKey, grant, options) {
        const resp = await this.client.POST('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants', {
            body: grant,
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get the value of a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param options - Request options including query parameters
     * @returns The entitlement value
     */
    async value(customerIdOrKey, entitlementIdOrFeatureKey, options) {
        const resp = await this.client.GET('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value', {
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
                query: options?.query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get the history of a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param windowSize - The window size for the history
     * @param options - Request options including query parameters
     * @returns The entitlement history
     */
    async history(customerIdOrKey, entitlementIdOrFeatureKey, windowSize, options) {
        const resp = await this.client.GET('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/history', {
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
                query: {
                    windowSize,
                    ...options?.query,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Reset the usage of a customer entitlement
     * @param customerIdOrKey - The ID or Key of the customer
     * @param entitlementIdOrFeatureKey - The ID or feature key of the entitlement
     * @param reset - The reset data
     * @param options - Request options
     * @returns The reset response
     */
    async resetUsage(customerIdOrKey, entitlementIdOrFeatureKey, reset, options) {
        const resp = await this.client.POST('/api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/reset', {
            body: reset,
            params: {
                path: { customerIdOrKey, entitlementIdOrFeatureKey },
            },
            ...options,
        });
        return transformResponse(resp);
    }
}
//# sourceMappingURL=customers.js.map