lita-zendesk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ed3bd3957808a547668213958374125fed8ebe9
4
- data.tar.gz: 9126e0044a74c67b1c20a9d8c5bc79f6a16c0735
3
+ metadata.gz: f63a7f1bbf0fd4a6a93e619e1f763fd63e995393
4
+ data.tar.gz: 8d74f5d3f2c59e1b9a505b63eb3d510460ce51b0
5
5
  SHA512:
6
- metadata.gz: c6624b406255735ca9e35fb5e5ec8c7e908f1b96c421867b75970b26500407949ee668c4158744215596cba0fdcc0a5ec24c47cd66ce321cb0fbd21b3b924ba3
7
- data.tar.gz: 06e78b27d1ee692b105de17f597909031676a2d657242581803ff160b86f29f1dde2c6058ff7426c1519401db33a1f8e4c86db349c8d393c18f269a8c1135f7d
6
+ metadata.gz: 21f85ea9ec84d9e7cc735408da833d378e7939d319957ed8fe20b17104bd058bb6231fc1ad748095fa505ec186c5f5830059c1018153f36b23827489e95d1c84
7
+ data.tar.gz: 8500af1c1e8f18900892da420e741130335b3147a29fb197623af66669da48291faf197df75a24abf1ca977c045b47c5a5e1d92939524eba1238e43e4ac71858
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **0.0.6** - 2016-09-05
4
+ - Make routes case insensitive
5
+ - Add additional logging
3
6
  - **0.0.5** - 2016-08-31
4
7
  - Add free form ticket search
5
8
  - **0.0.2-0.0.4** - 2015-08-30 - 31
data/README.md CHANGED
@@ -35,6 +35,9 @@ Lita.configure do |config|
35
35
  config.handlers.zendesk.password = 'my_zendesk_password'
36
36
  config.handlers.zendesk.token = 'my_zendesk_token'
37
37
 
38
+ # Optional config
39
+ config.handlers.zendesk.use_command = false # defaults to true
40
+
38
41
  end
