onesignal 5.16.0 → 5.18.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile.lock +3 -3
  4. data/README.md +3 -3
  5. data/docs/DefaultApi.md +281 -26
  6. data/docs/DuplicateJourneyOverrides.md +30 -0
  7. data/docs/DuplicateJourneyRequest.md +18 -0
  8. data/docs/EmailMetrics.md +34 -0
  9. data/docs/EmailProviderMetrics.md +20 -0
  10. data/docs/EmailProviderMetricsEvent.md +20 -0
  11. data/docs/EmailProviderMetricsResponse.md +18 -0
  12. data/docs/EmailProviderMetricsTimeseriesResponse.md +18 -0
  13. data/docs/JourneyNode.md +2 -2
  14. data/docs/UpdateJourneyNodeRequest.md +2 -2
  15. data/lib/onesignal/api/default_api.rb +265 -6
  16. data/lib/onesignal/api_client.rb +24 -1
  17. data/lib/onesignal/configuration.rb +4 -2
  18. data/lib/onesignal/models/duplicate_journey_overrides.rb +282 -0
  19. data/lib/onesignal/models/duplicate_journey_request.rb +219 -0
  20. data/lib/onesignal/models/email_metrics.rb +300 -0
  21. data/lib/onesignal/models/email_provider_metrics.rb +229 -0
  22. data/lib/onesignal/models/email_provider_metrics_event.rb +229 -0
  23. data/lib/onesignal/models/email_provider_metrics_response.rb +222 -0
  24. data/lib/onesignal/models/email_provider_metrics_timeseries_response.rb +222 -0
  25. data/lib/onesignal/models/journey.rb +1 -1
  26. data/lib/onesignal/models/journey_node.rb +2 -2
  27. data/lib/onesignal/models/update_journey_node_request.rb +2 -2
  28. data/lib/onesignal/version.rb +1 -1
  29. data/lib/onesignal.rb +7 -0
  30. data/spec/api/default_api_spec.rb +49 -3
  31. data/spec/api_client_spec.rb +6 -6
  32. data/spec/models/duplicate_journey_overrides_spec.rb +69 -0
  33. data/spec/models/duplicate_journey_request_spec.rb +33 -0
  34. data/spec/models/email_metrics_spec.rb +81 -0
  35. data/spec/models/email_provider_metrics_event_spec.rb +39 -0
  36. data/spec/models/email_provider_metrics_response_spec.rb +33 -0
  37. data/spec/models/email_provider_metrics_spec.rb +39 -0
  38. data/spec/models/email_provider_metrics_timeseries_response_spec.rb +33 -0
  39. data/vendor/bundle/ruby/3.2.0/cache/date-3.6.0.gem +0 -0
  40. data/vendor/bundle/ruby/3.2.0/cache/io-console-0.9.4.gem +0 -0
  41. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
  42. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.6.0/date_core.so +0 -0
  43. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.6.0/gem_make.out +26 -0
  44. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{date-3.5.1 → date-3.6.0}/mkmf.log +55 -2
  45. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.2 → io-console-0.9.4}/gem_make.out +12 -10
  46. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.4/io/console.so +0 -0
  47. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.2 → io-console-0.9.4}/mkmf.log +33 -6
  48. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
  49. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/gem_make.out +5 -5
  50. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
  51. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
  52. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/Makefile +1 -1
  53. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_core.c +293 -77
  54. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_parse.c +14 -4
  55. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_strptime.c +13 -13
  56. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/extconf.rb +6 -0
  57. data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/lib/date.rb +1 -1
  58. data/vendor/bundle/ruby/3.2.0/gems/date-3.6.0/lib/date_core.so +0 -0
  59. data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/ext/io/console/Makefile +3 -3
  60. data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/ext/io/console/console.c +101 -13
  61. data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/ext/io/console/extconf.rb +27 -2
  62. data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/lib/io/console/size.rb +4 -2
  63. data/vendor/bundle/ruby/3.2.0/gems/io-console-0.9.4/lib/io/console.so +0 -0
  64. data/vendor/bundle/ruby/3.2.0/specifications/{date-3.5.1.gemspec → date-3.6.0.gemspec} +3 -3
  65. data/vendor/bundle/ruby/3.2.0/specifications/{io-console-0.9.2.gemspec → io-console-0.9.4.gemspec} +3 -3
  66. metadata +158 -130
  67. data/vendor/bundle/ruby/3.2.0/cache/date-3.5.1.gem +0 -0
  68. data/vendor/bundle/ruby/3.2.0/cache/io-console-0.9.2.gem +0 -0
  69. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/date_core.so +0 -0
  70. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.5.1/gem_make.out +0 -24
  71. data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.2/io/console.so +0 -0
  72. data/vendor/bundle/ruby/3.2.0/gems/date-3.5.1/lib/date_core.so +0 -0
  73. data/vendor/bundle/ruby/3.2.0/gems/io-console-0.9.2/lib/io/console.so +0 -0
  74. /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{date-3.5.1 → date-3.6.0}/gem.build_complete +0 -0
  75. /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.2 → io-console-0.9.4}/gem.build_complete +0 -0
  76. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/BSDL +0 -0
  77. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/COPYING +0 -0
  78. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/README.md +0 -0
  79. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_strftime.c +0 -0
  80. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/date_tmx.h +0 -0
  81. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/prereq.mk +0 -0
  82. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/zonetab.h +0 -0
  83. /data/vendor/bundle/ruby/3.2.0/gems/{date-3.5.1 → date-3.6.0}/ext/date/zonetab.list +0 -0
  84. /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/.document +0 -0
  85. /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/BSDL +0 -0
  86. /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/COPYING +0 -0
  87. /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/README.md +0 -0
  88. /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.2 → io-console-0.9.4}/ext/io/console/win32_vk.inc +0 -0
