import { transformResponse } from './utils.js';
/**
 * Meters
 * @description Meters are used to track and manage usage of your application.
 */
export class Meters {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Create a meter
     * @param meter - The meter to create
     * @param signal - An optional abort signal
     * @returns The created meter
     */
    async create(meter, options) {
        const resp = await this.client.POST('/api/v1/meters', {
            body: meter,
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Get a meter by ID or slug
     * @param idOrSlug - The ID or slug of the meter
     * @param signal - An optional abort signal
     * @returns The meter
     */
    async get(idOrSlug, options) {
        const resp = await this.client.GET('/api/v1/meters/{meterIdOrSlug}', {
            params: {
                path: {
                    meterIdOrSlug: idOrSlug,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List meters
     * @param signal - An optional abort signal
     * @returns The meters
     */
    async list(options) {
        const resp = await this.client.GET('/api/v1/meters', {
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Query usage data for a meter by ID or slug
     * @param idOrSlug - The ID or slug of the meter
     * @param query - The query parameters
     * @param signal - An optional abort signal
     * @returns The meter data
     */
    async query(idOrSlug, query, options) {
        const resp = await this.client.GET('/api/v1/meters/{meterIdOrSlug}/query', {
            headers: {
                Accept: 'application/json',
            },
            params: {
                path: {
                    meterIdOrSlug: idOrSlug,
                },
                query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Update a meter by ID or slug
     * @param idOrSlug - The ID or slug of the meter
     * @param meter - The meter update data
     * @param options - Optional request options
     * @returns The updated meter
     */
    async update(idOrSlug, meter, options) {
        const resp = await this.client.PUT('/api/v1/meters/{meterIdOrSlug}', {
            body: meter,
            params: {
                path: {
                    meterIdOrSlug: idOrSlug,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Delete a meter by ID or slug
     * @param idOrSlug - The ID or slug of the meter
     * @param signal - An optional abort signal
     * @returns The deleted meter
     */
    async delete(idOrSlug, options) {
        const resp = await this.client.DELETE('/api/v1/meters/{meterIdOrSlug}', {
            params: {
                path: {
                    meterIdOrSlug: idOrSlug,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * List meter group-by values
     * @description List all values for a specific group-by key in a meter.
     * @param idOrSlug - The ID or slug of the meter
     * @param groupByKey - The group-by key to list values for
     * @param query - The query parameters
     * @param options - Optional request options
     * @returns The list of group-by values
     */
    async listGroupByValues(idOrSlug, groupByKey, query, options) {
        const resp = await this.client.GET('/api/v1/meters/{meterIdOrSlug}/group-by/{groupByKey}/values', {
            params: {
                path: {
                    groupByKey,
                    meterIdOrSlug: idOrSlug,
                },
                query,
            },
            ...options,
        });
        return transformResponse(resp);
    }
    /**
     * Query usage data for a meter by ID or slug using POST
     * @description Query meter using POST method. This is useful for complex queries that exceed URL length limits.
     * @param idOrSlug - The ID or slug of the meter
     * @param body - The query body parameters
     * @param options - Optional request options
     * @returns The meter data
     */
    async queryPost(idOrSlug, body, options) {
        const resp = await this.client.POST('/api/v1/meters/{meterIdOrSlug}/query', {
            body,
            headers: {
                Accept: 'application/json',
            },
            params: {
                path: {
                    meterIdOrSlug: idOrSlug,
                },
            },
            ...options,
        });
        return transformResponse(resp);
    }
}
//# sourceMappingURL=meters.js.map