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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1b4c93e50732069adea997b37a9377cff4444c8785971e1a194eac896b4e18d
4
- data.tar.gz: 2afff6846d7d8e981dbc8242bee37bdfe32d37845029ba11614365c898bd5f89
3
+ metadata.gz: 23e999cca8b986d2783ea662573e0fab71db0c0bb1e6bf0a1603b4442eea6acc
4
+ data.tar.gz: fc35ba076ba1c6597e1fb8f13b26c2a4319a92dc8c0a6215529c4f5aff2b9a09
5
5
  SHA512:
6
- metadata.gz: 7a12795cfc80d51487a8c5242f11b5796e2292e6fc440f1fab7a05ad32bc616ffb5c129d43679f622397a19001cc56fa4fb229f0f20473c40dec4961593f4d4b
7
- data.tar.gz: c6bb012dc5209dd55409c4cdcad760f4bc7a2686ee3265cd758bc9228be0ca0643a9d40cb54932815d9095d3722ee934a5d6ecaea1f9fbba2a5711bbb9f6de45
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
- # @param opt [Hash]
9
+ # @see https://s.id/list-customer-rooms
10
+ # @param options [Hash]
8
11
  # @return [Qismo::CollectionObject]
9
- def rooms(opt = {})
10
- body = post("/api/v2/customer_rooms", opt)
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(opt.merge(cursor_before: body.meta&.cursor_before)) },
16
- next_func: -> { rooms(opt.merge(cursor_after: body.meta&.cursor_after)) },
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 opt [Hash]
119
+ # @param options [Hash]
102
120
  # @return [Qismo::CollectionObject]
103
- def room_broadcast_history(room_id, opt = {})
104
- body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history", opt)
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(opt.merge(page: next_page)) },
114
- prev_func: -> { room_broadcast_history(opt.merge(page: prev_page)) },
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 opt [Hash]
141
+ # @param options [Hash]
123
142
  # @return [Qismo::SingleObject]
124
- def assign_agent(room_id, agent_id, opt = {})
125
- body = post("/api/v1/admin/service/assign_agent", opt.merge(room_id: room_id.to_s, agent_id: agent_id))
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 opt [Hash]
164
+ # @param options [Hash]
144
165
  # @return [Qismo::SingleObject]
145
- def resolve_room(room_id, last_comment_id, opt = {})
166
+ def resolve_room(room_id, last_comment_id, options = {})
146
167
  body = post("/api/v1/admin/service/mark_as_resolved",
147
- opt.merge(room_id: room_id.to_s, last_comment_id: last_comment_id))
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 opt [Hash]
178
+ # @param options [Hash]
157
179
  # @return [Qismo::SingleObject]
158
- def allocate_agent(source, opt = {})
159
- body = post("/api/v1/admin/service/allocate_agent", opt.merge(source: source))
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 opt [Hash]
189
+ # @param options [Hash]
167
190
  # @return [Qismo::SingleObject]
168
- def allocate_and_assign_agent(room_id, opt = {})
169
- body = post("/api/v1/admin/service/allocate_assign_agent", opt.merge(room_id: room_id))
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 opt [Hash]
200
+ # @param options [Hash]
177
201
  # @return [Qismo::CollectionObject]
178
- def other_agents(room_id, opt = {})
179
- body = get("/api/v2/admin/service/other_agents", opt.merge(room_id: room_id))
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(opt.merge(cursor_before: body.meta&.cursor_before)) },
185
- next_func: -> { other_agents(opt.merge(cursor_after: body.meta&.cursor_after)) },
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 opt [Hash]
217
+ # @param options [Hash]
193
218
  # @return [Qismo::CollectionObject]
194
- def available_agents(room_id, opt = {})
195
- body = get("/api/v2/admin/service/available_agents", opt.merge(room_id: room_id))
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(opt.merge(cursor_before: body.meta&.cursor_before)) },
201
- next_func: -> { available_agents(opt.merge(cursor_after: body.meta&.cursor_after)) },
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 opt [Hash]
240
+ # @param options [Hash]
216
241
  # @return [Qismo::SingleObject]
217
- def set_new_session_webhook(url, opt = {})
218
- post("/api/v2/app/config/new_session_webhook", opt.merge(url: url)).data.configs
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 opt [Hash]
256
+ # @param options [Hash]
232
257
  # @return [Qismo::SingleObject]
233
- def set_auth_webhook(url, opt = {})
234
- post("/api/v2/app/config/auth_webhook", opt.merge(url: url)).data.configs
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 opt [Hash]
272
+ # @param options [Hash]
248
273
  # @return [Qismo::SingleObject]
249
- def set_resolve_webhook(url, opt = {})
250
- post("/api/v1/app/webhook/mark_as_resolved", opt.merge(url: url)).data
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
- # @param opt [Hash]
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(opt = {})
258
- if opt[:page].nil? || opt[:page].empty?
259
- opt[:page] = 1
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", opt)
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 = opt[:page] < total_page ? (opt[:page] + 1) : nil
266
- prev_page = opt[:page] > 1 ? (opt[:page] - 1) : nil
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(opt.merge(page: next_page)) },
273
- prev_func: -> { agents(opt.merge(page: prev_page)) },
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 opt [Hash]
316
+ # @param options [Hash]
289
317
  # @return [Qismo::CollectionObject]
