qismo 0.13.0 → 0.14.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/lib/qismo/api.rb +483 -262
- data/lib/qismo/client.rb +30 -19
- data/lib/qismo/collection.rb +19 -0
- data/lib/qismo/object.rb +19 -0
- data/lib/qismo/objectified_hash.rb +25 -0
- data/lib/qismo/objects/agent_service.rb +49 -0
- data/lib/qismo/objects/broadcast_job.rb +95 -0
- data/lib/qismo/objects/broadcast_log.rb +57 -0
- data/lib/qismo/objects/custom_channel_message_response.rb +17 -0
- data/lib/qismo/objects/customer_room.rb +83 -0
- data/lib/qismo/objects/hsm_template.rb +105 -0
- data/lib/qismo/objects/office_hour.rb +63 -0
- data/lib/qismo/objects/room_additional_info.rb +13 -0
- data/lib/qismo/objects/tag.rb +25 -0
- data/lib/qismo/objects/user.rb +93 -0
- data/lib/qismo/objects/wa_credit_info.rb +65 -0
- data/lib/qismo/objects/webhook.rb +13 -0
- data/lib/qismo/types.rb +1 -1
- data/lib/qismo/version.rb +1 -1
- data/lib/qismo/webhook_requests/on_agent_allocation_needed.rb +2 -2
- data/lib/qismo/webhook_requests/on_custom_button_clicked.rb +5 -5
- data/lib/qismo/webhook_requests/on_custom_channel_message_sent.rb +6 -6
- data/lib/qismo/webhook_requests/on_message_for_bot_sent.rb +6 -6
- data/lib/qismo/webhook_requests/on_new_session_initiated.rb +10 -10
- data/lib/qismo/webhook_requests/on_room_resolved.rb +5 -5
- data/lib/qismo.rb +17 -34
- data/qismo.gemspec +1 -0
- metadata +31 -6
- data/lib/qismo/model.rb +0 -102
- data/lib/qismo/models/base.rb +0 -13
- data/lib/qismo/models/customer_room.rb +0 -6
- data/lib/qismo/util.rb +0 -31
data/lib/qismo/model.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Qismo
|
4
|
-
# Class to handle http response body
|
5
|
-
#
|
6
|
-
class SingleObject
|
7
|
-
# Initiate data object
|
8
|
-
#
|
9
|
-
# @param options [Hash]
|
10
|
-
def initialize(options = {})
|
11
|
-
options.each do |key, value|
|
12
|
-
value = if value.is_a?(Array)
|
13
|
-
CollectionObject.new(handle_array(value))
|
14
|
-
elsif value.is_a?(Hash)
|
15
|
-
self.class.new(value)
|
16
|
-
elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
17
|
-
self.class.define_method("#{key.to_s.delete_prefix("is_")}?".to_sym) { value }
|
18
|
-
value
|
19
|
-
else
|
20
|
-
value
|
21
|
-
end
|
22
|
-
|
23
|
-
self.class.attr_reader(key.to_sym)
|
24
|
-
instance_variable_set("@#{key}", value)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
inspected_func ||= -> do
|
30
|
-
attributes = instance_variables.map do |iv|
|
31
|
-
"#{iv.to_s.delete_prefix("@")}=#{instance_variable_get(iv).inspect}"
|
32
|
-
end
|
33
|
-
|
34
|
-
"#<#{self.class.name} #{attributes.join(", ")}>"
|
35
|
-
end
|
36
|
-
|
37
|
-
inspected_func.call
|
38
|
-
end
|
39
|
-
|
40
|
-
alias_method :to_s, :inspect
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def handle_array(values)
|
45
|
-
values.map do |value|
|
46
|
-
if value.is_a?(Hash)
|
47
|
-
self.class.new(value)
|
48
|
-
else
|
49
|
-
value
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Class to handle response body that contain pagination
|
56
|
-
#
|
57
|
-
class CollectionObject < Array
|
58
|
-
# Initiate collection
|
59
|
-
#
|
60
|
-
# @param data [Qismo::SingleObject]
|
61
|
-
# @param prev_page [String, Integer]
|
62
|
-
# @param next_page [String, Integer]
|
63
|
-
# @param prev_func [Proc, NilClass]
|
64
|
-
# @param next_func [Proc, NilClass]
|
65
|
-
def initialize(data = [], prev_page: nil, next_page: nil, prev_func: -> {}, next_func: -> {})
|
66
|
-
super(data)
|
67
|
-
|
68
|
-
@prev_page = prev_page
|
69
|
-
@next_page = next_page
|
70
|
-
@prev_func = prev_func
|
71
|
-
@next_func = next_func
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [TrueClass, FalseClass]
|
75
|
-
def has_next_page?
|
76
|
-
@next_page != nil
|
77
|
-
end
|
78
|
-
|
79
|
-
alias_method :next_page?, :has_next_page?
|
80
|
-
|
81
|
-
# @return [TrueClass, FalseClass]
|
82
|
-
def has_prev_page?
|
83
|
-
@prev_page != nil
|
84
|
-
end
|
85
|
-
|
86
|
-
alias_method :prev_page?, :has_prev_page?
|
87
|
-
|
88
|
-
# Call api request for next page
|
89
|
-
#
|
90
|
-
# @return [Qismo::SingleObject, Qismo::CollectionObject]
|
91
|
-
def next_page
|
92
|
-
@next_func.call if has_next_page?
|
93
|
-
end
|
94
|
-
|
95
|
-
# Call api request for previous page
|
96
|
-
#
|
97
|
-
# @return [Qismo::SingleObject, Qismo::CollectionObject]
|
98
|
-
def prev_page
|
99
|
-
@prev_func.call if has_prev_page?
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
data/lib/qismo/models/base.rb
DELETED
data/lib/qismo/util.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Qismo
|
4
|
-
class Util
|
5
|
-
class << self
|
6
|
-
# Check if now is in office hour or not
|
7
|
-
#
|
8
|
-
# @param data [Qismo::SingleObject]
|
9
|
-
# @return [TrueClass, FalseClass]
|
10
|
-
def in_office_hour?(data)
|
11
|
-
return false if data.timezone.blank?
|
12
|
-
|
13
|
-
offset = Time.zone_offset(data.timezone)
|
14
|
-
tz_current = Time.current.getlocal(offset)
|
15
|
-
|
16
|
-
today_office_hour = data.office_hours.find { |oh| oh.day == tz_current.strftime("%u").to_i }
|
17
|
-
return false if today_office_hour.nil?
|
18
|
-
|
19
|
-
start_hour = today_office_hour.starttime
|
20
|
-
end_hour = today_office_hour.endtime
|
21
|
-
|
22
|
-
# rubocop:disable Layout/LineLength
|
23
|
-
start_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{start_hour} #{data.timezone}")
|
24
|
-
end_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{end_hour} #{data.timezone}")
|
25
|
-
# rubocop:enable Layout/LineLength
|
26
|
-
|
27
|
-
tz_current.between?(start_time, end_time)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|