qismo 0.8.5 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qismo/api.rb +2 -1
- data/lib/qismo/client.rb +18 -10
- data/lib/qismo/model.rb +2 -9
- data/lib/qismo/util.rb +2 -0
- data/lib/qismo/version.rb +1 -1
- data/lib/qismo.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e2ec0fd1f33602149f8bdee9c1f197470c9bac2f381460fd7ade574a3106941
|
4
|
+
data.tar.gz: c08c1226ba080a9b42c114cf4e742efca2dc57c69d629c9402561c0fcb302b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e97d7caa322c1e60ad35316295fb1cf8107c3f9527abed5514e9ce83b20a1d141558356fe4fe825b259b849149402d71910a50d0e558dc358d581a8509c864d
|
7
|
+
data.tar.gz: 795bfb449d7d08bb654bdaee29486a29b654b98c69ad30fa736a3d1d12ecd8139a7776b96de07c651f371497d52f431837d86e010d6afd866a125399cc446172
|
data/Gemfile.lock
CHANGED
data/lib/qismo/api.rb
CHANGED
@@ -259,7 +259,8 @@ module Qismo
|
|
259
259
|
end
|
260
260
|
|
261
261
|
def initiate_widget_chat(user_id, name, **opt)
|
262
|
-
|
262
|
+
opt = opt.merge(app_id: app_id, user_id: user_id, name: name)
|
263
|
+
post("/api/v2/qiscus/initiate_chat", opt).data.customer_room
|
263
264
|
end
|
264
265
|
|
265
266
|
def send_message_to_custom_channel(identifier_key, user_id, name, **opt)
|
data/lib/qismo/client.rb
CHANGED
@@ -4,18 +4,26 @@ module Qismo
|
|
4
4
|
class Client
|
5
5
|
include Qismo::Api
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
DEFAULT_APP_ID = ENV["QISCUS_APP_ID"]
|
8
|
+
DEFAULT_SECRET_KEY = ENV["QISCUS_SECRET_KEY"]
|
9
|
+
DEFAULT_URL = ENV["QISCUS_OMNICHANNEL_URL"] || "https://qismo.qiscus.com"
|
10
|
+
|
11
|
+
DEFAULT_OPTIONS = {
|
12
|
+
app_id: DEFAULT_APP_ID,
|
13
|
+
secret_key: DEFAULT_SECRET_KEY,
|
14
|
+
url: DEFAULT_URL,
|
15
|
+
logger: nil,
|
16
|
+
instrumentation: nil,
|
17
|
+
timeout: nil,
|
18
|
+
proxy: nil,
|
19
|
+
}
|
20
|
+
|
21
|
+
attr_accessor(*DEFAULT_OPTIONS.keys)
|
10
22
|
|
11
23
|
def initialize(**opt)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@logger = opt[:logger]
|
16
|
-
@instrumentation = opt[:instrumentation]
|
17
|
-
@timeout = opt[:timeout]
|
18
|
-
@proxy = opt[:proxy]
|
24
|
+
DEFAULT_OPTIONS.merge(opt).each do |key, value|
|
25
|
+
instance_variable_set("@#{key}", value)
|
26
|
+
end
|
19
27
|
end
|
20
28
|
|
21
29
|
def post(path, body = {})
|
data/lib/qismo/model.rb
CHANGED
@@ -2,24 +2,17 @@
|
|
2
2
|
|
3
3
|
module Qismo
|
4
4
|
class DataObject
|
5
|
-
def initialize(opt
|
5
|
+
def initialize(**opt)
|
6
6
|
opt.each do |key, value|
|
7
7
|
value = if value.is_a?(Array)
|
8
8
|
handle_array(value)
|
9
|
-
# instance_variable_set("@#{key}", handle_array(value))
|
10
9
|
elsif value.is_a?(Hash)
|
11
10
|
self.class.new(value)
|
12
|
-
# instance_variable_set("@#{key}", self.class.new(value))
|
13
11
|
elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
14
|
-
|
15
|
-
method_name = "#{method_name}?".to_sym
|
16
|
-
|
17
|
-
self.class.define_method(method_name) { value }
|
18
|
-
|
12
|
+
self.class.define_method("#{key.to_s.delete_prefix("is_")}?".to_sym) { value }
|
19
13
|
value
|
20
14
|
else
|
21
15
|
value
|
22
|
-
# instance_variable_set("@#{key}", value)
|
23
16
|
end
|
24
17
|
|
25
18
|
self.class.attr_reader(key.to_sym)
|
data/lib/qismo/util.rb
CHANGED
@@ -15,8 +15,10 @@ module Qismo
|
|
15
15
|
start_hour = today_office_hour.starttime
|
16
16
|
end_hour = today_office_hour.endtime
|
17
17
|
|
18
|
+
# rubocop:disable Layout/LineLength
|
18
19
|
start_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{start_hour} #{data.timezone}")
|
19
20
|
end_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{end_hour} #{data.timezone}")
|
21
|
+
# rubocop:enable Layout/LineLength
|
20
22
|
|
21
23
|
tz_current.between?(start_time, end_time)
|
22
24
|
end
|
data/lib/qismo/version.rb
CHANGED
data/lib/qismo.rb
CHANGED
@@ -13,14 +13,14 @@ require "qismo/client"
|
|
13
13
|
# Qismo
|
14
14
|
module Qismo
|
15
15
|
class << self
|
16
|
-
attr_reader(*Qismo::Client::VALID_OPTIONS)
|
17
|
-
|
18
16
|
def configure
|
19
17
|
yield client
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
client
|
20
|
+
end
|
21
|
+
|
22
|
+
def new(**opt)
|
23
|
+
@client = Client.new(opt)
|
24
24
|
end
|
25
25
|
|
26
26
|
if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new("3.0.0")
|
@@ -41,6 +41,8 @@ module Qismo
|
|
41
41
|
Qismo::Client.instance_methods.include?(method_name)
|
42
42
|
end
|
43
43
|
|
44
|
+
private
|
45
|
+
|
44
46
|
def client
|
45
47
|
@client ||= Client.new
|
46
48
|
end
|