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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b7781b2ccc4ec1815ecb3cedd90a61ded7c84e0d564174a720dc7a7b7673528
4
- data.tar.gz: a6225b1ab73d4239c64374b5efead47d4a7aa34580766ef302450e18b05618ea
3
+ metadata.gz: 4e2ec0fd1f33602149f8bdee9c1f197470c9bac2f381460fd7ade574a3106941
4
+ data.tar.gz: c08c1226ba080a9b42c114cf4e742efca2dc57c69d629c9402561c0fcb302b9a
5
5
  SHA512:
6
- metadata.gz: b1766a77c3872a482f269ca69aedeb3c6c0384f2789732aef8dfeed670c74063ee24e7c36f53740160eb92379e37134c92a2b7b78c1061b32a467c31347151b3
7
- data.tar.gz: 12a8cdd291ede239d2749f719367837acfa269e8b4ad5b25536e19d174687f0fc9157e6fce5e03dffd6c58b1cbbc7e636b6ab4284c6958d8040302ed4c0fa87f
6
+ metadata.gz: 0e97d7caa322c1e60ad35316295fb1cf8107c3f9527abed5514e9ce83b20a1d141558356fe4fe825b259b849149402d71910a50d0e558dc358d581a8509c864d
7
+ data.tar.gz: 795bfb449d7d08bb654bdaee29486a29b654b98c69ad30fa736a3d1d12ecd8139a7776b96de07c651f371497d52f431837d86e010d6afd866a125399cc446172
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qismo (0.8.3)
4
+ qismo (0.8.6)
5
5
  activesupport
6
6
  http
7
7
 
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
- post("/api/v2/qiscus/initiate_chat", opt.merge(user_id: user_id, name: name)).data.customer_room
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
- VALID_OPTIONS = [:app_id, :secret_key, :url, :logger, :instrumentation, :timeout, :proxy]
8
-
9
- attr_accessor(*VALID_OPTIONS)
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
- @app_id = opt[:app_id] || ENV["QISCUS_APP_ID"]
13
- @secret_key = opt[:secret_key] || ENV["QISCUS_SECRET_KEY"]
14
- @url = opt[:url] || ENV["QISCUS_OMNICHANNEL_URL"] || "https://qismo.qiscus.com"
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
- method_name = key.to_s.delete_prefix("is_")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qismo
4
- VERSION = "0.8.5"
4
+ VERSION = "0.8.7"
5
5
  end
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
- Qismo::Client::VALID_OPTIONS.each do |opt|
22
- instance_variable_set("@#{opt}", client.send(opt))
23
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qismo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qiscus Integration