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,255 @@
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 Purchase
18
+ # The unique identifier of the purchased item.
19
+ attr_accessor :sku
20
+
21
+ # The amount, in USD, spent purchasing the item.
22
+ attr_accessor :amount
23
+
24
+ # The 3-letter ISO 4217 currency code. Required for correct storage and conversion of amount.
25
+ attr_accessor :iso
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'sku' => :'sku',
31
+ :'amount' => :'amount',
32
+ :'iso' => :'iso'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'sku' => :'String',
45
+ :'amount' => :'Float',
46
+ :'iso' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Purchase` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Purchase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'sku')
72
+ self.sku = attributes[:'sku']
73
+ end
74
+
75
+ if attributes.key?(:'amount')
76
+ self.amount = attributes[:'amount']
77
+ end
78
+
79
+ if attributes.key?(:'iso')
80
+ self.iso = attributes[:'iso']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @sku.nil?
89
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
90
+ end
91
+
92
+ if @amount.nil?
93
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
94
+ end
95
+
96
+ if @iso.nil?
97
+ invalid_properties.push('invalid value for "iso", iso cannot be nil.')
98
+ end
99
+
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ return false if @sku.nil?
107
+ return false if @amount.nil?
108
+ return false if @iso.nil?
109
+ true
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ sku == o.sku &&
118
+ amount == o.amount &&
119
+ iso == o.iso
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [sku, amount, iso].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ self.class.openapi_types.each_pair do |key, type|
148
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
149
+ self.send("#{key}=", nil)
150
+ elsif type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = OneSignal.const_get(type)
203
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end
@@ -0,0 +1,252 @@
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 Segment
18
+ # UUID of the segment. If left empty, it will be assigned automaticaly.
19
+ attr_accessor :id
20
+
21
+ # Name of the segment. You'll see this name on the Web UI.
22
+ attr_accessor :name
23
+
24
+ # Filter or operators the segment will have. For a list of available filters with details, please see Send to Users Based on Filters.
25
+ attr_accessor :filters
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'id' => :'id',
31
+ :'name' => :'name',
32
+ :'filters' => :'filters'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'id' => :'String',
45
+ :'name' => :'String',
46
+ :'filters' => :'Array<FilterExpressions>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Segment` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Segment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'id')
72
+ self.id = attributes[:'id']
73
+ end
74
+
75
+ if attributes.key?(:'name')
76
+ self.name = attributes[:'name']
77
+ end
78
+
79
+ if attributes.key?(:'filters')
80
+ if (value = attributes[:'filters']).is_a?(Array)
81
+ self.filters = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @name.nil?
91
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
92
+ end
93
+
94
+ if @filters.nil?
95
+ invalid_properties.push('invalid value for "filters", filters cannot be nil.')
96
+ end
97
+
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ return false if @name.nil?
105
+ return false if @filters.nil?
106
+ true
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ id == o.id &&
115
+ name == o.name &&
116
+ filters == o.filters
117
+ end
118
+
119
+ # @see the `==` method
120
+ # @param [Object] Object to be compared
121
+ def eql?(o)
122
+ self == o
123
+ end
124
+
125
+ # Calculates hash code according to all attributes.
126
+ # @return [Integer] Hash code
127
+ def hash
128
+ [id, name, filters].hash
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def self.build_from_hash(attributes)
135
+ new.build_from_hash(attributes)
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ attributes = attributes.transform_keys(&:to_sym)
144
+ self.class.openapi_types.each_pair do |key, type|
145
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
146
+ self.send("#{key}=", nil)
147
+ elsif type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :Time
168
+ Time.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ # models (e.g. Pet) or oneOf
199
+ klass = OneSignal.const_get(type)
200
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
201
+ end
202
+ end
203
+
204
+ # Returns the string representation of the object
205
+ # @return [String] String presentation of the object
206
+ def to_s
207
+ to_hash.to_s
208
+ end
209
+
210
+ # to_body is an alias to to_hash (backward compatibility)
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_body
213
+ to_hash
214
+ end
215
+
216
+ # Returns the object in the form of hash
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_hash
219
+ hash = {}
220
+ self.class.attribute_map.each_pair do |attr, param|
221
+ value = self.send(attr)
222
+ if value.nil?
223
+ is_nullable = self.class.openapi_nullable.include?(attr)
224
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
225
+ end
226
+
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end