39
42
  ```
40
43
 
@@ -2,10 +2,11 @@ require 'base64'
2
2
  require 'faraday'
3
3
  require 'faraday_middleware'
4
4
 
5
+ require 'pp'
6
+
5
7
  module Lita
6
8
  module Handlers
7
9
  class Zendesk < Handler
8
- is_command = false
9
10
 
10
11
  VERSION_URL = 'api/v2'
11
12
  QUERY_SEARCH_PREFIX = 'search.json?query='
@@ -19,6 +20,8 @@ module Lita
19
20
  QUERY_TICKETS_UNSOLVED = 'search.json?query=status<solved+type:ticket'
20
21
  QUERY_USERS = 'users'
21
22
 
23
+ config :use_command, types: [TrueClass, FalseClass], default: true
24
+
22
25
  config :subdomain, type: String, required: true
23
26
  config :auth_type, type: String, default: 'password' # or token
24
27
  config :user, type: String, required: true
@@ -66,94 +69,95 @@ module Lita
66
69
 
67
70
  # General
68
71
 
69
- route(/^(?:zd|zendesk)\s+connection\s*$/, :zd_instance_info, command: true, help: { 'zd connection' => 'returns information on the Zendesk connection' })
72
+ route(/^(?:zd|zendesk)\s+connection\s*$/i, :zd_instance_info, command: true, help: { 'zd connection' => 'returns information on the Zendesk connection' })
70
73
  def zd_instance_info(response)
71
74
  response.reply "Using Zendesk instance at: #{base_url}"
72
75
  end
73
76
 
74
- route(/^(?:zd|zendesk)\s+search\s+tickets?\s+(\S.*?)\s*$/, :search_tickets, command: true, help: { 'zd search tickets <QUERY>' => 'returns search results' })
77
+ route(/^(?:zd|zendesk)\s+search\s+tickets?\s+(\S.*?)\s*$/i, :search_tickets, command: true, help: { 'zd search tickets <QUERY>' => 'returns search results' })
75
78
  def search_tickets(response)
76
79
  ticket_search response, QUERY_TICKETS_SEARCH, response.matches[0][0]
77
80
  end
78
81
 
79
82
  # Ticket Counts
80
83
 
81
- route(/^(?:zd|zendesk)(\s+unsolved)?\s+tickets?\s*$/, :unsolved_tickets, command: true, help: { 'zd tickets' => 'returns the total count of all unsolved tickets' })
84
+ route(/^(?:zd|zendesk)(\s+unsolved)?\s+tickets?\s*$/i, :unsolved_tickets, command: true, help: { 'zd tickets' => 'returns the total count of all unsolved tickets' })
82
85
  def unsolved_tickets(response)
83
86
  ticket_count response, QUERY_TICKETS_UNSOLVED, 'unsolved'
84
87
  end
85
88
 
86
- route(/^(?:zd|zendesk)\s+(all|total)\s+tickets?\s*$/, :total_tickets, command: true, help: { 'zd all tickets' => 'returns the count of all tickets' })
89
+ route(/^(?:zd|zendesk)\s+(all|total)\s+tickets?\s*$/i, :total_tickets, command: true, help: { 'zd all tickets' => 'returns the count of all tickets' })
87
90
  def total_tickets(response)
88
91
  ticket_count response, QUERY_TICKETS_ALL, 'total'
89
92
  end
90
93
 
91
- route(/^(?:zd|zendesk)\s+pending\s+tickets?\s*$/, :pending_tickets, command: true, help: { 'zd pending tickets' => 'returns a count of tickets that are pending' })
94
+ route(/^(?:zd|zendesk)\s+pending\s+tickets?\s*$/i, :pending_tickets, command: true, help: { 'zd pending tickets' => 'returns a count of tickets that are pending' })
92
95
  def pending_tickets(response)
93
96
  ticket_count response, QUERY_TICKETS_PENDING, 'pending'
94
97
  end
95
98
 
96
- route(/^(?:zd|zendesk)\s+new\s+tickets?\s*$/, :new_tickets, command: true, help: { 'zd new tickets' => 'returns the count of all new (unassigned) tickets' })
99
+ route(/^(?:zd|zendesk)\s+new\s+tickets?\s*$/i, :new_tickets, command: true, help: { 'zd new tickets' => 'returns the count of all new (unassigned) tickets' })
97
100
  def new_tickets(response)
98
101
  ticket_count response, QUERY_TICKETS_NEW, 'new'
99
102
  end
100
103
 
101
- route(/^(?:zd|zendesk)\s+escalated\s+tickets?\s*$/, :escalated_tickets, command: true, help: { 'zd escalated tickets' => 'returns a count of tickets with escalated tag that are open or pending' })
104
+ route(/^(?:zd|zendesk)\s+escalated\s+tickets?\s*$/i, :escalated_tickets, command: true, help: { 'zd escalated tickets' => 'returns a count of tickets with escalated tag that are open or pending' })
102
105
  def escalated_tickets(response)
103
106
  ticket_count response, QUERY_TICKETS_ESCALATED, 'escalated'
104
107
  end
105
108
 
106
- route(/^(?:zd|zendesk)\s+open\s+tickets?\s*$/, :open_tickets, command: true, help: { 'zd open tickets' => 'returns the count of all open tickets' })
109
+ route(/^(?:zd|zendesk)\s+open\s+tickets?\s*$/i, :open_tickets, command: true, help: { 'zd open tickets' => 'returns the count of all open tickets' })
107
110
  def open_tickets(response)
108
111
  ticket_count response, QUERY_TICKETS_OPEN, 'open'
109
112
  end
110
113
 
111
- route(/^(?:zd|zendesk)\s+on\s+hold\s+tickets?\s*$/, :onhold_tickets, command: true, help: { 'zd on hold tickets' => 'returns the count of all on hold tickets' })
114
+ route(/^(?:zd|zendesk)\s+on\s+hold\s+tickets?\s*$/i, :onhold_tickets, command: true, help: { 'zd on hold tickets' => 'returns the count of all on hold tickets' })
112
115
  def onhold_tickets(response)
113
116
  ticket_count response, QUERY_TICKETS_HOLD, 'on hold'
114
117
  end
115
118
 
116
119
  # Ticket Lists
117
120
 
118
- route(/^(?:zd|zendesk)\s+list(\s+unsolved)?\s+tickets?\s*$/, :unsolved_tickets_list, command: true, help: { 'zd list tickets' => 'returns a list of unsolved tickets' })
121
+ route(/^(?:zd|zendesk)\s+list(\s+unsolved)?\s+tickets?\s*$/i, :unsolved_tickets_list, command: true, help: { 'zd list tickets' => 'returns a list of unsolved tickets' })
119
122
  def unsolved_tickets_list(response)
120
123
  ticket_list response, QUERY_TICKETS_UNSOLVED, 'unsolved'
121
124
  end
122
125
 
123
- route(/^(?:zd|zendesk)\s+list\s+(all|total)\s+tickets?\s*$/, :total_tickets_list, command: true, help: { 'zd list all tickets' => 'returns a list of all tickets' })
126
+ route(/^(?:zd|zendesk)\s+list\s+(all|total)\s+tickets?\s*$/i, :total_tickets_list, command: true, help: { 'zd list all tickets' => 'returns a list of all tickets' })
124
127
  def total_tickets_list(response)
125
128
  ticket_list response, QUERY_TICKETS_ALL, 'total'
126
129
  end
127
130
 
128
- route(/^(?:zd|zendesk)\s+list\s+pending\s+tickets?\s*$/, :pending_tickets_list, command: true, help: { 'zd list pending tickets' => 'returns a list of pending tickets' })
131
+ route(/^(?:zd|zendesk)\s+list\s+pending\s+tickets?\s*$/i, :pending_tickets_list, command: true, help: { 'zd list pending tickets' => 'returns a list of pending tickets' })
129
132
  def pending_tickets_list(response)
130
133
  ticket_list response, QUERY_TICKETS_PENDING, 'pending'
131
134
  end
132
135
 
133
- route(/^(?:zd|zendesk)\s+list\s+new\s+tickets?\s*$/, :new_tickets_list, command: true, help: { 'zd list new tickets' => 'returns a list of new tickets' })
136
+ route(/^(?:zd|zendesk)\s+list\s+new\s+tickets?\s*$/i, :new_tickets_list, command: true, help: { 'zd list new tickets' => 'returns a list of new tickets' })
134
137
  def new_tickets_list(response)
135
138
  ticket_list response, QUERY_TICKETS_NEW, 'new'
136
139
  end
137
140
 
138
- route(/^(?:zd|zendesk)\s+list\s+escalated\s+tickets?\s*$/, :escalated_tickets_list, command: true, help: { 'zd list esclated tickets' => 'returns a list of escalated tickets' })
141
+ route(/^(?:zd|zendesk)\s+list\s+escalated\s+tickets?\s*$/i, :escalated_tickets_list, command: true, help: { 'zd list esclated tickets' => 'returns a list of escalated tickets' })
139
142
  def escalated_tickets_list(response)
140
143
  ticket_list response, QUERY_TICKETS_ESCALATED, 'escalated'
141
144
  end
142
145
 
143
- route(/^(?:zd|zendesk)\s+list\s+open\s+tickets?\s*$/, :open_tickets_list, command: true, help: { 'zd list open tickets' => 'returns a list of open tickets' })
146
+ route(/^(?:zd|zendesk)\s+list\s+open\s+tickets?\s*$/i, :open_tickets_list, command: true, help: { 'zd list open tickets' => 'returns a list of open tickets' })
144
147
  def open_tickets_list(response)
145
148
  ticket_list response, QUERY_TICKETS_OPEN, 'open'
146
149
  end
147
150
 
148
- route(/^(?:zd|zendesk)\s+list\s+on\s+hold\s+tickets?\s*$/, :onhold_tickets_list, command: true, help: { 'zd list onhold tickets' => 'returns a list of on hold tickets' })
151
+ route(/^(?:zd|zendesk)\s+list\s+on\s+hold\s+tickets?\s*$/i, :onhold_tickets_list, command: true, help: { 'zd list onhold tickets' => 'returns a list of on hold tickets' })
149
152
  def onhold_tickets_list(response)
150
153
  ticket_list response, QUERY_TICKETS_HOLD, 'on hold'
151
154
  end
152
155
 
153
156
  # Ticket Details
154
157
 
155
- route(/^(?:zd|zendesk)\s+ticket\s+(\d+)\s*$/, :ticket_details, command: true, help: { 'zd ticket <ID>' => 'returns information about the specified ticket' })
158
+ route(/^(?:zd|zendesk)\s+ticket\s+(\d+)\s*$/i, :ticket_details, command: true, help: { 'zd ticket <ID>' => 'returns information about the specified ticket' })
156
159
  def ticket_details(response)
160
+ Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket Details"
157
161
  ticket_id = response.matches[0][0]
158
162
  url = "#{QUERY_TICKETS_ALL}/#{ticket_id}.json"
159
163
  res = zendesk_request url
@@ -171,6 +175,7 @@ module Lita
171
175
  private
172
176
 
173
177
  def ticket_count(response, url, ticket_type = '')
178
+ Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket Count"
174
179
  res = zendesk_request url
175
180
  ticket_count = res.body['count']
176
181
  ticket_word = ticket_count == 1 ? 'ticket' : 'tickets'
@@ -179,6 +184,7 @@ module Lita
179
184
  end
180
185
 
181
186
  def ticket_search(response, url, query)
187
+ Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket Search"
182
188
  url += query
183
189
  res = zendesk_request url
184
190
  tickets = res.body['results']
@@ -192,6 +198,7 @@ module Lita
192
198
  end
193
199
 
194
200
  def ticket_list(response, url, ticket_type = '')
201
+ Lita.logger.info "#{logger_prefix}Processing Zendesk Ticket List"
195
202
  res = zendesk_request url
196
203
  tickets = res.body['results']
197
204
  tickets.each do |ticket|
@@ -207,6 +214,10 @@ module Lita
207
214
  def tickets(count)
208
215
  count == 1 ? 'ticket' : 'tickets'
209
216
  end
217
+
218
+ def logger_prefix
219
+ " -- #{self.class.name}: "
220
+ end
210
221
  end
211
222
 
212
223
  Lita.register_handler(Zendesk)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-zendesk'
3
- spec.date = '2016-08-31'
4
- spec.version = '0.0.5'
3
+ spec.date = '2016-09-05'
4
+ spec.version = '0.0.6'
5
5
  spec.authors = ['John Wang']
6
6
  spec.email = ['johncwang@gmail.com']
7
7
  spec.description = %q{A Zendesk handler for Lita.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-zendesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday