qismo 0.17.4 → 0.17.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -51
- data/lib/qismo/api.rb +41 -24
- data/lib/qismo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a44082e18e6a2a83f52495239286434f94929f70ed04169719d54b31e3d222f
|
4
|
+
data.tar.gz: b4539c710a2172b0bdb7049d140d3cf197aa7e081507d6c1c12422e38eb7c8db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d53cfb2641b87854f7dd6dc5c96b228679e8c5fa96266b90085fb97e1bbe4a794cd12452d9f37123888c3cac07e30fc7915059eb362c269d46ec16468bb5b22f
|
7
|
+
data.tar.gz: 0a4550b86a6dd7e520bae304b3f59042fe3c4dee1b4ce315a25223f3d5f5635c3e55ed06a40ca94ca6f96ec698363611c57c696c11b80315b1c4540c06541f71
|
data/README.md
CHANGED
@@ -13,17 +13,8 @@ bundle add qismo
|
|
13
13
|
## Usage
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
|
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
|
-
|
35
|
-
rooms = Qismo.rooms(params)
|
25
|
+
rooms = client.rooms(params)
|
36
26
|
|
37
27
|
puts rooms
|
38
28
|
# [
|
39
|
-
# #<Qismo::
|
40
|
-
# channel_id=
|
41
|
-
# contact_id=
|
42
|
-
# id=
|
43
|
-
# is_handled_by_bot=true
|
44
|
-
# is_resolved=false
|
45
|
-
# is_waiting=false
|
46
|
-
# last_comment_sender="
|
47
|
-
# last_comment_sender_type="system"
|
48
|
-
# last_comment_text="
|
49
|
-
# last_comment_timestamp="2022-12-
|
50
|
-
# last_customer_comment_text=nil
|
51
|
-
# last_customer_timestamp="2022-
|
52
|
-
# name="
|
53
|
-
# room_badge="https://
|
54
|
-
# room_id=
|
55
|
-
# room_type="individual"
|
56
|
-
# source="
|
57
|
-
# user_avatar_url="https://
|
58
|
-
# user_id="
|
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
|
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,
|
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:
|
43
|
+
user_ids: user_ids,
|
42
44
|
order: order,
|
43
45
|
cursor_after: cursor_after,
|
44
|
-
cursor_before: cursor_before
|
45
|
-
|
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
|
87
|
+
# @param tag [String]
|
88
|
+
# Tag name
|
85
89
|
# @return [Qismo::Objects::Tag]
|
86
|
-
def add_room_tag(room_id:,
|
90
|
+
def add_room_tag(room_id:, tag:)
|
87
91
|
Qismo::Objects::Tag.new(
|
88
|
-
post("/api/v2/room_tags/#{room_id}", tag:
|
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
|
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 :
|
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:,
|
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:
|
192
|
-
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
|
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,
|
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:
|
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
|
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:,
|
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:
|
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
|
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
|
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,
|
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:
|
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
|
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