onesignal 0.3.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +6 -1
  3. data/README.md +126 -111
  4. data/Rakefile +8 -8
  5. data/docs/App.md +76 -0
  6. data/docs/Button.md +22 -0
  7. data/docs/DefaultApi.md +1394 -0
  8. data/docs/DeliveryData.md +26 -0
  9. data/docs/ExportPlayersRequestBody.md +22 -0
  10. data/docs/Filter.md +24 -0
  11. data/docs/FilterExpressions.md +26 -0
  12. data/docs/FilterNotificationTarget.md +40 -0
  13. data/docs/GetNotificationRequestBody.md +22 -0
  14. data/docs/InlineResponse200.md +24 -0
  15. data/docs/InlineResponse2001.md +18 -0
  16. data/docs/InlineResponse2002.md +20 -0
  17. data/docs/InlineResponse2003.md +18 -0
  18. data/docs/InlineResponse2004.md +20 -0
  19. data/docs/InlineResponse2005.md +18 -0
  20. data/docs/InlineResponse201.md +20 -0
  21. data/docs/InlineResponse400.md +18 -0
  22. data/docs/InlineResponse4001.md +20 -0
  23. data/docs/InlineResponse4002.md +18 -0
  24. data/docs/InlineResponse409.md +20 -0
  25. data/docs/Notification.md +240 -0
  26. data/docs/NotificationAllOf.md +192 -0
  27. data/docs/NotificationAllOfAndroidBackgroundLayout.md +22 -0
  28. data/docs/NotificationSlice.md +24 -0
  29. data/docs/NotificationTarget.md +64 -0
  30. data/docs/Operator.md +18 -0
  31. data/docs/OutcomeData.md +22 -0
  32. data/docs/PlatformDeliveryData.md +28 -0
  33. data/docs/Player.md +70 -0
  34. data/docs/PlayerNotificationTarget.md +36 -0
  35. data/docs/PlayerSlice.md +24 -0
  36. data/docs/Purchase.md +22 -0
  37. data/docs/Segment.md +22 -0
  38. data/docs/SegmentNotificationTarget.md +20 -0
  39. data/docs/StringMap.md +102 -0
  40. data/docs/UpdatePlayerTagsRequestBody.md +18 -0
  41. data/git_push.sh +58 -0
  42. data/lib/OneSignal.rb +75 -0
  43. data/lib/onesignal/api/default_api.rb +1338 -0
  44. data/lib/onesignal/api_client.rb +391 -0
  45. data/lib/onesignal/api_error.rb +57 -0
  46. data/lib/onesignal/configuration.rb +242 -0
  47. data/lib/onesignal/models/app.rb +519 -13
  48. data/lib/onesignal/models/button.rb +241 -0
  49. data/lib/onesignal/models/delivery_data.rb +254 -0
  50. data/lib/onesignal/models/export_players_request_body.rb +241 -0
  51. data/lib/onesignal/models/filter.rb +293 -0
  52. data/lib/onesignal/models/filter_expressions.rb +335 -0
  53. data/lib/onesignal/models/filter_notification_target.rb +329 -0
  54. data/lib/onesignal/models/get_notification_request_body.rb +272 -0
  55. data/lib/onesignal/models/inline_response200.rb +256 -0
  56. data/lib/onesignal/models/inline_response2001.rb +218 -0
  57. data/lib/onesignal/models/inline_response2002.rb +227 -0
  58. data/lib/onesignal/models/inline_response2003.rb +218 -0
  59. data/lib/onesignal/models/inline_response2004.rb +227 -0
  60. data/lib/onesignal/models/inline_response2005.rb +218 -0
  61. data/lib/onesignal/models/inline_response201.rb +228 -0
  62. data/lib/onesignal/models/inline_response400.rb +220 -0
  63. data/lib/onesignal/models/inline_response4001.rb +229 -0
  64. data/lib/onesignal/models/inline_response4002.rb +220 -0
  65. data/lib/onesignal/models/inline_response409.rb +229 -0
  66. data/lib/onesignal/models/notification.rb +1395 -5
  67. data/lib/onesignal/models/notification_all_of.rb +1124 -0
  68. data/lib/onesignal/models/notification_all_of_android_background_layout.rb +240 -0
  69. data/lib/onesignal/models/notification_slice.rb +247 -0
  70. data/lib/onesignal/models/notification_target.rb +494 -0
  71. data/lib/onesignal/models/operator.rb +253 -0
  72. data/lib/onesignal/models/outcome_data.rb +285 -0
  73. data/lib/onesignal/models/platform_delivery_data.rb +264 -0
  74. data/lib/onesignal/models/player.rb +483 -9
  75. data/lib/onesignal/models/player_notification_target.rb +329 -0
  76. data/lib/onesignal/models/player_slice.rb +247 -0
  77. data/lib/onesignal/models/purchase.rb +254 -0
  78. data/lib/onesignal/models/segment.rb +251 -0
  79. data/lib/onesignal/models/segment_notification_target.rb +233 -0
  80. data/lib/onesignal/models/string_map.rb +644 -0
  81. data/lib/onesignal/models/update_player_tags_request_body.rb +219 -0
  82. data/lib/onesignal/version.rb +13 -1
  83. data/onesignal.gemspec +36 -27
  84. data/spec/api/default_api_spec.rb +285 -0
  85. data/spec/api_client_spec.rb +226 -0
  86. data/spec/configuration_spec.rb +42 -0
  87. data/spec/models/app_spec.rb +212 -0
  88. data/spec/models/button_spec.rb +46 -0
  89. data/spec/models/delivery_data_spec.rb +58 -0
  90. data/spec/models/export_players_request_body_spec.rb +46 -0
  91. data/spec/models/filter_expressions_spec.rb +66 -0
  92. data/spec/models/filter_notification_target_spec.rb +100 -0
  93. data/spec/models/filter_spec.rb +56 -0
  94. data/spec/models/get_notification_request_body_spec.rb +50 -0
  95. data/spec/models/inline_response2001_spec.rb +34 -0
  96. data/spec/models/inline_response2002_spec.rb +40 -0
  97. data/spec/models/inline_response2003_spec.rb +34 -0
  98. data/spec/models/inline_response2004_spec.rb +40 -0
  99. data/spec/models/inline_response2005_spec.rb +34 -0
  100. data/spec/models/inline_response200_spec.rb +52 -0
  101. data/spec/models/inline_response201_spec.rb +40 -0
  102. data/spec/models/inline_response4001_spec.rb +40 -0
  103. data/spec/models/inline_response4002_spec.rb +34 -0
  104. data/spec/models/inline_response400_spec.rb +34 -0
  105. data/spec/models/inline_response409_spec.rb +40 -0
  106. data/spec/models/notification_all_of_android_background_layout_spec.rb +46 -0
  107. data/spec/models/notification_all_of_spec.rb +560 -0
  108. data/spec/models/notification_slice_spec.rb +52 -0
  109. data/spec/models/notification_spec.rb +704 -0
  110. data/spec/models/notification_target_spec.rb +172 -0
  111. data/spec/models/operator_spec.rb +38 -0
  112. data/spec/models/outcome_data_spec.rb +50 -0
  113. data/spec/models/platform_delivery_data_spec.rb +64 -0
  114. data/spec/models/player_notification_target_spec.rb +88 -0
  115. data/spec/models/player_slice_spec.rb +52 -0
  116. data/spec/models/player_spec.rb +190 -0
  117. data/spec/models/purchase_spec.rb +46 -0
  118. data/spec/models/segment_notification_target_spec.rb +40 -0
  119. data/spec/models/segment_spec.rb +46 -0
  120. data/spec/models/string_map_spec.rb +286 -0
  121. data/spec/models/update_player_tags_request_body_spec.rb +34 -0
  122. data/spec/spec_helper.rb +111 -0
  123. metadata +182 -65
  124. data/.gitignore +0 -10
  125. data/.rubocop.yml +0 -17
  126. data/.travis.yml +0 -16
  127. data/CHANGELOG.md +0 -22
  128. data/CODE_OF_CONDUCT.md +0 -49
  129. data/LICENSE +0 -21
  130. data/bin/console +0 -14
  131. data/bin/setup +0 -8
  132. data/lib/onesignal/app_id_missing_error.rb +0 -7
  133. data/lib/onesignal/client.rb +0 -44
  134. data/lib/onesignal/models/base_model.rb +0 -40
  135. data/lib/onesignal/request.rb +0 -94
  136. data/lib/onesignal/request_error.rb +0 -21
  137. data/lib/onesignal/resources/app_resource.rb +0 -27
  138. data/lib/onesignal/resources/base_resource.rb +0 -35
  139. data/lib/onesignal/resources/notification_resource.rb +0 -33
  140. data/lib/onesignal/resources/player_resource.rb +0 -53
  141. data/lib/onesignal.rb +0 -23
