wixanswers 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: 0ea3ae208b3949e16ea98b5a5b92a5b55f0b3238efd2a7166307d35bfcbfefc3
4
- data.tar.gz: e6b530888e60633decb0a3216a1786053f0a742fdb22ea7fb19603d93e2a9b3e
3
+ metadata.gz: 21d43335f8bcfa2fb50d395f15d2f91ebcc8dabd8232bd9c16e6aa6d1cd7d1b0
4
+ data.tar.gz: f007d21c8e72e016b8ab1fe1d05a94b6ea0f3773eee0fd75f805f45b4538808e
5
5
  SHA512:
6
- metadata.gz: 6fbf6a0659f0494a60620852000497cd74c902a20b276cf8088836cb353cf1e49f403041667d716abfef6226258ec5cb5cab01fc5ae4f899682219175e0a049b
7
- data.tar.gz: 2ee1de36a98bda372ffc06d7e274da99ba4cd1631977ed1e60c5a85072205c9a35495466ecbc9a0542727c6637c2f0772bfe80ae56c36aeaeca8c0326f0a7c1a
6
+ metadata.gz: 79a990f97a8b3af128ac72a3d2fa372813a3eddeba6341857a6912134621877303939cd3159aac2419df1a49dcac5ec1f479e7f63621fd2aa39b95a5153aae5e
7
+ data.tar.gz: 447cbf3731bd905b5132054f5632cf6f311c2c5ca7598ae21985d0e5931c8b5c55167a34b050ec0a2bcb8f7e9a47badfb547f88efe85bc43084ebf08ee3fa5f0
@@ -1,3 +1,15 @@
1
+ 0.0.6 (In Progress)
2
+ ------
3
+ * added PhoneNumber object
4
+ * added API and Request modules,
5
+ * added Client class
6
+ * added support for ticket 'Add', 'Get'
7
+
8
+ 0.0.5 (Stable)
9
+ ------
10
+ * added all Enumeration objects
11
+ * added Enumeration#title method
12
+
1
13
  0.0.3
2
14
  ------
3
15
  * support email-based tickets
@@ -1,6 +1,7 @@
1
1
  require 'wixanswers/rest/api'
2
- require 'wixanswers/rest/enumerations'
3
- require 'wixanswers/rest/exceptions'
2
+
3
+ require 'wixanswers/enumerations'
4
+ require 'wixanswers/exceptions'
4
5
 
5
6
  require 'wixanswers/models/base'
6
7
 
