qismo 0.8.6 → 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: 39920707bba81e3df5853731180b02e10d694a4cbf793c6f64c7bfe169a6a9c2
4
- data.tar.gz: 4871ab5d1557e8ccd6c249354b4117da16779b5ecdcafb906641597a8ca39358
3
+ metadata.gz: 4e2ec0fd1f33602149f8bdee9c1f197470c9bac2f381460fd7ade574a3106941
4
+ data.tar.gz: c08c1226ba080a9b42c114cf4e742efca2dc57c69d629c9402561c0fcb302b9a
5
5
  SHA512:
6
- metadata.gz: 448f4ba83da3cc5adefebe4b893b1372f2b43e582fa7b3ee8cd6d1d4f8ff2e07fc43a0a27de438c80b30a2dc7f65e2e7af718ad61757c33111b22ff88d5c4af4
7
- data.tar.gz: 824b127bfbaad9e0f380f1765011cd76b626e7a957aa52a3845a25789a68860d23af2de435b3a543dab9428be052ffc49ada6710e088d30c6a6e998a774bf641
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/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.6"
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.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qiscus Integration