onesignal 5.11.2 → 5.12.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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -3
  5. data/docs/CreateJourneyRequest.md +30 -0
  6. data/docs/DefaultApi.md +563 -0
  7. data/docs/Journey.md +48 -0
  8. data/docs/JourneyAudience.md +28 -0
  9. data/docs/JourneyBranch.md +24 -0
  10. data/docs/JourneyBranchStats.md +18 -0
  11. data/docs/JourneyCondition.md +34 -0
  12. data/docs/JourneyEarlyExit.md +20 -0
  13. data/docs/JourneyEarlyExitRules.md +24 -0
  14. data/docs/JourneyEarlyExitRulesOnEvent.md +18 -0
  15. data/docs/JourneyEarlyExitRulesOnSegment.md +18 -0
  16. data/docs/JourneyEventAttribute.md +22 -0
  17. data/docs/JourneyListAudience.md +18 -0
  18. data/docs/JourneyListItem.md +40 -0
  19. data/docs/JourneyListResponse.md +22 -0
  20. data/docs/JourneyMessageStats.md +18 -0
  21. data/docs/JourneyNode.md +50 -0
  22. data/docs/JourneyNodeStats.md +26 -0
  23. data/docs/JourneyReentryRules.md +18 -0
  24. data/docs/JourneySchedule.md +22 -0
  25. data/docs/JourneyStats.md +28 -0
  26. data/docs/JourneyTimePoint.md +20 -0
  27. data/docs/JourneyTimeWindow.md +22 -0
  28. data/docs/JourneyWaitUntilExpiration.md +20 -0
  29. data/docs/UpdateJourneyNodeRequest.md +48 -0
  30. data/docs/UpdateJourneyRequest.md +34 -0
  31. data/lib/onesignal/api/default_api.rb +524 -0
  32. data/lib/onesignal/api_client.rb +1 -1
  33. data/lib/onesignal/models/create_journey_request.rb +287 -0
  34. data/lib/onesignal/models/journey.rb +409 -0
  35. data/lib/onesignal/models/journey_audience.rb +316 -0
  36. data/lib/onesignal/models/journey_branch.rb +250 -0
  37. data/lib/onesignal/models/journey_branch_stats.rb +220 -0
  38. data/lib/onesignal/models/journey_condition.rb +360 -0
  39. data/lib/onesignal/models/journey_early_exit.rb +231 -0
  40. data/lib/onesignal/models/journey_early_exit_rules.rb +251 -0
  41. data/lib/onesignal/models/journey_early_exit_rules_on_event.rb +224 -0
  42. data/lib/onesignal/models/journey_early_exit_rules_on_segment.rb +221 -0
  43. data/lib/onesignal/models/journey_event_attribute.rb +283 -0
  44. data/lib/onesignal/models/journey_list_audience.rb +254 -0
  45. data/lib/onesignal/models/journey_list_item.rb +366 -0
  46. data/lib/onesignal/models/journey_list_response.rb +241 -0
  47. data/lib/onesignal/models/journey_message_stats.rb +222 -0
  48. data/lib/onesignal/models/journey_node.rb +480 -0
  49. data/lib/onesignal/models/journey_node_stats.rb +293 -0
  50. data/lib/onesignal/models/journey_reentry_rules.rb +236 -0
  51. data/lib/onesignal/models/journey_schedule.rb +243 -0
  52. data/lib/onesignal/models/journey_stats.rb +274 -0
  53. data/lib/onesignal/models/journey_time_point.rb +277 -0
  54. data/lib/onesignal/models/journey_time_window.rb +266 -0
  55. data/lib/onesignal/models/journey_wait_until_expiration.rb +256 -0
  56. data/lib/onesignal/models/update_journey_node_request.rb +454 -0
  57. data/lib/onesignal/models/update_journey_request.rb +337 -0
  58. data/lib/onesignal/version.rb +1 -1
  59. data/lib/onesignal.rb +25 -0
  60. data/spec/api/default_api_spec.rb +95 -0
  61. data/spec/models/create_journey_request_spec.rb +69 -0
  62. data/spec/models/journey_audience_spec.rb +67 -0
  63. data/spec/models/journey_branch_spec.rb +51 -0
  64. data/spec/models/journey_branch_stats_spec.rb +33 -0
  65. data/spec/models/journey_condition_spec.rb +89 -0
  66. data/spec/models/journey_early_exit_rules_on_event_spec.rb +33 -0
  67. data/spec/models/journey_early_exit_rules_on_segment_spec.rb +33 -0
  68. data/spec/models/journey_early_exit_rules_spec.rb +51 -0
  69. data/spec/models/journey_early_exit_spec.rb +39 -0
  70. data/spec/models/journey_event_attribute_spec.rb +49 -0
  71. data/spec/models/journey_list_audience_spec.rb +37 -0
  72. data/spec/models/journey_list_item_spec.rb +103 -0
  73. data/spec/models/journey_list_response_spec.rb +45 -0
  74. data/spec/models/journey_message_stats_spec.rb +33 -0
  75. data/spec/models/journey_node_spec.rb +137 -0
  76. data/spec/models/journey_node_stats_spec.rb +61 -0
  77. data/spec/models/journey_reentry_rules_spec.rb +33 -0
  78. data/spec/models/journey_schedule_spec.rb +45 -0
  79. data/spec/models/journey_spec.rb +127 -0
  80. data/spec/models/journey_stats_spec.rb +63 -0
  81. data/spec/models/journey_time_point_spec.rb +39 -0
  82. data/spec/models/journey_time_window_spec.rb +45 -0
  83. data/spec/models/journey_wait_until_expiration_spec.rb +39 -0
  84. data/spec/models/update_journey_node_request_spec.rb +127 -0
  85. data/spec/models/update_journey_request_spec.rb +85 -0
  86. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
  87. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +5 -5
  88. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/gem_make.out +5 -5
  89. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/mkmf.log +3 -3
  90. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  91. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.4.0/gem_make.out +5 -5
  92. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  93. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
  94. metadata +102 -2