290
- def agents_by_divisions(division_ids, opt = {})
291
- body = get("/api/v2/admin/agents/by_division", opt.merge({ "division_ids[]": division_ids }))
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(opt.merge(page: next_page)) },
301
- prev_func: -> { agents_by_divisions(opt.merge(page: prev_page)) },
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
- # @param opt [Hash]
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(opt = {})
329
- body = get("/api/v3/admin/hsm", opt)
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(opt.merge(page: next_page)) },
340
- prev_func: -> { wa_broadcast_templates(opt.merge(page: prev_page)) },
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
- # @param opt [Hash]
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(opt = {})
349
- post("/api/v3/admin/broadcast/client", opt).data
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
- # @param opt [Hash]
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(opt = {})
368
- post("/api/v3/admin/broadcast/send_broadcast", opt).data.broadcast_job
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
- # @param opt [Hash]
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(opt = {})
376
- body = get("/api/v2/admin/broadcast_jobs", opt)
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(opt.merge(page: next_page)) },
386
- prev_func: -> { wa_broadcast_jobs(opt.merge(page: prev_page)) },
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 opt [Hash]
443
+ # @param options [Hash]
402
444
  # @return [Qismo::CollectionObject]
403
- def wa_broadcast_logs(broadcast_job_id, opt = {})
404
- body = get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}", opt)
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(opt.merge(page: next_page)) },
414
- prev_func: -> { wa_broadcast_jobs(opt.merge(page: prev_page)) },
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
- # @param opt [Hash]
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(opt = {})
423
- post("#{app_id}/bot", opt)
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 opt [Hash]
505
+ # @param options [Hash]
459
506
  # @return [TrueClass]
460
- def handover_room_from_bot_to_division(room_id, roles, opt = {})
461
- post("/#{app_id}/bot/#{room_id}/hand_over_to_role", opt.merge(roles: roles))
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 opt [Hash]
517
+ # @param options [Hash]
470
518
  # @return [Qismo::SingleObject]
471
- def initiate_widget_chat(user_id, name, opt = {})
472
- opt = opt.merge(app_id: app_id, user_id: user_id, name: name)
473
- post("/api/v2/qiscus/initiate_chat", opt).data.customer_room
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 opt [Hash]
532
+ # @param options [Hash]
482
533
  # @return [Qismo::SingleObject]
483
- def send_message_to_custom_channel(identifier_key, user_id, name, opt = {})
534
+ def send_message_to_custom_channel(identifier_key, user_id, name, options = {})
484
535
  post("/#{app_id}/api/v2/custom_channel/send",
485
- opt.merge(identifier_key: identifier_key, user_id: user_id, name: name)).data
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 opt [Hash]
552
+ # @param options [Hash]
498
553
  # @return [Qismo::SingleObject]
499
- def create_custom_channel(identifier_key, name, webhook_url, opt = {})
500
- opt = opt.merge(
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
- opt[:is_active] = true unless opt[:is_active].nil?
561
+ options[:is_active] = true unless options[:is_active].nil?
507
562
 
508
- post("/api/v1/custom_channel/connect", opt.merge).data
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 opt [Hash]
569
+ # @param options [Hash]
515
570
  # @return [Qismo::SingleObject]
516
- def update_custom_channel(id, opt = {})
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(opt)
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 opt [Hash]
32
- def initialize(opt = {})
33
- DEFAULT_OPTIONS.merge(opt).each do |key, value|
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
- # Http request with post method to upload file
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 http request with get method
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, **params)
61
+ def get(path, params = {})
62
62
  request(:get, path, params: params)
63
63
  end
64
64
 
65
- def delete(path)
66
- request(:delete, path)
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 http request
74
+ # Send HTTP request
70
75
  #
71
76
  # @param method [Symbol, String]
72
77
  # @param path [String]
73
- # @param body [Hash]
78
+ # @param headers [Hash]
79
+ # @param params [Hash]
80
+ # @param json [Hash]
74
81
  # @return [Qismo::SingleObject]
75
- def request(method, path, opt = {})
76
- res = connection.request(method, @url + path, opt.compact)
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 opt [Hash]
10
- def initialize(opt = {})
11
- opt.each do |key, value|
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Qismo
4
4
  # @return [String]
5
- VERSION = "0.10.0"
5
+ VERSION = "0.11.0"
6
6
  end
data/lib/qismo.rb CHANGED
@@ -11,7 +11,8 @@ require "qismo/api"
11
11
  require "qismo/client"
12
12
 
13
13
  module Qismo
14
- # @!method rooms
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 opt [Hash]
25
+ # @param options [Hash]
25
26
  # @return [Qismo::Client]
26
- def new(opt = {})
27
- @client = Client.new(opt)
27
+ def new(options = {})
28
+ @client = Client.new(options)
28
29
  end
29
30
 
30
- if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new("3.0.0")
31
- def method_missing(method, *args, **kwargs, &block)
32
- return super unless client.respond_to?(method)
31
+ # @return [Qismo::Client]
32
+ def client
33
+ @client ||= Client.new
34
+ end
33
35
 
34
- client.send(method, *args, **kwargs, &block)
35
- end
36
- else
37
- def method_missing(method, *args, &block)
38
- return super unless client.respond_to?(method)
36
+ private
39
37
 
40
- client.send(method, *args, &block)
41
- end
42
- end
38
+ def method_missing(method, *args, &block)
39
+ return super unless client.respond_to?(method)
43
40
 
44
- def respond_to_missing?(method_name, *args)
45
- Qismo::Client.instance_methods.include?(method_name)
41
+ client.send(method * args, &block)
46
42
  end
47
43
 
48
- private
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 client
51
- @client ||= Client.new
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.10.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-06 00:00:00.000000000 Z
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.com
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 Ruby Gem
158
+ summary: Ruby wrapper for Qiscus Omnichannel public API
157
159
  test_files: []