import { transformResponse } from './utils.js';
/**
 * Subscriptions
 */
export class Subscriptions {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Create a subscription
     * @param body - The subscription to create
     * @param signal - An optional abort signal
     * @returns The created subscription
     */
    async create(body, options) {
        const resp = await this.client.POST('/api/v1/subscriptions', {
            body,
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get a subscription
     * @param id - The subscription ID
     * @param signal - An optional abort signal
     * @returns The subscription
     */
    async get(id, options) {
        const resp = await this.client.GET('/api/v1/subscriptions/{subscriptionId}', {
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Edit a subscription
     * @param id - The subscription ID
     * @param body - The subscription to edit
     * @param signal - An optional abort signal
     * @returns The edited subscription
     */
    async edit(id, body, options) {
        const resp = await this.client.PATCH('/api/v1/subscriptions/{subscriptionId}', {
            body,
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Cancel a subscription
     * @param id - The subscription ID
     * @param body - The subscription to cancel
     * @param signal - An optional abort signal
     * @returns The canceled subscription
     */
    async cancel(id, body, options) {
        const resp = await this.client.POST('/api/v1/subscriptions/{subscriptionId}/cancel', {
            body,
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Change a subscription
     * @description Closes a running subscription and starts a new one according to the specification. Can be used for upgrades, downgrades, and plan changes.
     * @param id - The subscription ID
     * @param body - The subscription to change
     * @param signal - An optional abort signal
     * @returns The changed subscription
     */
    async change(id, body, options) {
        const resp = await this.client.POST('/api/v1/subscriptions/{subscriptionId}/change', {
            body,
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Migrate a subscription
     * @description Migrates the subscripiton to the provided version of the current plan.
     * @param id - The subscription ID
     * @param body - The subscription to migrate
     * @param signal - An optional abort signal
     * @returns The migrated subscription
     */
    async migrate(id, body, options) {
        const resp = await this.client.POST('/api/v1/subscriptions/{subscriptionId}/migrate', {
            body,
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Unschedule a cancelation
     * @param id - The subscription ID
     * @param signal - An optional abort signal
     * @returns The unscheduled subscription
     */
    async unscheduleCancelation(id, options) {
        const resp = await this.client.POST('/api/v1/subscriptions/{subscriptionId}/unschedule-cancelation', {
            params: { path: { subscriptionId: id } },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Delete subscription
     * @description Deletes a subscription. Only scheduled subscriptions can be deleted.
     * @param subscriptionId - The ID of the subscription to delete
     * @param options - Optional request options
     * @returns void or standard error response structure
     */
    async delete(subscriptionId, options) {
        const resp = await this.client.DELETE('/api/v1/subscriptions/{subscriptionId}', {
            params: {
                path: { subscriptionId },
            },
            ...options,
        });
        return transformResponse(resp);
    }
}
//# sourceMappingURL=subscriptions.js.map