@@ -0,0 +1,427 @@
1
+
2
+
3
+ module WixAnswers
4
+ module Enumerations
5
+ class Enumeration
6
+ def self.values
7
+ Set.new(constants.map {|const| const_get(const) })
8
+ end
9
+
10
+ def self.valid?(value)
11
+ values.include?(value)
12
+ end
13
+
14
+ def self.validate!(value)
15
+ raise Exceptions::UnsupportedType.new(self.name, value) unless self.valid?(value)
16
+ end
17
+
18
+ def self.by_values
19
+ constants.map {|const| [const_get(const), const] }.to_h
20
+ end
21
+
22
+ def self.title(value)
23
+ const_name = self.by_values[value]
24
+ return '' if const_name.nil?
25
+
26
+ const_name.to_s.capitalize.gsub(/\_/, ' ')
27
+ end
28
+ end
29
+
30
+ class WebhookType < Enumeration
31
+ TICKET_CREATED ||= 2
32
+ TICKET_STATUS_CHANGED ||= 8
33
+ end
34
+
35
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#agent-channel-1
36
+ class AgentChannel < Enumeration
37
+ NONE ||= 0
38
+ TICKET ||= 10
39
+ CALL_CENTER ||= 20
40
+ CHAT ||= 30
41
+ end
42
+
43
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#agent-status
44
+ class AgentStatus < Enumeration
45
+ ONLINE ||= 10
46
+ IN_WORK ||= 40
47
+ BUSY ||= 60
48
+ OFFLINE ||= 100
49
+ end
50
+
51
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#article-resolution
52
+ class ArticleResolution < Enumeration
53
+ COLLECTING_VOTES ||= 110
54
+ IN_DEVELOPMENT ||= 112
55
+ COMING_SOON ||= 114
56
+ RELEASED ||= 116
57
+ INVESTIGATING ||= 120
58
+ WORKING_ON_IT ||= 122
59
+ RESOLVED ||= 124
60
+ THIRD_PARTY_BUG ||= 126
61
+ end
62
+
63
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#article-status
64
+ class ArticleStatus < Enumeration
65
+ DRAFT ||= 0
66
+ PUBLISHED ||= 10
67
+ DELETED ||= 30
68
+ end
69
+
70
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#article-type
71
+ class ArticleType < Enumeration
72
+ ARTICLE ||= 100
73
+ FEATURE_REQUEST ||= 110
74
+ KNOWN_ISSUE ||= 120
75
+ VIDEO ||= 130
76
+ end
77
+
78
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#article-version-publication-status
79
+ class ArticleVersionPublicationStatus < Enumeration
80
+ DRAFT ||= 0
81
+ PUBLISHED ||= 1
82
+ end
83
+
84
+ class AttachmentStatus < Enumeration
85
+ FAILED ||= 1
86
+ INVALID_EXTENSION ||= 2
87
+ MAX_FILE_SIZE_EXCEEDED ||= 3
88
+ OK ||= 200
89
+ end
90
+
91
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#call-participant-status
92
+ class CallParticipantStatus < Enumeration
93
+ CONNECTING ||= 10
94
+ TALKING ||= 20
95
+ ON_HOLD ||= 30
96
+ MUTED ||= 40
97
+ LEFT ||= 50
98
+ DECLINED ||= 60
99
+ NO_ANSWER ||= 70
100
+ CANCELLED ||= 80
101
+ INVITED ||= 90
102
+ FAILED ||= 100
103
+ end
104
+
105
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#call-priority
106
+ class CallPriority < Enumeration
107
+ NORMAL ||= 0
108
+ HIGH ||= 1
109
+ end
110
+
111
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#call-status
112
+ class CallStatus < Enumeration
113
+ IN_IVR ||= 10
114
+ IN_QUEUE ||= 20
115
+ RESERVED ||= 30
116
+ INITIATED ||= 40
117
+ RINGING ||= 50
118
+ IN_PROGRESS ||= 60
119
+ COMPLETED ||= 70
120
+ COMPLETED_IN_IVR ||= 71
121
+ FORWARDED ||= 72
122
+ TRANSFERRED_TO_NUMBER ||= 73
123
+ COMPLETED_VOICEMAIL ||= 74
124
+ PENDING_VOICEMAIL ||= 75
125
+ BUSY ||= 80
126
+ FAILED ||= 90
127
+ NO_ANSWER ||= 100
128
+ CANCELLED ||= 110
129
+ EXPIRED ||= 120
130
+ TRANSFERRED_TO_QUEUE ||= 130
131
+ ABANDONED ||= 140
132
+ HUNG_UP_IN_QUEUE ||= 150
133
+ HUNG_UP_IN_IVR ||= 160
134
+ TRANSFERRED_TO_IVR ||= 170
135
+ end
136
+
137
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#call-type
138
+ class CallType < Enumeration
139
+ INBOUND ||= 10
140
+ OUTBOUND ||= 20
141
+ CALLBACK ||= 30
142
+ end
143
+
144
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#channel
145
+ class Channel < Enumeration
146
+ WEB ||= 100
147
+ EMAIL ||= 110
148
+ PHONE_CALLBACK ||= 120
149
+ PHONE_OUTBOUND ||= 121
150
+ PHONE_INBOUND ||= 122
151
+ BY_AGENT ||= 130
152
+ FACEBOOK ||= 140
153
+ WHATSAPP ||= 150
154
+ CHAT ||= 160
155
+ WIDGET ||= 170
156
+ API ||= 180
157
+ SMS ||= 190
158
+ end
159
+
160
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#chat-message-status
161
+ class ChatMessageStatus < Enumeration
162
+ QUEUED ||= 10
163
+ FAILED ||= 20
164
+ SENT ||= 30
165
+ DELIVERED ||= 40
166
+ FAILED ||= 50
167
+ end
168
+
169
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#chat-message-type
170
+ class ChatMessageType < Enumeration
171
+ USER ||= 100
172
+ AGENT ||= 110
173
+ end
174
+
175
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#chat-participant-status
176
+ class ChatParticipantStatus < Enumeration
177
+ TALKING ||= 10
178
+ LEFT ||= 20
179
+ end
180
+
181
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#chat-status
182
+ class ChatStatus < Enumeration
183
+ WAITING ||= 0
184
+ ACTIVE ||= 1
185
+ COMPLETED ||= 2
186
+ end
187
+
188
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#content-task-priority
189
+ class ContentTaskPriority < Enumeration
190
+ LOW ||= 10
191
+ NORMAL ||= 20
192
+ HIGH ||= 30
193
+ end
194
+
195
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#content-task-status
196
+ class ContentTaskStatus < Enumeration
197
+ OPEN ||= 10
198
+ COMPLETED ||= 20
199
+ end
200
+
201
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#content-task-type
202
+ class ContentTaskType < Enumeration
203
+ WRITE ||= 10
204
+ UPDATE ||= 20
205
+ REVIEW ||= 30
206
+ TRANSLATE ||= 40
207
+ end
208
+
209
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#counter-type
210
+ class CounterType < Enumeration
211
+ FOLLOWER ||= 10
212
+ VIEW ||= 20
213
+ VOTE ||= 30
214
+
215
+ UNHELPFUL ||= 300
216
+ RATING_1 ||= 300
217
+
218
+ HELPFUL ||= 304
219
+ RATING_5 ||= 304
220
+ end
221
+
222
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#custom-field-type
223
+ class ContentTaskType < Enumeration
224
+ TEXT ||= 1
225
+ MULTI_LINE_TEXT ||= 2
226
+ SINGLE_SELECT ||= 3
227
+ MULTI_SELECT ||= 4
228
+ NUMBER ||= 5
229
+ CHECKBOX ||= 6
230
+ DATE_PICKER ||= 7
231
+ end
232
+
233
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#email-status
234
+ class EmailStatus < Enumeration
235
+ NOT_VERIFIED ||= 0
236
+ VERIFIED ||= 1
237
+ INVALIDATED ||= 99
238
+ end
239
+
240
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#event-type
241
+ class EventType < Enumeration
242
+ ARTICLE_ADDED ||= 650
243
+ ARTICLE_UPDATED ||= 651
244
+ ARTICLE_CONTENT_UPDATED ||= 652
245
+ ARTICLE_DELETED ||= 653
246
+ ARTICLE_RESTORED ||= 654
247
+ ARTICLE_MERGED ||= 655
248
+ ARTICLE_UNPUBLISHED ||= 656
249
+ ARTICLE_PUBLISHED ||= 663
250
+ ARTICLE_LABELS_UPDATED ||= 665
251
+ ARTICLE_PHRASES_UPDATED ||= 666
252
+ ARTICLE_VISIBILITY_CHANGED ||= 667
253
+ TICKET_UPDATED ||= 700
254
+ TICKET_CONTENT_UPDATED ||= 701
255
+ TICKET_DELETED ||= 702
256
+ TICKET_STATUS_CHANGED ||= 703
257
+ REPLY_DELETED ||= 705
258
+ OUTBOUND_TICKET_ADDED ||= 707
259
+ REPLY_CONTENT_UPDATED ||= 709
260
+ REPLY_MOVED ||= 710
261
+ TICKET_CREATED_FROM_REPLLY ||= 711
262
+ TICKET_LABELS_UPDATED ||= 712
263
+ SCHEDULED_CALL_CANCELLED ||= 713
264
+ REPLY_MADE_INTO_TICKET ||= 714
265
+ TICKET_LOCALE_CHANGED ||= 715
266
+ TICKET_SET_PRIVATE ||= 716
267
+ TICKET_ARTICLE_RELATIONS_CHANGED ||= 717
268
+ TICKET_PRIORITY_CHANGED ||= 718
269
+ TICKET_ASSIGNED ||= 722
270
+ TICKET_UNASSIGNED ||= 723
271
+ TICKET_MARKED_AS_SPAM ||= 724
272
+ REPLY_MOVED_TO_TICKET ||= 725
273
+ REPLY_MOVED_FROM_TICKET ||= 726
274
+ INTERNAL_NOTE_DELETED ||= 727
275
+ TICKET_CUSTOM_FIELDS_UPDATED ||= 728
276
+ AGENT_REPLY_ADDED ||= 729
277
+ TICKET_ATTACHMENTS_REMOVED ||= 730
278
+ REPLY_ATTACHMENTS_REMOVED ||= 731
279
+ RULE_FAILED ||= 732
280
+ TICKET_TRANSFERRED ||= 733
281
+ EMAIL_SENT||= 734
282
+ REPLY_UPDATED_ON_TICKET_TRANSFERRED ||= 735
283
+ TICKET_AUTHENTICATED ||= 736
284
+ SLA_POLICY_ADDED_TO_TICKET ||= 737
285
+ MACRO_APPLIED_ON_TICKET ||= 738
286
+ AGENT_INERNAL_REPLY_ADDED ||= 739
287
+ TICKET_AUTOMATICALLY_ASSIGNED_TO_ACCOUNT_MANAGER ||= 740
288
+ ADD_CUSTOM_TICKET_TIMELINE_API ||= 742
289
+ CATEGORY_ADDED ||= 800
290
+ CATEGORY_REMOVED ||= 801
291
+ CATEGORY_LANGUAGE_VALUES_CHANGED ||= 802
292
+ CATEGORY_UPDATED ||= 803
293
+ CATEGORY_MOVED ||= 804
294
+ CHAT_TICKET_USER_UPDATED ||= 1500
295
+ AGENT_JOINED_CHAT ||= 1501
296
+ AGENT_LEFT_CHAT ||= 1502
297
+ AGENT_ENDED_CHAT ||= 1503
298
+ TICKET_HANDLING_STARTED ||= 2500
299
+ TICKET_HANDLING_ENDED ||= 2501
300
+ ALL_TICKET_HANDLING_ENDED ||= 2502
301
+ end
302
+
303
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#item-type874
304
+ class ItemType < Enumeration
305
+ CATEGORY ||= 2
306
+ SEO_CONTENT ||= 6
307
+ TENANT ||= 7
308
+ TICKET ||= 8
309
+ REPLY ||= 9
310
+ ARTICLE ||= 10
311
+ EMAIL_TEMPLATE ||= 14
312
+ CONTENT_TASK ||= 40
313
+ MAILBOX ||= 50
314
+ USER ||= 60
315
+ SAVED_REPLY ||= 70
316
+ LABEL ||= 90
317
+ URL_MAPPING ||= 110
318
+ MULTILINGUAL_TEXT ||= 120
319
+ SAVED_FILTER ||= 130
320
+ PHONE_CALL ||= 150
321
+ NOTE ||= 160
322
+ CHAT_MESSAGE ||= 170
323
+ CHAT ||= 175
324
+ INTEGRATION ||= 180
325
+ SLA_POLICY ||= 190
326
+ GROUP ||= 200
327
+ WIDGET ||= 210
328
+ LINE ||= 220
329
+ WIDGET_MULTILINGUAL_TEXTS ||= 221
330
+ COMPANY ||= 230
331
+ QUEUE ||= 260
332
+ USER_ROLE ||= 280
333
+ AGENT ||= 300
334
+ end
335
+
336
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#rating
337
+ class Rating < Enumeration
338
+ POSITIVE ||= 10
339
+ NEUTRAL ||= 20
340
+ NEGATIVE ||= 30
341
+ end
342
+
343
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#reply-status
344
+ class ReplyStatus < Enumeration
345
+ DRAFT ||= 0
346
+ PUBLISHED ||= 1
347
+ DELETED ||= 2
348
+ end
349
+
350
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#reply-type
351
+ class ReplyType < Enumeration
352
+ USER ||= 100
353
+ CC_USER ||= 101
354
+ AGENT ||= 110
355
+ INTERNAL ||= 120
356
+ end
357
+
358
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#satisfaction
359
+ class Satisfaction < Enumeration
360
+ NOT_AT_ALL ||= 10
361
+ NOT_VERY ||= 10
362
+ SOMEWHAT ||= 20
363
+ VERY ||= 30
364
+ EXTREMELY ||= 40
365
+ end
366
+
367
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#saved-filter-context
368
+ class SavedFilterContext < Enumeration
369
+ TICKET ||= 0
370
+ CHAT ||= 10
371
+ end
372
+
373
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#saved-filter-type
374
+ class SavedFilterType < Enumeration
375
+ SYSTEM ||= 0
376
+ PRIVATE ||= 10
377
+ PUBLIC ||= 20
378
+ end
379
+
380
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#saved-reply-status
381
+ class SavedReplyStatus < Enumeration
382
+ DRAFT ||= 0
383
+ PUBLISHED ||= 1
384
+ DELETE ||= 2
385
+ end
386
+
387
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#search-type
388
+ class SearchType < Enumeration
389
+ EXACT ||= 1
390
+ CONTAINS ||= 2
391
+ NOT_CONTAINS ||= 3
392
+ end
393
+
394
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#sla-policy-status
395
+ class SLAPolicyStatus < Enumeration
396
+ PAUSED ||= 0
397
+ ACTIVE ||= 1
398
+ COMPLETED_SUCCESSFULLY ||= 2
399
+ COMPLETED_UNSUCCESSFULLY ||= 3
400
+ end
401
+
402
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#ticket-priority
403
+ class TicketPriority < Enumeration
404
+ LOW ||= 10
405
+ NORMAL ||= 20
406
+ HIGH ||= 30
407
+ end
408
+
409
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#ticket-status
410
+ class TicketStatus < Enumeration
411
+ OPEN ||= 100
412
+ PENDING ||= 110
413
+ CLOSED ||= 120
414
+ SOLVED = 140
415
+ INVESTIGATING = 150
416
+ end
417
+
418
+ # https://help.wixanswers.com/kb/en/article/api-enumerations#user-type
419
+ class UserType < Enumeration
420
+ AUTHENTICATED ||= 1
421
+ UNAUTHENTICATED ||= 2
422
+ PENDING_AUTHENTICATION ||= 4
423
+ PENDING_DELETION ||= 5
424
+ DELETED ||= 99
425
+ end
426
+ end
427
+ end
@@ -0,0 +1,12 @@
1
+
2
+ # https://help.wixanswers.com/kb/en/article/api-object-structures#phone-number-object
3
+ module WixAnswers
4
+ module Models
5
+ class PhoneNumber < Base
6
+ SCHEMA ||= {
7
+ countryCode: {type: 'String', description: 'The country code', required: true},
8
+ number: {type: 'String', description: 'The number', required: true},
9
+ }
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,9 @@
1
-
1
+ require 'wixanswers/rest/ticket'
2
2
 