@@ -1,19 +1,493 @@
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.0
7
+ Contact: devrel@onesignal.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
1
16
  module OneSignal
2
- class Player < BaseModel
3
- def created_at=(time)
4
- @created_at = Time.at(time)
17
+ class Player
18
+ # The device's OneSignal ID
19
+ attr_accessor :id
20
+
21
+ # If true, this is the equivalent of a user being Unsubscribed
22
+ attr_accessor :invalid_identifier
23
+
24
+ attr_accessor :app_id
25
+
26
+ # Required The device's platform: 0 = iOS 1 = Android 2 = Amazon 3 = WindowsPhone (MPNS) 4 = Chrome Apps / Extensions 5 = Chrome Web Push 6 = Windows (WNS) 7 = Safari 8 = Firefox 9 = MacOS 10 = Alexa 11 = Email 13 = For Huawei App Gallery Builds SDK Setup. Not for Huawei Devices using FCM 14 = SMS
27
+ attr_accessor :device_type
28
+
29
+ # a custom user ID
30
+ attr_accessor :external_user_id
31
+
32
+ # Only required if you have enabled Identity Verification and device_type is NOT 11 email.
33
+ attr_accessor :external_user_id_auth_hash
34
+
35
+ # Email - Only required if you have enabled Identity Verification and device_type is email (11).
36
+ attr_accessor :email_auth_hash
37
+
38
+ # Recommended: For Push Notifications, this is the Push Token Identifier from Google or Apple. For Apple Push identifiers, you must strip all non alphanumeric characters. Examples: iOS: 7abcd558f29d0b1f048083e2834ad8ea4b3d87d8ad9c088b33c132706ff445f0 Android: APA91bHbYHk7aq-Uam_2pyJ2qbZvqllyyh2wjfPRaw5gLEX2SUlQBRvOc6sck1sa7H7nGeLNlDco8lXj83HWWwzV... For Email Addresses, set the full email address email@email.com and make sure to set device_type to 11.
39
+ attr_accessor :identifier
40
+
41
+ # Language code. Typically lower case two letters, except for Chinese where it must be one of zh-Hans or zh-Hant. Example: en
42
+ attr_accessor :language
43
+
44
+ # Number of seconds away from UTC. Example: -28800
45
+ attr_accessor :timezone
46
+
47
+ # Version of your app. Example: 1.1
48
+ attr_accessor :game_version
49
+
50
+ # Device make and model. Example: iPhone5,1
51
+ attr_accessor :device_model
52
+
53
+ # Device operating system version. Example: 7.0.4
54
+ attr_accessor :device_os
55
+
56
+ # The ad id for the device's platform: Android = Advertising Id iOS = identifierForVendor WP8.0 = DeviceUniqueId WP8.1 = AdvertisingId
57
+ attr_accessor :ad_id
58
+
59
+ # Name and version of the sdk/plugin that's calling this API method (if any)
60
+ attr_accessor :sdk
61
+
62
+ # Number of times the user has played the game, defaults to 1
63
+ attr_accessor :session_count
64
+
65
+ # Custom tags for the player. Only support string and integer key value pairs. Does not support arrays or other nested objects. Setting a tag value to null or an empty string will remove the tag. Example: {\"foo\":\"bar\",\"this\":\"that\"} Limitations: - 100 tags per call - Android SDK users: tags cannot be removed or changed via API if set through SDK sendTag methods. Recommended to only tag devices with 1 kilobyte of data Please consider using your own Database to save more than 1 kilobyte of data. See: Internal Database & CRM
66
+ attr_accessor :tags
67
+
68
+ # Amount the user has spent in USD, up to two decimal places
69
+ attr_accessor :amount_spent
70
+
71
+ # Unixtime when the player joined the game
72
+ attr_accessor :created_at
73
+
74
+ # Seconds player was running your app.
75
+ attr_accessor :playtime
76
+
77
+ # Current iOS badge count displayed on the app icon NOTE: Not supported for apps created after June 2018, since badge count for apps created after this date are handled on the client.
78
+ attr_accessor :badge_count
79
+
80
+ # Unixtime when the player was last active
81
+ attr_accessor :last_active
82
+
83
+ # 1 = subscribed -2 = unsubscribed iOS - These values are set each time the user opens the app from the SDK. Use the SDK function set Subscription instead. Android - You may set this but you can no longer use the SDK method setSubscription later in your app as it will create synchronization issues.
84
+ attr_accessor :notification_types
85
+
86
+ # This is used in deciding whether to use your iOS Sandbox or Production push certificate when sending a push when both have been uploaded. Set to the iOS provisioning profile that was used to build your app. 1 = Development 2 = Ad-Hoc Omit this field for App Store builds.
87
+ attr_accessor :test_type
88
+
89
+ # Longitude of the device, used for geotagging to segment on.
90
+ attr_accessor :long
91
+
92
+ # Latitude of the device, used for geotagging to segment on.
93
+ attr_accessor :lat
94
+
95
+ # Country code in the ISO 3166-1 Alpha 2 format
96
+ attr_accessor :country
97
+
98
+ # Attribute mapping from ruby-style variable name to JSON key.
99
+ def self.attribute_map
100
+ {
101
+ :'id' => :'id',
102
+ :'invalid_identifier' => :'invalid_identifier',
103
+ :'app_id' => :'app_id',
104
+ :'device_type' => :'device_type',
105
+ :'external_user_id' => :'external_user_id',
106
+ :'external_user_id_auth_hash' => :'external_user_id_auth_hash',
107
+ :'email_auth_hash' => :'email_auth_hash',
108
+ :'identifier' => :'identifier',
109
+ :'language' => :'language',
110
+ :'timezone' => :'timezone',
111
+ :'game_version' => :'game_version',
112
+ :'device_model' => :'device_model',
113
+ :'device_os' => :'device_os',
114
+ :'ad_id' => :'ad_id',
115
+ :'sdk' => :'sdk',
116
+ :'session_count' => :'session_count',
117
+ :'tags' => :'tags',
118
+ :'amount_spent' => :'amount_spent',
119
+ :'created_at' => :'created_at',
120
+ :'playtime' => :'playtime',
121
+ :'badge_count' => :'badge_count',
122
+ :'last_active' => :'last_active',
123
+ :'notification_types' => :'notification_types',
124
+ :'test_type' => :'test_type',
125
+ :'long' => :'long',
126
+ :'lat' => :'lat',
127
+ :'country' => :'country'
128
+ }
129
+ end
130
+
131
+ # Returns all the JSON keys this model knows about
132
+ def self.acceptable_attributes
133
+ attribute_map.values
134
+ end
135
+
136
+ # Attribute type mapping.
137
+ def self.openapi_types
138
+ {
139
+ :'id' => :'String',
140
+ :'invalid_identifier' => :'Boolean',
141
+ :'app_id' => :'String',
142
+ :'device_type' => :'Integer',
143
+ :'external_user_id' => :'String',
144
+ :'external_user_id_auth_hash' => :'String',
145
+ :'email_auth_hash' => :'String',
146
+ :'identifier' => :'String',
147
+ :'language' => :'String',
148
+ :'timezone' => :'Integer',
149
+ :'game_version' => :'String',
150
+ :'device_model' => :'String',
151
+ :'device_os' => :'String',
152
+ :'ad_id' => :'String',
153
+ :'sdk' => :'String',
154
+ :'session_count' => :'Integer',
155
+ :'tags' => :'Object',
156
+ :'amount_spent' => :'String',
157
+ :'created_at' => :'Integer',
158
+ :'playtime' => :'Integer',
159
+ :'badge_count' => :'Integer',
160
+ :'last_active' => :'Integer',
161
+ :'notification_types' => :'Integer',
162
+ :'test_type' => :'Integer',
163
+ :'long' => :'Float',
164
+ :'lat' => :'Float',
165
+ :'country' => :'String'
166
+ }
167
+ end
168
+
169
+ # List of attributes with nullable: true
170
+ def self.openapi_nullable
171
+ Set.new([
172
+ ])
173
+ end
174
+
175
+ # Initializes the object
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ def initialize(attributes = {})
178
+ if (!attributes.is_a?(Hash))
179
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Player` initialize method"
180
+ end
181
+
182
+ # check to see if the attribute exists and convert string to symbol for hash key
183
+ attributes = attributes.each_with_object({}) { |(k, v), h|
184
+ if (!self.class.attribute_map.key?(k.to_sym))
185
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OneSignal::Player`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
186
+ end
187
+ h[k.to_sym] = v
188
+ }
189
+
190
+ if attributes.key?(:'id')
191
+ self.id = attributes[:'id']
192
+ end
193
+
194
+ if attributes.key?(:'invalid_identifier')
195
+ self.invalid_identifier = attributes[:'invalid_identifier']
196
+ end
197
+
198
+ if attributes.key?(:'app_id')
199
+ self.app_id = attributes[:'app_id']
200
+ end
201
+
202
+ if attributes.key?(:'device_type')
203
+ self.device_type = attributes[:'device_type']
204
+ end
205
+
206
+ if attributes.key?(:'external_user_id')
207
+ self.external_user_id = attributes[:'external_user_id']
208
+ end
209
+
210
+ if attributes.key?(:'external_user_id_auth_hash')
211
+ self.external_user_id_auth_hash = attributes[:'external_user_id_auth_hash']
212
+ end
213
+
214
+ if attributes.key?(:'email_auth_hash')
215
+ self.email_auth_hash = attributes[:'email_auth_hash']
216
+ end
217
+
218
+ if attributes.key?(:'identifier')
219
+ self.identifier = attributes[:'identifier']
220
+ end
221
+
222
+ if attributes.key?(:'language')
223
+ self.language = attributes[:'language']
224
+ end
225
+
226
+ if attributes.key?(:'timezone')
227
+ self.timezone = attributes[:'timezone']
228
+ end
229
+
230
+ if attributes.key?(:'game_version')
231
+ self.game_version = attributes[:'game_version']
232
+ end
233
+
234
+ if attributes.key?(:'device_model')
235
+ self.device_model = attributes[:'device_model']
236
+ end
237
+
238
+ if attributes.key?(:'device_os')
239
+ self.device_os = attributes[:'device_os']
240
+ end
241
+
242
+ if attributes.key?(:'ad_id')
243
+ self.ad_id = attributes[:'ad_id']
244
+ end
245
+
246
+ if attributes.key?(:'sdk')
247
+ self.sdk = attributes[:'sdk']
248
+ end
249
+
250
+ if attributes.key?(:'session_count')
251
+ self.session_count = attributes[:'session_count']
252
+ end
253
+
254
+ if attributes.key?(:'tags')
255
+ self.tags = attributes[:'tags']
256
+ end
257
+
258
+ if attributes.key?(:'amount_spent')
259
+ self.amount_spent = attributes[:'amount_spent']
260
+ end
261
+
262
+ if attributes.key?(:'created_at')
263
+ self.created_at = attributes[:'created_at']
264
+ end
265
+
266
+ if attributes.key?(:'playtime')
267
+ self.playtime = attributes[:'playtime']
268
+ end
269
+
270
+ if attributes.key?(:'badge_count')
271
+ self.badge_count = attributes[:'badge_count']
272
+ end
273
+
274
+ if attributes.key?(:'last_active')
275
+ self.last_active = attributes[:'last_active']
276
+ end
277
+
278
+ if attributes.key?(:'notification_types')
279
+ self.notification_types = attributes[:'notification_types']
280
+ end
281
+
282
+ if attributes.key?(:'test_type')
283
+ self.test_type = attributes[:'test_type']
284
+ end
285
+
286
+ if attributes.key?(:'long')
287
+ self.long = attributes[:'long']
288
+ end
289
+
290
+ if attributes.key?(:'lat')
291
+ self.lat = attributes[:'lat']
292
+ end
293
+
294
+ if attributes.key?(:'country')
295
+ self.country = attributes[:'country']
296
+ end
5
297
  end
