/* tslint:disable */
/* eslint-disable */
/**
 * Hexiosec Transfer API
 * API description for Hexiosec Transfer  ## Testing Requests  Endpoints that require authentication will use your session cookie from the main application if an API key is not provided. This is fine for testing GET requests, however POST/DELETE requests will require a CSRF token when using a session cookie. It is not possible to provide a CSRF token from this page, and so an API key must be used.
 *
 * The version of the OpenAPI document: 0.0.1
 * Contact: support@hexiosec.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
import * as runtime from '../runtime.js';
import { StripeCreateCheckoutResponseFromJSON, StripeCreatePortalResponseFromJSON, UsageResponseFromJSON, UserResponseFromJSON, UserStatsResponseFromJSON, UsersAPIKeyResponseFromJSON, UsersCreateAPIKeyRequestToJSON, UsersCreateAPIKeyResponseFromJSON, UsersUpdateCurrentRequestToJSON, } from '../models/index.js';
/**
 *
 */
export class UsersApi extends runtime.BaseAPI {
    /**
     * Create an API key for the user logged in to the current session
     */
    async createAPIKeyRaw(requestParameters, initOverrides) {
        if (requestParameters['usersCreateAPIKeyRequest'] == null) {
            throw new runtime.RequiredError('usersCreateAPIKeyRequest', 'Required parameter "usersCreateAPIKeyRequest" was null or undefined when calling createAPIKey().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        const response = await this.request({
            path: `/users/me/api_keys`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UsersCreateAPIKeyRequestToJSON(requestParameters['usersCreateAPIKeyRequest']),
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => UsersCreateAPIKeyResponseFromJSON(jsonValue));
    }
    /**
     * Create an API key for the user logged in to the current session
     */
    async createAPIKey(requestParameters, initOverrides) {
        const response = await this.createAPIKeyRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Creates a Stripe checkout URL for the current user
     */
    async createCheckoutUrlRaw(requestParameters, initOverrides) {
        if (requestParameters['product'] == null) {
            throw new runtime.RequiredError('product', 'Required parameter "product" was null or undefined when calling createCheckoutUrl().');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/checkout/{product}`.replace(`{${'product'}}`, encodeURIComponent(String(requestParameters['product']))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => StripeCreateCheckoutResponseFromJSON(jsonValue));
    }
    /**
     * Creates a Stripe checkout URL for the current user
     */
    async createCheckoutUrl(requestParameters, initOverrides) {
        const response = await this.createCheckoutUrlRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Creates a Stripe portal URL for the current user
     */
    async createPortalUrlRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/portal`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => StripeCreatePortalResponseFromJSON(jsonValue));
    }
    /**
     * Creates a Stripe portal URL for the current user
     */
    async createPortalUrl(initOverrides) {
        const response = await this.createPortalUrlRaw(initOverrides);
        return await response.value();
    }
    /**
     * Expire API Key
     */
    async deleteAPIKeyByIDRaw(requestParameters, initOverrides) {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError('id', 'Required parameter "id" was null or undefined when calling deleteAPIKeyByID().');
        }
        const queryParameters = {};
        const headerParameters = {};
        const response = await this.request({
            path: `/users/me/api_keys/{id}`.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id']))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Expire API Key
     */
    async deleteAPIKeyByID(requestParameters, initOverrides) {
        await this.deleteAPIKeyByIDRaw(requestParameters, initOverrides);
    }
    /**
     * Get current user API Keys
     */
    async getApiKeysRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/me/api_keys`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsersAPIKeyResponseFromJSON));
    }
    /**
     * Get current user API Keys
     */
    async getApiKeys(initOverrides) {
        const response = await this.getApiKeysRaw(initOverrides);
        return await response.value();
    }
    /**
     * Get current user
     */
    async getCurrentUserRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/me`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => UserResponseFromJSON(jsonValue));
    }
    /**
     * Get current user
     */
    async getCurrentUser(initOverrides) {
        const response = await this.getCurrentUserRaw(initOverrides);
        return await response.value();
    }
    /**
     * Get usage stats for the current user
     */
    async getStatsRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/me/stats`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => UserStatsResponseFromJSON(jsonValue));
    }
    /**
     * Get usage stats for the current user
     */
    async getStats(initOverrides) {
        const response = await this.getStatsRaw(initOverrides);
        return await response.value();
    }
    /**
     * Get usage stats for the current user
     */
    async getUserUsageRaw(initOverrides) {
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/me/usage`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UsageResponseFromJSON));
    }
    /**
     * Get usage stats for the current user
     */
    async getUserUsage(initOverrides) {
        const response = await this.getUserUsageRaw(initOverrides);
        return await response.value();
    }
    /**
     * Update current user fields
     */
    async updateCurrentUserRaw(requestParameters, initOverrides) {
        if (requestParameters['usersUpdateCurrentRequest'] == null) {
            throw new runtime.RequiredError('usersUpdateCurrentRequest', 'Required parameter "usersUpdateCurrentRequest" was null or undefined when calling updateCurrentUser().');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token('APIKey', []);
            if (tokenString) {
                headerParameters['Authorization'] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/users/me`,
            method: 'PATCH',
            headers: headerParameters,
            query: queryParameters,
            body: UsersUpdateCurrentRequestToJSON(requestParameters['usersUpdateCurrentRequest']),
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Update current user fields
     */
    async updateCurrentUser(requestParameters, initOverrides) {
        await this.updateCurrentUserRaw(requestParameters, initOverrides);
    }
}