3
3
  module WixAnswers
4
- module Api
4
+ module REST
5
+ module API
6
+ include WixAnswers::REST::Ticket
7
+ end
5
8
  end
6
9
  end
@@ -0,0 +1,26 @@
1
+
2
+ require 'wixanswers/rest/api'
3
+ require 'wixanswers/rest/request'
4
+
5
+ module WixAnswers
6
+ module REST
7
+ class Client
8
+ include WixAnswers::REST::API
9
+ attr_accessor :bearer_token
10
+
11
+ def perform_request(path, request_method=:get, options = {})
12
+ WixAnswers::REST::Request.new(self, path, request_method, options).perform
13
+ end
14
+
15
+ # @return [Boolean]
16
+ def bearer_token?
17
+ !!bearer_token
18
+ end
19
+
20
+ # @return [Boolean]
21
+ def credentials?
22
+ super || bearer_token?
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+
2
+
3
+ module WixAnswers
4
+ module REST
5
+ class Request
6
+ def initialize(client, request_method, path, options: {}, headers: {})
7
+ @client = client
8
+
9
+ @request_method = request_method.to_sym
10
+
11
+ @uri = Addressable::URI.parse("#{client.base_url}/#{client.version}/#{path}")
12
+ @path = @uri.path
13
+
14
+ @options = options
15
+ @headers = default_headers.merge(headers)
16
+ end
17
+
18
+ def perform
19
+ response = self.send(@request_method, @uri.to_s, headers: @headers)
20
+
21
+ response.body
22
+ end
23
+
24
+ def default_headers
25
+ {'Content-Type' => 'application/json; charset=utf-8', 'Accept' => 'application/json'}
26
+ end
27
+
28
+ private
29
+
30
+ def get(uri, params: {}, headers: {})
31
+ HTTParty.get("#{uri}/#{params.to_param}", headers: headers)
32
+ end
33
+
34
+ def post(uri, body, headers)
35
+ HTTParty.post(uri, body: body, headers: headers)
36
+ end
37
+
38
+ def put(uri, body, headers)
39
+ HTTParty.put(uri, body: body, headers: headers)
40
+ end
41
+
42
+ def delete(uri, body, headers)
43
+ HTTParty.delete(uri, body: body, headers: headers)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,162 @@
1
+
2
+
3
+ module WixAnswers
4
+ module REST
5
+ module Ticket
6
+ # Create a ticket for the authenticated user associated with the JWT token
7
+ #
8
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#add-a-ticket-as-an-authenticated-user
9
+ # @authorization Requires user authorization token for specific user
10
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied user credentials are not valid.
11
+ # @return <WixAnswers::Models::Ticket>
12
+ # @param options [Hash] A customizable set of options
13
+ # @option subject [String] A short description of the problem or question
14
+ # @option content [String] A complete description of the problem or question
15
+ # @option locale [String] The locale for the ticket
16
+ def add(options = {})
17
+ WixAnswers::Models::Ticket.new(perform_request("/tickets", :post, options))
18
+ end
19
+
20
+ # Create a ticket on behalf of an authenticated or unauthenticated user.
21
+ # Use this in response to a user request where the agent creates the ticket
22
+ # based on that request on behalf of the user.
23
+ #
24
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#add-a-ticket-as-an-agent-on-behalf-of-a-user
25
+ # @authorization Requires agent authorization token and permission CREATE_TICKETS
26
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
27
+ # @return <WixAnswers::Models::Ticket>
28
+ # @param options [Hash] A customizable set of options
29
+ # @option recipientEmail [String] Email of the user this ticket is created for.
30
+ # Either this parameter or recipientId is required.
31
+ # @option recipientId [String] ID of the user this ticket is created for
32
+ # @option subject [String] A short description of the problem or question
33
+ # @option content [String] A complete description of the problem or question
34
+ # @option locale [String] The locale for the ticket
35
+ def add_on_behalf(options = {})
36
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/onBehalf", :post, options))
37
+ end
38
+
39
+ # Create a new ticket for an unauthenticated user who has provided an email address.
40
+ # Use this API only when a user GUID is not available, for example when an unregistered
41
+ # user creates a ticket on your site or widget.
42
+ #
43
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#add-a-guest-unauthenticated-user-ticket
44
+ # @authorization Requires agent authorization token and permission CREATE_TICKETS
45
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied user credentials are not valid.
46
+ # @return <WixAnswers::Models::Ticket>
47
+ # @param options [Hash] A customizable set of options
48
+ # @option userEmail [String] Email of the user this ticket is associated with
49
+ # @option subject [String] A short description of the problem or question
50
+ # @option content [String] A complete description of the problem or question
51
+ # @option locale [String] The locale for the ticket
52
+ def add_as_guest(options = {})
53
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/guest", :post, options))
54
+ end
55
+
56
+ # Create a new ticket from an existing user reply. The new ticket takes many of its details
57
+ # (user, priority, status, and so forth) from the existing ticket, and the new contents from the reply.
58
+ # After creating the ticket, Wix Answer invokes the Ticket Created webhook.
59
+ #
60
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#convert-a-user-reply-into-a-new-ticket
61
+ # @authorization Requires agent authorization token and permission CREATE_TICKETS
62
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied user credentials are not valid.
63
+ # @return <WixAnswers::Models::Ticket>
64
+ # @param ticket_id [String] ticket GUID
65
+ # @param reply_id [String] reply GUID
66
+ # @param options [Hash] A customizable set of options
67
+ # @option subject [String] A short description of the problem or question
68
+ def add_as_agent(ticket_id, reply_id, options = {})
69
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/#{ticket_id}/replies/#{reply_id}/createTicket", :post, options))
70
+ end
71
+
72
+ # Create a new callback request ticket to the passed phone number, for the user associated with the JWT token.
73
+ # Requires a line that supports outbound calls.
74
+ #
75
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#add-a-phone-callback-request-ticket
76
+ # @authorization Requires user authorization token for specific user
77
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied user credentials are not valid.
78
+ # @return <WixAnswers::Models::Ticket>
79
+ # @param options [Hash] A customizable set of options
80
+ # @option phoneNumber [Hash, WixAnswers::Models::PhoneNumber] Phone number to call back
81
+ # @option lineId [Integer] The account's phone line ID from which the callback will take place.
82
+ # See Call Center Lines APIs.
83
+ def add_callback_request(options = {})
84
+ options[:phoneNumber] = options[:phoneNumber].is_a?(WixAnswers::Models::PhoneNumber) ? options[:phoneNumber].attrs : options[:phoneNumber]
85
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/callbackRequests", :post, options))
86
+ end
87
+
88
+ # Get a ticket by its ID. This requires agent privileges; to get one of your own tickets
89
+ # (with user privileges), see Get One of Your Tickets by ID.
90
+ #
91
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#get-a-ticket-by-id
92
+ # @authorization Requires agent authorization token and permission FETCH_TICKETS
93
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
94
+ # @return <WixAnswers::Models::Ticket>
95
+ # @param ticket_id [String] Ticket GUID
96
+ def ticket(ticket_id)
97
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/#{ticket_id}/admin"))
98
+ end
99
+ alias find_by_id ticket
100
+
101
+ # Get a ticket by its ticket reference number (issue ID). This requires agent privileges;
102
+ # to get one of your own tickets (with user privileges), see Get One of Your Tickets by ID.
103
+ #
104
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#get-a-ticket-by-ticket-reference-number
105
+ # @authorization Requires agent authorization token and permission FETCH_TICKETS
106
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
107
+ # @return <WixAnswers::Models::Ticket>
108
+ # @param ticket_number [Integer] Ticket Number
109
+ def find_by_number(ticket_number)
110
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/byNumber/#{ticket_number}/admin"))
111
+ end
112
+
113
+ # Get one of your tickets by its ID. The main use-case for this API is from the Help Center.
114
+ # If you have agent privileges, you can get any ticket by its reference number or id;
115
+ # see Get a Ticket by Ticket Reference Number.
116
+ #
117
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#get-a-ticket-by-ticket-reference-number
118
+ # @authorization Requires agent authorization token and permission FETCH_TICKETS
119
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
120
+ # @return <WixAnswers::Models::Ticket>
121
+ # @param ticket_id [String] Ticket GUID
122
+ def my_ticket(ticket_id)
123
+ WixAnswers::Models::Ticket.new(perform_request("/tickets/byNumber/#{ticket_id}/my"))
124
+ end
125
+
126
+ # Get list of tickets that match the search/filtering criteria.
127
+ #
128
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#search-tickets-agent
129
+ # @authorization Requires agent authorization token and permission FETCH_TICKETS
130
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
131
+ # @return [Array<WixAnswers::Models::Ticket>]
132
+ # @param options [Hash] A customizable set of options
133
+ def search(options = {})
134
+ perform_request("/tickets/search/admin", :post, options).map {|ticket| WixAnswers::Models::Ticket.new(ticket) }
135
+ end
136
+
137
+ # Get list of your tickets that match the search/filtering criteria.
138
+ # The main use-case for this API is from the Help Center.
139
+ #
140
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#search-your-tickets1097
141
+ # @authorization Requires user authorization token for specific user
142
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
143
+ # @return [Array<WixAnswers::Models::Ticket>]
144
+ # @param options [Hash] A customizable set of options
145
+ def search_mine(options = {})
146
+ perform_request("/tickets/my", :post, options).map {|ticket| WixAnswers::Models::Ticket.new(ticket) }
147
+ end
148
+
149
+ # Get the number of tickets matching one or more saved filters.
150
+ #
151
+ # @see https://help.wixanswers.com/kb/en/article/ticket-apis#get-the-number-of-tickets-matching-one-or-more-saved-filters
152
+ # @authorization Requires agent authorization token and permission FETCH_TICKET_VIEWS
153
+ # @raise [WixAnswers::Exceptions::Unauthorized] Error raised when supplied agent credentials are not valid.
154
+ # @return [Hash]
155
+ # @param options [Hash] A customizable set of options
156
+ # @option locale [String] Get the number of tickets matching one or more saved filters.
157
+ def count(options = {})
158
+ perform_request("/tickets/filtersCounts", :post, options)
159
+ end
160
+ end
161
+ end
162
+ end
@@ -11,7 +11,7 @@ module WixAnswers
11
11
  end
