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jD,EAOA,aAAa,UAAU,iBAAmB,SAAS,GAClD,KAAK,QAAQ,mCAAoC,CAAC,EAAG,EACtD,EAOA,aAAa,UAAU,KAAO,SAAS,GACtC,KAAK,QAAQ,uBAAwB,CAAC,EAAG,EAC1C,EAOA,aAAa,UAAU,QAAU,SAAS,GACzC,KAAK,QAAQ,0BAA2B,CAAC,EAAG,EAC7C,EAWA,aAAa,UAAU,YAAc,SAAS,EAAO,EAAO,EAAM,EAAQ,GACzE,KAAK,QAAQ,uBAAuB,CAAC,OAAQ,OAAQ,GAAI,MAAM,CAAC,cAAe,EAAO,WAAY,EAAO,UAAW,GAAO,IAAU,EACtI,EAQA,aAAa,UAAU,KAAO,SAAS,EAAO,GAC7C,KAAK,QAAQ,uBAAwB,CAAC,OAAQ,OAAQ,KAAM,CAAC,KAAM,IAAS,EAC7E,EAMA,OAAO,QAAU","file":"/npm/sirportly-api@1.0.1-pre/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/sirportly-api@1.0.1-pre/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Sirportly V2 API for NodeJS.\n *\n * @category\tsirportly\n * @package \tapi\n * @author\t\tRobert Pitt <rpitt@centiq.co.uk>\n * @copyright \tGPL V2\n * @version\t\t1.0.1\n * @link\t \thttps://centiq.co.uk/\n */\n\n/**\n * Require Dependancies\n */\nvar request\t= require(\"request\"),\n\tutil \t= require(\"util\"),\n\tdebug \t= require(\"debug\")(\"sirportly:api\"),\n\tmerge \t= require(\"merge\");\n\n/**\n * Sirportly API Class\n */\nfunction SirportlyAPI(config) {\n\t/**\n\t * Default configuration\n\t * @type {Object}\n\t */\n\tvar _default_config = {\n\t\t/**\n\t\t * Token used for requests\n\t\t * @type {String}\n\t\t */\n\t\ttoken : null,\n\n\t\t/**\n\t\t * Secret used with the token for authorization\n\t\t * @type {String}\n\t\t */\n\t\tsecret : null,\n\n\t\t/**\n\t\t * Target server\n\t\t * @type {String}\n\t\t */\n\t\tserver : null,\n\n\t\t/**\n\t\t * protocol used for requests\n\t\t * @type {String}\n\t\t */\n\t\tprotocol : 'http',\n\n\t\t/**\n\t\t * Port that sirportly is running on.\n\t\t * @type {Number}\n\t\t */\n\t\tport : 80\n\t};\n\t\n\t/**\n\t * merge the configuration\n\t */\n\tthis._config = merge(_default_config, config || {});\n\n\t/**\n\t * Validate the required parameters.\n\t */\n\tif(!this._config.token || !this._config.secret || !this._config.server)\n\t{\n\t\tthrow new Error(\"Misconfiguration, token, secret and server required in the config.\");\n\t}\n\n\tdebug(\"Initialized with [%s]\", this._config.server);\n}\n\n/**\n * make a request to the API\n * @param  {String}   uri      Path for the request\n * @param  {Object}   options  Request parameters, see @request\n * @param  {Function} callback Callback\n */\nSirportlyAPI.prototype.request = function(uri, options, callback) {\n\tif(!callback || typeof callback != \"function\")\n\t\tthrow new Error(\"Callback parameter must be a fuction\");\n\t/**\n\t * Server endpoint for this request\n\t * @type {String}\n\t */\n\tvar endpoint = this._config.protocol + \"://\" + this._config.server + \":\" + this._config.port + uri;\n\n\t/**\n\t * Default request options\n\t * @type {Object}\n\t */\n\tvar options = merge({\n\t\tmethod\t: 'GET',\n\t\turl \t: endpoint,\n\t\theaders : {\n\t\t\t\"X-Auth-Token\":  this._config.token,\n\t\t\t\"X-Auth-Secret\": this._config.secret\n\t\t}\n\t}, options);\n\n\n\t/**\n\t * Make the request\n\t * @param  {Object|null} \terror    Error from Request library\n\t * @param  {Response} \t\tresponse Response object from request library\n\t * @param  {String} \t\tbody     String representation of the repsonse body\n\t */\n\trequest(options, function(error, response, body){\n\t\t/**\n\t\t * Check for request error\n\t\t */\n\t\tif(error) return callback(error);\n\n\t\t/**\n\t\t * Small debug notice about the response.\n\t\t */\n\t\tdebug(\"Request to [%d] -> [%s]\", response.statusCode, uri);\n\t\t\n\t\t/**\n\t\t * Decode the JSON Body\n\t\t * @type {Object}\n\t\t */\n\t\tvar body_json = JSON.parse(body);\n\n\t\t/**\n\t\t * Check for response code\n\t\t */\n\t\tif(response.statusCode > 299 || response.statusCode < 200) {\n\t\t\t/**\n\t\t\t * Single error response\n\t\t\t */\n\t\t\tif(body_json.error)\n\t\t\t\treturn callback(new Error(body_json.error));\n\n\t\t\t/**\n\t\t\t * Multiple error resposnse, encode and represent as a string\n\t\t\t */\n\t\t\tif(body_json.errors)\n\t\t\t\treturn callback(new Error(body, response.statusCode, body));\n\t\t}\n\n\t\t/**\n\t\t * Successfull call\n\t\t */\n\t\tcallback(null, body_json);\n\t})\n};\n\n/**\n * Fetch the configuration object for this instance\n * @return {Object} Configuration object\n */\nSirportlyAPI.prototype.getConfig = function() {\n\treturn this._config;\n};\n\n/**\n * Fetch a specific ticket object\n * @param  {String}   ticket_reference Ticket Reference ID\n * @param  {Function} callback         Callback\n * @see http://sirportly.com/docs/api-specification/tickets/getting-all-ticket-properties\n */\nSirportlyAPI.prototype.ticket = function(ticket_reference, callback) {\n\tthis.request('/api/v2/tickets/ticket', {qs: {reference: ticket_reference}}, callback);\n}\n\n/**\n * Fetch a list of tickets\n * @param  {Number|Function}   page     Page or callback, page wil default to 1 if not present\n * @param  {Function} callback Callback\n * @todo Implement sort_by and order\n * @see http://sirportly.com/docs/api-specification/tickets/listing-all-tickets\n */\nSirportlyAPI.prototype.tickets = function(page, callback) {\n\tif(typeof page == 'function'){ page = 1; callback = page;};\n\tthis.request('/api/v2/tickets/all', {qs: {page: (page || 1)}}, callback);\n}\n\n/**\n * Create a new Ticket\n * @param  {Object}   params   Ticket Parameters\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/tickets/submitting-a-new-ticket\n */\nSirportlyAPI.prototype.submit_ticket = function(params, callback) {\n\tthis.request('/api/v2/tickets/submit',{method: \"POST\", qs : params || {}}, callback);\n}\n\n/**\n * Post an update to a ticket\n * @param  {String}   reference Ticket Reference\n * @param  {Object}   updates   Updates\n * @param  {Function} callback  Callback\n * @see http://sirportly.com/docs/api-specification/tickets/posting-an-update\n */\nSirportlyAPI.prototype.post_update = function(reference, updates, callback) {\n\tthis.request('/api/v2/tickets/post_update', merge({form: updates}, {method: \"POST\", qs: {ticket: reference}}) , callback);\n}\n\n/**\n * Update a tickets properties\n * @param  {String}   reference Ticekt Reference\n * @param  {Object}   updates   Updates for the ticket\n * @param  {Function} callback  Callback\n * @see http://sirportly.com/docs/api-specification/tickets/changing-ticket-properties\n */\nSirportlyAPI.prototype.update_ticket = function(reference, updates, callback) {\n\tthis.request('/api/v2/tickets/update', merge({form: updates}, {method: \"POST\", qs: {ticket: reference}}) , callback);\n}\n\n/**\n * Execute a macro\n * @param  {String}   \t\treference   Ticket Reference\n * @param  {String|Number}  macro    Macro name or id\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/tickets/execute-a-macro\n */\nSirportlyAPI.prototype.run_macro = function(reference, macro, callback) {\n\tthis.request('/api/v2/tickets/macro', {qs: {ticket: reference, macro: macro}}, callback);\n}\n\n/**\n * Add afollow up to a ticket\n * @param {String}   reference   Ticket Reference\n * @param {Object}   params   \t parameters for the request\n * @param {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/tickets/add-a-follow-up\n */\nSirportlyAPI.prototype.add_follow_up = function(reference, updates, callback) {\n\tthis.request('/api/v2/tickets/add_followup', merge({form: updates}, {method: \"POST\", qs: {ticket: reference}}) , callback);\n}\n\n/**\n * Request Statuses\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/statuses\n */\nSirportlyAPI.prototype.statuses = function(callback) {\n\tthis.request('/api/v2/objects/statuses', {}, callback);\n}\n\n/**\n * Request Priorities\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/priorities\n */\nSirportlyAPI.prototype.priorities = function(callback) {\n\tthis.request('/api/v2/objects/priorities', {}, callback);\n}\n\n/**\n * Request Teams\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/teams\n */\nSirportlyAPI.prototype.teams = function(callback) {\n\tthis.request('/api/v2/objects/teams', {}, callback);\n}\n\n/**\n * Request Brands\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/brands\n */\nSirportlyAPI.prototype.brands = function(callback) {\n\tthis.request('/api/v2/objects/brands', {}, callback);\n}\n\n/**\n * Request Departments\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/departments\n */\nSirportlyAPI.prototype.departments = function(callback) {\n\tthis.request('/api/v2/objects/departments', {}, callback);\n}\n\n/**\n * Request Escalation Paths\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/escalation-paths\n */\nSirportlyAPI.prototype.escalation_paths = function(callback) {\n\tthis.request('/api/v2/objects/escalation_paths', {}, callback);\n}\n\n/**\n * Request SLA's\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/slas\n */\nSirportlyAPI.prototype.slas = function(callback) {\n\tthis.request('/api/v2/objects/slas', {}, callback);\n}\n\n/**\n * Request Filters\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/objects/filters\n */\nSirportlyAPI.prototype.filters = function(callback) {\n\tthis.request('/api/v2/objects/filters', {}, callback);\n}\n\n/**\n * Create a new user\n * @param  {String}   email    Email Address\n * @param  {String}   first    Firstname\n * @param  {String}   last     Lastname\n * @param  {Object}   params   Other properties for the user\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/users/create-new-user\n */\nSirportlyAPI.prototype.create_user = function(email, first, last, params, callback) {\n\tthis.request('/api/v2/users/create',{method: \"POST\", qs: merge({email_address: email, first_name: first, last_name: last}, params)}, callback);\n}\n\n/**\n * Execute a SPQL Query.\n * @param  {String}   query    Query to execute\n * @param  {Function} callback Callback\n * @see http://sirportly.com/docs/api-specification/tickets/run-spql-query\n */\nSirportlyAPI.prototype.spql = function(query, callback) {\n\tthis.request('/api/v2/tickets/spql', {method: \"POST\", form: {spql: query}}, callback);\n}\n\n/**\n * Export the sirportly apiobject\n * @type {SirportlyAPI}\n */\nmodule.exports = SirportlyAPI;"]}