qismo 0.17.4 → 0.17.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -51
  3. data/lib/qismo/api.rb +41 -24
  4. data/lib/qismo/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32a1f3d54408a3ec4ac13282946090480b5e684537d8c37e8deca21ee37dab51
4
- data.tar.gz: c5c9c893cb57b4b33f17fa384b24947888a26335418ee6b1841fcbd74ca5af2b
3
+ metadata.gz: 387f549a5a7791dc0c36043b0e031767429e65dfd8cab179e6a9376acada2c62
4
+ data.tar.gz: 92ee18a231db835a294ad59dbd35162f0a84fc22e74277f461fbe5417e724717
5
5
  SHA512:
6
- metadata.gz: 6ae312acbe3a8805c115e4656e8f1d1385ec0ed891ee8637fa92ee625e0a765536d13f2409af429064f3ddd8b8f48dc7ab063ccde014daf5255dca0128340fe5
7
- data.tar.gz: 9be35658b3ef3804a70ec74c67c4f99a1582a4e956fd1e9497e694fdf585c121879b79d0a8a586af8241a6b5fe84308ebbc2b7102daad8556879072db2fd6c78
6
+ metadata.gz: 25a7554d219955a4436575cf61663966a9ed41b7954cf16a9511bb5e30967353ef91e1b26d61b266e86a863dab4dddde16cf3ec15b94d7983a2f6a4f105b72c3
7
+ data.tar.gz: eed71f20bb062736113ddae6a14c29925e8a850a46e5a2a9c98b4978a8a58b75d7398eea5febb7134be4d00bb82a8e21d24452f5778d57c24f5e18d58b874614
data/README.md CHANGED
@@ -13,17 +13,8 @@ bundle add qismo
13
13
  ## Usage
14
14
 
15
15
  ```ruby
16
- # config/initializers/qismo.rb
17
-
18
- Qismo.configure do |client|
19
- client.app_id = ENV["QISCUS_APP_ID"]
20
- client.secret_key = ENV["QISCUS_SECRET_KEY"]
21
- end
22
- ```
23
-
24
- Then, start requesting to available endpoint
16
+ client = Qismo::Client.new(app_id: "QISCUS_APP_ID", secret_key: "QISCUS_SECRET_KEY")
25
17
 
26
- ```ruby
27
18
  params = {
28
19
  channel: { channel_id: 12345, source: "wa" },
29
20
  status: "unresolved",
@@ -31,51 +22,33 @@ params = {
31
22
  is_handled_by_bot: true,
32
23
  }
33
24
 
34
- # List rooms
35
- rooms = Qismo.rooms(params)
25
+ rooms = client.rooms(params)
36
26
 
37
27
  puts rooms
38
28
  # [
39
- # #<Qismo::SingleObject
40
- # channel_id=6171,
41
- # contact_id=71716,
42
- # id=181917,
43
- # is_handled_by_bot=true,
44
- # is_resolved=false,
45
- # is_waiting=false,
46
- # last_comment_sender="admin@qismo.com",
47
- # last_comment_sender_type="system",
48
- # last_comment_text="Agent joined this conversation",
49
- # last_comment_timestamp="2022-12-09T04:25:55Z",
50
- # last_customer_comment_text=nil,
51
- # last_customer_timestamp="2022-11-28T09:03:08Z",
52
- # name="Customer - Yogyakarta",
53
- # room_badge="https://multichannel.qiscus.com/img/whatsapp_badge.svg",
54
- # room_id="8191816171",
55
- # room_type="individual",
56
- # source="wa",
57
- # user_avatar_url="https://multichannel.qiscus.com/img/default_avatar.svg",
58
- # user_id="628155555711"
59
- # >
29
+ # #<Qismo::Objects::CustomerRoom
30
+ # channel_id=126392
31
+ # contact_id=21608346
32
+ # id=68303333
33
+ # is_handled_by_bot=true
34
+ # is_resolved=false
35
+ # is_waiting=false
36
+ # last_comment_sender="karm-gzu41e4e4dv9fu3f_admin@qismo.com"
37
+ # last_comment_sender_type="system"
38
+ # last_comment_text="bayu joined this conversation"
39
+ # last_comment_timestamp="2022-12-22T06:37:58Z"
40
+ # last_customer_comment_text=nil
41
+ # last_customer_timestamp="2022-12-19T13:32:51Z"
42
+ # name="Oyis"
43
+ # room_badge="https://d1edrlpyc25xu0.cloudfront.net/ods-cc6rmwouax2thbow3/image/upload/5sYxRCGJl_/qiscus_badge.svg"
44
+ # room_id=103513607
45
+ # room_type="individual"
46
+ # source="qiscus"
47
+ # user_avatar_url="https://d1edrlpyc25xu0.cloudfront.net/kiwari-prod/image/upload/wMWsDZP6ta/1516689726-ic_qiscus_client.png"
48
+ # user_id="nurcholisart@gmail.com">
60
49
  # ]
61
50
  ```
