onesignal 5.13.0 → 5.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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/docs/BasicNotification.md +5 -1
- data/docs/BasicNotificationAllOf.md +5 -1
- data/docs/EmailWarmUp.md +24 -0
- data/docs/EmailWarmUpRequest.md +20 -0
- data/docs/EmailWarmUpStage.md +24 -0
- data/docs/Notification.md +5 -1
- data/docs/NotificationWithMeta.md +5 -1
- data/docs/NotificationWithMetaAllOf.md +3 -1
- data/lib/onesignal/api_client.rb +1 -1
- data/lib/onesignal/models/basic_notification.rb +35 -2
- data/lib/onesignal/models/basic_notification_all_of.rb +35 -2
- data/lib/onesignal/models/email_warm_up.rb +298 -0
- data/lib/onesignal/models/email_warm_up_request.rb +272 -0
- data/lib/onesignal/models/email_warm_up_stage.rb +284 -0
- data/lib/onesignal/models/notification.rb +35 -2
- data/lib/onesignal/models/notification_with_meta.rb +34 -2
- data/lib/onesignal/models/notification_with_meta_all_of.rb +14 -5
- data/lib/onesignal/version.rb +1 -1
- data/lib/onesignal.rb +3 -0
- data/spec/models/basic_notification_all_of_spec.rb +16 -0
- data/spec/models/basic_notification_spec.rb +16 -0
- data/spec/models/email_warm_up_request_spec.rb +43 -0
- data/spec/models/email_warm_up_spec.rb +59 -0
- data/spec/models/email_warm_up_stage_spec.rb +51 -0
- data/spec/models/notification_spec.rb +16 -0
- data/spec/models/notification_with_meta_all_of_spec.rb +6 -0
- data/spec/models/notification_with_meta_spec.rb +16 -0
- metadata +14 -2
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#OneSignal
|
|
3
|
+
|
|
4
|
+
#A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
|
5
|
+
|
|
6
|
+
Contact: devrel@onesignal.com
|
|
7
|
+
Generated by: https://openapi-generator.tech
|
|
8
|
+
OpenAPI Generator version: 6.0.0-SNAPSHOT
|
|
9
|
+
|
|
10
|
+
=end
|
|
11
|
+
|
|
12
|
+
require 'date'
|
|
13
|
+
require 'time'
|
|
14
|
+
|
|
15
|
+
module OneSignal
|
|
16
|
+
# Channel: Email Present only when this notification's `kind` is \"warmup\". The Auto Warm Up campaign's stage schedule, scheduling strategy, and live status.
|
|
17
|
+
class EmailWarmUp
|
|
18
|
+
# The campaign's sending schedule, stage by stage.
|
|
19
|
+
attr_accessor :stages
|
|
20
|
+
|
|
21
|
+
# How the stage schedule was produced: * `recommended` - OneSignal generated (and may still adjust) the schedule based on past delivery volumes, scheduled Auto Warm Up emails, and the size of the current audience. * `custom` - The stages were provided as-is in the create request.
|
|
22
|
+
attr_accessor :strategy
|
|
23
|
+
|
|
24
|
+
# Current status of the campaign: * `initializing` - The stages have been submitted and the schedule is being set up. * `draft` - The campaign has been created but has not started sending. * `active` - The campaign is currently working through its stages. * `finished` - All stages have completed. * `canceled` - The campaign was canceled before finishing.
|
|
25
|
+
attr_accessor :status
|
|
26
|
+
|
|
27
|
+
# Whether the campaign is currently live (actively sending).
|
|
28
|
+
attr_accessor :is_live
|
|
29
|
+
|
|
30
|
+
class EnumAttributeValidator
|
|
31
|
+
attr_reader :datatype
|
|
32
|
+
attr_reader :allowable_values
|
|
33
|
+
|
|
34
|
+
def initialize(datatype, allowable_values)
|
|
35
|
+
@allowable_values = allowable_values.map do |value|
|
|
36
|
+
case datatype.to_s
|
|
37
|
+
when /Integer/i
|
|
38
|
+
value.to_i
|
|
39
|
+
when /Float/i
|
|
40
|
+
value.to_f
|
|
41
|
+
else
|
|
42
|
+
value
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def valid?(value)
|
|
48
|
+
!value || allowable_values.include?(value)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
53
|
+
def self.attribute_map
|
|
54
|
+
{
|
|
55
|
+
:'stages' => :'stages',
|
|
56
|
+
:'strategy' => :'strategy',
|
|
57
|
+
:'status' => :'status',
|
|
58
|
+
:'is_live' => :'is_live'
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Returns all the JSON keys this model knows about
|
|
63
|
+
def self.acceptable_attributes
|
|
64
|
+
attribute_map.values
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Attribute type mapping.
|
|
68
|
+
def self.openapi_types
|
|
69
|
+
{
|
|
70
|
+
:'stages' => :'Array<EmailWarmUpStage>',
|
|
71
|
+
:'strategy' => :'String',
|
|
72
|
+
:'status' => :'String',
|
|
73
|
+
:'is_live' => :'Boolean'
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# List of attributes with nullable: true
|
|
78
|
+
def self.openapi_nullable
|
|
79
|
+
Set.new([
|
|
80
|
+
])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Initializes the object
|
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
85
|
+
def initialize(attributes = {})
|
|
86
|
+
if (!attributes.is_a?(Hash))
|
|
87
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailWarmUp` initialize method"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
91
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
92
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
93
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailWarmUp`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
94
|
+
end
|
|
95
|
+
h[k.to_sym] = v
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if attributes.key?(:'stages')
|
|
99
|
+
if (value = attributes[:'stages']).is_a?(Array)
|
|
100
|
+
self.stages = value
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if attributes.key?(:'strategy')
|
|
105
|
+
self.strategy = attributes[:'strategy']
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
if attributes.key?(:'status')
|
|
109
|
+
self.status = attributes[:'status']
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if attributes.key?(:'is_live')
|
|
113
|
+
self.is_live = attributes[:'is_live']
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
118
|
+
# @return Array for valid properties with the reasons
|
|
119
|
+
def list_invalid_properties
|
|
120
|
+
invalid_properties = Array.new
|
|
121
|
+
invalid_properties
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Check to see if the all the properties in the model are valid
|
|
125
|
+
# @return true if the model is valid
|
|
126
|
+
def valid?
|
|
127
|
+
strategy_validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
|
|
128
|
+
return false unless strategy_validator.valid?(@strategy)
|
|
129
|
+
status_validator = EnumAttributeValidator.new('String', ["initializing", "draft", "active", "finished", "canceled"])
|
|
130
|
+
return false unless status_validator.valid?(@status)
|
|
131
|
+
true
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
135
|
+
# @param [Object] strategy Object to be assigned
|
|
136
|
+
def strategy=(strategy)
|
|
137
|
+
validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
|
|
138
|
+
unless validator.valid?(strategy)
|
|
139
|
+
fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}."
|
|
140
|
+
end
|
|
141
|
+
@strategy = strategy
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
145
|
+
# @param [Object] status Object to be assigned
|
|
146
|
+
def status=(status)
|
|
147
|
+
validator = EnumAttributeValidator.new('String', ["initializing", "draft", "active", "finished", "canceled"])
|
|
148
|
+
unless validator.valid?(status)
|
|
149
|
+
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
|
150
|
+
end
|
|
151
|
+
@status = status
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Checks equality by comparing each attribute.
|
|
155
|
+
# @param [Object] Object to be compared
|
|
156
|
+
def ==(o)
|
|
157
|
+
return true if self.equal?(o)
|
|
158
|
+
self.class == o.class &&
|
|
159
|
+
stages == o.stages &&
|
|
160
|
+
strategy == o.strategy &&
|
|
161
|
+
status == o.status &&
|
|
162
|
+
is_live == o.is_live
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# @see the `==` method
|
|
166
|
+
# @param [Object] Object to be compared
|
|
167
|
+
def eql?(o)
|
|
168
|
+
self == o
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Calculates hash code according to all attributes.
|
|
172
|
+
# @return [Integer] Hash code
|
|
173
|
+
def hash
|
|
174
|
+
[stages, strategy, status, is_live].hash
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Builds the object from hash
|
|
178
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
179
|
+
# @return [Object] Returns the model itself
|
|
180
|
+
def self.build_from_hash(attributes)
|
|
181
|
+
new.build_from_hash(attributes)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Builds the object from hash
|
|
185
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
186
|
+
# @return [Object] Returns the model itself
|
|
187
|
+
def build_from_hash(attributes)
|
|
188
|
+
return nil unless attributes.is_a?(Hash)
|
|
189
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
190
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
191
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
192
|
+
self.send("#{key}=", nil)
|
|
193
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
194
|
+
# check to ensure the input is an array given that the attribute
|
|
195
|
+
# is documented as an array but the input is not
|
|
196
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
197
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
198
|
+
end
|
|
199
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
200
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
self
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Deserializes the data based on type
|
|
208
|
+
# @param string type Data type
|
|
209
|
+
# @param string value Value to be deserialized
|
|
210
|
+
# @return [Object] Deserialized data
|
|
211
|
+
def _deserialize(type, value)
|
|
212
|
+
case type.to_sym
|
|
213
|
+
when :Time
|
|
214
|
+
Time.parse(value)
|
|
215
|
+
when :Date
|
|
216
|
+
Date.parse(value)
|
|
217
|
+
when :String
|
|
218
|
+
value.to_s
|
|
219
|
+
when :Integer
|
|
220
|
+
value.to_i
|
|
221
|
+
when :Float
|
|
222
|
+
value.to_f
|
|
223
|
+
when :Boolean
|
|
224
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
225
|
+
true
|
|
226
|
+
else
|
|
227
|
+
false
|
|
228
|
+
end
|
|
229
|
+
when :Object
|
|
230
|
+
# generic object (usually a Hash), return directly
|
|
231
|
+
value
|
|
232
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
233
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
234
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
235
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
236
|
+
k_type = Regexp.last_match[:k_type]
|
|
237
|
+
v_type = Regexp.last_match[:v_type]
|
|
238
|
+
{}.tap do |hash|
|
|
239
|
+
value.each do |k, v|
|
|
240
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
else # model
|
|
244
|
+
# models (e.g. Pet) or oneOf
|
|
245
|
+
klass = OneSignal.const_get(type)
|
|
246
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Returns the string representation of the object
|
|
251
|
+
# @return [String] String presentation of the object
|
|
252
|
+
def to_s
|
|
253
|
+
to_hash.to_s
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
257
|
+
# @return [Hash] Returns the object in the form of hash
|
|
258
|
+
def to_body
|
|
259
|
+
to_hash
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Returns the object in the form of hash
|
|
263
|
+
# @return [Hash] Returns the object in the form of hash
|
|
264
|
+
def to_hash
|
|
265
|
+
hash = {}
|
|
266
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
267
|
+
value = self.send(attr)
|
|
268
|
+
if value.nil?
|
|
269
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
270
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
hash[param] = _to_hash(value)
|
|
274
|
+
end
|
|
275
|
+
hash
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# Outputs non-array value in the form of hash
|
|
279
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
280
|
+
# @param [Object] value Any valid value
|
|
281
|
+
# @return [Hash] Returns the value in the form of hash
|
|
282
|
+
def _to_hash(value)
|
|
283
|
+
if value.is_a?(Array)
|
|
284
|
+
value.compact.map { |v| _to_hash(v) }
|
|
285
|
+
elsif value.is_a?(Hash)
|
|
286
|
+
{}.tap do |hash|
|
|
287
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
288
|
+
end
|
|
289
|
+
elsif value.respond_to? :to_hash
|
|
290
|
+
value.to_hash
|
|
291
|
+
else
|
|
292
|
+
value
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
end
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#OneSignal
|
|
3
|
+
|
|
4
|
+
#A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
|
|
5
|
+
|
|
6
|
+
Contact: devrel@onesignal.com
|
|
7
|
+
Generated by: https://openapi-generator.tech
|
|
8
|
+
OpenAPI Generator version: 6.0.0-SNAPSHOT
|
|
9
|
+
|
|
10
|
+
=end
|
|
11
|
+
|
|
12
|
+
require 'date'
|
|
13
|
+
require 'time'
|
|
14
|
+
|
|
15
|
+
module OneSignal
|
|
16
|
+
# Channel: Email Required when `kind` is \"warmup\". The gradual sending schedule for the Auto Warm Up campaign.
|
|
17
|
+
class EmailWarmUpRequest
|
|
18
|
+
# Required. The ordered stages that make up the campaign's sending schedule.
|
|
19
|
+
attr_accessor :stages
|
|
20
|
+
|
|
21
|
+
# How the stage schedule should be treated: * `recommended` - (Default) OneSignal may adjust the provided stages based on past delivery volumes, scheduled Auto Warm Up emails, and the size of the current audience. * `custom` - The stages provided are sent as-is.
|
|
22
|
+
attr_accessor :strategy
|
|
23
|
+
|
|
24
|
+
class EnumAttributeValidator
|
|
25
|
+
attr_reader :datatype
|
|
26
|
+
attr_reader :allowable_values
|
|
27
|
+
|
|
28
|
+
def initialize(datatype, allowable_values)
|
|
29
|
+
@allowable_values = allowable_values.map do |value|
|
|
30
|
+
case datatype.to_s
|
|
31
|
+
when /Integer/i
|
|
32
|
+
value.to_i
|
|
33
|
+
when /Float/i
|
|
34
|
+
value.to_f
|
|
35
|
+
else
|
|
36
|
+
value
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def valid?(value)
|
|
42
|
+
!value || allowable_values.include?(value)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
47
|
+
def self.attribute_map
|
|
48
|
+
{
|
|
49
|
+
:'stages' => :'stages',
|
|
50
|
+
:'strategy' => :'strategy'
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Returns all the JSON keys this model knows about
|
|
55
|
+
def self.acceptable_attributes
|
|
56
|
+
attribute_map.values
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Attribute type mapping.
|
|
60
|
+
def self.openapi_types
|
|
61
|
+
{
|
|
62
|
+
:'stages' => :'Array<EmailWarmUpStage>',
|
|
63
|
+
:'strategy' => :'String'
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# List of attributes with nullable: true
|
|
68
|
+
def self.openapi_nullable
|
|
69
|
+
Set.new([
|
|
70
|
+
:'strategy'
|
|
71
|
+
])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Initializes the object
|
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
76
|
+
def initialize(attributes = {})
|
|
77
|
+
if (!attributes.is_a?(Hash))
|
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailWarmUpRequest` initialize method"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailWarmUpRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
85
|
+
end
|
|
86
|
+
h[k.to_sym] = v
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'stages')
|
|
90
|
+
if (value = attributes[:'stages']).is_a?(Array)
|
|
91
|
+
self.stages = value
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
if attributes.key?(:'strategy')
|
|
96
|
+
self.strategy = attributes[:'strategy']
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
101
|
+
# @return Array for valid properties with the reasons
|
|
102
|
+
def list_invalid_properties
|
|
103
|
+
invalid_properties = Array.new
|
|
104
|
+
if @stages.nil?
|
|
105
|
+
invalid_properties.push('invalid value for "stages", stages cannot be nil.')
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
invalid_properties
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Check to see if the all the properties in the model are valid
|
|
112
|
+
# @return true if the model is valid
|
|
113
|
+
def valid?
|
|
114
|
+
return false if @stages.nil?
|
|
115
|
+
strategy_validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
|
|
116
|
+
return false unless strategy_validator.valid?(@strategy)
|
|
117
|
+
true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
121
|
+
# @param [Object] strategy Object to be assigned
|
|
122
|
+
def strategy=(strategy)
|
|
123
|
+
validator = EnumAttributeValidator.new('String', ["recommended", "custom"])
|
|
124
|
+
unless validator.valid?(strategy)
|
|
125
|
+
fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}."
|
|
126
|
+
end
|
|
127
|
+
@strategy = strategy
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Checks equality by comparing each attribute.
|
|
131
|
+
# @param [Object] Object to be compared
|
|
132
|
+
def ==(o)
|
|
133
|
+
return true if self.equal?(o)
|
|
134
|
+
self.class == o.class &&
|
|
135
|
+
stages == o.stages &&
|
|
136
|
+
strategy == o.strategy
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# @see the `==` method
|
|
140
|
+
# @param [Object] Object to be compared
|
|
141
|
+
def eql?(o)
|
|
142
|
+
self == o
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Calculates hash code according to all attributes.
|
|
146
|
+
# @return [Integer] Hash code
|
|
147
|
+
def hash
|
|
148
|
+
[stages, strategy].hash
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Builds the object from hash
|
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
153
|
+
# @return [Object] Returns the model itself
|
|
154
|
+
def self.build_from_hash(attributes)
|
|
155
|
+
new.build_from_hash(attributes)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Builds the object from hash
|
|
159
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
160
|
+
# @return [Object] Returns the model itself
|
|
161
|
+
def build_from_hash(attributes)
|
|
162
|
+
return nil unless attributes.is_a?(Hash)
|
|
163
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
164
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
165
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
166
|
+
self.send("#{key}=", nil)
|
|
167
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
168
|
+
# check to ensure the input is an array given that the attribute
|
|
169
|
+
# is documented as an array but the input is not
|
|
170
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
171
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
172
|
+
end
|
|
173
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
174
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
self
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Deserializes the data based on type
|
|
182
|
+
# @param string type Data type
|
|
183
|
+
# @param string value Value to be deserialized
|
|
184
|
+
# @return [Object] Deserialized data
|
|
185
|
+
def _deserialize(type, value)
|
|
186
|
+
case type.to_sym
|
|
187
|
+
when :Time
|
|
188
|
+
Time.parse(value)
|
|
189
|
+
when :Date
|
|
190
|
+
Date.parse(value)
|
|
191
|
+
when :String
|
|
192
|
+
value.to_s
|
|
193
|
+
when :Integer
|
|
194
|
+
value.to_i
|
|
195
|
+
when :Float
|
|
196
|
+
value.to_f
|
|
197
|
+
when :Boolean
|
|
198
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
199
|
+
true
|
|
200
|
+
else
|
|
201
|
+
false
|
|
202
|
+
end
|
|
203
|
+
when :Object
|
|
204
|
+
# generic object (usually a Hash), return directly
|
|
205
|
+
value
|
|
206
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
207
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
208
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
209
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
210
|
+
k_type = Regexp.last_match[:k_type]
|
|
211
|
+
v_type = Regexp.last_match[:v_type]
|
|
212
|
+
{}.tap do |hash|
|
|
213
|
+
value.each do |k, v|
|
|
214
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
else # model
|
|
218
|
+
# models (e.g. Pet) or oneOf
|
|
219
|
+
klass = OneSignal.const_get(type)
|
|
220
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Returns the string representation of the object
|
|
225
|
+
# @return [String] String presentation of the object
|
|
226
|
+
def to_s
|
|
227
|
+
to_hash.to_s
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
|
232
|
+
def to_body
|
|
233
|
+
to_hash
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Returns the object in the form of hash
|
|
237
|
+
# @return [Hash] Returns the object in the form of hash
|
|
238
|
+
def to_hash
|
|
239
|
+
hash = {}
|
|
240
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
241
|
+
value = self.send(attr)
|
|
242
|
+
if value.nil?
|
|
243
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
244
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
hash[param] = _to_hash(value)
|
|
248
|
+
end
|
|
249
|
+
hash
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# Outputs non-array value in the form of hash
|
|
253
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
254
|
+
# @param [Object] value Any valid value
|
|
255
|
+
# @return [Hash] Returns the value in the form of hash
|
|
256
|
+
def _to_hash(value)
|
|
257
|
+
if value.is_a?(Array)
|
|
258
|
+
value.compact.map { |v| _to_hash(v) }
|
|
259
|
+
elsif value.is_a?(Hash)
|
|
260
|
+
{}.tap do |hash|
|
|
261
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
262
|
+
end
|
|
263
|
+
elsif value.respond_to? :to_hash
|
|
264
|
+
value.to_hash
|
|
265
|
+
else
|
|
266
|
+
value
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|