qismo 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qismo/api.rb +136 -125
  3. data/lib/qismo/client.rb +5 -4
  4. data/lib/qismo/collection.rb +2 -0
  5. data/lib/qismo/object.rb +2 -0
  6. data/lib/qismo/objectified_hash.rb +5 -0
  7. data/lib/qismo/objects/agent_service.rb +4 -0
  8. data/lib/qismo/objects/broadcast_job.rb +4 -0
  9. data/lib/qismo/objects/broadcast_log.rb +2 -0
  10. data/lib/qismo/objects/custom_channel.rb +35 -0
  11. data/lib/qismo/objects/custom_channel_message_response.rb +2 -0
  12. data/lib/qismo/objects/customer_room.rb +2 -0
  13. data/lib/qismo/objects/fb_channel.rb +31 -0
  14. data/lib/qismo/objects/hsm_template.rb +6 -0
  15. data/lib/qismo/objects/ig_channel.rb +43 -0
  16. data/lib/qismo/objects/line_channel.rb +27 -0
  17. data/lib/qismo/objects/list_channels_response.rb +39 -0
  18. data/lib/qismo/objects/office_hour.rb +4 -0
  19. data/lib/qismo/objects/qiscus_channel.rb +27 -0
  20. data/lib/qismo/objects/room_additional_info.rb +2 -0
  21. data/lib/qismo/objects/tag.rb +4 -2
  22. data/lib/qismo/objects/telegram_channel.rb +31 -0
  23. data/lib/qismo/objects/user.rb +6 -0
  24. data/lib/qismo/objects/wa_channel.rb +111 -0
  25. data/lib/qismo/objects/wa_credit_info.rb +6 -0
  26. data/lib/qismo/objects/waca_channel.rb +55 -0
  27. data/lib/qismo/objects/webhook.rb +2 -0
  28. data/lib/qismo/types.rb +9 -0
  29. data/lib/qismo/version.rb +1 -1
  30. data/lib/qismo/webhook_requests/on_agent_allocation_needed.rb +6 -0
  31. data/lib/qismo/webhook_requests/on_custom_button_clicked.rb +10 -2
  32. data/lib/qismo/webhook_requests/on_custom_channel_message_sent.rb +12 -0
  33. data/lib/qismo/webhook_requests/on_message_for_bot_sent.rb +12 -0
  34. data/lib/qismo/webhook_requests/on_new_session_initiated.rb +20 -0
  35. data/lib/qismo/webhook_requests/on_room_resolved.rb +10 -0
  36. data/lib/qismo.rb +11 -0
  37. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb77849305f7812a453eefbea9e5f288ede162774aadb8f638760ae6349b519
4
- data.tar.gz: e5f4fd6c8bbae34bc30707cd08f629ac32932b20f10a73307edd8689707ab532
3
+ metadata.gz: e06efa610df2f136d4775f01ba27d50b6f65576d7cc510024a903eff84547a8b
4
+ data.tar.gz: 4b3c9685a3c8600a7ea21577648f438fcfa7f76dbd8cf9e6b21a31148f29fd09
5
5
  SHA512:
6
- metadata.gz: 292760f08f8b16bf5093916564ee4ea0e3f641c7e51ca4c0e65aa6a54bbb3e67a83204a1b087a9e60d7fdcfd5dbced2179e6334b783f87e0570fae5f8f762b1d
7
- data.tar.gz: 5af35068e56009c635b0e43af48c2b51517095c610e29ea3d353f5519d4ed29935cee99158cf88a896945607f4c215895037e682c06e39dd45ec90863ef1f234
6
+ metadata.gz: a374d557e090a13205779073e45bf997922d7f7f874a240f11a2eb74aa7cc39a847c3220e4053b032ec2b97aa6329e522238fa444b1e722d63b6ab5e77283ed6
7
+ data.tar.gz: '07249fcc6d6d69b4693ac7e20ca6f2aa9909bb9fb5049a3d15b171fbaf2a6cf5b267867b75bf199031ef9ff1c872b7d22bb55c26c1e5ac91247e07ac293c21dc'
data/lib/qismo/api.rb CHANGED
@@ -1,39 +1,49 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qismo
4
+ # API wrappers
5
+ #
4
6
  module Api
5
7
  # @!parse include Qismo::Client
6
8
 
7
9
  # List customer rooms
8
10
  #