62
51
 
63
- ## Multiple app id client initialization
64
-
65
- ```ruby
66
- client = Qismo::Client.new(app_id: "QISCUS_APP_ID", secret_key: "QISCUS_SECRET_KEY")
67
-
68
- params = {
69
- channel: { channel_id: 12345, source: "wa" },
70
- status: "unresolved",
71
- serve_status: "served",
72
- is_handled_by_bot: true,
73
- }
74
-
75
- # This will produce same result as explained before
76
- client.rooms(params)
77
- ```
78
-
79
52
  ## Client optional configuration
80
53
 
81
54
  Qismo ruby also provide some optional configuration that you can pass, they are:
@@ -182,10 +155,10 @@ Qiscus Omnichannel provide webhooks that triggered from various action on your a
182
155
  ```ruby
183
156
  class QiscusWebhooksController < ApplicationController
184
157
  skip_before_action :verify_authenticity_token
185
-
158
+
186
159
  def handle_agent_allocation_webhook
187
160
  webhook = Qismo::WebhookRequests::OnAgentAllocationNeeded.new(JSON.parse(request.raw_body))
188
-
161
+
189
162
  # Do any action you want using payload that has been objectified
190
163
  if webhook.candidate_agent.present?
191
164
  Qismo.assign_agent(
data/lib/qismo/api.rb CHANGED
@@ -21,7 +21,7 @@ module Qismo
21
21
  # Limit the number of rooms returned in one page. By default, it will return 50 rooms data
22
22
  # @param tag_ids [Array<Integer>]
23
23
  # Filter rooms by its tag
24
- # @param agent_ids [Array<Integer>]
24
+ # @param user_ids [Array<Integer>]
25
25
  # Filter rooms by the agent who handled the rooms
26
26
  # @param order [String]
27
27
  # Order returned data by the timestamp. By default, we will return the newest rooms first
@@ -29,8 +29,10 @@ module Qismo
29
29
  # Next page cursor. If you are on last page, the cursor returned will be nil
30
30
  # @param cursor_before [String]
31
31
  # Previous page cursor. If you are on first page, the cursor returned will be nil
32
+ # @param is_handled_by_bot [TrueClass,FalseClass]
33
+ # Filter rooms by chatbot activation status in room
32
34
  # @return [Qismo::Collection<Qismo::CustomerRoom>]
33
- def rooms(channels: nil, status: nil, serve_status: nil, name: nil, limit: 50, tag_ids: nil, agent_ids: nil, order: "desc", cursor_after: nil, cursor_before: nil)
35
+ def rooms(channels: nil, status: nil, serve_status: nil, name: nil, limit: 50, tag_ids: nil, user_ids: nil, order: "desc", cursor_after: nil, cursor_before: nil, is_handled_by_bot: nil)
34
36
  body = post("/api/v2/customer_rooms", {
35
37
  channels: channels,
36
38
  status: status,
@@ -38,11 +40,12 @@ module Qismo
38
40
  name: name,
39
41
  limit: limit,
40
42
  tag_ids: tag_ids,
41
- user_ids: agent_ids,
43
+ user_ids: user_ids,
42
44
  order: order,
43
45
  cursor_after: cursor_after,
44
- cursor_before: cursor_before
45
- }.compact)
46
+ cursor_before: cursor_before,
47
+ is_handled_by_bot: is_handled_by_bot
48
+ })
46
49
 
47
50
  Collection.new(
48
51
  Qismo::Objects::CustomerRoom.from_array(body.data.customer_rooms),
@@ -81,11 +84,12 @@ module Qismo
81
84
  #
82
85
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#9737d580-d156-4213-85a8-95fb3f1ad964
83
86
  # @param room_id [Integer]
84
- # @param tag_name [String]
87
+ # @param tag [String]
88
+ # Tag name
85
89
  # @return [Qismo::Objects::Tag]
86
- def add_room_tag(room_id:, tag_name:)
90
+ def add_room_tag(room_id:, tag:)
87
91
  Qismo::Objects::Tag.new(
88
- post("/api/v2/room_tags/#{room_id}", tag: tag_name).data
92
+ post("/api/v2/room_tags/#{room_id}", tag: tag).data
89
93
  )
90
94
  end
91
95
 
@@ -173,23 +177,23 @@ module Qismo
173
177
  #
174
178
  # @param room_id [Integer]
175
179
  # @param agent_id [Integer]
176
- # @param replace_agents [TrueClass,FalseClass]
180
+ # @param replace_latest_agent [TrueClass,FalseClass]
177
181
  # Replace agents in room or not. Don't combine this param
178
182
  # with :max_agent param
179
183
  # @param max_agent [Integer]
180
184
  # Specify max agent that can be assigned to a room. For
181
185
  # example, if there are 1 agent in a room and you specific
182
186
  # max_agent to 1, you will get bad request error. If you set
183
- # param :relpace_agents to true, this param will be forced
187
+ # param :replace_latest_agent to true, this param will be forced
184
188
  # to nil, which no be sent on http request
185
189
  # @return [Qismo::Objects::User]
186
- def assign_agent(room_id:, agent_id:, replace_agents: false, max_agent: nil)
190
+ def assign_agent(room_id:, agent_id:, replace_latest_agent: false, max_agent: nil)
187
191
  Qismo::Objects::User.new(
188
192
  post("/api/v1/admin/service/assign_agent", {
189
193
  room_id: room_id.to_s,
190
194
  agent_id: agent_id,
191
- replace_latest_agent: replace_agents,
192
- max_agent: (replace_agents == true) ? nil : max_agent
195
+ replace_latest_agent: replace_latest_agent,
196
+ max_agent: (replace_latest_agent == true) ? nil : max_agent
193
197
  }).data.assign_agent
194
198
  )
195
199
  end
@@ -221,19 +225,19 @@ module Qismo
221
225
  # @param notes [String]
222
226
  # Specify room notes. You can also use simple markdown markup
223
227
  # for this param
224
- # @param send_email [TrueClass,FalseClass]
228
+ # @param is_send_email [TrueClass,FalseClass]
225
229
  # Send email to customer or no. This param will only worked if
226
230
  # you are using valid email as customer identifier
227
231
  # @param extras [Hash]
228
232
  # Room extras in valid hash
229
233
  # @return [Qismo::Objects::AgentService]
230
- def resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, send_email: false, extras: nil)
234
+ def resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, is_send_email: false, extras: nil)
231
235
  Qismo::Objects::AgentService.new(
232
236
  post("/api/v1/admin/service/mark_as_resolved", {
233
237
  room_id: room_id.to_s,
234
238
  last_comment_id: last_comment_id,
235
239
  notes: notes,
236
- is_send_email: send_email,
240
+ is_send_email: is_send_email,
237
241
  extras: extras
238
242
  }).data.service
239
243
  )
@@ -310,16 +314,16 @@ module Qismo
310
314
  #
311
315
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#0d5db283-c7f8-42e0-ba02-6cbcbc1d2bb3
312
316
  # @param room_id [Integer]
313
- # @param available_in_room [TrueClass,FalseClass]
317
+ # @param is_available_in_room [TrueClass,FalseClass]
314
318
  # @param search [String]
315
319
  # @param limit [Integer]
316
320
  # @param cursor_after [String]
317
321
  # @param cursor_before [String]
318
322
  # @return [Qismo::Collection<Qismo::Objects::User>]
319
- def available_agents(room_id:, available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
323
+ def available_agents(room_id:, is_available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
320
324
  body = get("/api/v2/admin/service/available_agents", {
321
325
  room_id: room_id.to_s,
322
- is_available_in_room: available_in_room,
326
+ is_available_in_room: is_available_in_room,
323
327
  search: search,
324
328
  limit: limit,
325
329
  cursor_after: cursor_after,
@@ -430,7 +434,7 @@ module Qismo
430
434
  # List agents by ids
431
435
  #
432
436
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3db6c8c8-8ffe-4a88-b630-41f9d5b62298
433
- # @param ids [Array<Integer>]
437
+ # @param agent_ids [Array<Integer>]
434
438
  # @return [Qismo::Collection<Qismo::Objects::User>]
435
439
  def agents_by_ids(agent_ids:)
436
440
  Qismo::Collection.new(
@@ -442,14 +446,21 @@ module Qismo
442
446
  #
443
447
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#94eeb9cb-dd70-4baf-9f63-361e7922299a
444
448
  # @param division_ids [Array<Integer>]
445
- # @param options [Hash]
449
+ # @param page [Integer]
450
+ # Page number
451
+ # @param limit [Integer]
452
+ # Number of data returned in one page
453
+ # @param is_available [TrueClass,FalseClass]
454
+ # Filter only available or unavailable agents
455
+ # @param sort [String]
456
+ # Sort result by descending or ascending
446
457
  # @return [Qismo::Collection<Qismo::Objects::User>]
447
- def agents_by_divisions(division_ids, page: 1, limit: 10, available: nil, sort: "asc")
458
+ def agents_by_divisions(division_ids, page: 1, limit: 10, is_available: nil, sort: "asc")
448
459
  body = get("/api/v2/admin/agents/by_division", {
449
460
  "division_ids[]": division_ids,
450
461
  page: page,
451
462
  limit: limit,
452
- is_available: available,
463
+ is_available: is_available,
453
464
  sort: sort
454
465
  })
455
466
 
@@ -482,7 +493,12 @@ module Qismo
482
493
  # List WA broadcast templates
483
494
  #
484
495
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#e38d2244-9559-4015-99d5-8c707f6c01bd
485
- # @param options [Hash]
496
+ # @param page [Integer]
497
+ # Page number
498
+ # @param limit [Integer]
499
+ # Number of data returned in one page
500
+ # @param approved [TrueClass,FalseClass]
501
+ # Filter template by approval status
486
502
  # @return [Qismo::Collection<Qismo::Objects::HsmTemplate>]
487
503
  def wa_broadcast_templates(page: 1, limit: 10, approved: nil)
488
504
  body = get("/api/v3/admin/hsm", {
@@ -561,6 +577,7 @@ module Qismo
561
577
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#030acde2-21cf-4373-8d11-075206053c1d
562
578
  # @param file [HTTP::FormData]
563
579
  # @param template_detail_id [Integer]
580
+ # @param separator [String]
564
581
  # @return [Integer]
565
582
  def upload_wa_broadcast_csv(file:, template_detail_id:, separator: ",")
566
583
  raise ArgumentError, "Invalid file" unless file.is_a?(HTTP::FormData::File)
data/lib/qismo/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Qismo
4
4
  # @return [String]
5
- VERSION = "0.17.4"
5
+ VERSION = "0.17.5"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qismo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.4
4
+ version: 0.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qiscus Integration