onesignal 0.2.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile +6 -1
  4. data/LICENSE +6 -3
  5. data/README.md +144 -99
  6. data/RELEASE_INSTRUCTIONS.md +11 -0
  7. data/Rakefile +8 -8
  8. data/docs/App.md +76 -0
  9. data/docs/Button.md +22 -0
  10. data/docs/DefaultApi.md +1394 -0
  11. data/docs/DeliveryData.md +26 -0
  12. data/docs/ExportPlayersRequestBody.md +22 -0
  13. data/docs/Filter.md +24 -0
  14. data/docs/FilterExpressions.md +26 -0
  15. data/docs/FilterNotificationTarget.md +40 -0
  16. data/docs/GetNotificationRequestBody.md +22 -0
  17. data/docs/InlineResponse200.md +24 -0
  18. data/docs/InlineResponse2001.md +18 -0
  19. data/docs/InlineResponse2002.md +20 -0
  20. data/docs/InlineResponse2005.md +20 -0
  21. data/docs/InlineResponse2007.md +18 -0
  22. data/docs/InlineResponse2008.md +18 -0
  23. data/docs/InlineResponse201.md +20 -0
  24. data/docs/InlineResponse400.md +18 -0
  25. data/docs/InlineResponse4001.md +20 -0
  26. data/docs/InlineResponse4002.md +20 -0
  27. data/docs/InlineResponse4003.md +18 -0
  28. data/docs/InvalidIdentifierError.md +20 -0
  29. data/docs/Notification.md +240 -0
  30. data/docs/Notification200Errors.md +49 -0
  31. data/docs/NotificationAllOf.md +192 -0
  32. data/docs/NotificationAllOfAndroidBackgroundLayout.md +22 -0
  33. data/docs/NotificationSlice.md +24 -0
  34. data/docs/NotificationTarget.md +64 -0
  35. data/docs/NotificationWithMeta.md +260 -0
  36. data/docs/NotificationWithMetaAllOf.md +38 -0
  37. data/docs/Operator.md +18 -0
  38. data/docs/OutcomeData.md +22 -0
  39. data/docs/OutcomesData.md +18 -0
  40. data/docs/PlatformDeliveryData.md +28 -0
  41. data/docs/Player.md +70 -0
  42. data/docs/PlayerNotificationTarget.md +36 -0
  43. data/docs/PlayerSlice.md +24 -0
  44. data/docs/Purchase.md +22 -0
  45. data/docs/Segment.md +22 -0
  46. data/docs/SegmentNotificationTarget.md +20 -0
  47. data/docs/StringMap.md +102 -0
  48. data/docs/UpdatePlayerTagsRequestBody.md +18 -0
  49. data/lib/onesignal/api/default_api.rb +1365 -0
  50. data/lib/onesignal/api_client.rb +393 -0
  51. data/lib/onesignal/api_error.rb +57 -0
  52. data/lib/onesignal/configuration.rb +245 -0
  53. data/lib/onesignal/models/app.rb +519 -20
  54. data/lib/onesignal/models/button.rb +242 -0
  55. data/lib/onesignal/models/delivery_data.rb +260 -0
  56. data/lib/onesignal/models/export_players_request_body.rb +242 -0
  57. data/lib/onesignal/models/filter.rb +294 -0
  58. data/lib/onesignal/models/filter_expressions.rb +336 -0
  59. data/lib/onesignal/models/filter_notification_target.rb +330 -0
  60. data/lib/onesignal/models/get_notification_request_body.rb +273 -0
  61. data/lib/onesignal/models/inline_response200.rb +257 -0
  62. data/lib/onesignal/models/inline_response2001.rb +219 -0
  63. data/lib/onesignal/models/inline_response2002.rb +228 -0
  64. data/lib/onesignal/models/inline_response2005.rb +228 -0
  65. data/lib/onesignal/models/inline_response2007.rb +219 -0
  66. data/lib/onesignal/models/inline_response2008.rb +219 -0
  67. data/lib/onesignal/models/inline_response201.rb +229 -0
  68. data/lib/onesignal/models/inline_response400.rb +221 -0
  69. data/lib/onesignal/models/inline_response4001.rb +230 -0
  70. data/lib/onesignal/models/inline_response4002.rb +230 -0
  71. data/lib/onesignal/models/inline_response4003.rb +221 -0
  72. data/lib/onesignal/models/invalid_identifier_error.rb +234 -0
  73. data/lib/onesignal/models/notification.rb +1414 -9
  74. data/lib/onesignal/models/notification200_errors.rb +105 -0
  75. data/lib/onesignal/models/notification_all_of.rb +1144 -0
  76. data/lib/onesignal/models/notification_all_of_android_background_layout.rb +241 -0
  77. data/lib/onesignal/models/notification_slice.rb +248 -0
  78. data/lib/onesignal/models/notification_target.rb +495 -0
  79. data/lib/onesignal/models/notification_with_meta.rb +1526 -0
  80. data/lib/onesignal/models/notification_with_meta_all_of.rb +322 -0
  81. data/lib/onesignal/models/operator.rb +254 -0
  82. data/lib/onesignal/models/outcome_data.rb +286 -0
  83. data/lib/onesignal/models/outcomes_data.rb +221 -0
  84. data/lib/onesignal/models/platform_delivery_data.rb +265 -0
  85. data/lib/onesignal/models/player.rb +480 -13
  86. data/lib/onesignal/models/player_notification_target.rb +330 -0
  87. data/lib/onesignal/models/player_slice.rb +248 -0
  88. data/lib/onesignal/models/purchase.rb +255 -0
  89. data/lib/onesignal/models/segment.rb +252 -0
  90. data/lib/onesignal/models/segment_notification_target.rb +234 -0
  91. data/lib/onesignal/models/string_map.rb +640 -0
  92. data/lib/onesignal/models/update_player_tags_request_body.rb +220 -0
  93. data/lib/onesignal/version.rb +13 -1
  94. data/lib/onesignal.rb +73 -16
  95. data/onesignal.gemspec +37 -27
  96. data/spec/api/default_api_spec.rb +285 -0
  97. data/spec/api_client_spec.rb +226 -0
  98. data/spec/configuration_spec.rb +42 -0
  99. data/spec/models/app_spec.rb +212 -0
  100. data/spec/models/button_spec.rb +46 -0
  101. data/spec/models/delivery_data_spec.rb +58 -0
  102. data/spec/models/export_players_request_body_spec.rb +46 -0
  103. data/spec/models/filter_expressions_spec.rb +66 -0
  104. data/spec/models/filter_notification_target_spec.rb +100 -0
  105. data/spec/models/filter_spec.rb +56 -0
  106. data/spec/models/get_notification_request_body_spec.rb +50 -0
  107. data/spec/models/inline_response2001_spec.rb +34 -0
  108. data/spec/models/inline_response2002_spec.rb +40 -0
  109. data/spec/models/inline_response2005_spec.rb +40 -0
  110. data/spec/models/inline_response2007_spec.rb +34 -0
  111. data/spec/models/inline_response2008_spec.rb +34 -0
  112. data/spec/models/inline_response200_spec.rb +52 -0
  113. data/spec/models/inline_response201_spec.rb +40 -0
  114. data/spec/models/inline_response4001_spec.rb +40 -0
  115. data/spec/models/inline_response4002_spec.rb +40 -0
  116. data/spec/models/inline_response4003_spec.rb +34 -0
  117. data/spec/models/inline_response400_spec.rb +34 -0
  118. data/spec/models/invalid_identifier_error_spec.rb +40 -0
  119. data/spec/models/notification200_errors_spec.rb +31 -0
  120. data/spec/models/notification_all_of_android_background_layout_spec.rb +46 -0
  121. data/spec/models/notification_all_of_spec.rb +560 -0
  122. data/spec/models/notification_slice_spec.rb +52 -0
  123. data/spec/models/notification_spec.rb +704 -0
  124. data/spec/models/notification_target_spec.rb +172 -0
  125. data/spec/models/notification_with_meta_all_of_spec.rb +94 -0
  126. data/spec/models/notification_with_meta_spec.rb +764 -0
  127. data/spec/models/operator_spec.rb +38 -0
  128. data/spec/models/outcome_data_spec.rb +50 -0
  129. data/spec/models/outcomes_data_spec.rb +34 -0
  130. data/spec/models/platform_delivery_data_spec.rb +64 -0
  131. data/spec/models/player_notification_target_spec.rb +88 -0
  132. data/spec/models/player_slice_spec.rb +52 -0
  133. data/spec/models/player_spec.rb +190 -0
  134. data/spec/models/purchase_spec.rb +46 -0
  135. data/spec/models/segment_notification_target_spec.rb +40 -0
  136. data/spec/models/segment_spec.rb +46 -0
  137. data/spec/models/string_map_spec.rb +286 -0
  138. data/spec/models/update_player_tags_request_body_spec.rb +34 -0
  139. data/spec/spec_helper.rb +111 -0
  140. metadata +203 -64
  141. data/.gitignore +0 -10
  142. data/.rubocop.yml +0 -17
  143. data/.travis.yml +0 -16
  144. data/CODE_OF_CONDUCT.md +0 -49
  145. data/bin/console +0 -14
  146. data/bin/setup +0 -8
  147. data/lib/onesignal/app_id_missing_error.rb +0 -7
  148. data/lib/onesignal/client.rb +0 -44
  149. data/lib/onesignal/models/base_model.rb +0 -19
  150. data/lib/onesignal/request.rb +0 -94
  151. data/lib/onesignal/request_error.rb +0 -21
  152. data/lib/onesignal/resources/app_resource.rb +0 -27
  153. data/lib/onesignal/resources/base_resource.rb +0 -35
  154. data/lib/onesignal/resources/notification_resource.rb +0 -33
  155. data/lib/onesignal/resources/player_resource.rb +0 -53
