text: "use strict";
  /**
   * Netsparker Enterprise API
   * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
   *
   * The version of the OpenAPI document: v1
   *
   *
   * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.RolesApi = exports.RolesApiApiKeys = void 0;
  const request_1 = __importDefault(require("request"));
  const models_1 = require("../model/models");
  const apis_1 = require("./apis");
  let defaultBasePath = 'https://www.netsparkercloud.com';
  // ===============================================
  // This file is autogenerated - Please do not edit
  // ===============================================
  var RolesApiApiKeys;
  (function (RolesApiApiKeys) {
  })(RolesApiApiKeys = exports.RolesApiApiKeys || (exports.RolesApiApiKeys = {}));
  class RolesApi {
      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[RolesApiApiKeys[key]].apiKey = value;
      }
      addInterceptor(interceptor) {
          this.interceptors.push(interceptor);
      }
      /**
       *
       * @summary Deletes a role.
       * @param id Role id
       */
      async rolesDelete(id, options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/delete/{id}'
              .replace('{' + 'id' + '}', encodeURIComponent(String(id)));
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // give precedence to 'application/json'
          if (produces.indexOf('application/json') >= 0) {
              localVarHeaderParams.Accept = 'application/json';
          }
          else {
              localVarHeaderParams.Accept = produces.join(',');
          }
          let localVarFormParams = {};
          // verify required parameter 'id' is not null or undefined
          if (id === null || id === undefined) {
              throw new Error('Required parameter id was null or undefined when calling rolesDelete.');
          }
          Object.assign(localVarHeaderParams, options.headers);
          let localVarUseFormData = false;
          let localVarRequestOptions = {
              method: 'POST',
              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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "string");
                          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                              resolve({ response: response, body: body });
                          }
                          else {
                              reject(new apis_1.HttpError(response, body, response.statusCode));
                          }
                      }
                  });
              });
          });
      }
      /**
       *
       * @summary Gets the role by the specified id.
       * @param id Role id
       */
      async rolesGet(id, options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/get/{id}'
              .replace('{' + 'id' + '}', encodeURIComponent(String(id)));
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // give precedence to 'application/json'
          if (produces.indexOf('application/json') >= 0) {
              localVarHeaderParams.Accept = 'application/json';
          }
          else {
              localVarHeaderParams.Accept = produces.join(',');
          }
          let localVarFormParams = {};
          // verify required parameter 'id' is not null or undefined
          if (id === null || id === undefined) {
              throw new Error('Required parameter id was null or undefined when calling rolesGet.');
          }
          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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "RoleApiViewModel");
                          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                              resolve({ response: response, body: body });
                          }
                          else {
                              reject(new apis_1.HttpError(response, body, response.statusCode));
                          }
                      }
                  });
              });
          });
      }
      /**
       *
       * @summary Gets the list of roles.
       * @param page The page index.
       * @param pageSize The page size. Page size can be any value between 1 and 200.
       */
      async rolesList(page, pageSize, options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/list';
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // give precedence to 'application/json'
          if (produces.indexOf('application/json') >= 0) {
              localVarHeaderParams.Accept = 'application/json';
          }
          else {
              localVarHeaderParams.Accept = produces.join(',');
          }
          let localVarFormParams = {};
          if (page !== undefined) {
              localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "number");
          }
          if (pageSize !== undefined) {
              localVarQueryParameters['pageSize'] = models_1.ObjectSerializer.serialize(pageSize, "number");
          }
          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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "RoleApiModelListApiResult");
                          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                              resolve({ response: response, body: body });
                          }
                          else {
                              reject(new apis_1.HttpError(response, body, response.statusCode));
                          }
                      }
                  });
              });
          });
      }
      /**
       *
       * @summary Gets the list of roles.
       */
      async rolesListPermissions(options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/listpermissions';
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // 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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "Array<PermissionApiModel>");
                          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                              resolve({ response: response, body: body });
                          }
                          else {
                              reject(new apis_1.HttpError(response, body, response.statusCode));
                          }
                      }
                  });
              });
          });
      }
      /**
       *
       * @summary Creates a new role
       * @param model Model of the role
       */
      async rolesNew(model, options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/new';
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // give precedence to 'application/json'
          if (produces.indexOf('application/json') >= 0) {
              localVarHeaderParams.Accept = 'application/json';
          }
          else {
              localVarHeaderParams.Accept = produces.join(',');
          }
          let localVarFormParams = {};
          // verify required parameter 'model' is not null or undefined
          if (model === null || model === undefined) {
              throw new Error('Required parameter model was null or undefined when calling rolesNew.');
          }
          Object.assign(localVarHeaderParams, options.headers);
          let localVarUseFormData = false;
          let localVarRequestOptions = {
              method: 'POST',
              qs: localVarQueryParameters,
              headers: localVarHeaderParams,
              uri: localVarPath,
              useQuerystring: this._useQuerystring,
              json: true,
              body: models_1.ObjectSerializer.serialize(model, "NewRoleApiModel")
          };
          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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "RoleApiViewModel");
                          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                              resolve({ response: response, body: body });
                          }
                          else {
                              reject(new apis_1.HttpError(response, body, response.statusCode));
                          }
                      }
                  });
              });
          });
      }
      /**
       *
       * @summary Updates a role
       * @param model Model of the role
       */
      async rolesUpdate(model, options = { headers: {} }) {
          const localVarPath = this.basePath + '/api/1.0/roles/update';
          let localVarQueryParameters = {};
          let localVarHeaderParams = Object.assign({}, this._defaultHeaders);
          const produces = ['application/json', 'text/json', 'application/scim+json', 'application/xml', 'text/xml', 'multipart/form-data'];
          // give precedence to 'application/json'
          if (produces.indexOf('application/json') >= 0) {
              localVarHeaderParams.Accept = 'application/json';
          }
          else {
              localVarHeaderParams.Accept = produces.join(',');
          }
          let localVarFormParams = {};
          // verify required parameter 'model' is not null or undefined
          if (model === null || model === undefined) {
              throw new Error('Required parameter model was null or undefined when calling rolesUpdate.');
          }
          Object.assign(localVarHeaderParams, options.headers);
          let localVarUseFormData = false;
          let localVarRequestOptions = {
              method: 'POST',
              qs: localVarQueryParameters,
              headers: localVarHeaderParams,
              uri: localVarPath,
              useQuerystring: this._useQuerystring,
              json: true,
              body: models_1.ObjectSerializer.serialize(model, "UpdateRoleApiModel")
          };
          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) => {
                  request_1.default(localVarRequestOptions, (error, response, body) => {
                      if (error) {
                          reject(error);
                      }
                      else {
                          body = models_1.ObjectSerializer.deserialize(body, "RoleApiViewModel");
                          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.RolesApi = RolesApi;
  //# sourceMappingURL=rolesApi.js.map