Source: resource/project.js

"use strict";
const baseResource_1 = require('./baseResource');
/**
 * The project class for the Jira Connector
 *
 * @constructor project
 * @property {IConnector} connector the jira connector instance
 * @property {Model} model the model definition
 */
class project extends baseResource_1.baseResource {
    constructor(connector, definition) {
        super(connector, definition);
        /**
         * Returns all projects which are visible for the currently logged in user. If no user is logged in, it returns the list of projects that are visible when using anonymous access.
         *
         * @method find
         * @memberOf project#
         * @param {Object} options The request options passed onto the Jira API.
         * @param {string} [options.token] The token to use for authentication. This token is supplied on a sucessful login. If not supplied, the default token (if set) is used
         * @param {string} [options.expand] the parameters to expand
         * @param {number} [options.recent] if this parameter is set then only projects recently accessed by the current user will be returned (maximum count limited to the specified number but no more than 20).
         * @param [callback] if supplied, called with Array of matching records
         * @return {Promise.<Array>} Array of matching records
         */
        this.find = (options = {}, callback) => {
            return this.makeRequest("find", options, callback);
        };
        /**
         * Contains a full representation of a project in JSON format. All project keys associated with the project will only be returned if expand=projectKeys.
         *
         * @method findById
         * @memberOf project#
         * @param {Object} options The request options passed onto the Jira API.
         * @param {string} [options.token] The token to use for authentication. This token is supplied on a sucessful login. If not supplied, the default token (if set) is used
         * @param {string} [options.id] The key or id of the project to find
         * @param {number} [options.recent] if this parameter is set then only projects recently accessed by the current user will be returned (maximum count limited to the specified number but no more than 20).
         * @param [callback] if supplied, called with Array of matching records
         * @return {Promise.<Object>} the selected Project
         */
        this.findById = (options = {}, callback) => {
            return this.makeRequest("findById", options, callback);
        };
        /* ### */
        /**
         * Deletes a project
         *
         * @method deleteById
         * @memberOf project#
         * @param {Object} options The request options passed onto the Jira API.
         * @param {string} [options.id] The key or id of the project to delete
         * @param [callback] if supplied, called with Array of matching records
         * @return {Promise.<Object>} the selected Project
         */
        this.deleteById = (options = {}, callback) => {
            return this.makeRequest("deleteById", options, callback);
        };
        /**
         * Creates a project.
         *
         * @method create
         * @memberOf ProjectClient#
         * @param {Object} options The request options sent to the Jira API. See {@link https://docs.atlassian.com/jira/REST/latest/#api/2/project}
         * @param {string} options.key The key of the project
         * @param {string} options.name The name of the project
         * @param {string} options.lead The name of the user leading the project
         * @param [callback] Called when the project has been created.
         * @return {Promise} Resolved when the project has been created.
         */
        this.create = (options = {}, callback) => {
            return this.makeRequest("create", options, callback);
        };
        this.register();
    }
}
exports.project = project;