12
12
 
13
13
  def patch
14
- 4
14
+ 5
15
15
  end
16
16
 
17
17
  def pre
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wixanswers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roee Sheelo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-17 00:00:00.000000000 Z
11
+ date: 2020-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -35,9 +35,12 @@ files:
35
35
  - LICENSE.md
36
36
  - README.md
37
37
  - lib/wixanswers.rb
38
+ - lib/wixanswers/enumerations.rb
39
+ - lib/wixanswers/exceptions.rb
38
40
  - lib/wixanswers/models/attachment.rb
39
41
  - lib/wixanswers/models/base.rb
40
42
  - lib/wixanswers/models/label.rb
43
+ - lib/wixanswers/models/line/phone_number.rb
41
44
  - lib/wixanswers/models/ticket/by_agent.rb
42
45
  - lib/wixanswers/models/ticket/chat.rb
43
46
  - lib/wixanswers/models/ticket/phone_callback.rb
@@ -52,8 +55,9 @@ files:
52
55
  - lib/wixanswers/models/user/user.rb
53
56
  - lib/wixanswers/models/user_info.rb
54
57
  - lib/wixanswers/rest/api.rb
55
- - lib/wixanswers/rest/enumerations.rb
56
- - lib/wixanswers/rest/exceptions.rb
58
+ - lib/wixanswers/rest/client.rb
59
+ - lib/wixanswers/rest/request.rb
60
+ - lib/wixanswers/rest/ticket.rb
57
61
  - lib/wixanswers/version.rb
