traccar-api
Version:
traccar-api-client
151 lines (142 loc) • 6.65 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* Traccar
* Traccar GPS tracking server API documentation. To use the API you need to have a server instance. For testing purposes you can use one of free [demo servers](https://www.traccar.org/demo-server/). For production use you can install your own server or get a [subscription service](https://www.traccar.org/product/tracking-server/).
*
* OpenAPI spec version: 4.11
* Contact: support@traccar.org
*
* 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, { AxiosPromise, AxiosInstance } 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 { Statistics } from '../models';
/**
* StatisticsApi - axios parameter creator
* @export
*/
export const StatisticsApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary Fetch server Statistics
* @param {Date} from in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {Date} to in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
statisticsGet: async (from: Date, to: Date, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'from' is not null or undefined
if (from === null || from === undefined) {
throw new RequiredError('from','Required parameter from was null or undefined when calling statisticsGet.');
}
// verify required parameter 'to' is not null or undefined
if (to === null || to === undefined) {
throw new RequiredError('to','Required parameter to was null or undefined when calling statisticsGet.');
}
const localVarPath = `/statistics`;
// 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 = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
if (from !== undefined) {
localVarQueryParameter['from'] = (from as any instanceof Date) ?
(from as any).toISOString() :
from;
}
if (to !== undefined) {
localVarQueryParameter['to'] = (to as any instanceof Date) ?
(to as any).toISOString() :
to;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.query) {
query.set(key, options.query[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,
};
},
}
};
/**
* StatisticsApi - functional programming interface
* @export
*/
export const StatisticsApiFp = function(configuration?: Configuration) {
return {
/**
*
* @summary Fetch server Statistics
* @param {Date} from in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {Date} to in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async statisticsGet(from: Date, to: Date, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Statistics>>> {
const localVarAxiosArgs = await StatisticsApiAxiosParamCreator(configuration).statisticsGet(from, to, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};
/**
* StatisticsApi - factory interface
* @export
*/
export const StatisticsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
return {
/**
*
* @summary Fetch server Statistics
* @param {Date} from in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {Date} to in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
statisticsGet(from: Date, to: Date, options?: any): AxiosPromise<Array<Statistics>> {
return StatisticsApiFp(configuration).statisticsGet(from, to, options).then((request) => request(axios, basePath));
},
};
};
/**
* StatisticsApi - object-oriented interface
* @export
* @class StatisticsApi
* @extends {BaseAPI}
*/
export class StatisticsApi extends BaseAPI {
/**
*
* @summary Fetch server Statistics
* @param {Date} from in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {Date} to in IS0 8601 format. eg. `1963-11-22T18:30:00Z`
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof StatisticsApi
*/
public statisticsGet(from: Date, to: Date, options?: any) {
return StatisticsApiFp(this.configuration).statisticsGet(from, to, options).then((request) => request(this.axios, this.basePath));
}
}