6
298
 
7
- def device_type=(type)
8
- if type.is_a?(Integer)
9
- type = OneSignal::DEVICE_TYPES[type]
299
+ # Show invalid properties with the reasons. Usually used together with valid?
300
+ # @return Array for valid properties with the reasons
301
+ def list_invalid_properties
302
+ invalid_properties = Array.new
303
+ if @id.nil?
304
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
10
305
  end
11
306
 
12
- @device_type = type
307
+ if @app_id.nil?
308
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
309
+ end
310
+
311
+ if @device_type.nil?
312
+ invalid_properties.push('invalid value for "device_type", device_type cannot be nil.')
313
+ end
314
+
315
+ invalid_properties
316
+ end
317
+
318
+ # Check to see if the all the properties in the model are valid
319
+ # @return true if the model is valid
320
+ def valid?
321
+ return false if @id.nil?
322
+ return false if @app_id.nil?
323
+ return false if @device_type.nil?
324
+ true
325
+ end
326
+
327
+ # Checks equality by comparing each attribute.
328
+ # @param [Object] Object to be compared
329
+ def ==(o)
330
+ return true if self.equal?(o)
331
+ self.class == o.class &&
332
+ id == o.id &&
333
+ invalid_identifier == o.invalid_identifier &&
334
+ app_id == o.app_id &&
335
+ device_type == o.device_type &&
336
+ external_user_id == o.external_user_id &&
337
+ external_user_id_auth_hash == o.external_user_id_auth_hash &&
338
+ email_auth_hash == o.email_auth_hash &&
339
+ identifier == o.identifier &&
340
+ language == o.language &&
341
+ timezone == o.timezone &&
342
+ game_version == o.game_version &&
343
+ device_model == o.device_model &&
344
+ device_os == o.device_os &&
345
+ ad_id == o.ad_id &&
346
+ sdk == o.sdk &&
347
+ session_count == o.session_count &&
348
+ tags == o.tags &&
349
+ amount_spent == o.amount_spent &&
350
+ created_at == o.created_at &&
351
+ playtime == o.playtime &&
352
+ badge_count == o.badge_count &&
353
+ last_active == o.last_active &&
354
+ notification_types == o.notification_types &&
355
+ test_type == o.test_type &&
356
+ long == o.long &&
357
+ lat == o.lat &&
358
+ country == o.country
359
+ end
360
+
361
+ # @see the `==` method
362
+ # @param [Object] Object to be compared
363
+ def eql?(o)
364
+ self == o
365
+ end
366
+
367
+ # Calculates hash code according to all attributes.
368
+ # @return [Integer] Hash code
369
+ def hash
370
+ [id, invalid_identifier, app_id, device_type, external_user_id, external_user_id_auth_hash, email_auth_hash, identifier, language, timezone, game_version, device_model, device_os, ad_id, sdk, session_count, tags, amount_spent, created_at, playtime, badge_count, last_active, notification_types, test_type, long, lat, country].hash
371
+ end
372
+
373
+ # Builds the object from hash
374
+ # @param [Hash] attributes Model attributes in the form of hash
375
+ # @return [Object] Returns the model itself
376
+ def self.build_from_hash(attributes)
377
+ new.build_from_hash(attributes)
378
+ end
379
+
380
+ # Builds the object from hash
381
+ # @param [Hash] attributes Model attributes in the form of hash
382
+ # @return [Object] Returns the model itself
383
+ def build_from_hash(attributes)
384
+ return nil unless attributes.is_a?(Hash)
385
+ self.class.openapi_types.each_pair do |key, type|
386
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
387
+ self.send("#{key}=", nil)
388
+ elsif type =~ /\AArray<(.*)>/i
389
+ # check to ensure the input is an array given that the attribute
390
+ # is documented as an array but the input is not
391
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
392
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
393
+ end
394
+ elsif !attributes[self.class.attribute_map[key]].nil?
395
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
396
+ end
397
+ end
398
+
399
+ self
400
+ end
401
+
402
+ # Deserializes the data based on type
403
+ # @param string type Data type
404
+ # @param string value Value to be deserialized
405
+ # @return [Object] Deserialized data
406
+ def _deserialize(type, value)
407
+ case type.to_sym
408
+ when :Time
409
+ Time.parse(value)
410
+ when :Date
411
+ Date.parse(value)
412
+ when :String
413
+ value.to_s
414
+ when :Integer
415
+ value.to_i
416
+ when :Float
417
+ value.to_f
418
+ when :Boolean
419
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
420
+ true
421
+ else
422
+ false
423
+ end
424
+ when :Object
425
+ # generic object (usually a Hash), return directly
426
+ value
427
+ when /\AArray<(?<inner_type>.+)>\z/
428
+ inner_type = Regexp.last_match[:inner_type]
429
+ value.map { |v| _deserialize(inner_type, v) }
430
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
431
+ k_type = Regexp.last_match[:k_type]
432
+ v_type = Regexp.last_match[:v_type]
433
+ {}.tap do |hash|
434
+ value.each do |k, v|
435
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
436
+ end
437
+ end
438
+ else # model
439
+ # models (e.g. Pet) or oneOf
440
+ klass = OneSignal.const_get(type)
441
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
442
+ end
443
+ end
444
+
445
+ # Returns the string representation of the object
446
+ # @return [String] String presentation of the object
447
+ def to_s
448
+ to_hash.to_s
449
+ end
450
+
451
+ # to_body is an alias to to_hash (backward compatibility)
452
+ # @return [Hash] Returns the object in the form of hash
453
+ def to_body
454
+ to_hash
455
+ end
456
+
457
+ # Returns the object in the form of hash
458
+ # @return [Hash] Returns the object in the form of hash
459
+ def to_hash
460
+ hash = {}
461
+ self.class.attribute_map.each_pair do |attr, param|
462
+ value = self.send(attr)
463
+ if value.nil?
464
+ is_nullable = self.class.openapi_nullable.include?(attr)
465
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
466
+ end
467
+
468
+ hash[param] = _to_hash(value)
469
+ end
470
+ hash
13
471
  end
14
472
 
15
- def last_active=(time)
16
- @last_active = Time.at(time)
473
+ # Outputs non-array value in the form of hash
474
+ # For object, use to_hash. Otherwise, just return the value
475
+ # @param [Object] value Any valid value
476
+ # @return [Hash] Returns the value in the form of hash
477
+ def _to_hash(value)
478
+ if value.is_a?(Array)
479
+ value.compact.map { |v| _to_hash(v) }
480
+ elsif value.is_a?(Hash)
481
+ {}.tap do |hash|
482
+ value.each { |k, v| hash[k] = _to_hash(v) }
483
+ end
484
+ elsif value.respond_to? :to_hash
485
+ value.to_hash
486
+ else
487
+ value
488
+ end
17
489
  end
490
+
18
491
  end
492
+
19
493
  end