58
62
  - wixanswers.gemspec
59
63
  homepage: https://github.com/communit-team/wixanswers
@@ -1,95 +0,0 @@
1
-
2
-
3
- module WixAnswers
4
- module Enumerations
5
- class Enumeration
6
- def self.values
7
- Set.new(constants.map {|const| const_get(const) })
8
- end
9
-
10
- def self.valid?(value)
11
- values.include?(value)
12
- end
13
-
14
- def self.validate!(value)
15
- raise Exceptions::UnsupportedType.new(self.name, value) unless self.valid?(value)
16
- end
17
- end
18
-
19
- class WebhookType < Enumeration
20
- TICKET_CREATED ||= 2
21
- TICKET_STATUS_CHANGED ||= 8
22
- end
23
-
24
- class AttachmentStatus < Enumeration
25
- FAILED ||= 1
26
- INVALID_EXTENSION ||= 2
27
- MAX_FILE_SIZE_EXCEEDED ||= 3
28
- OK ||= 200
29
- end
30
-
31
- # https://help.wixanswers.com/kb/en/article/api-enumerations#user-type
32
- class UserType < Enumeration
33
- AUTHENTICATED ||= 1
34
- UNAUTHENTICATED ||= 2
35
- PENDING_AUTHENTICATION ||= 4
36
- PENDING_DELETION ||= 5
37
- DELETED ||= 99
38
- end
39
-
40
- # https://help.wixanswers.com/kb/en/article/api-enumerations#call-type
41
- class CallType < Enumeration
42
- INBOUND ||= 10
43
- OUTBOUND ||= 20
44
- CALLBACK ||= 30
45
- end
46
-
47
- # https://help.wixanswers.com/kb/en/article/api-enumerations#reply-type
48
- class ReplyType < Enumeration
49
- USER ||= 100
50
- CC_USER ||= 101
51
- AGENT ||= 110
52
- INTERNAL ||= 120
53
- end
54
-
55
- # https://help.wixanswers.com/kb/en/article/api-enumerations#article-type
56
- class ArticleType < Enumeration
57
- ARTICLE ||= 100
58
- FEATURE_REQUEST ||= 110
59
- KNOWN_ISSUE ||= 120
60
- VIDEO ||= 130
61
- end
62
-
63
- # https://help.wixanswers.com/kb/en/article/api-enumerations#ticket-priority
64
- class TicketPriority < Enumeration
65
- LOW ||= 10
66
- NORMAL ||= 20
67
- HIGH ||= 30
68
- end
69
-
70
- # https://help.wixanswers.com/kb/en/article/api-enumerations#channel
71
- class Channel < Enumeration
72
- WEB ||= 100
73
- EMAIL ||= 110
74
- PHONE_CALLBACK ||= 120
75
- PHONE_OUTBOUND ||= 121
76
- PHONE_INBOUND ||= 122
77
- BY_AGENT ||= 130
78
- FACEBOOK ||= 140
79
- WHATSAPP ||= 150
80
- CHAT ||= 160
81
- WIDGET ||= 170
82
- API ||= 180
83
- SMS ||= 190
84
- end
85
-
86
- # https://help.wixanswers.com/kb/en/article/api-enumerations#satisfaction
87
- class Satisfaction < Enumeration
88
- NOT_AT_ALL ||= 10
89
- NOT_VERY ||= 10
90
- SOMEWHAT ||= 20
91
- VERY ||= 30
92
- EXTREMELY ||= 40
93
- end
94
- end
95
- end