text: "use strict";
  /*
   * 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 API Reference
   * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
   *
   * The version of the OpenAPI document: 0.7.15
   *
   *
   * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
      function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
      return new (P || (P = Promise))(function (resolve, reject) {
          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
          function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
          step((generator = generator.apply(thisArg, _arguments || [])).next());
      });
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const localVarRequest = require("request");
  const models_1 = require("../model/models");
  const apis_1 = require("./apis");
  let defaultBasePath = 'http://localhost:3000';
  // ===============================================
  // This file is autogenerated - Please do not edit
  // ===============================================
  var ChainRoutesApiApiKeys;
  (function (ChainRoutesApiApiKeys) {
  })(ChainRoutesApiApiKeys = exports.ChainRoutesApiApiKeys || (exports.ChainRoutesApiApiKeys = {}));
  class ChainRoutesApi {
      constructor(basePathOrUsername, password, basePath) {
          this._basePath = defaultBasePath;
          this._defaultHeaders = {};
          this._useQuerystring = false;
          this.authentications = {
              'default': new models_1.VoidAuth(),
          };
          this.interceptors = [];
          if (password) {
              if (basePath) {
                  this.basePath = basePath;
              }
          }
          else {
              if (basePathOrUsername) {
                  this.basePath = basePathOrUsername;
              }
          }
      }
      set useQuerystring(value) {
          this._useQuerystring = value;
      }
      set basePath(basePath) {
          this._basePath = basePath;
      }
      set defaultHeaders(defaultHeaders) {
          this._defaultHeaders = defaultHeaders;
      }
      get defaultHeaders() {
          return this._defaultHeaders;
      }
      get basePath() {
          return this._basePath;
      }
      setDefaultAuthentication(auth) {
          this.authentications.default = auth;
      }
      setApiKey(key, value) {
          this.authentications[ChainRoutesApiApiKeys[key]].apiKey = value;
      }
      addInterceptor(interceptor) {
          this.interceptors.push(interceptor);
      }
      /**
       * Returns the current height of the blockchain.
       * @summary Get the current height of the chain
       */
      getBlockchainHeight(options = { headers: {} }) {
          return __awaiter(this, void 0, void 0, function* () {
              const localVarPath = this.basePath + '/chain/height';
              let localVarQueryParameters = {};
              let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
              const produces = ['application/json'];
              // give precedence to 'application/json'
              if (produces.indexOf('application/json') >= 0) {
                  localVarHeaderParams.Accept = 'application/json';
              }
              else {
                  localVarHeaderParams.Accept = produces.join(',');
              }
              let localVarFormParams = {};
              Object.assign(localVarHeaderParams, options.headers);
              let localVarUseFormData = false;
              let localVarRequestOptions = {
                  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));
              let interceptorPromise = authenticationPromise;
              for (const interceptor of this.interceptors) {
                  interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
              }
              return interceptorPromise.then(() => {
                  if (Object.keys(localVarFormParams).length) {
                      if (localVarUseFormData) {
                          localVarRequestOptions.formData = localVarFormParams;
                      }
                      else {
                          localVarRequestOptions.form = localVarFormParams;
                      }
                  }
                  return new Promise((resolve, reject) => {
                      localVarRequest(localVarRequestOptions, (error, response, body) => {
                          if (error) {
                              reject(error);
                          }
                          else {
                              body = models_1.ObjectSerializer.deserialize(body, "HeightInfoDTO");
                              if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                  resolve({ response: response, body: body });
                              }
                              else {
                                  reject(new apis_1.HttpError(response, body, response.statusCode));
                              }
                          }
                      });
                  });
              });
          });
      }
      /**
       * Gets the current score of the blockchain. The higher the score, the better the chain. During synchronization, nodes try to get the best blockchain in the network.  The score for a block is derived from its difficulty and the time (in seconds) that has elapsed since the last block:      block score = difficulty − time elapsed since last block
       * @summary Get the current score of the chain
       */
      getBlockchainScore(options = { headers: {} }) {
          return __awaiter(this, void 0, void 0, function* () {
              const localVarPath = this.basePath + '/chain/score';
              let localVarQueryParameters = {};
              let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
              const produces = ['application/json'];
              // give precedence to 'application/json'
              if (produces.indexOf('application/json') >= 0) {
                  localVarHeaderParams.Accept = 'application/json';
              }
              else {
                  localVarHeaderParams.Accept = produces.join(',');
              }
              let localVarFormParams = {};
              Object.assign(localVarHeaderParams, options.headers);
              let localVarUseFormData = false;
              let localVarRequestOptions = {
                  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));
              let interceptorPromise = authenticationPromise;
              for (const interceptor of this.interceptors) {
                  interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
              }
              return interceptorPromise.then(() => {
                  if (Object.keys(localVarFormParams).length) {
                      if (localVarUseFormData) {
                          localVarRequestOptions.formData = localVarFormParams;
                      }
                      else {
                          localVarRequestOptions.form = localVarFormParams;
                      }
                  }
                  return new Promise((resolve, reject) => {
                      localVarRequest(localVarRequestOptions, (error, response, body) => {
                          if (error) {
                              reject(error);
                          }
                          else {
                              body = models_1.ObjectSerializer.deserialize(body, "BlockchainScoreDTO");
                              if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                  resolve({ response: response, body: body });
                              }
                              else {
                                  reject(new apis_1.HttpError(response, body, response.statusCode));
                              }
                          }
                      });
                  });
              });
          });
      }
  }
  exports.ChainRoutesApi = ChainRoutesApi;
  //# sourceMappingURL=chainRoutesApi.js.map