@@ -0,0 +1,316 @@
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
+ # The journey entry audience. The kind field selects which other fields apply.
17
+ class JourneyAudience
18
+ # Audience kind. Selects which other fields apply.
19
+ attr_accessor :kind
20
+
21
+ # segment audiences: Segment UUIDs whose users enter the journey.
22
+ attr_accessor :included_segment_ids
23
+
24
+ # segment audiences: Segment UUIDs whose users are excluded.
25
+ attr_accessor :excluded_segment_ids
26
+
27
+ # segment audiences: when true, only users who newly match the segment after activation enter the journey. Defaults to false.
28
+ attr_accessor :future_additions_only
29
+
30
+ # event_trigger audiences: event name that triggers entry, up to 255 characters.
31
+ attr_accessor :name
32
+
33
+ # Event attribute matchers, as a list of condition groups. Send a single group whose conditions are AND'd together. More than one group is rejected.
34
+ attr_accessor :attributes
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'kind' => :'kind',
62
+ :'included_segment_ids' => :'included_segment_ids',
63
+ :'excluded_segment_ids' => :'excluded_segment_ids',
64
+ :'future_additions_only' => :'future_additions_only',
65
+ :'name' => :'name',
66
+ :'attributes' => :'attributes'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'kind' => :'String',
79
+ :'included_segment_ids' => :'Array<String>',
80
+ :'excluded_segment_ids' => :'Array<String>',
81
+ :'future_additions_only' => :'Boolean',
82
+ :'name' => :'String',
83
+ :'attributes' => :'Array<Array<JourneyEventAttribute>>'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ :'future_additions_only',
91
+ ])
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::JourneyAudience` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ attributes = attributes.each_with_object({}) { |(k, v), h|
103
+ if (!self.class.attribute_map.key?(k.to_sym))
104
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::JourneyAudience`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+ h[k.to_sym] = v
107
+ }
108
+
109
+ if attributes.key?(:'kind')
110
+ self.kind = attributes[:'kind']
111
+ end
112
+
113
+ if attributes.key?(:'included_segment_ids')
114
+ if (value = attributes[:'included_segment_ids']).is_a?(Array)
115
+ self.included_segment_ids = value
116
+ end
117
+ end
118
+
119
+ if attributes.key?(:'excluded_segment_ids')
120
+ if (value = attributes[:'excluded_segment_ids']).is_a?(Array)
121
+ self.excluded_segment_ids = value
122
+ end
123
+ end
124
+
125
+ if attributes.key?(:'future_additions_only')
126
+ self.future_additions_only = attributes[:'future_additions_only']
127
+ end
128
+
129
+ if attributes.key?(:'name')
130
+ self.name = attributes[:'name']
131
+ end
132
+
133
+ if attributes.key?(:'attributes')
134
+ if (value = attributes[:'attributes']).is_a?(Array)
135
+ self.attributes = value
136
+ end
137
+ end
138
+ end
139
+
140
+ # Show invalid properties with the reasons. Usually used together with valid?
141
+ # @return Array for valid properties with the reasons
142
+ def list_invalid_properties
143
+ invalid_properties = Array.new
144
+ if @kind.nil?
145
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
146
+ end
147
+
148
+ invalid_properties
149
+ end
150
+
151
+ # Check to see if the all the properties in the model are valid
152
+ # @return true if the model is valid
153
+ def valid?
154
+ return false if @kind.nil?
155
+ kind_validator = EnumAttributeValidator.new('String', ["segment", "event_trigger"])
156
+ return false unless kind_validator.valid?(@kind)
157
+ true
158
+ end
159
+
160
+ # Custom attribute writer method checking allowed values (enum).
161
+ # @param [Object] kind Object to be assigned
162
+ def kind=(kind)
163
+ validator = EnumAttributeValidator.new('String', ["segment", "event_trigger"])
164
+ unless validator.valid?(kind)
165
+ fail ArgumentError, "invalid value for \"kind\", must be one of #{validator.allowable_values}."
166
+ end
167
+ @kind = kind
168
+ end
169
+
170
+ # Checks equality by comparing each attribute.
171
+ # @param [Object] Object to be compared
172
+ def ==(o)
173
+ return true if self.equal?(o)
174
+ self.class == o.class &&
175
+ kind == o.kind &&
176
+ included_segment_ids == o.included_segment_ids &&
177
+ excluded_segment_ids == o.excluded_segment_ids &&
178
+ future_additions_only == o.future_additions_only &&
179
+ name == o.name &&
180
+ attributes == o.attributes
181
+ end
182
+
183
+ # @see the `==` method
184
+ # @param [Object] Object to be compared
185
+ def eql?(o)
186
+ self == o
187
+ end
188
+
189
+ # Calculates hash code according to all attributes.
190
+ # @return [Integer] Hash code
191
+ def hash
192
+ [kind, included_segment_ids, excluded_segment_ids, future_additions_only, name, attributes].hash
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def self.build_from_hash(attributes)
199
+ new.build_from_hash(attributes)
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def build_from_hash(attributes)
206
+ return nil unless attributes.is_a?(Hash)
207
+ attributes = attributes.transform_keys(&:to_sym)
208
+ self.class.openapi_types.each_pair do |key, type|
209
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
210
+ self.send("#{key}=", nil)
211
+ elsif type =~ /\AArray<(.*)>/i
212
+ # check to ensure the input is an array given that the attribute
213
+ # is documented as an array but the input is not
214
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
215
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
216
+ end
217
+ elsif !attributes[self.class.attribute_map[key]].nil?
218
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
219
+ end
220
+ end
221
+
222
+ self
223
+ end
224
+
225
+ # Deserializes the data based on type
226
+ # @param string type Data type
227
+ # @param string value Value to be deserialized
228
+ # @return [Object] Deserialized data
229
+ def _deserialize(type, value)
230
+ case type.to_sym
231
+ when :Time
232
+ Time.parse(value)
233
+ when :Date
234
+ Date.parse(value)
235
+ when :String
236
+ value.to_s
237
+ when :Integer
238
+ value.to_i
239
+ when :Float
240
+ value.to_f
241
+ when :Boolean
242
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
243
+ true
244
+ else
245
+ false
246
+ end
247
+ when :Object
248
+ # generic object (usually a Hash), return directly
249
+ value
250
+ when /\AArray<(?<inner_type>.+)>\z/
251
+ inner_type = Regexp.last_match[:inner_type]
252
+ value.map { |v| _deserialize(inner_type, v) }
253
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
254
+ k_type = Regexp.last_match[:k_type]
255
+ v_type = Regexp.last_match[:v_type]
256
+ {}.tap do |hash|
257
+ value.each do |k, v|
258
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
259
+ end
260
+ end
261
+ else # model
262
+ # models (e.g. Pet) or oneOf
263
+ klass = OneSignal.const_get(type)
264
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
265
+ end
266
+ end
267
+
268
+ # Returns the string representation of the object
269
+ # @return [String] String presentation of the object
270
+ def to_s
271
+ to_hash.to_s
272
+ end
273
+
274
+ # to_body is an alias to to_hash (backward compatibility)
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_body
277
+ to_hash
278
+ end
279
+
280
+ # Returns the object in the form of hash
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_hash
283
+ hash = {}
284
+ self.class.attribute_map.each_pair do |attr, param|
285
+ value = self.send(attr)
286
+ if value.nil?
287
+ is_nullable = self.class.openapi_nullable.include?(attr)
288
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
289
+ end
290
+
291
+ hash[param] = _to_hash(value)
292
+ end
293
+ hash
294
+ end
295
+
296
+ # Outputs non-array value in the form of hash
297
+ # For object, use to_hash. Otherwise, just return the value
298
+ # @param [Object] value Any valid value
299
+ # @return [Hash] Returns the value in the form of hash
300
+ def _to_hash(value)
301
+ if value.is_a?(Array)
302
+ value.compact.map { |v| _to_hash(v) }
303
+ elsif value.is_a?(Hash)
304
+ {}.tap do |hash|
305
+ value.each { |k, v| hash[k] = _to_hash(v) }
306
+ end
307
+ elsif value.respond_to? :to_hash
308
+ value.to_hash
309
+ else
310
+ value
311
+ end
312
+ end
313
+
314
+ end
315
+
316
+ end
@@ -0,0 +1,250 @@
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
+ class JourneyBranch
17
+ # Server-assigned branch identifier. Read-only on create; echo it on update to keep the branch.
18
+ attr_accessor :id
19
+
20
+ attr_accessor :condition
21
+
22
+ # Branch weight for split_range nodes. Weights across a node's branches must sum to 100.
23
+ attr_accessor :weight
24
+
25
+ # Nodes run when this branch is taken, before flow converges to the next sibling node.
26
+ attr_accessor :nodes
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'id' => :'id',
32
+ :'condition' => :'condition',
33
+ :'weight' => :'weight',
34
+ :'nodes' => :'nodes'
35
+ }
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'id' => :'String',
47
+ :'condition' => :'JourneyCondition',
48
+ :'weight' => :'Float',
49
+ :'nodes' => :'Array<JourneyNode>'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::JourneyBranch` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::JourneyBranch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'id')
75
+ self.id = attributes[:'id']
76
+ end
77
+
78
+ if attributes.key?(:'condition')
79
+ self.condition = attributes[:'condition']
80
+ end
81
+
82
+ if attributes.key?(:'weight')
83
+ self.weight = attributes[:'weight']
84
+ end
85
+
86
+ if attributes.key?(:'nodes')
87
+ if (value = attributes[:'nodes']).is_a?(Array)
88
+ self.nodes = value
89
+ end
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ id == o.id &&
112
+ condition == o.condition &&
113
+ weight == o.weight &&
114
+ nodes == o.nodes
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [id, condition, weight, nodes].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ attributes = attributes.transform_keys(&:to_sym)
142
+ self.class.openapi_types.each_pair do |key, type|
143
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
144
+ self.send("#{key}=", nil)
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
149
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
150
+ end
151
+ elsif !attributes[self.class.attribute_map[key]].nil?
152
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153
+ end
154
+ end
155
+
156
+ self
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def _deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ # models (e.g. Pet) or oneOf
197
+ klass = OneSignal.const_get(type)
198
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ end