qismo 0.1.8 → 0.5.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: d4eaffbee238679bb22787462d15da8eeba47b130485a197f25798f9972df663
4
- data.tar.gz: 8503bd0773f35a80cc29d0e2ac28f4eebf0a77856f83f629452b2ee57c1e28bd
3
+ metadata.gz: 835aca8c69a0b94f348930cefdc3454d2d90c131718bc1d825960e928ca43c3b
4
+ data.tar.gz: '0240594c5422307db61e8dc208cef8ac06513c76bde7fda0ba649920bf4a400c'
5
5
  SHA512:
6
- metadata.gz: 4d58a2a88592ff4d8cc65c50afeda3ec153ed1a2abc451827ae670c3eff5c0af8fdcecb837689eb2915de5ebd08c1216913b15c9ef14a75b93cbba4c3ee81f06
7
- data.tar.gz: 4ef954fed64bd7e30ee7314524cccc6baa89709c0e3e279fb07df608e6927cb05aee7ef19e7e747c86e1dd499d68037b1d9ad2539ec9da7ab89f47e481a9839f
6
+ metadata.gz: 57b4ebebb1efea8ea65f47b53cab0d8057864afd45ee5df75a05e0fd9c36ad7d4ee68d591d8e5d5e30d869787d22eb93a90a2da4a973dde5f7f0613215aff99d
7
+ data.tar.gz: 305fa3917126e9abccdf3ed2c517e8a305675b6ad3aa46d3adb91a42fc0219d38da49bb57a2f391e6ba8b2393982a78d4d3a0022b1211dc46feb71c71e2d726d
data/.rubocop.yml CHANGED
@@ -1,8 +1,19 @@
1
1
  inherit_gem:
2
2
  rubocop-shopify: rubocop.yml
3
3
 
4
- Lint/MissingSuper:
5
- Enabled: false
4
+ AllCops:
5
+ TargetRubyVersion: 2.6
6
+ Exclude:
7
+ - "bin/**/*"
8
+ - "examples/*"
9
+
10
+ Style/StringLiterals:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ Enabled: true
16
+ EnforcedStyle: double_quotes
6
17
 
7
18
  Layout/LineLength:
8
19
  Max: 120
