diff --git a/README.md b/README.md index 0d9a9c1..102849d 100755 --- a/README.md +++ b/README.md @@ -202,6 +202,24 @@ Shows the number of reached goals. Returns current LiveChat status. +### Tickets + +#### api.tickets.list(parameters, callback) + +Returns all tickets. + +#### api.tickets.get(id, parameters, callback) + +Returns single ticket item for the given `id`. + +#### api.tickets.create(parameters, callback) + +Create a ticket. + +#### api.tickets.tags(id, parameters, callback) + +Update tags of a single ticket item for the given `id`. + ### Visitors ### api.visitors.list(callback) diff --git a/lib/api.js b/lib/api.js old mode 100755 new mode 100644 index 12ac918..4e4085b --- a/lib/api.js +++ b/lib/api.js @@ -1,5 +1,5 @@ -// Generated by CoffeeScript 1.12.4 -var Agents, BasicCrud, ButtonCode, CannedResponses, Chats, Goals, Greetings, Groups, LiveChatApi, OfflineMessages, Operators, PushPages, Reports, ReportsV1, Requester, Skills, Status, TrackingCode, Visitors, crypto, request, +// Generated by CoffeeScript 1.12.7 +var Agents, BasicCrud, ButtonCode, CannedResponses, Chats, Goals, Greetings, Groups, LiveChatApi, OfflineMessages, Operators, PushPages, Reports, ReportsV1, Requester, Skills, Status, Tickets, TrackingCode, Visitors, crypto, request, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; @@ -757,6 +757,38 @@ PushPages = (function(superClass) { })(BasicCrud); +Tickets = (function(superClass) { + extend(Tickets, superClass); + + function Tickets(api) { + this.api = api; + this.tags = bind(this.tags, this); + Tickets.__super__.constructor.call(this, this.api, 'tickets'); + delete this.update; + delete this["delete"]; + } + + Tickets.prototype.tags = function(id, params, callback) { + if (params == null) { + params = {}; + } + if (typeof params === 'function' && (callback == null)) { + callback = params; + params = {}; + } + return this.api.put('tickets/' + id + '/tags', params, (function(_this) { + return function(response) { + if (callback != null) { + return callback(response); + } + }; + })(this)); + }; + + return Tickets; + +})(BasicCrud); + TrackingCode = (function() { function TrackingCode(api) { this.api = api; @@ -813,6 +845,7 @@ LiveChatApi = (function(superClass) { this.groups = new Groups(this); this.reports = new Reports(this); this.greetings = new Greetings(this); + this.tickets = new Tickets(this); } else if (this.apiVersion === 1) { this.operators = new Operators(this); this.offline_messages = new OfflineMessages(this); diff --git a/src/api.coffee b/src/api.coffee index 6f1bd3b..9eb4254 100755 --- a/src/api.coffee +++ b/src/api.coffee @@ -338,6 +338,22 @@ class PushPages extends BasicCrud constructor: (@api) -> super @api, 'push_pages' +class Tickets extends BasicCrud + constructor: (@api) -> + super @api, 'tickets' + + delete @.update + delete @.delete + + tags: (id, params = {}, callback) => + if typeof params == 'function' and !callback? + callback = params + params = {} + + @api.put 'tickets/' + id + '/tags', params, (response) => + if callback? + callback response + class TrackingCode constructor: (@api) -> @path = 'tracking_code' @@ -367,6 +383,7 @@ class LiveChatApi extends Requester @groups = new Groups(@) # 2 @reports = new Reports(@) # @ 2 @greetings = new Greetings(@) # 2 + @tickets = new Tickets(@) # 2 else if @apiVersion == 1 @operators = new Operators(@) # 1 @offline_messages = new OfflineMessages(@) # 1