@@ -0,0 +1,300 @@
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
+ # Email delivery and engagement counts for the reporting window.
17
+ class EmailMetrics
18
+ # The number of emails sent.
19
+ attr_accessor :sent
20
+
21
+ # The number of emails successfully delivered.
22
+ attr_accessor :delivered
23
+
24
+ # The total number of email opens, including repeat opens by the same recipient.
25
+ attr_accessor :opened
26
+
27
+ # The total number of email link clicks, including repeat clicks by the same recipient.
28
+ attr_accessor :clicked
29
+
30
+ # The number of emails opened at least once.
31
+ attr_accessor :unique_opened
32
+
33
+ # The number of emails with at least one link click.
34
+ attr_accessor :unique_clicked
35
+
36
+ # The number of emails that failed to send.
37
+ attr_accessor :failed
38
+
39
+ # The number of emails that bounced.
40
+ attr_accessor :bounced
41
+
42
+ # The number of emails that recipients reported as spam.
43
+ attr_accessor :complained
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'sent' => :'sent',
49
+ :'delivered' => :'delivered',
50
+ :'opened' => :'opened',
51
+ :'clicked' => :'clicked',
52
+ :'unique_opened' => :'unique_opened',
53
+ :'unique_clicked' => :'unique_clicked',
54
+ :'failed' => :'failed',
55
+ :'bounced' => :'bounced',
56
+ :'complained' => :'complained'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'sent' => :'Integer',
69
+ :'delivered' => :'Integer',
70
+ :'opened' => :'Integer',
71
+ :'clicked' => :'Integer',
72
+ :'unique_opened' => :'Integer',
73
+ :'unique_clicked' => :'Integer',
74
+ :'failed' => :'Integer',
75
+ :'bounced' => :'Integer',
76
+ :'complained' => :'Integer'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailMetrics` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailMetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'sent')
102
+ self.sent = attributes[:'sent']
103
+ end
104
+
105
+ if attributes.key?(:'delivered')
106
+ self.delivered = attributes[:'delivered']
107
+ end
108
+
109
+ if attributes.key?(:'opened')
110
+ self.opened = attributes[:'opened']
111
+ end
112
+
113
+ if attributes.key?(:'clicked')
114
+ self.clicked = attributes[:'clicked']
115
+ end
116
+
117
+ if attributes.key?(:'unique_opened')
118
+ self.unique_opened = attributes[:'unique_opened']
119
+ end
120
+
121
+ if attributes.key?(:'unique_clicked')
122
+ self.unique_clicked = attributes[:'unique_clicked']
123
+ end
124
+
125
+ if attributes.key?(:'failed')
126
+ self.failed = attributes[:'failed']
127
+ end
128
+
129
+ if attributes.key?(:'bounced')
130
+ self.bounced = attributes[:'bounced']
131
+ end
132
+
133
+ if attributes.key?(:'complained')
134
+ self.complained = attributes[:'complained']
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ invalid_properties = Array.new
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ true
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ sent == o.sent &&
157
+ delivered == o.delivered &&
158
+ opened == o.opened &&
159
+ clicked == o.clicked &&
160
+ unique_opened == o.unique_opened &&
161
+ unique_clicked == o.unique_clicked &&
162
+ failed == o.failed &&
163
+ bounced == o.bounced &&
164
+ complained == o.complained
165
+ end
166
+
167
+ # @see the `==` method
168
+ # @param [Object] Object to be compared
169
+ def eql?(o)
170
+ self == o
171
+ end
172
+
173
+ # Calculates hash code according to all attributes.
174
+ # @return [Integer] Hash code
175
+ def hash
176
+ [sent, delivered, opened, clicked, unique_opened, unique_clicked, failed, bounced, complained].hash
177
+ end
178
+
179
+ # Builds the object from hash
180
+ # @param [Hash] attributes Model attributes in the form of hash
181
+ # @return [Object] Returns the model itself
182
+ def self.build_from_hash(attributes)
183
+ new.build_from_hash(attributes)
184
+ end
185
+
186
+ # Builds the object from hash
187
+ # @param [Hash] attributes Model attributes in the form of hash
188
+ # @return [Object] Returns the model itself
189
+ def build_from_hash(attributes)
190
+ return nil unless attributes.is_a?(Hash)
191
+ attributes = attributes.transform_keys(&:to_sym)
192
+ self.class.openapi_types.each_pair do |key, type|
193
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
194
+ self.send("#{key}=", nil)
195
+ elsif type =~ /\AArray<(.*)>/i
196
+ # check to ensure the input is an array given that the attribute
197
+ # is documented as an array but the input is not
198
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
199
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
200
+ end
201
+ elsif !attributes[self.class.attribute_map[key]].nil?
202
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
203
+ end
204
+ end
205
+
206
+ self
207
+ end
208
+
209
+ # Deserializes the data based on type
210
+ # @param string type Data type
211
+ # @param string value Value to be deserialized
212
+ # @return [Object] Deserialized data
213
+ def _deserialize(type, value)
214
+ case type.to_sym
215
+ when :Time
216
+ Time.parse(value)
217
+ when :Date
218
+ Date.parse(value)
219
+ when :String
220
+ value.to_s
221
+ when :Integer
222
+ value.to_i
223
+ when :Float
224
+ value.to_f
225
+ when :Boolean
226
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
227
+ true
228
+ else
229
+ false
230
+ end
231
+ when :Object
232
+ # generic object (usually a Hash), return directly
233
+ value
234
+ when /\AArray<(?<inner_type>.+)>\z/
235
+ inner_type = Regexp.last_match[:inner_type]
236
+ value.map { |v| _deserialize(inner_type, v) }
237
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
238
+ k_type = Regexp.last_match[:k_type]
239
+ v_type = Regexp.last_match[:v_type]
240
+ {}.tap do |hash|
241
+ value.each do |k, v|
242
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
243
+ end
244
+ end
245
+ else # model
246
+ # models (e.g. Pet) or oneOf
247
+ klass = OneSignal.const_get(type)
248
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
249
+ end
250
+ end
251
+
252
+ # Returns the string representation of the object
253
+ # @return [String] String presentation of the object
254
+ def to_s
255
+ to_hash.to_s
256
+ end
257
+
258
+ # to_body is an alias to to_hash (backward compatibility)
259
+ # @return [Hash] Returns the object in the form of hash
260
+ def to_body
261
+ to_hash
262
+ end
263
+
264
+ # Returns the object in the form of hash
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_hash
267
+ hash = {}
268
+ self.class.attribute_map.each_pair do |attr, param|
269
+ value = self.send(attr)
270
+ if value.nil?
271
+ is_nullable = self.class.openapi_nullable.include?(attr)
272
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
273
+ end
274
+
275
+ hash[param] = _to_hash(value)
276
+ end
277
+ hash
278
+ end
279
+
280
+ # Outputs non-array value in the form of hash
281
+ # For object, use to_hash. Otherwise, just return the value
282
+ # @param [Object] value Any valid value
283
+ # @return [Hash] Returns the value in the form of hash
284
+ def _to_hash(value)
285
+ if value.is_a?(Array)
286
+ value.compact.map { |v| _to_hash(v) }
287
+ elsif value.is_a?(Hash)
288
+ {}.tap do |hash|
289
+ value.each { |k, v| hash[k] = _to_hash(v) }
290
+ end
291
+ elsif value.respond_to? :to_hash
292
+ value.to_hash
293
+ else
294
+ value
295
+ end
296
+ end
297
+
298
+ end
299
+
300
+ end
@@ -0,0 +1,229 @@
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
+ # Email metrics for a single inbox provider.
17
+ class EmailProviderMetrics
18
+ # The inbox provider. Known values include `apple`, `att`, `canadian`, `chinese`, `comcast`, `free_fr`, `french`, `german`, `gmail`, `google_workspace`, `googlers`, `inbox_lv`, `italian`, `japanese`, `outlook_365`, `outlook_eu`, `outlook_us`, `proton`, `rackspace`, `russian`, `uk`, `united_online`, `yahoo_eu`, `yahoo_us`, `other_eu`, `other_us`, and `other`. New providers may be added over time.
19
+ attr_accessor :provider
20
+
21
+ attr_accessor :metrics
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'provider' => :'provider',
27
+ :'metrics' => :'metrics'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'provider' => :'String',
40
+ :'metrics' => :'EmailMetrics'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::EmailProviderMetrics` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::EmailProviderMetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'provider')
66
+ self.provider = attributes[:'provider']
67
+ end
68
+
69
+ if attributes.key?(:'metrics')
70
+ self.metrics = attributes[:'metrics']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ provider == o.provider &&
93
+ metrics == o.metrics
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [provider, metrics].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ self.class.openapi_types.each_pair do |key, type|
122
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
123
+ self.send("#{key}=", nil)
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = OneSignal.const_get(type)
177
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end