qismo 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qismo/api.rb +156 -97
- data/lib/qismo/client.rb +24 -12
- data/lib/qismo/model.rb +3 -3
- data/lib/qismo/version.rb +1 -1
- data/lib/qismo.rb +18 -20
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e999cca8b986d2783ea662573e0fab71db0c0bb1e6bf0a1603b4442eea6acc
|
4
|
+
data.tar.gz: fc35ba076ba1c6597e1fb8f13b26c2a4319a92dc8c0a6215529c4f5aff2b9a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d45397820b9bdf5214ff8e45d164f2253824d20c4e8d2017d3c4cec9993c1e550e51754f4743be566b5296edb90d6eb7b1c6b82f098f25ce67b74db87422ee31
|
7
|
+
data.tar.gz: 40b3d89d5d06bce5e7460d7d36b3c0010da9fd583f0e7d66574a052be6b61bfda33688751380b32c1b6e436553f79f0661a739941e742aaf876800707fbb19cf
|
data/lib/qismo/api.rb
CHANGED
@@ -2,23 +2,27 @@
|
|
2
2
|
|
3
3
|
module Qismo
|
4
4
|
module Api
|
5
|
+
# @!parse include Qismo::Client
|
6
|
+
|
5
7
|
# List customer rooms
|
6
8
|
#
|
7
|
-
# @
|
9
|
+
# @see https://s.id/list-customer-rooms
|
10
|
+
# @param options [Hash]
|
8
11
|
# @return [Qismo::CollectionObject]
|
9
|
-
def rooms(
|
10
|
-
body = post("/api/v2/customer_rooms",
|
12
|
+
def rooms(options = {})
|
13
|
+
body = post("/api/v2/customer_rooms", options)
|
11
14
|
CollectionObject.new(
|
12
15
|
body.data.customer_rooms,
|
13
16
|
prev_page: body.meta&.cursor_before,
|
14
17
|
next_page: body.meta&.cursor_after,
|
15
|
-
prev_func: -> { rooms(
|
16
|
-
next_func: -> { rooms(
|
18
|
+
prev_func: -> { rooms(options.merge(cursor_before: body.meta&.cursor_before)) },
|
19
|
+
next_func: -> { rooms(options.merge(cursor_after: body.meta&.cursor_after)) },
|
17
20
|
)
|
18
21
|
end
|
19
22
|
|
20
23
|
# Get room by id
|
21
24
|
#
|
25
|
+
# @see https://s.id/get-room-by-room-id
|
22
26
|
# @param room_id [Integer]
|
23
27
|
# @return [Qismo::SingleObject]
|
24
28
|
def room(room_id)
|
@@ -32,6 +36,7 @@ module Qismo
|
|
32
36
|
|
33
37
|
# List tags inside room
|
34
38
|
#
|
39
|
+
# @see https://s.id/list-room-tags
|
35
40
|
# @param room_id [Integer]
|
36
41
|
# @return [Qismo::CollectionObject]
|
37
42
|
def room_tags(room_id)
|
@@ -40,6 +45,7 @@ module Qismo
|
|
40
45
|
|
41
46
|
# Add room tag
|
42
47
|
#
|
48
|
+
# @see https://s.id/add-room-tag
|
43
49
|
# @param room_id [Integer]
|
44
50
|
# @param tag_name [String]
|
45
51
|
# @return [Qismo::SingleObject]
|
@@ -49,6 +55,7 @@ module Qismo
|
|
49
55
|
|
50
56
|
# Delete room tag
|
51
57
|
#
|
58
|
+
# @see https://s.id/delete-room-tag
|
52
59
|
# @param room_id [Integer]
|
53
60
|
# @param tag_id [Integer]
|
54
61
|
# @return [TrueClass]
|
@@ -59,6 +66,7 @@ module Qismo
|
|
59
66
|
|
60
67
|
# List room additional info
|
61
68
|
#
|
69
|
+
# @see https://s.id/list-room-info
|
62
70
|
# @param room_id [Integer]
|
63
71
|
# @return [Qismo::CollectionObject]
|
64
72
|
def room_additional_info(room_id)
|
@@ -69,8 +77,11 @@ module Qismo
|
|
69
77
|
) || CollectionObject.new
|
70
78
|
end
|
71
79
|
|
80
|
+
alias_method :room_info, :room_additional_info
|
81
|
+
|
72
82
|
# Set room additional info
|
73
83
|
#
|
84
|
+
# @see https://s.id/set-room-info
|
74
85
|
# @note This will replace your current room additional info
|
75
86
|
# @param room_id [Integer]
|
76
87
|
# @param additional_info [Array<Hash>]
|
@@ -84,6 +95,10 @@ module Qismo
|
|
84
95
|
) || CollectionObject.new
|
85
96
|
end
|
86
97
|
|
98
|
+
alias_method :set_room_info, :set_room_additional_info
|
99
|
+
alias_method :create_room_info, :set_room_additional_info
|
100
|
+
alias_method :create_room_additional_info, :set_room_additional_info
|
101
|
+
|
87
102
|
# Update room additional info
|
88
103
|
#
|
89
104
|
# @param room_id [Integer]
|
@@ -95,13 +110,16 @@ module Qismo
|
|
95
110
|
set_room_additional_info(room_id, new_additional_info)
|
96
111
|
end
|
97
112
|
|
113
|
+
alias_method :update_room_info, :update_room_additional_info
|
114
|
+
|
98
115
|
# List Whatsapp broadcast history inside room
|
99
116
|
#
|
117
|
+
# @see https://s.id/list-room-broadcast-history
|
100
118
|
# @param room_id [Integer]
|
101
|
-
# @param
|
119
|
+
# @param options [Hash]
|
102
120
|
# @return [Qismo::CollectionObject]
|
103
|
-
def room_broadcast_history(room_id,
|
104
|
-
body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history",
|
121
|
+
def room_broadcast_history(room_id, options = {})
|
122
|
+
body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history", options)
|
105
123
|
|
106
124
|
next_page = body.meta.page < body.meta.total_page ? (body.meta.page + 1) : nil
|
107
125
|
prev_page = body.meta.page > 1 ? (body.meta.page - 1) : nil
|
@@ -110,24 +128,26 @@ module Qismo
|
|
110
128
|
body.data.broadcast_logs,
|
111
129
|
next_page: next_page,
|
112
130
|
prev_page: prev_page,
|
113
|
-
next_func: -> { room_broadcast_history(
|
114
|
-
prev_func: -> { room_broadcast_history(
|
131
|
+
next_func: -> { room_broadcast_history(options.merge(page: next_page)) },
|
132
|
+
prev_func: -> { room_broadcast_history(options.merge(page: prev_page)) },
|
115
133
|
)
|
116
134
|
end
|
117
135
|
|
118
136
|
# Assign agent to room
|
119
137
|
#
|
138
|
+
# @see https://s.id/assign-agent
|
120
139
|
# @param room_id [Integer]
|
121
140
|
# @param agent_id [Integer]
|
122
|
-
# @param
|
141
|
+
# @param options [Hash]
|
123
142
|
# @return [Qismo::SingleObject]
|
124
|
-
def assign_agent(room_id, agent_id,
|
125
|
-
body = post("/api/v1/admin/service/assign_agent",
|
143
|
+
def assign_agent(room_id, agent_id, options = {})
|
144
|
+
body = post("/api/v1/admin/service/assign_agent", options.merge(room_id: room_id.to_s, agent_id: agent_id))
|
126
145
|
body.data.added_agent
|
127
146
|
end
|
128
147
|
|
129
148
|
# Remove agent from room
|
130
149
|
#
|
150
|
+
# @see https://s.id/remove-agent
|
131
151
|
# @param room_id [Integer]
|
132
152
|
# @param agent_id [Integer]
|
133
153
|
# @return [TrueClass]
|
@@ -138,13 +158,14 @@ module Qismo
|
|
138
158
|
|
139
159
|
# Resolve room
|
140
160
|
#
|
161
|
+
# @see https://s.id/resolve-room
|
141
162
|
# @param room_id [Integer]
|
142
163
|
# @param last_comment_id [Integer]
|
143
|
-
# @param
|
164
|
+
# @param options [Hash]
|
144
165
|
# @return [Qismo::SingleObject]
|
145
|
-
def resolve_room(room_id, last_comment_id,
|
166
|
+
def resolve_room(room_id, last_comment_id, options = {})
|
146
167
|
body = post("/api/v1/admin/service/mark_as_resolved",
|
147
|
-
|
168
|
+
options.merge(room_id: room_id.to_s, last_comment_id: last_comment_id))
|
148
169
|
body.data.service
|
149
170
|
end
|
150
171
|
|
@@ -152,53 +173,57 @@ module Qismo
|
|
152
173
|
|
153
174
|
# Get agent that can be assigned to room
|
154
175
|
#
|
176
|
+
# @see https://s.id/allocate-agent
|
155
177
|
# @param source [String]
|
156
|
-
# @param
|
178
|
+
# @param options [Hash]
|
157
179
|
# @return [Qismo::SingleObject]
|
158
|
-
def allocate_agent(source,
|
159
|
-
body = post("/api/v1/admin/service/allocate_agent",
|
180
|
+
def allocate_agent(source, options = {})
|
181
|
+
body = post("/api/v1/admin/service/allocate_agent", options.merge(source: source))
|
160
182
|
body.data.agent
|
161
183
|
end
|
162
184
|
|
163
185
|
# Get agent that can be allocated to room and automatically assign them
|
164
186
|
#
|
187
|
+
# @see https://s.id/allocate-and-assign-agent
|
165
188
|
# @param room_id [Integer]
|
166
|
-
# @param
|
189
|
+
# @param options [Hash]
|
167
190
|
# @return [Qismo::SingleObject]
|
168
|
-
def allocate_and_assign_agent(room_id,
|
169
|
-
body = post("/api/v1/admin/service/allocate_assign_agent",
|
191
|
+
def allocate_and_assign_agent(room_id, options = {})
|
192
|
+
body = post("/api/v1/admin/service/allocate_assign_agent", options.merge(room_id: room_id))
|
170
193
|
body.data.agent
|
171
194
|
end
|
172
195
|
|
173
196
|
# List agents that are not in room and can be assigned to room
|
174
197
|
#
|
198
|
+
# @see https://s.id/list-other-agents
|
175
199
|
# @param room_id [Integer]
|
176
|
-
# @param
|
200
|
+
# @param options [Hash]
|
177
201
|
# @return [Qismo::CollectionObject]
|
178
|
-
def other_agents(room_id,
|
179
|
-
body = get("/api/v2/admin/service/other_agents",
|
202
|
+
def other_agents(room_id, options = {})
|
203
|
+
body = get("/api/v2/admin/service/other_agents", options.merge(room_id: room_id))
|
180
204
|
CollectionObject.new(
|
181
205
|
body.data.agents,
|
182
206
|
prev_page: body.meta&.cursor_before,
|
183
207
|
next_page: body.meta&.cursor_after,
|
184
|
-
prev_func: -> { other_agents(
|
185
|
-
next_func: -> { other_agents(
|
208
|
+
prev_func: -> { other_agents(options.merge(cursor_before: body.meta&.cursor_before)) },
|
209
|
+
next_func: -> { other_agents(options.merge(cursor_after: body.meta&.cursor_after)) },
|
186
210
|
)
|
187
211
|
end
|
188
212
|
|
189
213
|
# List available agents in room
|
190
214
|
#
|
215
|
+
# @see https://s.id/list-available-agents
|
191
216
|
# @param room_id [Integer]
|
192
|
-
# @param
|
217
|
+
# @param options [Hash]
|
193
218
|
# @return [Qismo::CollectionObject]
|
194
|
-
def available_agents(room_id,
|
195
|
-
body = get("/api/v2/admin/service/available_agents",
|
219
|
+
def available_agents(room_id, options = {})
|
220
|
+
body = get("/api/v2/admin/service/available_agents", options.merge(room_id: room_id))
|
196
221
|
CollectionObject.new(
|
197
222
|
body.data.agents,
|
198
223
|
prev_page: body.meta&.cursor_before,
|
199
224
|
next_page: body.meta&.cursor_after,
|
200
|
-
prev_func: -> { available_agents(
|
201
|
-
next_func: -> { available_agents(
|
225
|
+
prev_func: -> { available_agents(options.merge(cursor_before: body.meta&.cursor_before)) },
|
226
|
+
next_func: -> { available_agents(options.merge(cursor_after: body.meta&.cursor_after)) },
|
202
227
|
)
|
203
228
|
end
|
204
229
|
|
@@ -212,10 +237,10 @@ module Qismo
|
|
212
237
|
# Set new session webhook
|
213
238
|
#
|
214
239
|
# @param url [String]
|
215
|
-
# @param
|
240
|
+
# @param options [Hash]
|
216
241
|
# @return [Qismo::SingleObject]
|
217
|
-
def set_new_session_webhook(url,
|
218
|
-
post("/api/v2/app/config/new_session_webhook",
|
242
|
+
def set_new_session_webhook(url, options = {})
|
243
|
+
post("/api/v2/app/config/new_session_webhook", options.merge(url: url)).data.configs
|
219
244
|
end
|
220
245
|
|
221
246
|
# Get auth webhook config
|
@@ -228,10 +253,10 @@ module Qismo
|
|
228
253
|
# Set auth webhook
|
229
254
|
#
|
230
255
|
# @param url [String]
|
231
|
-
# @param
|
256
|
+
# @param options [Hash]
|
232
257
|
# @return [Qismo::SingleObject]
|
233
|
-
def set_auth_webhook(url,
|
234
|
-
post("/api/v2/app/config/auth_webhook",
|
258
|
+
def set_auth_webhook(url, options = {})
|
259
|
+
post("/api/v2/app/config/auth_webhook", options.merge(url: url)).data.configs
|
235
260
|
end
|
236
261
|
|
237
262
|
# Get resolve webhook config
|
@@ -244,38 +269,40 @@ module Qismo
|
|
244
269
|
# Set resolve webhook
|
245
270
|
#
|
246
271
|
# @param url [String]
|
247
|
-
# @param
|
272
|
+
# @param options [Hash]
|
248
273
|
# @return [Qismo::SingleObject]
|
249
|
-
def set_resolve_webhook(url,
|
250
|
-
post("/api/v1/app/webhook/mark_as_resolved",
|
274
|
+
def set_resolve_webhook(url, options = {})
|
275
|
+
post("/api/v1/app/webhook/mark_as_resolved", options.merge(url: url)).data
|
251
276
|
end
|
252
277
|
|
253
278
|
# List agents
|
254
279
|
#
|
255
|
-
# @
|
280
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#849205ca-00d9-4356-9fdd-f05bff777b4e
|
281
|
+
# @param options [Hash]
|
256
282
|
# @return [Qismo::CollectionObject]
|
257
|
-
def agents(
|
258
|
-
if
|
259
|
-
|
283
|
+
def agents(options = {})
|
284
|
+
if options[:page].nil? || options[:page].empty?
|
285
|
+
options[:page] = 1
|
260
286
|
end
|
261
287
|
|
262
|
-
body = get("/api/v2/admin/agents",
|
288
|
+
body = get("/api/v2/admin/agents", options)
|
263
289
|
|
264
290
|
total_page = (body.meta.total_count.to_f / body.meta.per_page.to_f).ceil
|
265
|
-
next_page =
|
266
|
-
prev_page =
|
291
|
+
next_page = options[:page] < total_page ? (options[:page] + 1) : nil
|
292
|
+
prev_page = options[:page] > 1 ? (options[:page] - 1) : nil
|
267
293
|
|
268
294
|
CollectionObject.new(
|
269
295
|
body.data.agents,
|
270
296
|
next_page: next_page,
|
271
297
|
prev_page: prev_page,
|
272
|
-
next_func: -> { agents(
|
273
|
-
prev_func: -> { agents(
|
298
|
+
next_func: -> { agents(options.merge(page: next_page)) },
|
299
|
+
prev_func: -> { agents(options.merge(page: prev_page)) },
|
274
300
|
)
|
275
301
|
end
|
276
302
|
|
277
303
|
# List agents by id
|
278
304
|
#
|
305
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3db6c8c8-8ffe-4a88-b630-41f9d5b62298
|
279
306
|
# @param ids [Array<Integer>]
|
280
307
|
# @return [Qismo::CollectionObject]
|
281
308
|
def agents_by_ids(ids)
|
@@ -284,11 +311,12 @@ module Qismo
|
|
284
311
|
|
285
312
|
# List agents by divisions
|
286
313
|
#
|
314
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#94eeb9cb-dd70-4baf-9f63-361e7922299a
|
287
315
|
# @param division_ids [Array<Integer>]
|
288
|
-
# @param
|
316
|
+
# @param options [Hash]
|
289
317
|
# @return [Qismo::CollectionObject]
|
290
|
-
def agents_by_divisions(division_ids,
|
291
|
-
body = get("/api/v2/admin/agents/by_division",
|
318
|
+
def agents_by_divisions(division_ids, options = {})
|
319
|
+
body = get("/api/v2/admin/agents/by_division", options.merge({ "division_ids[]": division_ids }))
|
292
320
|
|
293
321
|
next_page = body.meta.page < body.meta.total_page ? (body.meta.page + 1) : nil
|
294
322
|
prev_page = body.meta.page > 1 ? (body.meta.page - 1) : nil
|
@@ -297,13 +325,14 @@ module Qismo
|
|
297
325
|
body.data,
|
298
326
|
next_page: next_page,
|
299
327
|
prev_page: prev_page,
|
300
|
-
next_func: -> { agents_by_divisions(
|
301
|
-
prev_func: -> { agents_by_divisions(
|
328
|
+
next_func: -> { agents_by_divisions(options.merge(page: next_page)) },
|
329
|
+
prev_func: -> { agents_by_divisions(options.merge(page: prev_page)) },
|
302
330
|
)
|
303
331
|
end
|
304
332
|
|
305
333
|
# Get agent by id
|
306
334
|
#
|
335
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#c6184a6b-ba4d-4f3e-a4da-c6d0fa4597af
|
307
336
|
# @param agent_id [Integer]
|
308
337
|
# @return [Qismo::SingleObject]
|
309
338
|
def agent(agent_id)
|
@@ -312,6 +341,7 @@ module Qismo
|
|
312
341
|
|
313
342
|
# Get office hour config
|
314
343
|
#
|
344
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#6f3f0cb0-a391-4945-b01a-95ce81138913
|
315
345
|
# @return [Qismo::SingleObject]
|
316
346
|
def office_hours
|
317
347
|
data = get("/api/v1/admin/office_hours").data
|
@@ -323,10 +353,11 @@ module Qismo
|
|
323
353
|
|
324
354
|
# List WA broadcast templates
|
325
355
|
#
|
326
|
-
# @
|
356
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#e38d2244-9559-4015-99d5-8c707f6c01bd
|
357
|
+
# @param options [Hash]
|
327
358
|
# @return [Qismo::CollectionObject]
|
328
|
-
def wa_broadcast_templates(
|
329
|
-
body = get("/api/v3/admin/hsm",
|
359
|
+
def wa_broadcast_templates(options = {})
|
360
|
+
body = get("/api/v3/admin/hsm", options)
|
330
361
|
|
331
362
|
meta = body.meta
|
332
363
|
next_page = meta.page < meta.total_page ? (meta.page + 1) : nil
|
@@ -336,21 +367,26 @@ module Qismo
|
|
336
367
|
body.data.hsm_templates,
|
337
368
|
next_page: next_page,
|
338
369
|
prev_page: prev_page,
|
339
|
-
next_func: -> { wa_broadcast_templates(
|
340
|
-
prev_func: -> { wa_broadcast_templates(
|
370
|
+
next_func: -> { wa_broadcast_templates(options.merge(page: next_page)) },
|
371
|
+
prev_func: -> { wa_broadcast_templates(options.merge(page: prev_page)) },
|
341
372
|
)
|
342
373
|
end
|
343
374
|
|
375
|
+
alias_method :wa_message_templates, :wa_broadcast_templates
|
376
|
+
alias_method :wa_outbound_templates, :wa_broadcast_templates
|
377
|
+
|
344
378
|
# Send WA outbound message
|
345
379
|
#
|
346
|
-
# @
|
380
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#d0183cf6-deca-439b-aff3-2e2f007c15a9
|
381
|
+
# @param options [Hash]
|
347
382
|
# @return [Qismo::SingleObject]
|
348
|
-
def send_wa_outbound(
|
349
|
-
post("/api/v3/admin/broadcast/client",
|
383
|
+
def send_wa_outbound(options = {})
|
384
|
+
post("/api/v3/admin/broadcast/client", options).data
|
350
385
|
end
|
351
386
|
|
352
387
|
# Upload wa broadcast file that want to be sent in broadcast
|
353
388
|
#
|
389
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#030acde2-21cf-4373-8d11-075206053c1d
|
354
390
|
# @param file [HTTP::FormData]
|
355
391
|
# @param template_detail_id [Integer]
|
356
392
|
# @return [Qismo::SingleObject]
|
@@ -362,18 +398,22 @@ module Qismo
|
|
362
398
|
|
363
399
|
# Send wa broadcast
|
364
400
|
#
|
365
|
-
# @
|
401
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#717c1a12-facb-4945-aed5-04557696b873
|
402
|
+
# @param options [Hash]
|
366
403
|
# @return [Qismo::SingleObject]
|
367
|
-
def send_wa_broadcast(
|
368
|
-
post("/api/v3/admin/broadcast/send_broadcast",
|
404
|
+
def send_wa_broadcast(options = {})
|
405
|
+
post("/api/v3/admin/broadcast/send_broadcast", options).data.broadcast_job
|
369
406
|
end
|
370
407
|
|
408
|
+
alias_method :create_wa_broadcast, :send_wa_broadcast
|
409
|
+
|
371
410
|
# List wa broadcast jobs
|
372
411
|
#
|
373
|
-
# @
|
412
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3a4caa8b-eef4-427f-adcb-d065989899c9
|
413
|
+
# @param options [Hash]
|
374
414
|
# @return [Qismo::CollectionObject]
|
375
|
-
def wa_broadcast_jobs(
|
376
|
-
body = get("/api/v2/admin/broadcast_jobs",
|
415
|
+
def wa_broadcast_jobs(options = {})
|
416
|
+
body = get("/api/v2/admin/broadcast_jobs", options)
|
377
417
|
|
378
418
|
prev_page = body.meta.page > 1 ? (body.meta.meta - 1) : nil
|
379
419
|
next_page = body.meta.page < body.meta.total_page ? (body.meta.page + 1) : nil
|
@@ -382,13 +422,14 @@ module Qismo
|
|
382
422
|
body.data.broadcast_jobs,
|
383
423
|
next_page: next_page,
|
384
424
|
prev_page: prev_page,
|
385
|
-
next_func: -> { wa_broadcast_jobs(
|
386
|
-
prev_func: -> { wa_broadcast_jobs(
|
425
|
+
next_func: -> { wa_broadcast_jobs(options.merge(page: next_page)) },
|
426
|
+
prev_func: -> { wa_broadcast_jobs(options.merge(page: prev_page)) },
|
387
427
|
)
|
388
428
|
end
|
389
429
|
|
390
430
|
# Get wa broadcast job by id
|
391
431
|
#
|
432
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#ed0806c8-2e4a-4ea4-8acb-45c84c63c2da
|
392
433
|
# @param broadcast_job_id [Integer]
|
393
434
|
# @return [Qismo::SingleObject]
|
394
435
|
def wa_broadcast_job(broadcast_job_id)
|
@@ -397,11 +438,12 @@ module Qismo
|
|
397
438
|
|
398
439
|
# List wa broadcast logs
|
399
440
|
#
|
441
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3f2d8ba8-ab14-43b2-af82-74c8b766216f
|
400
442
|
# @param broadcast_job_id [Integer]
|
401
|
-
# @param
|
443
|
+
# @param options [Hash]
|
402
444
|
# @return [Qismo::CollectionObject]
|
403
|
-
def wa_broadcast_logs(broadcast_job_id,
|
404
|
-
body = get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}",
|
445
|
+
def wa_broadcast_logs(broadcast_job_id, options = {})
|
446
|
+
body = get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}", options)
|
405
447
|
|
406
448
|
prev_page = body.meta.page > 1 ? (body.meta.meta - 1) : nil
|
407
449
|
next_page = body.meta.page < body.meta.total_page ? (body.meta.page + 1) : nil
|
@@ -410,22 +452,24 @@ module Qismo
|
|
410
452
|
body.data.broadcast_logs,
|
411
453
|
next_page: next_page,
|
412
454
|
prev_page: prev_page,
|
413
|
-
next_func: -> { wa_broadcast_logs(
|
414
|
-
prev_func: -> { wa_broadcast_jobs(
|
455
|
+
next_func: -> { wa_broadcast_logs(options.merge(page: next_page)) },
|
456
|
+
prev_func: -> { wa_broadcast_jobs(options.merge(page: prev_page)) },
|
415
457
|
)
|
416
458
|
end
|
417
459
|
|
418
460
|
# Send message as bot
|
419
461
|
#
|
420
|
-
# @
|
462
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#bb77c653-5daa-4e1c-a866-43bca7c494fc
|
463
|
+
# @param options [Hash]
|
421
464
|
# @return [TrueClass]
|
422
|
-
def send_bot_message(
|
423
|
-
post("#{app_id}/bot",
|
465
|
+
def send_bot_message(options = {})
|
466
|
+
post("#{app_id}/bot", options)
|
424
467
|
true
|
425
468
|
end
|
426
469
|
|
427
470
|
# Enable chabot in room
|
428
471
|
#
|
472
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#494d825f-a49c-4b18-954e-eaaccb738bcd
|
429
473
|
# @param room_id [Integer]
|
430
474
|
# @return [TrueClass]
|
431
475
|
def enable_bot_in_room(room_id)
|
@@ -435,6 +479,7 @@ module Qismo
|
|
435
479
|
|
436
480
|
# Disable chatbot in room
|
437
481
|
#
|
482
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#494d825f-a49c-4b18-954e-eaaccb738bcd
|
438
483
|
# @param room_id [Integer]
|
439
484
|
# @return [TrueClass]
|
440
485
|
def disable_bot_in_room(room_id)
|
@@ -444,6 +489,7 @@ module Qismo
|
|
444
489
|
|
445
490
|
# Handover room from chatbot to human agent
|
446
491
|
#
|
492
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#40867e85-7412-4e0d-84bd-e2506df23df8
|
447
493
|
# @param room_id [Integer]
|
448
494
|
# @return [TrueClass]
|
449
495
|
def handover_room_from_bot(room_id)
|
@@ -453,38 +499,47 @@ module Qismo
|
|
453
499
|
|
454
500
|
# Handover room from chatbot to human agent in specific divisions
|
455
501
|
#
|
502
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#8218db08-9753-4d74-ae5f-0ee62f8579b9
|
456
503
|
# @param room_id [Integer]
|
457
504
|
# @param roles [Array<Integer>]
|
458
|
-
# @param
|
505
|
+
# @param options [Hash]
|
459
506
|
# @return [TrueClass]
|
460
|
-
def handover_room_from_bot_to_division(room_id, roles,
|
461
|
-
post("/#{app_id}/bot/#{room_id}/hand_over_to_role",
|
507
|
+
def handover_room_from_bot_to_division(room_id, roles, options = {})
|
508
|
+
post("/#{app_id}/bot/#{room_id}/hand_over_to_role", options.merge(roles: roles))
|
462
509
|
true
|
463
510
|
end
|
464
511
|
|
465
512
|
# Initiate chat using Qiscus widget channel
|
466
513
|
#
|
514
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#d5a555de-59e0-4705-9582-c216d79e9390
|
467
515
|
# @param user_id [String]
|
468
516
|
# @param name [String]
|
469
|
-
# @param
|
517
|
+
# @param options [Hash]
|
470
518
|
# @return [Qismo::SingleObject]
|
471
|
-
def initiate_widget_chat(user_id, name,
|
472
|
-
|
473
|
-
post("/api/v2/qiscus/initiate_chat",
|
519
|
+
def initiate_widget_chat(user_id, name, options = {})
|
520
|
+
options = options.merge(app_id: app_id, user_id: user_id, name: name)
|
521
|
+
post("/api/v2/qiscus/initiate_chat", options).data.customer_room
|
474
522
|
end
|
475
523
|
|
524
|
+
alias_method :initiate_chat, :initiate_widget_chat
|
525
|
+
|
476
526
|
# Send message to custom channel
|
477
527
|
#
|
528
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#aee54b21-68f1-4d31-9d81-d3c73b3e125b
|
478
529
|
# @param identifier_key [String]
|
479
530
|
# @param user_id [String]
|
480
531
|
# @param name [String]
|
481
|
-
# @param
|
532
|
+
# @param options [Hash]
|
482
533
|
# @return [Qismo::SingleObject]
|
483
|
-
def send_message_to_custom_channel(identifier_key, user_id, name,
|
534
|
+
def send_message_to_custom_channel(identifier_key, user_id, name, options = {})
|
484
535
|
post("/#{app_id}/api/v2/custom_channel/send",
|
485
|
-
|
536
|
+
options.merge(identifier_key: identifier_key, user_id: user_id, name: name)).data
|
486
537
|
end
|
487
538
|
|
539
|
+
# List integrated channels
|
540
|
+
#
|
541
|
+
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#aee54b21-68f1-4d31-9d81-d3c73b3e125b
|
542
|
+
# @return [Qismo::SingleObject]
|
488
543
|
def channels
|
489
544
|
get("/api/v2/channels").data
|
490
545
|
end
|
@@ -494,33 +549,33 @@ module Qismo
|
|
494
549
|
# @param identifier_key [String]
|
495
550
|
# @param name [String]
|
496
551
|
# @param webhook_url [String]
|
497
|
-
# @param
|
552
|
+
# @param options [Hash]
|
498
553
|
# @return [Qismo::SingleObject]
|
499
|
-
def create_custom_channel(identifier_key, name, webhook_url,
|
500
|
-
|
554
|
+
def create_custom_channel(identifier_key, name, webhook_url, options = {})
|
555
|
+
options = options.merge(
|
501
556
|
identifier_key: identifier_key,
|
502
557
|
name: name,
|
503
558
|
webhook_url: webhook_url,
|
504
559
|
)
|
505
560
|
|
506
|
-
|
561
|
+
options[:is_active] = true unless options[:is_active].nil?
|
507
562
|
|
508
|
-
post("/api/v1/custom_channel/connect",
|
563
|
+
post("/api/v1/custom_channel/connect", options.merge).data
|
509
564
|
end
|
510
565
|
|
511
566
|
# Update custom channel
|
512
567
|
#
|
513
568
|
# @param id [Integer]
|
514
|
-
# @param
|
569
|
+
# @param options [Hash]
|
515
570
|
# @return [Qismo::SingleObject]
|
516
|
-
def update_custom_channel(id,
|
571
|
+
def update_custom_channel(id, options = {})
|
517
572
|
channel = channels.custom_channels.find { |cc| cc.id == id }
|
518
573
|
if channel.nil?
|
519
574
|
raise Qismo::NotFoundError.new("Channel not found", status_code: 404, response_body: nil)
|
520
575
|
end
|
521
576
|
|
522
577
|
channel_hash = JSON.parse(channel.to_json, symbolize_names: true)
|
523
|
-
new_channel_config = channel_hash.merge(
|
578
|
+
new_channel_config = channel_hash.merge(options)
|
524
579
|
|
525
580
|
post("/api/v1/custom_channel/connect/update", new_channel_config).data
|
526
581
|
end
|
@@ -541,6 +596,10 @@ module Qismo
|
|
541
596
|
update_custom_channel(id, is_active: false)
|
542
597
|
end
|
543
598
|
|
599
|
+
# Delete custom channel
|
600
|
+
#
|
601
|
+
# @param id [Integer]
|
602
|
+
# @return [TrueClass]
|
544
603
|
def delete_custom_channel(id)
|
545
604
|
post("/api/v2/custom_channel/connect/#{id}/delete")
|
546
605
|
true
|
data/lib/qismo/client.rb
CHANGED
@@ -28,9 +28,9 @@ module Qismo
|
|
28
28
|
|
29
29
|
# Initialize client
|
30
30
|
#
|
31
|
-
# @param
|
32
|
-
def initialize(
|
33
|
-
DEFAULT_OPTIONS.merge(
|
31
|
+
# @param options [Hash]
|
32
|
+
def initialize(options = {})
|
33
|
+
DEFAULT_OPTIONS.merge(options).each do |key, value|
|
34
34
|
instance_variable_set("@#{key}", value)
|
35
35
|
end
|
36
36
|
end
|
@@ -44,7 +44,7 @@ module Qismo
|
|
44
44
|
request(:post, path, json: body)
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
47
|
+
# Send HTTP request with post method to upload file
|
48
48
|
#
|
49
49
|
# @param path [String]
|
50
50
|
# @param body [Hash]
|
@@ -53,27 +53,39 @@ module Qismo
|
|
53
53
|
request(:post, form: body)
|
54
54
|
end
|
55
55
|
|
56
|
-
# Send
|
56
|
+
# Send HTTP request with get method
|
57
57
|
#
|
58
58
|
# @param path [String]
|
59
59
|
# @param params [Hash]
|
60
60
|
# @return [Qismo::SingleObject]
|
61
|
-
def get(path,
|
61
|
+
def get(path, params = {})
|
62
62
|
request(:get, path, params: params)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
# Send HTTP request with delete method
|
66
|
+
#
|
67
|
+
# @param path [String]
|
68
|
+
# @param params [Hash]
|
69
|
+
# @return [Qismo::SingleObject]
|
70
|
+
def delete(path, params = {})
|
71
|
+
request(:delete, path, params: params)
|
67
72
|
end
|
68
73
|
|
69
|
-
# Send
|
74
|
+
# Send HTTP request
|
70
75
|
#
|
71
76
|
# @param method [Symbol, String]
|
72
77
|
# @param path [String]
|
73
|
-
# @param
|
78
|
+
# @param headers [Hash]
|
79
|
+
# @param params [Hash]
|
80
|
+
# @param json [Hash]
|
74
81
|
# @return [Qismo::SingleObject]
|
75
|
-
def request(method, path,
|
76
|
-
res = connection.request(method, @url + path,
|
82
|
+
def request(method, path, headers: {}, params: {}, json: {})
|
83
|
+
res = connection.request(method, @url + path, {
|
84
|
+
headers: headers,
|
85
|
+
params: params,
|
86
|
+
json: json,
|
87
|
+
})
|
88
|
+
|
77
89
|
if res.status.success?
|
78
90
|
return SingleObject.new(JSON.parse(res.to_s))
|
79
91
|
end
|
data/lib/qismo/model.rb
CHANGED
@@ -6,9 +6,9 @@ module Qismo
|
|
6
6
|
class SingleObject
|
7
7
|
# Initiate data object
|
8
8
|
#
|
9
|
-
# @param
|
10
|
-
def initialize(
|
11
|
-
|
9
|
+
# @param options [Hash]
|
10
|
+
def initialize(options = {})
|
11
|
+
options.each do |key, value|
|
12
12
|
value = if value.is_a?(Array)
|
13
13
|
CollectionObject.new(handle_array(value))
|
14
14
|
elsif value.is_a?(Hash)
|
data/lib/qismo/version.rb
CHANGED
data/lib/qismo.rb
CHANGED
@@ -11,7 +11,8 @@ require "qismo/api"
|
|
11
11
|
require "qismo/client"
|
12
12
|
|
13
13
|
module Qismo
|
14
|
-
# @!
|
14
|
+
# @!parse extend Qismo::Api
|
15
|
+
|
15
16
|
class << self
|
16
17
|
def configure
|
17
18
|
yield client
|
@@ -21,34 +22,31 @@ module Qismo
|
|
21
22
|
|
22
23
|
# Initiate Qismo ruby client
|
23
24
|
#
|
24
|
-
# @param
|
25
|
+
# @param options [Hash]
|
25
26
|
# @return [Qismo::Client]
|
26
|
-
def new(
|
27
|
-
@client = Client.new(
|
27
|
+
def new(options = {})
|
28
|
+
@client = Client.new(options)
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
# @return [Qismo::Client]
|
32
|
+
def client
|
33
|
+
@client ||= Client.new
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
end
|
36
|
-
else
|
37
|
-
def method_missing(method, *args, &block)
|
38
|
-
return super unless client.respond_to?(method)
|
36
|
+
private
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
38
|
+
def method_missing(method, *args, &block)
|
39
|
+
return super unless client.respond_to?(method)
|
43
40
|
|
44
|
-
|
45
|
-
Qismo::Client.instance_methods.include?(method_name)
|
41
|
+
client.send(method * args, &block)
|
46
42
|
end
|
47
43
|
|
48
|
-
|
44
|
+
def respond_to?(method_name, include_private = false)
|
45
|
+
client.respond_to?(method_name, include_private) || super(method_name, include_private)
|
46
|
+
end
|
49
47
|
|
50
|
-
def
|
51
|
-
|
48
|
+
def respond_to_missing?(method_name, include_private = false)
|
49
|
+
client.respond_to?(method_name, include_private) || super(method_name, include_private)
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qismo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qiscus Integration
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -129,12 +129,14 @@ files:
|
|
129
129
|
- lib/qismo/model.rb
|
130
130
|
- lib/qismo/util.rb
|
131
131
|
- lib/qismo/version.rb
|
132
|
-
homepage: https://qiscus
|
132
|
+
homepage: https://bitbucket.org/qiscus/qismo-rb
|
133
133
|
licenses:
|
134
134
|
- MIT
|
135
135
|
metadata:
|
136
136
|
allowed_push_host: https://rubygems.org
|
137
137
|
source_code_uri: https://bitbucket.org/qiscus/qismo-rb
|
138
|
+
homepage_uri: https://bitbucket.org/qiscus/qismo-rb
|
139
|
+
documentation_uri: https://www.rubydoc.info/gems/qismo
|
138
140
|
post_install_message:
|
139
141
|
rdoc_options: []
|
140
142
|
require_paths:
|
@@ -153,5 +155,5 @@ requirements: []
|
|
153
155
|
rubygems_version: 3.1.6
|
154
156
|
signing_key:
|
155
157
|
specification_version: 4
|
156
|
-
summary: Qiscus Omnichannel
|
158
|
+
summary: Ruby wrapper for Qiscus Omnichannel public API
|
157
159
|
test_files: []
|