9
- # @see https://s.id/list-customer-rooms
10
- # @param options [Hash]
11
- # List room optional filters
12
- # @option options [String] :status
13
- # Filter by room status. Valid values are "resolved", "unresolved", "expired", or "almost_expired"
14
- # @option options [String] :serve_status
15
- # Filter by room serve status. Valid values are "served" or "unserved"
16
- # @option options [Array<Hash>] :channels
17
- # Filter by channels. Example: [{ source: "wa", channel_id: 716171 }]
18
- # @option options [TrueClass,FalseClass] :is_handled_by_bot
19
- # Filter by bot handling status
20
- # @option options [String] :name
21
- # Filter by customer name
22
- # @option options [Integer] :limit
23
- # Number of data returned in one page. Default is 50
24
- # @option options [String] :order
25
- # Order data by timestamp. Can be ordered "asc" or "desc". Default is "desc"
26
- # @option options [String] :cursor_after
11
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#704a0c40-56b2-4a94-9c1d-e1529923cbb6
12
+ # @param channels [Array<Hash>]
13
+ # Filter rooms by channels. Example: [{ source: "wa", channel_id: 716171 }]
14
+ # @param status [String]
15
+ # Filter rooms by status. Valid values are "resolved", "unresolved", "expired",or "almost_expired"
16
+ # @param serve_status [String]
17
+ # Filter rooms by serve status. Valid values are "served" or "unserved". By default, we will retrieve all serve_status
18
+ # @param name [String]
19
+ # Filter rooms by customer nam
20
+ # @param limit [Integer]
21
+ # Limit the number of rooms returned in one page. By default, it will return 50 rooms data
22
+ # @param tag_ids [Array<Integer>]
23
+ # Filter rooms by its tag
24
+ # @param agent_ids [Array<Integer>]
25
+ # Filter rooms by the agent who handled the rooms
26
+ # @param order [String]
27
+ # Order returned data by the timestamp. By default, we will return the newest rooms first
28
+ # @param cursor_after [String]
27
29
  # Next page cursor. If you are on last page, the cursor returned will be nil
28
- # @option options [String] :cursor_before
30
+ # @param cursor_before [String]
29
31
  # Previous page cursor. If you are on first page, the cursor returned will be nil
30
- # @option options [Array<Integer>] :tag_ids
31
- # Filter by tags
32
- # @option options [Array<Integer>] :user_ids
33
- # Filter by agent who handled or assigned to the room
34
32
  # @return [Qismo::Collection<Qismo::CustomerRoom>]
