/**
 * Forge SDK
 * The Forge Platform contains an expanding collection of web service components that can be used with Autodesk cloud-based products or your own technologies. Take advantage of Autodesk’s expertise in design and engineering.
 *
 * Contact: forge.help@autodesk.com
 *
 * 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.
 *
 * 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.
 */
/*jshint esversion: 9 */

module.exports = (function () {
	'use strict';

	var ApiClient = require('../ApiClient');

	/**
	* Issues service.
	* @module api/IssuesApi
	*/

	/**
	 * Constructs a new IssuesApi.
	 * @alias module:api/IssuesApi
	 * @class
	 * @param {module:ApiClient} apiClient Optional API client implementation to use,
	 * default to {@link module:ApiClient#instance} if unspecified.
	 */
	var exports = function (apiClient, region) {
		this.apiClient = apiClient || ApiClient.instance;
		//this.region = region || RegionEnum.US; // US is default

		/**
		 * Returns issues.
	 * @param {String} containerId Project ID
		 * @param {Object} opts Optional parameters
		 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
		 * @param {Object} oauth2client oauth2client for the call
		 * @param {Object} credentials credentials for the call
		 */
		this.GetIssues = function (containerId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetIssues");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'filter[target_urn]': this.apiClient.buildCollectionParam(opts.filterTargetUrn, 'csv'),
				'filter[due_date]': opts.dueDate,
				'filter[synced_after]': opts.syncedAfter,
				'filter[created_at]': opts.createdAt,
				'filter[created_by]': opts.createdBy,
				'filter[ng_issue_type_id]': this.apiClient.buildCollectionParam(opts.filterType, 'csv'),
				'filter[ng_issue_subtype_id]': this.apiClient.buildCollectionParam(opts.filterSubtype, 'csv'),
				'page[limit]': opts.pageLimit,
				'page[offset]': opts.offset,
				'sort': this.apiClient.buildCollectionParam(opts.sort, 'csv'),
				'fields[quality_issues]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
				'include': this.apiClient.buildCollectionParam(opts.include, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns one issue by id.
		 * @param {String} containerId Project ID
		 * @param {String} issueId Issue ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetIssue = function (containerId, issueId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetIssue");

			if (issueId == undefined || issueId == null)
				return Promise.reject("Missing the required parameter 'issueId' when calling GetIssue");

			var pathParams = {
				'container_id': containerId,
				'issue_id': issueId,
			};
			var queryParams = {
				'fields[quality_issues]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
				'include': this.apiClient.buildCollectionParam(opts.include, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues/{issue_id}', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Creates a new issue
		 * @param {String} containerId Container ID
		 * @param {Object} body Payload body
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.PostIssue = function (containerId, body, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = body;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling PostIssue");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'fields[quality_issues]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues', 'POST',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Updates an issue
		 * @param {String} containerId Container ID
		 * @param {String} issueId Issue ID
		 * @param {Object} body Payload body
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.PatchIssue = function (containerId, issueId, body, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = body;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling PatchIssue");

			if (issueId == undefined || issueId == null)
				return Promise.reject("Missing the required parameter 'issueId' when calling PatchIssue");

			var pathParams = {
				'container_id': containerId,
				'issue_id': issueId,
			};
			var queryParams = {};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues/{issue_id}', 'PATCH',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns issue comments.
		 * @param {String} containerId Project ID
		 * @param {String} issueId Issue ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetComments = function (containerId, issueId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetComments");

			if (issueId == undefined || issueId == null)
				return Promise.reject("Missing the required parameter 'issueId' when calling GetComments");

			var pathParams = {
				'container_id': containerId,
				'issue_id': issueId,
			};
			var queryParams = {};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues/{issue_id}/comments', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Creates issue comment.
		 * @param {String} containerId Project ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.PostComment = function (containerId, body, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = body;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling PostComment");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'fields[comments]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/comments', 'POST',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns issue attachments.
		 * @param {String} containerId Project ID
		 * @param {String} issueId Issue ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetAttachments = function (containerId, issueId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetAttachments");

			if (issueId == undefined || issueId == null)
				return Promise.reject("Missing the required parameter 'issueId' when calling GetAttachments");

			var pathParams = {
				'container_id': containerId,
				'issue_id': issueId,
			};
			var queryParams = {
				'filter[synced_after]': opts.syncedAfter,
				'filter[created_at]': opts.createdAt,
				'page[limit]': opts.pageLimit,
				'page[offset]': opts.offset,
				'sort': this.apiClient.buildCollectionParam(opts.sort, 'csv'),
				'fields[attachments]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
				'include': this.apiClient.buildCollectionParam(opts.include, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/quality-issues/{issue_id}/attachments', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Creates issue attachments.
		 * @param {String} containerId Project ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.PostAttachments = function (containerId, body, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = body;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling PostAttachment");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'fields[attachments]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/attachments', 'POST',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns root causes.
		 * @param {String} containerId Container ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetRootCauses = function (containerId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetRootCauses");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'fields[root_causes]': this.apiClient.buildCollectionParam(opts.fields, 'csv'),
				'include': this.apiClient.buildCollectionParam(opts.include, 'csv'),
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/root_causes', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns types.
		 * @param {String} containerId Container ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetTypes = function (containerId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetTypes");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'include': opts.include,
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/ng-issue-types', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns attribute definitions.
		 * @param {String} containerId Container ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetAttributeDefinitions = function (containerId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetAttributeDefinitions");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'filter[createdAt]': opts.createdAt,
				'filter[updatedAt]': opts.updatedAt,
				'filter[deletedAt]': opts.deletedAt,
				'filter[dataType]': this.apiClient.buildCollectionParam(opts.dataType, 'csv'),
				'limit': opts.limit,
				'offset': opts.offset,
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/issue-attribute-definitions', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};

		/**
			 * Returns attribute mappings.
		 * @param {String} containerId Container ID
			 * @param {Object} opts Optional parameters
			 * @param {String} opts.acceptEncoding If specified with `gzip` or `*`, content will be compressed and returned in a GZIP format.
			 * @param {Object} oauth2client oauth2client for the call
			 * @param {Object} credentials credentials for the call
			 */
		this.GetAttributeMappings = function (containerId, opts, oauth2client, credentials) {
			opts = opts || {};
			var postBody = null;

			if (containerId == undefined || containerId == null)
				return Promise.reject("Missing the required parameter 'containerId' when calling GetAttributeMappings");

			var pathParams = {
				'container_id': containerId,
			};
			var queryParams = {
				'filter[createdAt]': opts.createdAt,
				'filter[updatedAt]': opts.updatedAt,
				'filter[deletedAt]': opts.deletedAt,
				'filter[attributeDefinitionId]': this.apiClient.buildCollectionParam(opts.attributeDefinitionId, 'csv'),
				'filter[mappedItemId]': this.apiClient.buildCollectionParam(opts.mappedItemId, 'csv'),
				'filter[isRequired]': opts.isRequired,
				'limit': opts.limit,
				'offset': opts.offset,
			};
			var headerParams = {
				'Accept-Encoding': opts.acceptEncoding,
			};
			var formParams = {};

			var contentTypes = ['application/vnd.api+json'];
			var accepts = ['application/vnd.api+json'];
			var returnType = Object;

			return this.apiClient.callApi(
				'/issues/v1/containers/{container_id}/issue-attribute-mappings', 'GET',
				pathParams, queryParams, headerParams, formParams, postBody,
				contentTypes, accepts, returnType, oauth2client, credentials
			);
		};


	};

	/**
	 * Allowed values for the <code>region</code> property.
	 * @enum {String}
	 * @readonly
	 */
	exports.RegionEnum = {
		/**
		 * value: "US"
		 * @const
		 */
		"US": "US",
		/**
		 * value: "EMEA"
		 * @const
		 */
		"EMEA": "EMEA",
		/**
		 * value: "EU"
		 * @const
		 */
		"EU": "EMEA",

	};

	return exports;
}());