qismo 0.12.1 → 0.13.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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +128 -28
- data/lib/qismo/api.rb +14 -2
- data/lib/qismo/client.rb +3 -0
- data/lib/qismo/models/base.rb +13 -0
- data/lib/qismo/models/customer_room.rb +6 -0
- data/lib/qismo/types.rb +10 -0
- data/lib/qismo/version.rb +1 -1
- data/lib/qismo/webhook_requests/on_agent_allocation_needed.rb +75 -0
- data/lib/qismo/webhook_requests/on_custom_button_clicked.rb +86 -0
- data/lib/qismo/webhook_requests/on_custom_channel_message_sent.rb +95 -0
- data/lib/qismo/webhook_requests/on_message_for_bot_sent.rb +95 -0
- data/lib/qismo/webhook_requests/on_new_session_initiated.rb +170 -0
- data/lib/qismo/webhook_requests/on_room_resolved.rb +81 -0
- data/lib/qismo.rb +15 -3
- data/qismo.gemspec +1 -0
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a661003cb31406d91ff9af0717d796b4bf4e425d395fa16304fb871f6174c3f
|
4
|
+
data.tar.gz: d46b28c74af1561c93f12d23e291fcc8d1e8a865f072f10ffacbc608a7eda1fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74ceea740b566d0e24c61929af9f2697ca8a1c961625853a6ee999f53d67cc6ddf4e0334e0b5f39e4856a243167ca1b39e94abf2347fa6ef242a7c399ffc21e
|
7
|
+
data.tar.gz: 55035df4c8ca13362e43b82e434c88389bc62d5aa7263fb5cb45031569a897b6d2dac2709bf29d9743061c52acd9ad95d1abcb85491f17a143f4235cd2d50835
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -12,57 +12,73 @@ bundle add qismo
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
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.
|
18
|
-
|
19
15
|
```ruby
|
16
|
+
# config/initializers/qismo.rb
|
17
|
+
|
20
18
|
Qismo.configure do |client|
|
21
|
-
client.app_id = "
|
22
|
-
client.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"]
|
19
|
+
client.app_id = ENV["QISCUS_APP_ID"]
|
20
|
+
client.secret_key = ENV["QISCUS_SECRET_KEY"]
|
30
21
|
end
|
31
22
|
```
|
32
23
|
|
33
|
-
Then, start requesting to
|
24
|
+
Then, start requesting to available endpoint
|
34
25
|
|
35
26
|
```ruby
|
36
27
|
params = {
|
37
|
-
channel: {
|
28
|
+
channel: { channel_id: 12345, source: "wa" },
|
38
29
|
status: "unresolved",
|
39
30
|
serve_status: "served",
|
40
|
-
is_handled_by_bot:
|
31
|
+
is_handled_by_bot: true,
|
41
32
|
}
|
42
33
|
|
34
|
+
# List rooms
|
43
35
|
rooms = Qismo.rooms(params)
|
44
|
-
```
|
45
36
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
puts rooms
|
38
|
+
# [
|
39
|
+
# #<Qismo::SingleObject
|
40
|
+
# channel_id=6171,
|
41
|
+
# contact_id=71716,
|
42
|
+
# id=181917,
|
43
|
+
# is_handled_by_bot=true,
|
44
|
+
# is_resolved=false,
|
45
|
+
# is_waiting=false,
|
46
|
+
# last_comment_sender="admin@qismo.com",
|
47
|
+
# last_comment_sender_type="system",
|
48
|
+
# last_comment_text="Agent joined this conversation",
|
49
|
+
# last_comment_timestamp="2022-12-09T04:25:55Z",
|
50
|
+
# last_customer_comment_text=nil,
|
51
|
+
# last_customer_timestamp="2022-11-28T09:03:08Z",
|
52
|
+
# name="Customer - Yogyakarta",
|
53
|
+
# room_badge="https://multichannel.qiscus.com/img/whatsapp_badge.svg",
|
54
|
+
# room_id="8191816171",
|
55
|
+
# room_type="individual",
|
56
|
+
# source="wa",
|
57
|
+
# user_avatar_url="https://multichannel.qiscus.com/img/default_avatar.svg",
|
58
|
+
# user_id="628155555711"
|
59
|
+
# >
|
60
|
+
# ]
|
50
61
|
```
|
51
62
|
|
52
|
-
|
63
|
+
## Multiple app id client initialization
|
53
64
|
|
54
65
|
```ruby
|
66
|
+
client = Qismo::Client.new(app_id: "QISCUS_APP_ID", secret_key: "QISCUS_SECRET_KEY")
|
67
|
+
|
55
68
|
params = {
|
56
|
-
channel: {
|
69
|
+
channel: { channel_id: 12345, source: "wa" },
|
57
70
|
status: "unresolved",
|
58
71
|
serve_status: "served",
|
59
|
-
is_handled_by_bot:
|
72
|
+
is_handled_by_bot: true,
|
60
73
|
}
|
61
74
|
|
62
|
-
|
75
|
+
# This will produce same result as explained before
|
76
|
+
client.rooms(params)
|
63
77
|
```
|
64
78
|
|
65
|
-
|
79
|
+
## Client optional configuration
|
80
|
+
|
81
|
+
Qismo ruby also provide some optional configuration that you can pass, they are:
|
66
82
|
|
67
83
|
**url**
|
68
84
|
|
@@ -130,7 +146,7 @@ Proxy needs authentication?
|
|
130
146
|
client.proxy = ["proxy-hostname.local", 8080, "username", "password"]
|
131
147
|
```
|
132
148
|
|
133
|
-
|
149
|
+
## Handling pagination
|
134
150
|
|
135
151
|
Some of the Qiscus Omnichannel API will return list of data with pagination. To handle the pagination, you can to that like this example:
|
136
152
|
|
@@ -145,7 +161,7 @@ while rooms.has_next_page?
|
|
145
161
|
end
|
146
162
|
```
|
147
163
|
|
148
|
-
|
164
|
+
## Handling error
|
149
165
|
|
150
166
|
Qismo ruby raise error while getting non successful http code from Qiscus Omnichannel API. To handle it, you follow this example:
|
151
167
|
|
@@ -158,3 +174,87 @@ rescue Qismo::HTTPRequestError => e
|
|
158
174
|
e.response_body
|
159
175
|
end
|
160
176
|
```
|
177
|
+
|
178
|
+
## Handle incoming webhook request
|
179
|
+
|
180
|
+
Qiscus Omnichannel provide webhooks that triggered from various action on your account. Qismo ruby gem provide convenient way to handle the request.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
class QiscusWebhooksController < ApplicationController
|
184
|
+
skip_before_action :verify_authenticity_token
|
185
|
+
|
186
|
+
def handle_agent_allocation_webhook
|
187
|
+
webhook = Qismo::WebhookRequests::OnAgentAllocationNeeded.new(JSON.parse(request.raw_body))
|
188
|
+
|
189
|
+
# Do any action you want using payload that has been objectified
|
190
|
+
if webhook.candidate_agent.present?
|
191
|
+
Qismo.assign_agent(
|
192
|
+
webhook.room_id,
|
193
|
+
webhook.candidate_agent.id
|
194
|
+
)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def handle_custom_button_webhook
|
199
|
+
webhook = Qismo::WebhookRequests::OnCustomButtonClicked.new(JSON.parse(request.raw_body))
|
200
|
+
|
201
|
+
# Do any action you want using payload that has been objectified. The
|
202
|
+
# following example assuming you want to create Zendesk ticket
|
203
|
+
# everytime your agent click custom button "Create Ticket". We are
|
204
|
+
# assuming, you have setup Zendesk ruby client
|
205
|
+
zendesk_ticket_subject = webhook.additional_info.find do |info|
|
206
|
+
info.key == "Zendesk Ticket Subject"
|
207
|
+
end
|
208
|
+
|
209
|
+
if zendesk_ticket_subject.present?
|
210
|
+
ZendeskAPI::Ticket.create!(
|
211
|
+
zendesk_client,
|
212
|
+
subject: zendesk_ticket_subject.value,
|
213
|
+
submitter_id: webhook.agent.email,
|
214
|
+
priority: "urgent"
|
215
|
+
)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def handle_custom_channel_webhook
|
220
|
+
webhook = Qismo::WebhookRequests::OnCustomChannelMessageSent.new(JSON.parse(request.raw_body))
|
221
|
+
|
222
|
+
# Do any action you want
|
223
|
+
# The following example assuming you want to reply customer's message from Twitter
|
224
|
+
# Assuming that you have installed and setup twitter ruby client
|
225
|
+
|
226
|
+
# Fetch customer from room participants
|
227
|
+
customer = webhook.payload.room.participants.find { |participant| participant.email.start_with?("twitter_customer_") }
|
228
|
+
if customer.present?
|
229
|
+
twitter_rest_client.create_direct_message(webhook.payload.rooms, webhook.payload.message.text)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def handle_bot_webhook
|
234
|
+
webhook = Qismo::WebhookRequests::OnMessageForBotSent.new(JSON.parse(request.raw_body))
|
235
|
+
|
236
|
+
# Do any action you want. The following example assuming you want to use
|
237
|
+
# Dialogflow as bot engine
|
238
|
+
|
239
|
+
# Detect intent for customer's message
|
240
|
+
response = dialogflow_client.detect_intent(
|
241
|
+
session: "session_#{webhook.payload.room.id}",
|
242
|
+
query_input: {
|
243
|
+
text: {
|
244
|
+
text: webhook.payload.message.text,
|
245
|
+
language_code: "en-US"
|
246
|
+
}
|
247
|
+
}
|
248
|
+
)
|
249
|
+
|
250
|
+
# Parse bot message which will be sent back to customer
|
251
|
+
bot_message = response.query_result.fulfillment_text
|
252
|
+
|
253
|
+
# Send message to Qismo room
|
254
|
+
Qismo.send_bot_message(
|
255
|
+
webhook.payload.room.id,
|
256
|
+
message: bot_message
|
257
|
+
)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
```
|
data/lib/qismo/api.rb
CHANGED
@@ -7,7 +7,18 @@ module Qismo
|
|
7
7
|
# List customer rooms
|
8
8
|
#
|
9
9
|
# @see https://s.id/list-customer-rooms
|
10
|
-
# @param
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [String] :status Filter by room status. Valid values are "resolved", "unresolved", "expired", or "almost_expired"
|
12
|
+
# @option options [String] :serve_status Filter by room serve status. Valid values are "served" or "unserved"
|
13
|
+
# @option options [Array<Hash>] :channels Filter by channels. Example: [{ source: "wa", channel_id: 716171 }]
|
14
|
+
# @option options [TrueClass,FalseClass] :is_handled_by_bot Filter by bot handling status
|
15
|
+
# @option options [String] :name Filter by customer name
|
16
|
+
# @option options [Integer] :limit Number of data returned in one page. Default is 50
|
17
|
+
# @option options [String] :order Order data by timestamp. Can be ordered "asc" or "desc". Default is "desc"
|
18
|
+
# @option options [String] :cursor_after Next page cursor. If you are on last page, the cursor returned will be nil
|
19
|
+
# @option options [String] :cursor_before Previous page cursor. If you are on first page, the cursor returned will be nil
|
20
|
+
# @option options [Array<Integer>] :tag_ids Filter by tags
|
21
|
+
# @option options [Array<Integer>] :user_ids Filter by agent who handled or assigned to the room
|
11
22
|
# @return [Qismo::CollectionObject]
|
12
23
|
def rooms(options = {})
|
13
24
|
body = post("/api/v2/customer_rooms", options)
|
@@ -463,7 +474,8 @@ module Qismo
|
|
463
474
|
# @see https://documenter.getpostman.com/view/8259884/TVsuCSeT#bb77c653-5daa-4e1c-a866-43bca7c494fc
|
464
475
|
# @param options [Hash]
|
465
476
|
# @return [TrueClass]
|
466
|
-
def send_bot_message(options = {})
|
477
|
+
def send_bot_message(room_id, options = {})
|
478
|
+
options = options.merge(room_id: room_id.to_s, sender_email: admin_email)
|
467
479
|
post("#{app_id}/bot", options)
|
468
480
|
true
|
469
481
|
end
|
data/lib/qismo/client.rb
CHANGED
@@ -25,6 +25,7 @@ module Qismo
|
|
25
25
|
}
|
26
26
|
|
27
27
|
attr_accessor(*DEFAULT_OPTIONS.keys)
|
28
|
+
attr_reader :admin_email
|
28
29
|
|
29
30
|
# Initialize client
|
30
31
|
#
|
@@ -33,6 +34,8 @@ module Qismo
|
|
33
34
|
DEFAULT_OPTIONS.merge(options).each do |key, value|
|
34
35
|
instance_variable_set("@#{key}", value)
|
35
36
|
end
|
37
|
+
|
38
|
+
@admin_email = "#{@app_id}_admin@qismo.com"
|
36
39
|
end
|
37
40
|
|
38
41
|
# Send http request with post method
|
data/lib/qismo/types.rb
ADDED
data/lib/qismo/version.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
class OnAgentAllocationNeeded < Qismo::Models::Base
|
4
|
+
# @!attribute [r] avatar_url
|
5
|
+
# @return [String]
|
6
|
+
# @!attribute [r] created_at
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] email
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute [r] force_offline
|
11
|
+
# @return [TrueClass,FalseClass]
|
12
|
+
# @!attribute [r] id
|
13
|
+
# @return [Integer]
|
14
|
+
# @!attribute [r] is_available
|
15
|
+
# @return [TrueClass,FalseClass]
|
16
|
+
# @!attribute [r] is_verified
|
17
|
+
# @return [TrueClass,FalseClass]
|
18
|
+
# @!attribute [r] last_login
|
19
|
+
# @return [String]
|
20
|
+
# @!attribute [r] name
|
21
|
+
# @return [String]
|
22
|
+
# @!attribute [r] sdk_email
|
23
|
+
# @return [String]
|
24
|
+
# @!attribute [r] sdk_key
|
25
|
+
# @return [String]
|
26
|
+
# @!attribute [r] updated_at
|
27
|
+
# @return [String]
|
28
|
+
class CandidateAgent < Qismo::Models::Base
|
29
|
+
attribute? :avatar_url, Types::String.optional
|
30
|
+
attribute? :created_at, Types::String.optional
|
31
|
+
attribute? :email, Types::String.optional
|
32
|
+
attribute? :force_offline, Types::Bool.optional
|
33
|
+
attribute? :id, Types::Int.optional
|
34
|
+
attribute? :is_available, Types::Bool.optional
|
35
|
+
attribute? :is_verified, Types::Bool.optional
|
36
|
+
attribute? :last_login, Types::String.optional
|
37
|
+
attribute? :name, Types::String.optional
|
38
|
+
attribute? :sdk_email, Types::String.optional
|
39
|
+
attribute? :sdk_key, Types::String.optional
|
40
|
+
attribute? :updated_at, Types::String.optional
|
41
|
+
end
|
42
|
+
|
43
|
+
# @!attribute [r] app_id
|
44
|
+
# @return [String]
|
45
|
+
# @!attribute [r] avatar_url
|
46
|
+
# @return [String]
|
47
|
+
# @!attribute [r] candidate_agent
|
48
|
+
# @return [CandidateAgent]
|
49
|
+
# @!attribute [r] email
|
50
|
+
# @return [String]
|
51
|
+
# @!attribute [r] extras
|
52
|
+
# @return [String]
|
53
|
+
# @!attribute [r] is_new_session
|
54
|
+
# @return [TrueClass,FalseClass]
|
55
|
+
# @!attribute [r] is_resolved
|
56
|
+
# @return [TrueClass,FalseClass]
|
57
|
+
# @!attribute [r] name
|
58
|
+
# @return [String]
|
59
|
+
# @!attribute [r] room_id
|
60
|
+
# @return [String]
|
61
|
+
# @!attribute [r] source
|
62
|
+
# @return [String]
|
63
|
+
attribute? :app_id, Types::String.optional
|
64
|
+
attribute? :avatar_url, Types::String.optional
|
65
|
+
attribute? :candidate_agent, CandidateAgent
|
66
|
+
attribute? :email, Types::String.optional
|
67
|
+
attribute? :extras, Types::String.optional
|
68
|
+
attribute? :is_new_session, Types::Bool.optional
|
69
|
+
attribute? :is_resolved, Types::Bool.optional
|
70
|
+
attribute? :name, Types::String.optional
|
71
|
+
attribute? :room_id, Types::String.optional
|
72
|
+
attribute? :source, Types::String.optional
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
# @!attribute [r] additional_info
|
4
|
+
# @return [Array<AdditionalInfo>]
|
5
|
+
# @!attribute [r] agent
|
6
|
+
# @return [Agent]
|
7
|
+
# @!attribute [r] channel_id
|
8
|
+
# @return [Integer]
|
9
|
+
# @!attribute [r] channel_name
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] channel_type
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute [r] customer
|
14
|
+
# @return [Customer]
|
15
|
+
# @!attribute [r] notes
|
16
|
+
# @return [String]
|
17
|
+
# @!attribute [r] room_id
|
18
|
+
# @return [Integer]
|
19
|
+
# @!attribute [r] tag
|
20
|
+
# @return [Array<Tag>]
|
21
|
+
class OnCustomButtonClicked < Qismo::Models::Base
|
22
|
+
# @!parse include Qismo::Models
|
23
|
+
|
24
|
+
# @!attribute [r] key
|
25
|
+
# @return [String]
|
26
|
+
# @!attribute [r] value
|
27
|
+
# @return [String,Integer,TrueClass,FalseClass]
|
28
|
+
class AdditionalInfo < Qismo::Models::Base
|
29
|
+
attribute? :key, Types::String.optional
|
30
|
+
attribute? :value, (Types::String.optional | Types::Int.optional | Types::Params::Bool.optional)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @!attribute [r] email
|
34
|
+
# @return [String]
|
35
|
+
# @!attribute [r] name
|
36
|
+
# @return [String]
|
37
|
+
# @!attribute [r] type
|
38
|
+
# @return [String]
|
39
|
+
class Agent < Qismo::Models::Base
|
40
|
+
attribute? :email, Types::String.optional
|
41
|
+
attribute? :name, Types::String.optional
|
42
|
+
attribute? :type, Types::String.optional
|
43
|
+
end
|
44
|
+
|
45
|
+
# @!attribute [r] avatar
|
46
|
+
# @return [String]
|
47
|
+
# @!attribute [r] name
|
48
|
+
# @return [String]
|
49
|
+
# @!attribute [r] user_id
|
50
|
+
# @return [String]
|
51
|
+
class Customer < Qismo::Models::Base
|
52
|
+
attribute? :avatar, Types::String.optional
|
53
|
+
attribute? :name, Types::String.optional
|
54
|
+
attribute? :user_id, Types::String.optional
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!attribute [r] id
|
58
|
+
# @return [Integer]
|
59
|
+
# @!attribute [r] name
|
60
|
+
# @return [String]
|
61
|
+
# @!attribute [r] created_at
|
62
|
+
# @return [String]
|
63
|
+
# @!attribute [r] updated_at
|
64
|
+
# @return [String]
|
65
|
+
# @!attribute [r] room_tag_created_at
|
66
|
+
# @return [String]
|
67
|
+
class Tag < Qismo::Models::Base
|
68
|
+
attribute? :id, Types::Int.optional
|
69
|
+
attribute? :name, Types::String.optional
|
70
|
+
attribute? :created_at, Types::String.optional
|
71
|
+
attribute? :updated_at, Types::String.optional
|
72
|
+
attribute? :room_tag_created, Types::String.optional
|
73
|
+
end
|
74
|
+
|
75
|
+
attribute? :additional_info, Types.Array(AdditionalInfo.optional).optional
|
76
|
+
attribute? :agent, Agent.optional
|
77
|
+
attribute? :channel_id, Types::Int.optional
|
78
|
+
attribute? :channel_name, Types::String.optional
|
79
|
+
attribute? :channel_type, Types::String.optional
|
80
|
+
attribute? :customer, Customer.optional
|
81
|
+
attribute? :notes, Types::String.optional
|
82
|
+
attribute? :room_id, Types::Int.optional
|
83
|
+
attribute? :tag, Types.Array(Tag.optional).optional
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
# @!attribute [r] payload
|
4
|
+
# @return [Payload]
|
5
|
+
class OnCustomChannelMessageSent < Qismo::Models::Base
|
6
|
+
# @!attribute [r] avatar_url
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] email
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute [r] id
|
11
|
+
# @return [Integer]
|
12
|
+
# @!attribute [r] name
|
13
|
+
# @return [String]
|
14
|
+
class From < Qismo::Models::Base
|
15
|
+
attribute? :avatar_url, Types::String.optional
|
16
|
+
attribute? :email, Types::String.optional
|
17
|
+
attribute? :id, Types::Int.optional
|
18
|
+
attribute? :name, Types::String.optional
|
19
|
+
end
|
20
|
+
|
21
|
+
# @!attribute [r] comment_before_id
|
22
|
+
# @return [Integer]
|
23
|
+
# @!attribute [r] created_at
|
24
|
+
# @return [String]
|
25
|
+
# @!attribute [r] id
|
26
|
+
# @return [Integer]
|
27
|
+
# @!attribute [r] payload
|
28
|
+
# @return [Hash]
|
29
|
+
# @!attribute [r] text
|
30
|
+
# @return [String]
|
31
|
+
# @!attribute [r] timestamp
|
32
|
+
# @return [String]
|
33
|
+
# @!attribute [r] type
|
34
|
+
# @return [String]
|
35
|
+
# @!attribute [r] unique_temp_id
|
36
|
+
# @return [String]
|
37
|
+
# @!attribute [r] unix_nano_timestamp
|
38
|
+
# @return [String]
|
39
|
+
# @!attribute [r] unix_timestamp
|
40
|
+
# @return [String]
|
41
|
+
class Message < Qismo::Models::Base
|
42
|
+
attribute? :comment_before_id, Types::Int.optional
|
43
|
+
attribute? :created_at, Types::String.optional
|
44
|
+
attribute? :id, Types::Int.optional
|
45
|
+
attribute? :payload, Types::Hash.optional
|
46
|
+
attribute? :text, Types::String.optional
|
47
|
+
attribute? :timestamp, Types::String.optional
|
48
|
+
attribute? :type, Types::String.optional
|
49
|
+
attribute? :unique_temp_id, Types::String.optional
|
50
|
+
attribute? :unix_nano_timestamp, Types::String.optional
|
51
|
+
attribute? :unix_timestamp, Types::String.optional
|
52
|
+
end
|
53
|
+
|
54
|
+
# @!attribute [r] email
|
55
|
+
# @return [String]
|
56
|
+
class Participant < Qismo::Models::Base
|
57
|
+
attribute? :email, Types::String.optional
|
58
|
+
end
|
59
|
+
|
60
|
+
# @!attribute [r] id
|
61
|
+
# @return [String]
|
62
|
+
# @!attribute [r] name
|
63
|
+
# @return [String]
|
64
|
+
# @!attribute [r] options
|
65
|
+
# @return [String]
|
66
|
+
# @!attribute [r] participants
|
67
|
+
# @return [Array<Participant>]
|
68
|
+
# @!attribute [r] room_avatar
|
69
|
+
# @return [String]
|
70
|
+
class Room < Qismo::Models::Base
|
71
|
+
attribute? :id, Types::String.optional
|
72
|
+
attribute? :name, Types::String.optional
|
73
|
+
attribute? :options, Types::String.optional
|
74
|
+
attribute? :participants, Types.Array(Participant.optional).optional
|
75
|
+
attribute? :room_avatar, Types::String.optional
|
76
|
+
end
|
77
|
+
|
78
|
+
# @!attribute [r] from
|
79
|
+
# @return [From]
|
80
|
+
# @!attribute [r] message
|
81
|
+
# @return [Message]
|
82
|
+
# @!attribute [r] room
|
83
|
+
# @return [Room]
|
84
|
+
# @!attribute [r] type
|
85
|
+
# @return [String]
|
86
|
+
class Payload < Qismo::Models::Base
|
87
|
+
attribute? :from, From.optional
|
88
|
+
attribute? :message, Message.optional
|
89
|
+
attribute? :room, Room.optional
|
90
|
+
end
|
91
|
+
|
92
|
+
attribute? :payload, Payload.optional
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
class OnMessageForBotSent < Qismo::Models::Base
|
4
|
+
# @!attribute [r] avatar_url
|
5
|
+
# @return [String]
|
6
|
+
# @!attribute [r] email
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute [r] id
|
9
|
+
# @return [Integer]
|
10
|
+
# @!attribute [r] name
|
11
|
+
# @return [String]
|
12
|
+
class From < Qismo::Models::Base
|
13
|
+
attribute? :avatar_url, Types::String.optional
|
14
|
+
attribute? :email, Types::String.optional
|
15
|
+
attribute? :id, Types::Int.optional
|
16
|
+
attribute? :name, Types::String.optional
|
17
|
+
end
|
18
|
+
|
19
|
+
# @!attribute [r] comment_before_id
|
20
|
+
# @return [Integer]
|
21
|
+
# @!attribute [r] created_at
|
22
|
+
# @return [String]
|
23
|
+
# @!attribute [r] id
|
24
|
+
# @return [Integer]
|
25
|
+
# @!attribute [r] payload
|
26
|
+
# @return [Hash]
|
27
|
+
# @!attribute [r] text
|
28
|
+
# @return [String]
|
29
|
+
# @!attribute [r] timestamp
|
30
|
+
# @return [String]
|
31
|
+
# @!attribute [r] type
|
32
|
+
# @return [String]
|
33
|
+
# @!attribute [r] unique_temp_id
|
34
|
+
# @return [String]
|
35
|
+
# @!attribute [r] unix_nano_timestamp
|
36
|
+
# @return [String]
|
37
|
+
# @!attribute [r] unix_timestamp
|
38
|
+
# @return [String]
|
39
|
+
class Message < Qismo::Models::Base
|
40
|
+
attribute? :comment_before_id, Types::Int.optional
|
41
|
+
attribute? :created_at, Types::String.optional
|
42
|
+
attribute? :id, Types::Int.optional
|
43
|
+
attribute? :payload, Types::Hash.optional
|
44
|
+
attribute? :text, Types::String.optional
|
45
|
+
attribute? :timestamp, Types::String.optional
|
46
|
+
attribute? :type, Types::String.optional
|
47
|
+
attribute? :unique_temp_id, Types::String.optional
|
48
|
+
attribute? :unix_nano_timestamp, Types::String.optional
|
49
|
+
attribute? :unix_timestamp, Types::String.optional
|
50
|
+
end
|
51
|
+
|
52
|
+
# @!attribute [r] email
|
53
|
+
# @return [String]
|
54
|
+
class Participant < Qismo::Models::Base
|
55
|
+
attribute? :email, Types::String.optional
|
56
|
+
end
|
57
|
+
|
58
|
+
# @!attribute [r] id
|
59
|
+
# @return [String]
|
60
|
+
# @!attribute [r] name
|
61
|
+
# @return [String]
|
62
|
+
# @!attribute [r] options
|
63
|
+
# @return [String]
|
64
|
+
# @!attribute [r] participants
|
65
|
+
# @return [Array<Participant>]
|
66
|
+
# @!attribute [r] room_avatar
|
67
|
+
# @return [String]
|
68
|
+
class Room < Qismo::Models::Base
|
69
|
+
attribute? :id, Types::String.optional
|
70
|
+
attribute? :name, Types::String.optional
|
71
|
+
attribute? :options, Types::String.optional
|
72
|
+
attribute? :participants, Types.Array(Participant.optional).optional
|
73
|
+
attribute? :room_avatar, Types::String.optional
|
74
|
+
end
|
75
|
+
|
76
|
+
# @!attribute [r] from
|
77
|
+
# @return [From]
|
78
|
+
# @!attribute [r] message
|
79
|
+
# @return [Message]
|
80
|
+
# @!attribute [r] room
|
81
|
+
# @return [Room]
|
82
|
+
# @!attribute [r] type
|
83
|
+
# @return [String]
|
84
|
+
class Payload < Qismo::Models::Base
|
85
|
+
attribute? :from, From.optional
|
86
|
+
attribute? :message, Message.optional
|
87
|
+
attribute? :room, Room.optional
|
88
|
+
end
|
89
|
+
|
90
|
+
# @!attribute [r] payload
|
91
|
+
# @return [Payload]
|
92
|
+
attribute? :payload, Payload.optional
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
# @!attribute [r] is_new_session
|
4
|
+
# @return [TrueClass,FalseClass]
|
5
|
+
# @!attribute [r] payload
|
6
|
+
# @return [Payload]
|
7
|
+
# @!attribute [r] room_log
|
8
|
+
# @return [RoomLog]
|
9
|
+
class OnNewSessionInitiated < Qismo::Models::Base
|
10
|
+
# @!attribute [r] avatar_url
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [r] email
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute [r] id
|
15
|
+
# @return [Integer]
|
16
|
+
# @!attribute [r] name
|
17
|
+
# @return [String]
|
18
|
+
class From < Qismo::Models::Base
|
19
|
+
attribute? :avatar_url, Types::String.optional
|
20
|
+
attribute? :email, Types::String.optional
|
21
|
+
attribute? :id, Types::Int.optional
|
22
|
+
attribute? :name, Types::String.optional
|
23
|
+
end
|
24
|
+
|
25
|
+
# @!attribute [r] comment_before_id
|
26
|
+
# @return [Integer]
|
27
|
+
# @!attribute [r] created_at
|
28
|
+
# @return [String]
|
29
|
+
# @!attribute [r] id
|
30
|
+
# @return [Integer]
|
31
|
+
# @!attribute [r] payload
|
32
|
+
# @return [Hash]
|
33
|
+
# @!attribute [r] text
|
34
|
+
# @return [String]
|
35
|
+
# @!attribute [r] timestamp
|
36
|
+
# @return [String]
|
37
|
+
# @!attribute [r] type
|
38
|
+
# @return [String]
|
39
|
+
# @!attribute [r] unique_temp_id
|
40
|
+
# @return [String]
|
41
|
+
# @!attribute [r] unix_nano_timestamp
|
42
|
+
# @return [String]
|
43
|
+
# @!attribute [r] unix_timestamp
|
44
|
+
# @return [String]
|
45
|
+
class Message < Qismo::Models::Base
|
46
|
+
attribute? :comment_before_id, Types::Int.optional
|
47
|
+
attribute? :created_at, Types::String.optional
|
48
|
+
attribute? :id, Types::Int.optional
|
49
|
+
attribute? :payload, Types::Hash.optional
|
50
|
+
attribute? :text, Types::String.optional
|
51
|
+
attribute? :timestamp, Types::String.optional
|
52
|
+
attribute? :type, Types::String.optional
|
53
|
+
attribute? :unique_temp_id, Types::String.optional
|
54
|
+
attribute? :unix_nano_timestamp, Types::String.optional
|
55
|
+
attribute? :unix_timestamp, Types::String.optional
|
56
|
+
end
|
57
|
+
|
58
|
+
# @!attribute [r] email
|
59
|
+
# @return [String]
|
60
|
+
class Participant < Qismo::Models::Base
|
61
|
+
attribute? :email, Types::String.optional
|
62
|
+
end
|
63
|
+
|
64
|
+
# @!attribute [r] id
|
65
|
+
# @return [String]
|
66
|
+
# @!attribute [r] name
|
67
|
+
# @return [String]
|
68
|
+
# @!attribute [r] options
|
69
|
+
# @return [String]
|
70
|
+
# @!attribute [r] participants
|
71
|
+
# @return [Array<Participant>]
|
72
|
+
# @!attribute [r] room_avatar
|
73
|
+
# @return [String]
|
74
|
+
class Room < Qismo::Models::Base
|
75
|
+
attribute? :id, Types::String.optional
|
76
|
+
attribute? :name, Types::String.optional
|
77
|
+
attribute? :options, Types::String.optional
|
78
|
+
attribute? :participants, Types.Array(Participant.optional).optional
|
79
|
+
attribute? :room_avatar, Types::String.optional
|
80
|
+
end
|
81
|
+
|
82
|
+
# @!attribute [r] from
|
83
|
+
# @return [From]
|
84
|
+
# @!attribute [r] message
|
85
|
+
# @return [Message]
|
86
|
+
# @!attribute [r] room
|
87
|
+
# @return [Room]
|
88
|
+
# @!attribute [r] type
|
89
|
+
# @return [String]
|
90
|
+
class Payload < Qismo::Models::Base
|
91
|
+
attribute? :from, From.optional
|
92
|
+
attribute? :message, Message.optional
|
93
|
+
attribute? :room, Room.optional
|
94
|
+
end
|
95
|
+
|
96
|
+
# @!attribute [r] key
|
97
|
+
# @return [String]
|
98
|
+
# @!attribute [r] value
|
99
|
+
# @return [String,Integer,TrueClass,FalseClass]
|
100
|
+
class UserProperty < Qismo::Models::Base
|
101
|
+
attribute? :key, Types::String.optional
|
102
|
+
attribute? :value, (Types::String.optional | Types::Int.optional | Types::Params::Bool.optional)
|
103
|
+
end
|
104
|
+
|
105
|
+
# @!attribute [r] timezone_offset
|
106
|
+
# @return [String]
|
107
|
+
class AdditionalExtras < Qismo::Models::Base
|
108
|
+
attribute? :timezone_offset, Types::String
|
109
|
+
end
|
110
|
+
|
111
|
+
# @!attribute [r] additional_extras
|
112
|
+
# @return [AdditionalExtras]
|
113
|
+
# @!attribute [r] notes
|
114
|
+
# @return [String]
|
115
|
+
# @!attribute [r] timezone_offset
|
116
|
+
# @return [String]
|
117
|
+
# @!attribute [r] user_properties
|
118
|
+
# @return [Array<UserProperty>]
|
119
|
+
class Extras < Qismo::Models::Base
|
120
|
+
attribute? :additional_extras, AdditionalExtras.optional
|
121
|
+
attribute? :notes, Types::String
|
122
|
+
attribute? :timezone_offset, Types::String
|
123
|
+
attribute? :user_properties, Types.Array(UserProperty.optional).optional
|
124
|
+
end
|
125
|
+
|
126
|
+
# @!attribute [r] channel_id
|
127
|
+
# @return [Integer]
|
128
|
+
# @!attribute [r] created_at
|
129
|
+
# @return [String]
|
130
|
+
# @!attribute [r] extras
|
131
|
+
# @return [String]
|
132
|
+
# @!attribute [r] has_no_message
|
133
|
+
# @return [TrueClass,FalseClass]
|
134
|
+
# @!attribute [r] is_waiting
|
135
|
+
# @return [TrueClass,FalseClass]
|
136
|
+
# @!attribute [r] name
|
137
|
+
# @return [String]
|
138
|
+
# @!attribute [r] resolved
|
139
|
+
# @return [TrueClass,FalseClass]
|
140
|
+
# @!attribute [r] room_badge
|
141
|
+
# @return [String]
|
142
|
+
# @!attribute [r] room_id
|
143
|
+
# @return [String]
|
144
|
+
# @!attribute [r] source
|
145
|
+
# @return [String]
|
146
|
+
# @!attribute [r] user_avatar_url
|
147
|
+
# @return [String]
|
148
|
+
# @!attribute [r] user_id
|
149
|
+
# @return [String]
|
150
|
+
class RoomLog < Qismo::Models::Base
|
151
|
+
attribute? :channel_id, Types::Int
|
152
|
+
attribute? :created_at, Types::String
|
153
|
+
attribute? :extras, Extras
|
154
|
+
attribute? :has_no_message, Types::Bool
|
155
|
+
attribute? :is_waiting, Types::Nil
|
156
|
+
attribute? :name, Types::String
|
157
|
+
attribute? :resolved, Types::Bool
|
158
|
+
attribute? :room_badge, Types::String
|
159
|
+
attribute? :room_id, Types::String
|
160
|
+
attribute? :source, Types::String
|
161
|
+
attribute? :user_avatar_url, Types::String
|
162
|
+
attribute? :user_id, Types::String
|
163
|
+
end
|
164
|
+
|
165
|
+
attribute? :is_new_session, Types::Bool
|
166
|
+
attribute? :payload, Payload
|
167
|
+
attribute? :room_log, RoomLog
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Qismo
|
2
|
+
module WebhookRequests
|
3
|
+
# @!attribute [r] customer
|
4
|
+
# @return [Customer]
|
5
|
+
# @!attribute [r] resolved_by
|
6
|
+
# @return [ResolvedBy]
|
7
|
+
# @!attribute [r] service
|
8
|
+
# @return [Service]
|
9
|
+
class OnRoomResolved < Qismo::Models::Base
|
10
|
+
# @!attribute [r] key
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [r] value
|
13
|
+
# @return [String,Integer,TrueClass,FalseClass]
|
14
|
+
class AdditionalInfo < Qismo::Models::Base
|
15
|
+
attribute? :key, Types::String.optional
|
16
|
+
attribute? :value, (Types::String.optional | Types::Int.optional | Types::Params::Bool.optional)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @!attribute [r] additional_info
|
20
|
+
# @return [Array<AdditionalInfo>]
|
21
|
+
# @!attribute [r] avatar
|
22
|
+
# @return [String]
|
23
|
+
# @!attribute [r] name
|
24
|
+
# @return [String]
|
25
|
+
# @!attribute [r] user_id
|
26
|
+
# @return [String]
|
27
|
+
class Customer < Qismo::Models::Base
|
28
|
+
attribute? :additional_info, Types.Array(AdditionalInfo.optional).optional
|
29
|
+
attribute? :avatar, Types::String.optional
|
30
|
+
attribute? :name, Types::String.optional
|
31
|
+
attribute? :user_id, Types::String.optional
|
32
|
+
end
|
33
|
+
|
34
|
+
# @!attribute [r] email
|
35
|
+
# @return [String]
|
36
|
+
# @!attribute [r] id
|
37
|
+
# @return [Integer]
|
38
|
+
# @!attribute [r] is_available
|
39
|
+
# @return [TrueClass,FalseClass]
|
40
|
+
# @!attribute [r] name
|
41
|
+
# @return [String]
|
42
|
+
# @!attribute [r] type
|
43
|
+
# @return [String]
|
44
|
+
class ResolvedBy < Qismo::Models::Base
|
45
|
+
attribute? :email, Types::String.optional
|
46
|
+
attribute? :id, Types::Int.optional
|
47
|
+
attribute? :is_available, Types::Bool.optional
|
48
|
+
attribute? :name, Types::String.optional
|
49
|
+
attribute? :type, Types::String.optional
|
50
|
+
end
|
51
|
+
|
52
|
+
# @!attribute [r] first_comment_id
|
53
|
+
# @return [String]
|
54
|
+
# @!attribute [r] last_comment_id
|
55
|
+
# @return [String]
|
56
|
+
# @!attribute [r] id
|
57
|
+
# @return [Integer]
|
58
|
+
# @!attribute [r] is_resolved
|
59
|
+
# @return [TrueClass,FalseClass]
|
60
|
+
# @!attribute [r] notes
|
61
|
+
# @return [String]
|
62
|
+
# @!attribute [r] room_id
|
63
|
+
# @return [String]
|
64
|
+
# @!attribute [r] source
|
65
|
+
# @return [String]
|
66
|
+
class Service < Qismo::Models::Base
|
67
|
+
attribute? :first_comment_id, Types::String.optional
|
68
|
+
attribute? :last_comment_id, Types::String.optional
|
69
|
+
attribute? :id, Types::Int.optional
|
70
|
+
attribute? :is_resolved, Types::Bool.optional
|
71
|
+
attribute? :notes, Types::String.optional
|
72
|
+
attribute? :room_id, Types::String.optional
|
73
|
+
attribute? :source, Types::String.optional
|
74
|
+
end
|
75
|
+
|
76
|
+
attribute? :customer, Customer
|
77
|
+
attribute? :resolved_by, ResolvedBy
|
78
|
+
attribute? :service, Service
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/qismo.rb
CHANGED
@@ -1,19 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/all"
|
4
|
+
require "dry-struct"
|
4
5
|
require "http"
|
5
6
|
|
6
|
-
require "qismo/util"
|
7
7
|
require "qismo/version"
|
8
|
+
require "qismo/types"
|
9
|
+
require "qismo/util"
|
10
|
+
|
11
|
+
require "qismo/models/base"
|
12
|
+
|
13
|
+
require "qismo/webhook_requests/on_agent_allocation_needed"
|
14
|
+
require "qismo/webhook_requests/on_custom_button_clicked"
|
15
|
+
require "qismo/webhook_requests/on_custom_channel_message_sent"
|
16
|
+
require "qismo/webhook_requests/on_message_for_bot_sent"
|
17
|
+
require "qismo/webhook_requests/on_new_session_initiated"
|
18
|
+
require "qismo/webhook_requests/on_room_resolved"
|
19
|
+
|
8
20
|
require "qismo/error"
|
9
21
|
require "qismo/model"
|
10
22
|
require "qismo/api"
|
11
23
|
require "qismo/client"
|
12
24
|
|
13
25
|
module Qismo
|
14
|
-
# @!parse extend Qismo::Api
|
15
|
-
|
16
26
|
class << self
|
27
|
+
# @!parse extend Qismo::Api
|
28
|
+
|
17
29
|
def configure
|
18
30
|
yield client
|
19
31
|
|
data/qismo.gemspec
CHANGED
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.13.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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-struct
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
41
55
|
description: Ruby wrapper for Qiscus Omnichannel public API
|
42
56
|
email:
|
43
57
|
- developer@qiscus.net
|
@@ -53,8 +67,17 @@ files:
|
|
53
67
|
- lib/qismo/client.rb
|
54
68
|
- lib/qismo/error.rb
|
55
69
|
- lib/qismo/model.rb
|
70
|
+
- lib/qismo/models/base.rb
|
71
|
+
- lib/qismo/models/customer_room.rb
|
72
|
+
- lib/qismo/types.rb
|
56
73
|
- lib/qismo/util.rb
|
57
74
|
- lib/qismo/version.rb
|
75
|
+
- lib/qismo/webhook_requests/on_agent_allocation_needed.rb
|
76
|
+
- lib/qismo/webhook_requests/on_custom_button_clicked.rb
|
77
|
+
- lib/qismo/webhook_requests/on_custom_channel_message_sent.rb
|
78
|
+
- lib/qismo/webhook_requests/on_message_for_bot_sent.rb
|
79
|
+
- lib/qismo/webhook_requests/on_new_session_initiated.rb
|
80
|
+
- lib/qismo/webhook_requests/on_room_resolved.rb
|
58
81
|
- qismo.gemspec
|
59
82
|
homepage: https://bitbucket.org/qiscus/qismo-rb
|
60
83
|
licenses:
|