35
- def rooms(options = {})
36
- body = post("/api/v2/customer_rooms", options)
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)
34
+ body = post("/api/v2/customer_rooms", json: {
35
+ channels: channels,
36
+ status: status,
37
+ serve_status: serve_status,
38
+ name: name,
39
+ limit: limit,
40
+ tag_ids: tag_ids,
41
+ user_ids: agent_ids,
42
+ order: order,
43
+ cursor_after: cursor_after,
44
+ cursor_before: cursor_before
45
+ }.compact)
46
+
37
47
  Collection.new(
38
48
  Qismo::Objects::CustomerRoom.from_array(body.data.customer_rooms),
39
49
  next_page: body.meta.cursor_after,
@@ -42,10 +52,10 @@ module Qismo
42
52
  end
43
53
 
44
54
  # Get room by id
45
- # @see https://s.id/get-room-by-room-id
55
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#8c803377-eea2-4879-9d66-8906d9f41275
46
56
  # @param room_id [Integer]
47
- # @return [Qismo::SingleObject]
48
- def room(room_id)
57
+ # @return [Qismo::Objects::CustomerRoom]
58
+ def room(room_id:)
49
59
  body = get("/api/v2/customer_rooms/#{room_id}")
50
60
  if body.data.customer_room.nil?
51
61
  raise Qismo::NotFoundError.new("Room not found", status_code: 404, response_body: body.to_json)
@@ -56,10 +66,10 @@ module Qismo
56
66
 
57
67
  # List tags inside room
58
68
  #
59
- # @see https://s.id/list-room-tags
69
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#d40b54a7-2b37-4afc-b474-62593001274e
60
70
  # @param room_id [Integer]
61
71
  # @return [Qismo::Collection<Qismo::Objects::Tag>]
62
- def room_tags(room_id)
72
+ def room_tags(room_id:)
63
73
  Qismo::Collection.new(
64
74
  Qismo::Objects::Tag.from_array(
65
75
  get("/api/v2/room_tags/#{room_id}").data
@@ -69,33 +79,33 @@ module Qismo
69
79
 
70
80
  # Add room tag
71
81
  #
72
- # @see https://s.id/add-room-tag
82
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#9737d580-d156-4213-85a8-95fb3f1ad964
73
83
  # @param room_id [Integer]
74
84
  # @param tag_name [String]
75
85
  # @return [Qismo::Objects::Tag]
76
- def add_room_tag(room_id, tag_name)
86
+ def add_room_tag(room_id:, tag_name:)
77
87
  Qismo::Objects::Tag.new(
78
- post("/api/v2/room_tags/#{room_id}", tag: tag_name).data
88
+ post("/api/v2/room_tags/#{room_id}", tag_name: tag).data
79
89
  )
80
90
  end
81
91
 
82
92
  # Delete room tag
83
93
  #
84
- # @see https://s.id/delete-room-tag
94
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#f4d173a1-3fb1-4151-87fd-106982bcc4a2
85
95
  # @param room_id [Integer]
86
96
  # @param tag_id [Integer]
87
97
  # @return [TrueClass]
88
- def delete_room_tag(room_id, tag_id)
98
+ def delete_room_tag(room_id:, tag_id:)
89
99
  delete("/api/v2/room_tags/#{room_id}/#{tag_id}")
90
100
  true
91
101
  end
92
102
 
93
103
  # List room additional info
94
104
  #
95
- # @see https://s.id/list-room-info
105
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#88c2287b-21af-4afd-b495-aaaa2818c381
96
106
  # @param room_id [Integer]
97
107
  # @return [Array<Qismo::Objects::RoomAdditionalInfo>]
98
- def room_additional_info(room_id)
108
+ def room_additional_info(room_id:)
99
109
  Qismo::Objects::RoomAdditionalInfo.from_array(
100
110
  get("/api/v1/qiscus/room/#{room_id}/user_info").data.extras.user_properties
101
111
  )
@@ -107,17 +117,17 @@ module Qismo
107
117
 
108
118
  # Set room additional info
109
119
  #
110
- # @see https://s.id/set-room-info
120
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#2b968e9e-2a76-4569-8763-f883e11dc5a7
111
121
  # @note This will replace your current room additional info
112
122
  # @param room_id [Integer]
113
- # @param additional_info [Array<Hash>]
123
+ # @param info [Array<Hash>]
114
124
  # Key value pair of additional info. Ex: [{ key: "Ticket Link", value: "https://ticket.com" }]
115
125
  # @return [Array<Qismo::Objects::RoomAdditionalInfo>]
116
- def set_room_additional_info(room_id, additional_info)
126
+ def set_room_additional_info(room_id:, info:)
117
127
  Qismo::Objects::RoomAdditionalInfo.from_array(
118
128
  post(
119
129
  "/api/v1/qiscus/room/#{room_id}/user_info",
120
- user_properties: additional_info
130
+ user_properties: info
121
131
  ).data.extras.user_properties
122
132
  )
123
133
  end
@@ -129,31 +139,24 @@ module Qismo
129
139
  # Update room additional info
130
140
  #
131
141
  # @param room_id [Integer]
132
- # @param additional_info [Array<Hash>]
142
+ # @param info [Array<Hash>]
133
143
  # Key value pair of additional info. Ex: [{ key: "Ticket Link", value: "https://ticket.com" }]
134
144
  # @return [Array<Qismo::Objects::RoomAdditionalInfo>]
135
- def update_room_additional_info(room_id, additional_info)
136
- old_additional_info = room_additional_info(room_id).as_json
137
- new_additional_info = (additional_info.as_json + old_additional_info).uniq { |h| h.values_at("key") }
138
- set_room_additional_info(room_id, new_additional_info)
145
+ def update_room_additional_info(room_id:, info:)
146
+ old_info = room_additional_info(room_id).as_json
147
+ new_info = (info.as_json + old_info).uniq { |h| h.values_at("key") }
148
+ set_room_additional_info(room_id: room_id, info: new_info)
139
149
  end
140
150
 
141
151
  alias_method :update_room_info, :update_room_additional_info
142
152
 
143
- # List Whatsapp broadcast history inside room
144
- #
145
- # @see https://s.id/list-room-broadcast-history
146
- # @param room_id [Integer]
147
- # @param options [Hash]
148
- # @return [Qismo::CollectionObject]
149
-
150
153
  # List broadcast history inside room
151
154
  #
152
155
  # @param room_id [Integer]
153
156
  # @param page [Integer]
154
157
  # @param limit [Integer]
155
158
  # @return [Qismo::Collection<Qismo::Objects::BroadcastLog>]
156
- def room_broadcast_history(room_id, page: 1, limit: 25)
159
+ def room_broadcast_history(room_id:, page: 1, limit: 25)
157
160
  body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history", {
158
161
  page: page,
159
162
  limit: limit
@@ -180,7 +183,7 @@ module Qismo
180
183
  # param :relpace_agents to true, this param will be forced
181
184
  # to nil, which no be sent on http request
182
185
  # @return [Qismo::Objects::User]
183
- def assign_agent(room_id, agent_id, replace_agents: false, max_agent: nil)
186
+ def assign_agent(room_id:, agent_id:, replace_agents: false, max_agent: nil)
184
187
  Qismo::Objects::User.new(
185
188
  post("/api/v1/admin/service/assign_agent", {
186
189
  room_id: room_id.to_s,
@@ -193,11 +196,11 @@ module Qismo
193
196
 
194
197
  # Remove agent from room
195
198
  #
196
- # @see https://s.id/remove-agent
199
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#7a67e214-28e5-47c1-b4ee-7246977dfcff
197
200
  # @param room_id [Integer]
198
201
  # @param agent_id [Integer]
199
202
  # @return [TrueClass]
200
- def remove_agent(room_id, agent_id)
203
+ def remove_agent(room_id:, agent_id:)
201
204
  post(
202
205
  "/api/v1/admin/service/remove_agent", {
203
206
  room_id: room_id.to_s,
@@ -210,7 +213,7 @@ module Qismo
210
213
 
211
214
  # Resolve room
212
215
  #
213
- # @see https://s.id/resolve-room
216
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#a1ff75d0-b637-4b79-a259-fb9d084d1659
214
217
  # @param room_id [Integer]
215
218
  # @param last_comment_id [Integer]
216
219
  # Id of last message in the room. If you dont specify this param,
@@ -223,8 +226,8 @@ module Qismo
223
226
  # you are using valid email as customer identifier
224
227
  # @param extras [Hash]
225
228
  # Room extras in valid hash
226
- # @return [Qismo::SingleObject]
227
- def resolve_room(room_id, last_comment_id: Time.now.to_i, notes: nil, send_email: false, extras: nil)
229
+ # @return [Qismo::Objects::AgentService]
230
+ def resolve_room(room_id:, last_comment_id: Time.now.to_i, notes: nil, send_email: false, extras: nil)
228
231
  Qismo::Objects::AgentService.new(
229
232
  post("/api/v1/admin/service/mark_as_resolved", {
230
233
  room_id: room_id.to_s,
@@ -240,7 +243,7 @@ module Qismo
240
243
 
241
244
  # Get agent that can be assigned to room
242
245
  #
243
- # @see https://s.id/allocate-agent
246
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#a62432c6-1aba-4e2b-be9a-2f7151db9119
244
247
  # @param source [String]
245
248
  # Channel source. Available sources are `wa`, `line`, `telegram`,
246
249
  # `qiscus`, `ig`, or `fb`. For custom channel, use that channel's
@@ -251,7 +254,7 @@ module Qismo
251
254
  # Ignore agent availability. If you set this param to true, agent
252
255
  # that are unavailable will be considered as allocatable too
253
256
  # @return [Qismo::Objects::User]
254
- def allocate_agent(source, channel_id, ignore_availability: false)
257
+ def allocate_agent(source:, channel_id:, ignore_availability: false)
255
258
  Qismo::Objects::User.new(
256
259
  post("/api/v1/admin/service/allocate_agent", {
257
260
  source: source,
@@ -263,13 +266,13 @@ module Qismo
263
266
 
264
267
  # Get agent that can be allocated to room and automatically assign them
265
268
  #
266
- # @see https://s.id/allocate-and-assign-agent
269
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#f88465ed-379f-4202-a8a4-e0c3bebcfeab
267
270
  # @param room_id [Integer]
268
271
  # @param ignore_availability [TrueClass,FalseClass]
269
272
  # Ignore agent availability. If you set this param to true, agent
270
273
  # that are unavailable will be considered as allocatable too
271
- # @return [Qismo::SingleObject]
272
- def allocate_and_assign_agent(room_id, ignore_availability: false)
274
+ # @return [Qismo::Objects::User]
275
+ def allocate_and_assign_agent(room_id:, ignore_availability: false)
273
276
  Qismo::Objects::User.new(
274
277
  post("/api/v1/admin/service/allocate_assign_agent", {
275
278
  room_id: room_id.to_s,
@@ -280,14 +283,14 @@ module Qismo
280
283
 
281
284
  # List agents that are not in room and can be assigned to room
282
285
  #
283
- # @see https://s.id/list-other-agents
286
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#10d75d0c-ebd2-44c6-ab19-a0bafe7ad982
284
287
  # @param room_id [Integer]
285
288
  # @param search [String]
286
289
  # @param limit [Integer]
287
290
  # @param cursor_after [String]
288
291
  # @param cursor_before [String]
289
292
  # @return [Qismo::Collection<Qismo::Objects::User>]
290
- def other_agents(room_id, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
293
+ def other_agents(room_id:, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
291
294
  body = get("/api/v2/admin/service/other_agents", {
292
295
  room_id: room_id.to_s,
293
296
  search: search,
@@ -305,7 +308,7 @@ module Qismo
305
308
 
306
309
  # List available agents in room
307
310
  #
308
- # @see https://s.id/list-available-agents
311
+ # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#0d5db283-c7f8-42e0-ba02-6cbcbc1d2bb3
309
312
  # @param room_id [Integer]
310
313
  # @param available_in_room [TrueClass,FalseClass]
311
314
  # @param search [String]
@@ -313,7 +316,7 @@ module Qismo
313
316
  # @param cursor_after [String]
314
317
  # @param cursor_before [String]
315
318
  # @return [Qismo::Collection<Qismo::Objects::User>]
316
- def available_agents(room_id, available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
319
+ def available_agents(room_id:, available_in_room: true, search: nil, limit: 15, cursor_after: nil, cursor_before: nil)
317
320
  body = get("/api/v2/admin/service/available_agents", {
318
321
  room_id: room_id.to_s,
319
322
  is_available_in_room: available_in_room,
@@ -346,7 +349,7 @@ module Qismo
346
349
  # @param url [String]
347
350
  # @param enabled [TrueClass,FalseClass]
348
351
  # @return [Qismo::Objects::Webhook]
349
- def set_new_session_webhook(url, enabled: true)
352
+ def set_new_session_webhook(url:, enabled: true)
350
353
  config = post("/api/v2/app/config/new_session_webhook", url: url, enabled: enabled).data.configs
351
354
  Qismo::Objects::Webhook.new(
352
355
  enabled: config.is_new_session_webhook_enabled,
@@ -356,7 +359,7 @@ module Qismo
356
359
 
357
360
  # Get auth webhook config
358
361
  #
359
- # @return [Qismo::SingleObject]
362
+ # @return [Qismo::Objects::Webhook]
360
363
  def auth_webhook
361
364
  config = get("/api/v2/app/config/auth_webhook").data.configs
362
365
  Qismo::Objects::Webhook.new(
@@ -369,8 +372,8 @@ module Qismo
369
372
  #
370
373
  # @param url [String]
371
374
  # @param enabled [TrueClass, FalseClass]
372
- # @return [Qismo::SingleObject]
373
- def set_auth_webhook(url, enabled: true)
375
+ # @return [Qismo::Objects::Webhook]
376
+ def set_auth_webhook(url:, enabled: true)
374
377
  config = post("/api/v2/app/config/auth_webhook", url: url, enabled: enabled).data.configs
375
378
  Qismo::Objects::Webhook.new(
376
379
  enabled: config.is_auth_webhook_enabled,
@@ -394,7 +397,7 @@ module Qismo
394
397
  # @param url [String]
395
398
  # @param options [Hash]
396
399
  # @return [Qismo::Objects::Webhook]
397
- def set_resolve_webhook(url, enabled: true)
400
+ def set_resolve_webhook(url:, enabled: true)
398
401
  config = post("/api/v1/app/webhook/mark_as_resolved", webhook_url: url, is_webhook_enabled: enabled).data
399
402
  Qismo::Objects::Webhook.new(
400
403
  enabled: config.is_mark_as_resolved_webhook_enabled,
@@ -429,9 +432,9 @@ module Qismo
429
432
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3db6c8c8-8ffe-4a88-b630-41f9d5b62298
430
433
  # @param ids [Array<Integer>]
431
434
  # @return [Qismo::Collection<Qismo::Objects::User>]
432
- def agents_by_ids(ids)
435
+ def agents_by_ids(agent_ids:)
433
436
  Qismo::Collection.new(
434
- Qismo::Objects::User.from_array(get("/api/v1/admin/agents/get_by_ids", {"ids[]": ids}).data)
437
+ Qismo::Objects::User.from_array(get("/api/v1/admin/agents/get_by_ids", {"ids[]": agent_ids}).data)
435
438
  )
436
439
  end
437
440
 
@@ -462,7 +465,7 @@ module Qismo
462
465
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#c6184a6b-ba4d-4f3e-a4da-c6d0fa4597af
463
466
  # @param agent_id [Integer]
464
467
  # @return [Qismo::Objects::User]
465
- def agent(agent_id)
468
+ def agent(agent_id:)
466
469
  Qismo::Objects::User.new(get("/api/v2/admin/agent/#{agent_id}").data.agent)
467
470
  end
468
471
 
@@ -480,7 +483,7 @@ module Qismo
480
483
  #
481
484
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#e38d2244-9559-4015-99d5-8c707f6c01bd
482
485
  # @param options [Hash]
483
- # @return [Qismo::CollectionObject]
486
+ # @return [Qismo::Collection<Qismo::Objects::HsmTemplate>]
484
487
  def wa_broadcast_templates(page: 1, limit: 10, approved: nil)
485
488
  body = get("/api/v3/admin/hsm", {
486
489
  page: page,
@@ -559,7 +562,7 @@ module Qismo
559
562
  # @param file [HTTP::FormData]
560
563
  # @param template_detail_id [Integer]
561
564
  # @return [Integer]
562
- def upload_wa_broadcast_csv(file, template_detail_id, separator: ",")
565
+ def upload_wa_broadcast_csv(file:, template_detail_id:, separator: ",")
563
566
  raise ArgumentError, "Invalid file" unless file.is_a?(HTTP::FormData::File)
564
567
 
565
568
  body = post_upload("/api/v3/admin/broadcast/upload_csv", {
@@ -580,7 +583,7 @@ module Qismo
580
583
  # @param separator [String]
581
584
  # @param started_at [Time]
582
585
  # @return [Qismo::Objects::BroadcastJob]
583
- def send_wa_broadcast(file, template_detail_id, name: nil, separator: ",", started_at: nil)
586
+ def send_wa_broadcast(file:, template_detail_id:, name: nil, separator: ",", started_at: nil)
584
587
  if name.blank?
585
588
  name = default_broadcast_name
586
589
  end
@@ -614,12 +617,6 @@ module Qismo
614
617
 
615
618
  alias_method :create_wa_broadcast, :send_wa_broadcast
616
619
 
617
- # List wa broadcast jobs
618
- #
619
- # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3a4caa8b-eef4-427f-adcb-d065989899c9
620
- # @param options [Hash]
621
- # @return [Qismo::CollectionObject]
622
-
623
620
  # List WA broadcast jobs
624
621
  #
625
622
  # @param page [Integer]
@@ -648,7 +645,7 @@ module Qismo
648
645
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#ed0806c8-2e4a-4ea4-8acb-45c84c63c2da
649
646
  # @param broadcast_job_id [Integer]
650
647
  # @return [Qismo::Objects::BroadcastJob]
651
- def wa_broadcast_job(broadcast_job_id)
648
+ def wa_broadcast_job(broadcast_job_id:)
652
649
  Qismo::Objects::BroadcastJob.new(
653
650
  get("/api/v2/admin/broadcast_jobs/#{broadcast_job_id}").data.broadcast_job
654
651
  )
@@ -659,8 +656,8 @@ module Qismo
659
656
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#3f2d8ba8-ab14-43b2-af82-74c8b766216f
660
657
  # @param broadcast_job_id [Integer]
661
658
  # @param options [Hash]
662
- # @return [Qismo::CollectionObject]
663
- def wa_broadcast_logs(broadcast_job_id, page: 1, limit: 10)
659
+ # @return [Qismo::Collection<Qismo::Objects::BroadcastLog>]
660
+ def wa_broadcast_logs(broadcast_job_id:, page: 1, limit: 10)
664
661
  body = get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}", {
665
662
  page: page,
666
663
  limit: limit
@@ -685,7 +682,7 @@ module Qismo
685
682
  # @param payload [Hash]
686
683
  # @param extras [Hash]
687
684
  # @return [TrueClass]
688
- def send_bot_message(room_id, message, type: "text", payload: {}, extras: {})
685
+ def send_bot_message(room_id:, message:, type: "text", payload: {}, extras: {})
689
686
  body = post("/#{app_id}/bot", {
690
687
  sender_email: admin_email,
691
688
  room_id: room_id.to_s,
@@ -707,7 +704,7 @@ module Qismo
707
704
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#494d825f-a49c-4b18-954e-eaaccb738bcd
708
705
  # @param room_id [Integer]
709
706
  # @return [TrueClass]
710
- def enable_bot_in_room(room_id)
707
+ def enable_bot_in_room(room_id:)
711
708
  post("/bot/#{room_id}/activate", is_active: true)
712
709
  true
713
710
  end
@@ -717,7 +714,7 @@ module Qismo
717
714
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#494d825f-a49c-4b18-954e-eaaccb738bcd
718
715
  # @param room_id [Integer]
719
716
  # @return [TrueClass]
720
- def disable_bot_in_room(room_id)
717
+ def disable_bot_in_room(room_id:)
721
718
  post("/bot/#{room_id}/activate", is_active: false)
722
719
  true
723
720
  end
@@ -727,7 +724,7 @@ module Qismo
727
724
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#40867e85-7412-4e0d-84bd-e2506df23df8
728
725
  # @param room_id [Integer]
729
726
  # @return [TrueClass]
730
- def handover_room_from_bot(room_id)
727
+ def handover_room_from_bot(room_id:)
731
728
  request(:post, "/#{app_id}/bot/#{room_id}/hand_over", headers: {
732
729
  Authorization: secret_key
733
730
  })
@@ -735,31 +732,23 @@ module Qismo
735
732
  true
736
733
  end
737
734
 
738
- # Handover room from chatbot to human agent in specific divisions
739
- #
740
- # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#8218db08-9753-4d74-ae5f-0ee62f8579b9
741
- # @param room_id [Integer]
742
- # @param roles [Array<Integer>]
743
- # @param options [Hash]
744
- # @return [TrueClass]
745
-
746
735
  # Handover room from chatbot to human agent in specific divisions
747
736
  #
748
737
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#8218db08-9753-4d74-ae5f-0ee62f8579b9# <Description>
749
738
  #
750
739
  # @param room_id [Integer]
751
- # @param role [Integer,Array<Integer>]
740
+ # @param roles [Integer,Array<Integer>]
752
741
  # @param find_online_agent [TrueClass,FalseClass]
753
742
  # @return [TrueClass,FalseClass]
754
- def handover_room_from_bot_to_division(room_id, role, find_online_agent: true)
743
+ def handover_room_from_bot_to_division(room_id:, roles:, find_online_agent: true)
755
744
  options = {}
756
745
  options[:room_id] = room_id.to_s
757
746
  options[:find_online_agent] = find_online_agent
758
747
 
759
- if role.is_a?(Array)
760
- options[:roles] = role
748
+ if roles.is_a?(Array)
749
+ options[:roles] = roles
761
750
  else
762
- options[:role] = role
751
+ options[:role] = roles
763
752
  end
764
753
 
765
754
  request(
@@ -777,24 +766,44 @@ module Qismo
777
766
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#d5a555de-59e0-4705-9582-c216d79e9390
778
767
  # @param user_id [String]
779
768
  # @param name [String]
780
- # @param options [Hash]
781
- # @return [Qismo::SingleObject]
782
- def initiate_widget_chat(user_id, name, options = {})
783
- options = options.merge(app_id: app_id, user_id: user_id, name: name)
769
+ # @param nonce [String]
770
+ # @param channel_id [Integer]
771
+ # @param extras [Hash]
772
+ # @param reset_extras [TrueClass,FalseClass]
773
+ # @param room_badge [String]
774
+ # @param avatar [String]
775
+ # @param allocate_agent [TrueClass,FalseClass]
776
+ # @param user_properties [Hash]
777
+ # @param sdk_user_extras [Hash]
778
+ # @param timezone_offset [String]
779
+ # @param notes [String]
780
+ # @param phone_number [String]
781
+ # @param email [String]
782
+ # @return [Qismo::Objects::CustomerRoom]
783
+ def initiate_widget_chat(user_id:, name:, nonce: nil, channel_id: nil, extras: nil, reset_extras: false, room_badge: nil, avatar: nil, allocate_agent: nil, user_properties: nil, sdk_user_extras: nil, timezone_offset: nil, notes: nil, phone_number: nil, email: nil)
784
+ options = {
785
+ user_id: user_id,
786
+ name: name,
787
+ nonce: nonce,
788
+ channel_id: channel_id,
789
+ extras: extras,
790
+ reset_extras: reset_extras,
791
+ room_badge: room_badge,
792
+ avatar: avatar,
793
+ allocate_agent: allocate_agent,
794
+ user_properties: user_properties,
795
+ sdk_user_extras: sdk_user_extras,
796
+ timezone_offset: timezone_offset,
797
+ notes: notes,
798
+ phone_number: phone_number,
799
+ email: email
800
+ }.compact
801
+
784
802
  Qismo::Objects::CustomerRoom.new(post("/api/v2/qiscus/initiate_chat", options).data.customer_room)
785
803
  end
786
804
 
787
805
  alias_method :initiate_chat, :initiate_widget_chat
788
806
 
789
- # Send message to custom channel
790
- #
791
- # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#aee54b21-68f1-4d31-9d81-d3c73b3e125b
792
- # @param identifier_key [String]
793
- # @param user_id [String]
794
- # @param name [String]
795
- # @param options [Hash]
796
- # @return [Qismo::SingleObject]
797
-
798
807
  # Send messsage to custom channel
799
808
  #
800
809
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#aee54b21-68f1-4d31-9d81-d3c73b3e125b
@@ -808,10 +817,10 @@ module Qismo
808
817
  # @param extras [Hash]
809
818
  # @return [Qismo::Objects::CustomChannelMessageResponse]
810
819
  def send_message_to_custom_channel(
811
- identifier_key,
812
- user_id,
813
- name,
814
- message,
820
+ identifier_key:,
821
+ user_id:,
822
+ name:,
823
+ message:,
815
824
  avatar: nil,
816
825
  type: "text",
817
826
  payload: {},
@@ -834,9 +843,11 @@ module Qismo
834
843
  # List integrated channels
835
844
  #
836
845
  # @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#aee54b21-68f1-4d31-9d81-d3c73b3e125b
837
- # @return [Qismo::ObjectifiedHash]
846
+ # @return [Qismo::Objects::ListChannelsResponse]
838
847
  def channels
839
- get("/api/v2/channels").data
848
+ Qismo::Objects::ListChannelsResponse.new(
849
+ get("/api/v2/channels").data
850
+ )
840
851
  end
841
852
  end
842
853
  end
data/lib/qismo/client.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qismo
4
+ # Qismo ruby client
5
+ #
4
6
  class Client
5
7
  include Qismo::Api
6
8
 
@@ -44,7 +46,6 @@ module Qismo
44
46
  # @param body [Hash]
45
47
  # @return [Qismo::ObjectifiedHash]
46
48
  def post(path, body = {})
47
- puts body.to_json
48
49
  request(:post, path, json: body.compact)
49
50
  end
50
51
 
@@ -86,9 +87,6 @@ module Qismo
86
87
  def request(method, path, options = {})
87
88
  res = connection.request(method, @url + path, options.compact)
88
89
 
89
- # require "byebug"
90
- # byebug
91
-
92
90
  if res.status.success?
93
91
  begin
94
92
  return JSON.parse(res.to_s, object_class: Qismo::ObjectifiedHash)
@@ -170,6 +168,9 @@ module Qismo
170
168
  "#{format[:lib_name]}/#{format[:lib_version]} (#{format[:platform]}; #{format[:lang]}; v#{format[:lang_version]}) app_id:#{@app_id}"
171
169
  end
172
170
 
171
+ # Default broadcast name for using in send broadcast api
172
+ #
173
+ # @return [String]
173
174
  def default_broadcast_name
174
175
  Time.current.strftime("%d/%m/%Y, %H:%I %z")
175
176
  end
@@ -1,4 +1,6 @@
1
1
  module Qismo
2
+ # Class to handle paginated response from API
3
+ #
2
4
  class Collection < Array
3
5
  # Collection object
4
6
  #
data/lib/qismo/object.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "dry-struct"
2
2
 
3
3
  module Qismo
4
+ # Object interface
5
+ #
4
6
  class Object < Dry::Struct
5
7
  include Qismo::Types
6
8