@@ -0,0 +1,242 @@
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
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class Button
18
+ attr_accessor :id
19
+
20
+ attr_accessor :text
21
+
22
+ attr_accessor :icon
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'id' => :'id',
28
+ :'text' => :'text',
29
+ :'icon' => :'icon'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'id' => :'String',
42
+ :'text' => :'String',
43
+ :'icon' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Button` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Button`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'id')
69
+ self.id = attributes[:'id']
70
+ end
71
+
72
+ if attributes.key?(:'text')
73
+ self.text = attributes[:'text']
74
+ end
75
+
76
+ if attributes.key?(:'icon')
77
+ self.icon = attributes[:'icon']
78
+ end
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ if @id.nil?
86
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
87
+ end
88
+
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ return false if @id.nil?
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ id == o.id &&
105
+ text == o.text &&
106
+ icon == o.icon
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [id, text, icon].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ new.build_from_hash(attributes)
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ attributes = attributes.transform_keys(&:to_sym)
134
+ self.class.openapi_types.each_pair do |key, type|
135
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
136
+ self.send("#{key}=", nil)
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
141
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
142
+ end
143
+ elsif !attributes[self.class.attribute_map[key]].nil?
144
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
145
+ end
146
+ end
147
+
148
+ self
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def _deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ # models (e.g. Pet) or oneOf
189
+ klass = OneSignal.const_get(type)
190
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+ end
241
+
242
+ end
@@ -0,0 +1,260 @@
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
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OneSignal
17
+ class DeliveryData
18
+ attr_accessor :successful
19
+
20
+ attr_accessor :failed
21
+
22
+ attr_accessor :errored
23
+
24
+ attr_accessor :converted
25
+
26
+ attr_accessor :received
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'successful' => :'successful',
32
+ :'failed' => :'failed',
33
+ :'errored' => :'errored',
34
+ :'converted' => :'converted',
35
+ :'received' => :'received'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'successful' => :'Integer',
48
+ :'failed' => :'Integer',
49
+ :'errored' => :'Integer',
50
+ :'converted' => :'Integer',
51
+ :'received' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ :'successful',
59
+ :'failed',
60
+ :'errored',
61
+ :'converted',
62
+ :'received'
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::DeliveryData` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::DeliveryData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ end
78
+ h[k.to_sym] = v
79
+ }
80
+
81
+ if attributes.key?(:'successful')
82
+ self.successful = attributes[:'successful']
83
+ end
84
+
85
+ if attributes.key?(:'failed')
86
+ self.failed = attributes[:'failed']
87
+ end
88
+
89
+ if attributes.key?(:'errored')
90
+ self.errored = attributes[:'errored']
91
+ end
92
+
93
+ if attributes.key?(:'converted')
94
+ self.converted = attributes[:'converted']
95
+ end
96
+
97
+ if attributes.key?(:'received')
98
+ self.received = attributes[:'received']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ successful == o.successful &&
121
+ failed == o.failed &&
122
+ errored == o.errored &&
123
+ converted == o.converted &&
124
+ received == o.received
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [successful, failed, errored, converted, received].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ attributes = attributes.transform_keys(&:to_sym)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
154
+ self.send("#{key}=", nil)
155
+ elsif type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :Time
176
+ Time.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ # models (e.g. Pet) or oneOf
207
+ klass = OneSignal.const_get(type)
208
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ if value.nil?
231
+ is_nullable = self.class.openapi_nullable.include?(attr)
232
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
+ end
234
+
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to? :to_hash
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+
258
+ end
259
+
260
+ end