text: "use strict";
  
  /* global dw empty */
  var ObjectSerializer = require("../serializers/ObjectSerializer");
  // @ts-ignore
  var ClientError = require("../models/ClientError");
  // @ts-ignore
  var EntityQuery = require("../models/EntityQuery");
  // @ts-ignore
  var EntityQueryFilter = require("../models/EntityQueryFilter");
  // @ts-ignore
  var InstallmentPlanConfiguration = require("../models/InstallmentPlanConfiguration");
  // @ts-ignore
  var ServerError = require("../models/ServerError");
  var InstallmentPlanConfigurationService = /** @class */ (function () {
      function InstallmentPlanConfigurationService(httpService) {
          this.basePath = "https://app-wallee.com:443/api";
          this.defaultHeaders = {};
          this._useQuerystring = false;
          this.httpService = {};
          this.httpService = httpService;
      }
      /**
      * Counts the number of items in the database as restricted by the given filter.
      * @summary Count
      * @param { number } spaceId spaceId
      * @param { EntityQueryFilter } filter filter The filter which restricts the installment plan configurations which are used to calculate the count.
      * @param {*} [options] Override http request options.
      * @return {  number  }
      */
      InstallmentPlanConfigurationService.prototype.count = function (spaceId, filter, options) {
          if (options === void 0) { options = {}; }
          var localVarQueryParameters = {};
          var localVarHeaderParams = {};
          var localVarFormParams = {};
          // verify required parameter 'spaceId' is not null or undefined
          if (spaceId === null || spaceId === undefined) {
              throw new Error("Required parameter spaceId was null or undefined when calling count.");
          }
          // verify required parameter 'filter' is not null or undefined
          if (filter === null || filter === undefined) {
              throw new Error("Required parameter filter was null or undefined when calling count.");
          }
          if (spaceId !== undefined) {
              localVarQueryParameters["spaceId"] = ObjectSerializer.serialize(spaceId, "number");
          }
          for (var optionsHeadersKey in options.headers) {
              if (options.headers.hasOwnProperty(optionsHeadersKey)) {
                  localVarHeaderParams[optionsHeadersKey] = options.headers[optionsHeadersKey];
              }
          }
          var localVarUseFormData = false;
          var localVarRequestOptions = {
              method: "POST",
              queryString: localVarQueryParameters,
              headers: localVarHeaderParams,
              useQuerystring: this._useQuerystring,
              url: this.basePath,
              path: "/installment-plan-configuration/count",
              contentType: "application/json",
              body: JSON.stringify(ObjectSerializer.serialize(filter, "EntityQueryFilter")),
              form: {},
              formData: {}
          };
          if (Object.keys(localVarFormParams).length) {
              if (localVarUseFormData) {
                  localVarRequestOptions.formData = localVarFormParams;
              }
              else {
                  localVarRequestOptions.form = localVarFormParams;
              }
          }
          // dw.net.HTTPClient
          var response = this.httpService.callApi(localVarRequestOptions);
          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
              var body = response.text;
              if (ObjectSerializer.primitives.indexOf("number".toLowerCase()) !== -1) {
                  return body;
              }
              try {
                  body = JSON.parse(body);
                  body = ObjectSerializer.deserialize(body, "number");
              }
              catch (e) {
                  dw.system.Logger.error("wallee > InstallmentPlanConfigurationService > count > unable to parse JSON > " + JSON.stringify({ message: e.message, fileName: e.fileName, lineNumber: e.lineNumber }));
              }
              return body;
          }
          else {
              var error = {
                  type: "Unknown",
                  date: (new Date()).toUTCString(),
                  statusCode: response.statusCode,
                  statusMessage: response.statusMessage,
                  errorText: response.errorText
              };
              if (response.statusCode && response.statusCode >= 400 && response.statusCode <= 499) {
                  error.type = "ClientError";
              }
              else if (response.statusCode && response.statusCode >= 500 && response.statusCode <= 599) {
                  error.type = "ServerError";
              }
              throw new Error("wallee > InstallmentPlanConfigurationService > count > " + error.type + " > " + JSON.stringify(error));
          }
      };
      /**
      * Reads the entity with the given 'id' and returns it.
      * @summary Read
      * @param { number } spaceId spaceId
      * @param { number } id id The id of the installment plan configuration which should be returned.
      * @param {*} [options] Override http request options.
      * @return {  InstallmentPlanConfiguration  }
      */
      InstallmentPlanConfigurationService.prototype.read = function (spaceId, id, options) {
          if (options === void 0) { options = {}; }
          var localVarQueryParameters = {};
          var localVarHeaderParams = {};
          var localVarFormParams = {};
          // verify required parameter 'spaceId' is not null or undefined
          if (spaceId === null || spaceId === undefined) {
              throw new Error("Required parameter spaceId was null or undefined when calling read.");
          }
          // 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 read.");
          }
          if (spaceId !== undefined) {
              localVarQueryParameters["spaceId"] = ObjectSerializer.serialize(spaceId, "number");
          }
          if (id !== undefined) {
              localVarQueryParameters["id"] = ObjectSerializer.serialize(id, "number");
          }
          for (var optionsHeadersKey in options.headers) {
              if (options.headers.hasOwnProperty(optionsHeadersKey)) {
                  localVarHeaderParams[optionsHeadersKey] = options.headers[optionsHeadersKey];
              }
          }
          var localVarUseFormData = false;
          var localVarRequestOptions = {
              method: "GET",
              queryString: localVarQueryParameters,
              headers: localVarHeaderParams,
              useQuerystring: this._useQuerystring,
              url: this.basePath,
              path: "/installment-plan-configuration/read",
              contentType: "application/json",
              form: {},
              formData: {}
          };
          if (Object.keys(localVarFormParams).length) {
              if (localVarUseFormData) {
                  localVarRequestOptions.formData = localVarFormParams;
              }
              else {
                  localVarRequestOptions.form = localVarFormParams;
              }
          }
          // dw.net.HTTPClient
          var response = this.httpService.callApi(localVarRequestOptions);
          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
              var body = response.text;
              if (ObjectSerializer.primitives.indexOf("InstallmentPlanConfiguration".toLowerCase()) !== -1) {
                  return body;
              }
              try {
                  body = JSON.parse(body);
                  body = ObjectSerializer.deserialize(body, "InstallmentPlanConfiguration");
              }
              catch (e) {
                  dw.system.Logger.error("wallee > InstallmentPlanConfigurationService > read > unable to parse JSON > " + JSON.stringify({ message: e.message, fileName: e.fileName, lineNumber: e.lineNumber }));
              }
              return body;
          }
          else {
              var error = {
                  type: "Unknown",
                  date: (new Date()).toUTCString(),
                  statusCode: response.statusCode,
                  statusMessage: response.statusMessage,
                  errorText: response.errorText
              };
              if (response.statusCode && response.statusCode >= 400 && response.statusCode <= 499) {
                  error.type = "ClientError";
              }
              else if (response.statusCode && response.statusCode >= 500 && response.statusCode <= 599) {
                  error.type = "ServerError";
              }
              throw new Error("wallee > InstallmentPlanConfigurationService > read > " + error.type + " > " + JSON.stringify(error));
          }
      };
      /**
      * Searches for the entities as specified by the given query.
      * @summary Search
      * @param { number } spaceId spaceId
      * @param { EntityQuery } query query The query restricts the installment plan configurations which are returned by the search.
      * @param {*} [options] Override http request options.
      * @return {  Array<InstallmentPlanConfiguration>  }
      */
      InstallmentPlanConfigurationService.prototype.search = function (spaceId, query, options) {
          if (options === void 0) { options = {}; }
          var localVarQueryParameters = {};
          var localVarHeaderParams = {};
          var localVarFormParams = {};
          // verify required parameter 'spaceId' is not null or undefined
          if (spaceId === null || spaceId === undefined) {
              throw new Error("Required parameter spaceId was null or undefined when calling search.");
          }
          // verify required parameter 'query' is not null or undefined
          if (query === null || query === undefined) {
              throw new Error("Required parameter query was null or undefined when calling search.");
          }
          if (spaceId !== undefined) {
              localVarQueryParameters["spaceId"] = ObjectSerializer.serialize(spaceId, "number");
          }
          for (var optionsHeadersKey in options.headers) {
              if (options.headers.hasOwnProperty(optionsHeadersKey)) {
                  localVarHeaderParams[optionsHeadersKey] = options.headers[optionsHeadersKey];
              }
          }
          var localVarUseFormData = false;
          var localVarRequestOptions = {
              method: "POST",
              queryString: localVarQueryParameters,
              headers: localVarHeaderParams,
              useQuerystring: this._useQuerystring,
              url: this.basePath,
              path: "/installment-plan-configuration/search",
              contentType: "application/json",
              body: JSON.stringify(ObjectSerializer.serialize(query, "EntityQuery")),
              form: {},
              formData: {}
          };
          if (Object.keys(localVarFormParams).length) {
              if (localVarUseFormData) {
                  localVarRequestOptions.formData = localVarFormParams;
              }
              else {
                  localVarRequestOptions.form = localVarFormParams;
              }
          }
          // dw.net.HTTPClient
          var response = this.httpService.callApi(localVarRequestOptions);
          if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
              var body = response.text;
              if (ObjectSerializer.primitives.indexOf("Array<InstallmentPlanConfiguration>".toLowerCase()) !== -1) {
                  return body;
              }
              try {
                  body = JSON.parse(body);
                  body = ObjectSerializer.deserialize(body, "Array<InstallmentPlanConfiguration>");
              }
              catch (e) {
                  dw.system.Logger.error("wallee > InstallmentPlanConfigurationService > search > unable to parse JSON > " + JSON.stringify({ message: e.message, fileName: e.fileName, lineNumber: e.lineNumber }));
              }
              return body;
          }
          else {
              var error = {
                  type: "Unknown",
                  date: (new Date()).toUTCString(),
                  statusCode: response.statusCode,
                  statusMessage: response.statusMessage,
                  errorText: response.errorText
              };
              if (response.statusCode && response.statusCode >= 400 && response.statusCode <= 499) {
                  error.type = "ClientError";
              }
              else if (response.statusCode && response.statusCode >= 500 && response.statusCode <= 599) {
                  error.type = "ServerError";
              }
              throw new Error("wallee > InstallmentPlanConfigurationService > search > " + error.type + " > " + JSON.stringify(error));
          }
      };
      return InstallmentPlanConfigurationService;
  }());
  exports.InstallmentPlanConfigurationService = InstallmentPlanConfigurationService;
  module.exports = InstallmentPlanConfigurationService;
  