data/Gemfile CHANGED
@@ -4,6 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in qismo.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
data/Gemfile.lock CHANGED
@@ -1,15 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qismo (0.1.8)
5
- http (~> 5.0)
4
+ qismo (0.1.0)
5
+ activesupport
6
+ http
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- addressable (2.8.0)
11
- public_suffix (>= 2.0.2, < 5.0)
11
+ activesupport (7.0.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ addressable (2.8.1)
17
+ public_suffix (>= 2.0.2, < 6.0)
12
18
  ast (2.4.2)
19
+ byebug (11.1.3)
20
+ concurrent-ruby (1.1.10)
13
21
  diff-lcs (1.5.0)
14
22
  domain_name (0.5.20190701)
15
23
  unf (>= 0.0.5, < 1.0.0)
@@ -17,24 +25,30 @@ GEM
17
25
  ffi-compiler (1.0.1)
18
26
  ffi (>= 1.0.0)
19
27
  rake
20
- http (5.0.4)
28
+ http (5.1.0)
21
29
  addressable (~> 2.8)
22
30
  http-cookie (~> 1.0)
23
31
  http-form_data (~> 2.2)
24
32
  llhttp-ffi (~> 0.4.0)
25
- http-cookie (1.0.4)
33
+ http-cookie (1.0.5)
26
34
  domain_name (~> 0.5)
27
35
  http-form_data (2.3.0)
36
+ i18n (1.12.0)
37
+ concurrent-ruby (~> 1.0)
38
+ json (2.6.2)
39
+ language_server-protocol (3.17.0.1)
28
40
  llhttp-ffi (0.4.0)
29
41
  ffi-compiler (~> 1.0)
30
42
  rake (~> 13.0)
31
- parallel (1.21.0)
32
- parser (3.1.1.0)
43
+ minitest (5.16.3)
44
+ parallel (1.22.1)
45
+ parser (3.1.2.1)
33
46
  ast (~> 2.4.1)
34
- public_suffix (4.0.6)
47
+ prettier_print (1.1.0)
48
+ public_suffix (5.0.0)
35
49
  rainbow (3.1.1)
36
50
  rake (13.0.6)
37
- regexp_parser (2.2.1)
51
+ regexp_parser (2.6.0)
38
52
  rexml (3.2.5)
39
53
  rspec (3.11.0)
40
54
  rspec-core (~> 3.11.0)
@@ -45,37 +59,49 @@ GEM
45
59
  rspec-expectations (3.11.0)
46
60
  diff-lcs (>= 1.2.0, < 2.0)
47
61
  rspec-support (~> 3.11.0)
48
- rspec-mocks (3.11.0)
62
+ rspec-mocks (3.11.1)
49
63
  diff-lcs (>= 1.2.0, < 2.0)
50
64
  rspec-support (~> 3.11.0)
51
65
  rspec-support (3.11.0)
52
- rubocop (1.25.1)
66
+ rubocop (1.36.0)
67
+ json (~> 2.3)
53
68
  parallel (~> 1.10)
54
- parser (>= 3.1.0.0)
69
+ parser (>= 3.1.2.1)
55
70
  rainbow (>= 2.2.2, < 4.0)
56
71
  regexp_parser (>= 1.8, < 3.0)
57
- rexml
58
- rubocop-ast (>= 1.15.1, < 2.0)
72
+ rexml (>= 3.2.5, < 4.0)
73
+ rubocop-ast (>= 1.20.1, < 2.0)
59
74
  ruby-progressbar (~> 1.7)
60
75
  unicode-display_width (>= 1.4.0, < 3.0)
61
- rubocop-ast (1.16.0)
76
+ rubocop-ast (1.21.0)
62
77
  parser (>= 3.1.1.0)
63
- rubocop-shopify (2.4.0)
64
- rubocop (~> 1.24)
78
+ rubocop-shopify (2.10.1)
79
+ rubocop (~> 1.35)
80
+ ruby-lsp (0.3.6)
81
+ language_server-protocol (~> 3.17.0)
82
+ sorbet-runtime
83
+ syntax_tree (>= 4.0.2, < 5.0.0)
65
84
  ruby-progressbar (1.11.0)
85
+ sorbet-runtime (0.5.10564)
86
+ syntax_tree (4.3.0)
87
+ prettier_print (>= 1.0.2)
88
+ tzinfo (2.0.5)
89
+ concurrent-ruby (~> 1.0)
66
90
  unf (0.1.4)
67
91
  unf_ext
68
- unf_ext (0.0.8)
69
- unicode-display_width (2.1.0)
92
+ unf_ext (0.0.8.2)
93
+ unicode-display_width (2.3.0)
70
94
 
71
95
  PLATFORMS
72
- ruby
96
+ x86_64-linux
73
97
 
74
98
  DEPENDENCIES
99
+ byebug
75
100
  qismo!
76
- rake (~> 13.0)
101
+ rake
77
102
  rspec (~> 3.0)
78
- rubocop-shopify (~> 2.3)
103
+ rubocop-shopify
104
+ ruby-lsp
79
105
 
80
106
  BUNDLED WITH
81
- 2.1.4
107
+ 2.3.12
data/README.md CHANGED
@@ -1,120 +1,160 @@
1
1
  # Qismo Ruby
2
2
 
3
- A Ruby API wrapper for Qiscus Multichannel API
3
+ A Ruby API wrapper for Qiscus Omnichannel API
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem "qismo"
11
- ```
12
-
13
- And then execute:
7
+ Install the gem and add to the application's Gemfile by executing:
14
8
 
15
9
  ```bash
16
- bundle install
10
+ bundle add qismo
17
11
  ```
18
12
 
19
13
  ## Usage
20
14
 
21
- **Example for single app id**
15
+ ### Initialize and make request
16
+
17
+ To start using Qismo ruby, you must get your account's `App ID` and `Qiscus Secret Key` which can be checked in your admin dashboard's [settings page](https://omnichannel.qiscus.com/settings). After getting these data, you can start initialize the client.
22
18
 
23
19
  ```ruby
24
- # config/initializers/qismo.rb
25
- # Initialization
26
- Qismo.init do |config|
27
- config.app_id = ENV["QISCUS_APP_ID"]
28
- config.secret_key = ENV["QISCUS_SECRET_KEY"]
29
- config.base_url = ENV["QISCUS_MULTICHANNEL_BASE_URL"]
20
+ Qismo.configure do |client|
21
+ client.app_id = "YOU_ACCOUNT_APP_ID"
22
+ client.secret_key = "YOUR_ACCOUNT_SECRET_KEY"
23
+
24
+ ## Optional
25
+ client.url = "https://qismo.qiscus.com"
26
+ client.logger = { logger: Logger.new($stdout) }
27
+ client.instrumentation = { instrumenter: ActiveSupport::Notifications.instrumenter }
28
+ client.timeout = { connect: 5, write: 2, read: 5 }
29
+ client.proxy = ["proxy-hostname.local", 8080, "username", "password"]
30
30
  end
31
+ ```
31
32
 
32
- # Get all rooms that have been waiting for a week
33
- rooms = Room.where(status: "waiting")
34
- .where("created_at >= :a_week", a_week: 1.week.ago)
33
+ Then, start requesting to any endpoint yg want
35
34
 
36
- # Resolve the rooms
37
- rooms.each(Qismo::Room.resolve(&:id))
35
+ ```ruby
36
+ params = {
37
+ channel: { id: 12345, source: "wa" },
38
+ status: "unresolved",
39
+ serve_status: "served",
40
+ is_handled_by_bot: false,
41
+ }
42
+
43
+ rooms = Qismo.rooms(params)
38
44
  ```
39
45
 
40
- **Example for multi app id**
46
+ If your app manage multiple app id, you initialize the client like below
41
47
 
42
48
  ```ruby
43
- # Get all rooms that have been waiting for a week
44
- rooms = Room.includes(:qiscus_app)
45
- .where(status: "waiting")
46
- .where("created_at >= :a_week", a_week: 1.week.ago)
47
-
48
- # Resolve the rooms
49
- rooms.each do |room|
50
- Qismo.new(app_id: room.qiscus_app.app_id, secret_key: room.qiscus_app.secret_key)
51
- Qismo::Room.resolve(room.id)
52
- end
49
+ client = Qismo::Client.new(app_id: "YOUR_ACCOUNT_APP_ID", secret_key: "YOUR_ACCOUNT_SECRET_KEY")
50
+ ```
51
+
52
+ Then, start requesting to an endpoint using that `client` variable
53
+
54
+ ```ruby
55
+ params = {
56
+ channel: { id: 12345, source: "wa" },
57
+ status: "unresolved",
58
+ serve_status: "served",
59
+ is_handled_by_bot: false,
60
+ }
61
+
62
+ rooms = client.rooms(params)
53
63
  ```
54
64
 
55
- **Nested operations**
65
+ ### Client configuration
56
66
 
57
- If you prefer to use nested operations, you can also use this package like below
67
+ **url**
68
+
69
+ Defaultly, Qismo ruby will use your QISCUS_OMNICHANNEL_URL env as base url. If its nil, it will use https://qismo.qiscus.com. If you need to customize URL other than that, you can pass it at client initialization
58
70
 
59
71
  ```ruby
60
- client = Qismo.new(app_id: room.qiscus_app.app_id, secret_key: room.qiscus_app.secret_key)
61
- client.room.resolve(id)
72
+ client.url = "https://qismo.qiscus.com"
62
73
  ```
63
74
 
64
- **Requesting to unhandled API**
75
+ **logger**
65
76
 
66
- Qiscus Multichannel is on fast development mode and at some condition, you might find this library is not handle the new API. If that happen, you can use the operations like below:
77
+ You can also log the request and response the any HTTP request you make in Qismo ruby by using this configuration
67
78
 
68
79
  ```ruby
69
- Qismo.client.call("post", "/api/v2/api_endpoint", json: {}, params: {})
80
+ require "logger"
81
+
82
+ client.logger = Logger.new($stdout)
70
83
  ```
71
84
 
72
- **Error handling**
85
+ **instrumentation**
86
+
87
+ For advanced logging, you can also use laverage ActiveSupport instrumentation. If you are using Rails, you can use ActiveSupport without installing the gem by your self.
73
88
 
74
89
  ```ruby
75
- begin
76
- room = Qismo::Room.resolve(123456) # Not Found
77
- rescue Qismo::HTTPError => e
78
- e.message # return error message
79
- e.http_code # return response code
80
- e.http_headers # return response headers in hash
81
- e.http_body # return response body in hash or string
82
- e.http_raw_body # return raw response body in string
90
+ ActiveSupport::Notifications.subscribe('start_request.http') d |name, start, finish, id, payload|
91
+ pp :name => name, :start => start.to_f, :finish => finish.to_f, :id => id, :payload => payload
83
92
  end
93
+
94
+ client.instrumentation = { instrumenter: ActiveSupport::Notifications.instrumenter }client.instrumentation = { instrumenter: ActiveSupport::Notifications.instrumenter }client.instrumentation = { instrumenter: ActiveSupport::Notifications.instrumenter }
95
+ ```
96
+
97
+ You can also customize the instrumentation's namespace by using this configuration
98
+
99
+ ```ruby
100
+ client.instrumentation = { instrumenter: ActiveSupport::Notifications.instrumenter, namespace: "qiscus.http_request" }
84
101
  ```
85
102
 
86
- ## Experience
103
+ **timeout**
87
104
 
88
- This gem leverage YARD to improve text editor autocompletion
105
+ By default, the Qismo ruby gem does not enforce timeout on a request. You can enable per operation timeouts (each read/write/connect call) or global timeouts (sum of all read/write/connect calls) by configuring them through the chaining API.
89
106
 
90
- Install YARD
107
+ Per operation timeouts are what `Net::HTTP` and the majority of HTTP clients do:
91
108
 
92
- ```shell
93
- gem install yard
109
+ ```ruby
110
+ client.timeout = { connect: 5, write: 2, read: 10 }
94
111
  ```
95
112
 
96
- Change to project directory and expose gem YARD documentation
113
+ Global timeouts let you set an upper bound of how long a request can take
97
114
 
98
- ```shell
99
- yard gems
115
+ ```ruby
116
+ client.timeout = 5 # in seconds
100
117
  ```
101
118
 
102
- For VSCode users, you can use Solargraph gem to improve the autocompletion
119
+ **proxy**
120
+
121
+ Making request behind proxy is as simple as making them directly. Just specify hostname (or IP address) of your proxy server and its port, and here you go
122
+
123
+ ```ruby
124
+ client.proxy = ["proxy-hostname.local", 8080]
125
+ ```
103
126
 
104
- ## Development
127
+ Proxy needs authentication?
105
128
 
106
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
129
+ ```ruby
130
+ client.proxy = ["proxy-hostname.local", 8080, "username", "password"]
131
+ ```
107
132
 
108
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
133
+ ### Handling pagination
109
134
 
110
- ## Contributing
135
+ Some of the Qiscus Omnichannel API will return list of data with pagination. To handle the pagination, you can to that like this example:
111
136
 
112
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qismo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/qismo/blob/master/CODE_OF_CONDUCT.md).
137
+ ```ruby
138
+ all_rooms = []
139
+ rooms = client.rooms
140
+ all_rooms.append(rooms)
113
141
 
114
- ## License
142
+ while rooms.has_next_page?
143
+ rooms = rooms.next_page
144
+ all_rooms.append(rooms)
145
+ end
146
+ ```
115
147
 
116
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
148
+ ### Handling error
117
149
 
118
- ## Code of Conduct
150
+ Qismo ruby raise error while getting non successful http code from Qiscus Omnichannel API. To handle it, you follow this example:
119
151
 
120
- Everyone interacting in the Qismo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/qismo/blob/master/CODE_OF_CONDUCT.md).
152
+ ```ruby
153
+ begin
154
+ client.rooms
155
+ rescue Qismo::HTTPRequestError => e
156
+ e.message
157
+ e.status_code
158
+ e.response_body
159
+ end
160
+ ```
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/lib/qismo/api.rb ADDED
@@ -0,0 +1,202 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qismo
4
+ module Api
5
+ include Qismo::Model
6
+
7
+ def rooms(**opt)
8
+ body = post("/api/v2/customer_rooms", opt)
9
+ Collection.new(
10
+ body.data.customer_rooms,
11
+ prev_page: body.meta.cursor_before,
12
+ next_page: body.meta.cursor_after,
13
+ prev_func: -> do
14
+ if body.meta.cursor_before.nil? || body.meta.cursor_before.empty?
15
+ Collection.new([])
16
+ else
17
+ rooms(opt.merge(cursor_before: body.meta.cursor_before))
18
+ end
19
+ end,
20
+ next_func: -> do
21
+ if body.meta.cursor_after.nil? || body.meta.cursor_after.empty?
22
+ Collection.new([])
23
+ else
24
+ rooms(opt.merge(cursor_after: body.meta.cursor_after))
25
+ end
26
+ end,
27
+ )
28
+ end
29
+
30
+ def room(room_id)
31
+ body = get("/api/v2/customer_rooms/#{room_id}")
32
+ body.data.customer_room
33
+ end
34
+
35
+ def room_additional_info(room_id)
36
+ body = get("/api/v1/qiscus/room/#{room_id}/user_info")
37
+ body.data.extras.user_properties
38
+ end
39
+
40
+ def set_room_additional_info(room_id, *additional_info)
41
+ body = post("/api/v1/qiscus/room/#{room_id}/user_info", user_properties: additional_info)
42
+ body.data.extras.user_properties
43
+ end
44
+
45
+ def update_room_additional_info(room_id, *additional_info)
46
+ old_additional_info = room_additional_info(room_id)
47
+ new_additional_info = (additional_info + old_additional_info).uniq { |h| h.values_at("key") }
48
+ set_room_additional_info(room_id, *new_additional_info)
49
+ end
50
+
51
+ def room_broadcast_history(room_id, **opt)
52
+ body = get("/api/v2/customer_rooms/#{room_id}/broadcast_history", opt)
53
+ Collection.new(body.data.broadcast_logs, body.data.meta)
54
+ end
55
+
56
+ def assign_agent(room_id, agent_id, **opt)
57
+ body = post("/api/v1/admin/service/assign_agent", opt.merge(room_id: room_id.to_s, agent_id: agent_id))
58
+ body.data.added_agent
59
+ end
60
+
61
+ def remove_agent(room_id, agent_id)
62
+ post("/api/v1/admin/service/remove_agent", room_id: room_id.to_s, agent_id: agent_id)
63
+ true
64
+ end
65
+
66
+ def resolve(room_id, last_comment_id, **opt)
67
+ body = post("/api/v1/admin/service/mark_as_resolved",
68
+ opt.merge(room_id: room_id, last_comment_id: last_comment_id))
69
+ body.data.service
70
+ end
71
+
72
+ def allocate_agent(source, **opt)
73
+ body = post("/api/v1/admin/service/allocate_agent", opt.merge(source: source))
74
+ body.data.agent
75
+ end
76
+
77
+ def allocate_and_assign_agent(room_id, **opt)
78
+ body = post("/api/v1/admin/service/allocate_assign_agent", opt.merge(room_id: room_id))
79
+ body.data.agent
80
+ end
81
+
82
+ def other_agents(room_id, **opt)
83
+ body = get("/api/v2/admin/service/other_agents", opt.merge(room_id: room_id))
84
+ Collection.new(body.data.agents, body.meta)
85
+ end
86
+
87
+ def available_agents(room_id, **opt)
88
+ body = get("/api/v2/admin/service/available_agents", opt.merge(room_id: room_id))
89
+ Collection.new(body.data.agents, body.meta)
90
+ end
91
+
92
+ def new_session_webhook
93
+ get("/api/v2/app/config/new_session_webhook").data.configs
94
+ end
95
+
96
+ def set_new_session_webhook(url, **opt)
97
+ post("/api/v2/app/config/new_session_webhook", opt.merge(url: url)).data.configs
98
+ end
99
+
100
+ def auth_webhook
101
+ get("/api/v2/app/config/auth_webhook").data.configs
102
+ end
103
+
104
+ def set_auth_webhook(url, **opt)
105
+ post("/api/v2/app/config/auth_webhook", opt.merge(url: url)).data.configs
106
+ end
107
+
108
+ def resolve_webhook
109
+ get("/api/v1/app/webhook/mark_as_resolved").data
110
+ end
111
+
112
+ def set_resolve_webhook(url, **opt)
113
+ post("/api/v1/app/webhook/mark_as_resolved", opt.merge(url: url)).data
114
+ end
115
+
116
+ def agents(**opt)
117
+ body = get("/api/v2/admin/agents", opt)
118
+ [body.data.agents, body.meta]
119
+ end
120
+
121
+ def agents_by_ids(*ids)
122
+ get("/api/v1/admin/agents/get_by_ids", ids: ids).data
123
+ end
124
+
125
+ def agent_by_divisions(*division_ids, **opt)
126
+ get("/api/v2/admin/agents/by_division", opt.merge(division_ids: division_ids)).data
127
+ end
128
+
129
+ def agent(agent_id)
130
+ get("/api/v2/admin/agent/#{agent_id}").data.agent
131
+ end
132
+
133
+ def office_hours
134
+ get("/api/v1/admin/office_hours").data
135
+ end
136
+
137
+ def wa_broadcast_templates(**opt)
138
+ body = get("/api/v2/admin/hsm", opt)
139
+ [body.data.hsm_templates, body.meta]
140
+ end
141
+
142
+ def send_wa_outbound(**opt)
143
+ post("/api/v3/admin/broadcast/client", opt).data
144
+ end
145
+
146
+ def upload_wa_broadcast_csv(file, template_detail_id)
147
+ raise ArgumentError, "Invalid file" unless file.is_a?(HTTP::FormData::File)
148
+
149
+ post_upload("/api/v3/admin/broadcast/upload_csv", file: file, template_detail_id: template_detail_id)
150
+ end
151
+
152
+ def send_wa_broadcast(**opt)
153
+ post("/api/v3/admin/broadcast/send_broadcast", opt).data.broadcast_job
154
+ end
155
+
156
+ def wa_broadcast_jobs(**opt)
157
+ get("/api/v2/admin/broadcast_jobs", opt).data.broadcast_jobs
158
+ end
159
+
160
+ def wa_broadcast_job(broadcast_job_id)
161
+ get("/api/v2/admin/broadcast_jobs/#{broadcast_job_id}").data.broadcast_job
162
+ end
163
+
164
+ def wa_broadcast_logs(broadcast_job_id, **opt)
165
+ get("/api/v2/admin/broadcast_logs/#{broadcast_job_id}", opt).data.broadcast_logs
166
+ end
167
+
168
+ def send_bot_message(**opt)
169
+ post("#{app_id}/bot", opt)
170
+ true
171
+ end
172
+
173
+ def enable_chatbot_in_room(room_id)
174
+ post("/bot/#{room_id}/activate", is_active: true)
175
+ true
176
+ end
177
+
178
+ def disable_chatbot_in_room(room_id)
179
+ post("/bot/#{room_id}/activate", is_active: false)
180
+ true
181
+ end
182
+
183
+ def handover_room_from_bot(room_id)
184
+ post("/#{app_id}/bot/#{room_id}/hand_over")
185
+ true
186
+ end
187
+
188
+ def handover_room_from_bot_to_division(room_id, *roles, **opt)
189
+ post("/#{app_id}/bot/#{room_id}/hand_over_to_role", opt.merge(roles: roles))
190
+ true
191
+ end
192
+
193
+ def initiate_widget_chat(user_id, name, **opt)
194
+ post("/api/v2/qiscus/initiate_chat", opt.merge(user_id: user_id, name: name)).data.customer_room
195
+ end
196
+
197
+ def send_message_to_custom_channel(identifier_key, user_id, name, **opt)
198
+ post("/#{app_id}/api/v2/custom_channel/send",
199
+ opt.merge(identifier_key: identifier_key, user_id: user_id, name: name)).data
200
+ end
201
+ end
202
+ end