/* * Copyright 2019 NEM * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Catapult REST Endpoints * OpenAPI Specification of catapult-rest 1.0.20.16 * * The version of the OpenAPI document: 0.8.4 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import localVarRequest = require('request'); import http = require('http'); /* tslint:disable:no-unused-locals */ import { NetworkFeesDTO } from '../model/networkFeesDTO'; import { NetworkTypeDTO } from '../model/networkTypeDTO'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; let defaultBasePath = 'http://localhost:3000'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum NetworkRoutesApiApiKeys { } export class NetworkRoutesApi { protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), } constructor(basePath?: string); constructor(basePathOrUsername: string, password?: string, basePath?: string) { if (password) { if (basePath) { this.basePath = basePath; } } else { if (basePathOrUsername) { this.basePath = basePathOrUsername } } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: NetworkRoutesApiApiKeys, value: string) { (this.authentications as any)[NetworkRoutesApiApiKeys[key]].apiKey = value; } /** * Returns information about the average, median, highest and lower fee multiplier over the last \"numBlocksTransactionFeeStats\". The setting \"numBlocksTransactionFeeStats\" is adjustable via a configuration file (rest/resources/rest.json) per REST instance. * @summary Get transaction fees information */ public async getNetworkFees (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: NetworkFeesDTO; }> { const localVarPath = this.basePath + '/network/fees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); let localVarFormParams: any = {}; (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: NetworkFeesDTO; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "NetworkFeesDTO"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); } /** * Returns the current network type. * @summary Get the current network type of the chain */ public async getNetworkType (options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: NetworkTypeDTO; }> { const localVarPath = this.basePath + '/network'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); let localVarFormParams: any = {}; (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: NetworkTypeDTO; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "NetworkTypeDTO"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject({ response: response, body: body }); } } }); }); }); } }