UNPKG

@forestvpn/forestvpn_api

Version:

A package to interact api.forestvpn.com (manage vpn profiles, check usage statistics, manage locations, ...)

206 lines (195 loc) 8.77 kB
/* tslint:disable */ /* eslint-disable */ /** * ForestVPN API * ForestVPN - Fast, secure, and modern VPN. It offers Distributed Computing, Crypto Mining, P2P, Ad Blocking, TOR over VPN, 30+ locations, and a free version with unlimited data. * * OpenAPI spec version: 2.0 * Contact: support@forestvpn.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios'; import { Configuration } from '../configuration'; // Some imports not used depending on template conditions // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; import { User } from '../models'; /** * UserApi - axios parameter creator * @export */ export const UserApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * * @summary Delete my account permanently * @param {*} [options] Override http request option. * @throws {RequiredError} */ deleteMyAccount: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => { const localVarPath = `/users/me/`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions :AxiosRequestConfig = { method: 'DELETE', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication bearerAuth required // http bearer authentication required if (configuration && configuration.accessToken) { const accessToken = typeof configuration.accessToken === 'function' ? await configuration.accessToken() : await configuration.accessToken; localVarHeaderParameter["Authorization"] = "Bearer " + accessToken; } const query = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { query.set(key, localVarQueryParameter[key]); } for (const key in options.params) { query.set(key, options.params[key]); } localVarUrlObj.search = (new URLSearchParams(query)).toString(); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, options: localVarRequestOptions, }; }, /** * * @summary Get my account details * @param {*} [options] Override http request option. * @throws {RequiredError} */ getMyAccount: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => { const localVarPath = `/users/me/`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, 'https://example.com'); let baseOptions; if (configuration) { baseOptions = configuration.baseOptions; } const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options}; const localVarHeaderParameter = {} as any; const localVarQueryParameter = {} as any; // authentication bearerAuth required // http bearer authentication required if (configuration && configuration.accessToken) { const accessToken = typeof configuration.accessToken === 'function' ? await configuration.accessToken() : await configuration.accessToken; localVarHeaderParameter["Authorization"] = "Bearer " + accessToken; } const query = new URLSearchParams(localVarUrlObj.search); for (const key in localVarQueryParameter) { query.set(key, localVarQueryParameter[key]); } for (const key in options.params) { query.set(key, options.params[key]); } localVarUrlObj.search = (new URLSearchParams(query)).toString(); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, options: localVarRequestOptions, }; }, } }; /** * UserApi - functional programming interface * @export */ export const UserApiFp = function(configuration?: Configuration) { return { /** * * @summary Delete my account permanently * @param {*} [options] Override http request option. * @throws {RequiredError} */ async deleteMyAccount(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> { const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).deleteMyAccount(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, /** * * @summary Get my account details * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getMyAccount(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<User>>> { const localVarAxiosArgs = await UserApiAxiosParamCreator(configuration).getMyAccount(options); return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; return axios.request(axiosRequestArgs); }; }, } }; /** * UserApi - factory interface * @export */ export const UserApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { return { /** * * @summary Delete my account permanently * @param {*} [options] Override http request option. * @throws {RequiredError} */ async deleteMyAccount(options?: AxiosRequestConfig): Promise<AxiosResponse<void>> { return UserApiFp(configuration).deleteMyAccount(options).then((request) => request(axios, basePath)); }, /** * * @summary Get my account details * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getMyAccount(options?: AxiosRequestConfig): Promise<AxiosResponse<User>> { return UserApiFp(configuration).getMyAccount(options).then((request) => request(axios, basePath)); }, }; }; /** * UserApi - object-oriented interface * @export * @class UserApi * @extends {BaseAPI} */ export class UserApi extends BaseAPI { /** * * @summary Delete my account permanently * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ public async deleteMyAccount(options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> { return UserApiFp(this.configuration).deleteMyAccount(options).then((request) => request(this.axios, this.basePath)); } /** * * @summary Get my account details * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof UserApi */ public async getMyAccount(options?: AxiosRequestConfig) : Promise<AxiosResponse<User>> { return UserApiFp(this.configuration).getMyAccount(options).then((request) => request(this.axios, this.basePath)); } }