Class: OneSignal::Player
- Inherits:
-
Object
- Object
- OneSignal::Player
- Defined in:
- lib/onesignal/models/player.rb
Instance Attribute Summary collapse
-
#ad_id ⇒ Object
The ad id for the device’s platform: Android = Advertising Id iOS = identifierForVendor WP8.0 = DeviceUniqueId WP8.1 = AdvertisingId.
-
#amount_spent ⇒ Object
Amount the user has spent in USD, up to two decimal places.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#badge_count ⇒ Object
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.
-
#country ⇒ Object
Country code in the ISO 3166-1 Alpha 2 format.
-
#created_at ⇒ Object
Unixtime when the player joined the game.
-
#device_model ⇒ Object
Device make and model.
-
#device_os ⇒ Object
Device operating system version.
-
#device_type ⇒ Object
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.
-
#email_auth_hash ⇒ Object
Email - Only required if you have enabled Identity Verification and device_type is email (11).
-
#external_user_id ⇒ Object
a custom user ID.
-
#external_user_id_auth_hash ⇒ Object
Only required if you have enabled Identity Verification and device_type is NOT 11 email.
-
#game_version ⇒ Object
Version of your app.
-
#id ⇒ Object
The device’s OneSignal ID.
-
#identifier ⇒ Object
Recommended: For Push Notifications, this is the Push Token Identifier from Google or Apple.
-
#invalid_identifier ⇒ Object
If true, this is the equivalent of a user being Unsubscribed.
-
#language ⇒ Object
Language code.
-
#last_active ⇒ Object
Unixtime when the player was last active.
-
#lat ⇒ Object
Latitude of the device, used for geotagging to segment on.
-
#long ⇒ Object
Longitude of the device, used for geotagging to segment on.
-
#notification_types ⇒ Object
1 = subscribed -2 = unsubscribed iOS - These values are set each time the user opens the app from the SDK.
-
#playtime ⇒ Object
Seconds player was running your app.
-
#sdk ⇒ Object
Name and version of the sdk/plugin that’s calling this API method (if any).
-
#session_count ⇒ Object
Number of times the user has played the game, defaults to 1.
-
#tags ⇒ Object
Custom tags for the player.
-
#test_type ⇒ Object
This is used in deciding whether to use your iOS Sandbox or Production push certificate when sending a push when both have been uploaded.
-
#timezone ⇒ Object
Number of seconds away from UTC.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Player
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Player
Initializes the object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/onesignal/models/player.rb', line 187 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::Player` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) 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 end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'invalid_identifier') self.invalid_identifier = attributes[:'invalid_identifier'] end if attributes.key?(:'app_id') self.app_id = attributes[:'app_id'] end if attributes.key?(:'device_type') self.device_type = attributes[:'device_type'] end if attributes.key?(:'external_user_id') self.external_user_id = attributes[:'external_user_id'] end if attributes.key?(:'external_user_id_auth_hash') self.external_user_id_auth_hash = attributes[:'external_user_id_auth_hash'] end if attributes.key?(:'email_auth_hash') self.email_auth_hash = attributes[:'email_auth_hash'] end if attributes.key?(:'identifier') self.identifier = attributes[:'identifier'] end if attributes.key?(:'language') self.language = attributes[:'language'] end if attributes.key?(:'timezone') self.timezone = attributes[:'timezone'] end if attributes.key?(:'game_version') self.game_version = attributes[:'game_version'] end if attributes.key?(:'device_model') self.device_model = attributes[:'device_model'] end if attributes.key?(:'device_os') self.device_os = attributes[:'device_os'] end if attributes.key?(:'ad_id') self.ad_id = attributes[:'ad_id'] end if attributes.key?(:'sdk') self.sdk = attributes[:'sdk'] end if attributes.key?(:'session_count') self.session_count = attributes[:'session_count'] end if attributes.key?(:'tags') self. = attributes[:'tags'] end if attributes.key?(:'amount_spent') self.amount_spent = attributes[:'amount_spent'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'playtime') self.playtime = attributes[:'playtime'] end if attributes.key?(:'badge_count') self.badge_count = attributes[:'badge_count'] end if attributes.key?(:'last_active') self.last_active = attributes[:'last_active'] end if attributes.key?(:'notification_types') self.notification_types = attributes[:'notification_types'] end if attributes.key?(:'test_type') self.test_type = attributes[:'test_type'] end if attributes.key?(:'long') self.long = attributes[:'long'] end if attributes.key?(:'lat') self.lat = attributes[:'lat'] end if attributes.key?(:'country') self.country = attributes[:'country'] end end |
Instance Attribute Details
#ad_id ⇒ Object
The ad id for the device’s platform: Android = Advertising Id iOS = identifierForVendor WP8.0 = DeviceUniqueId WP8.1 = AdvertisingId
57 58 59 |
# File 'lib/onesignal/models/player.rb', line 57 def ad_id @ad_id end |
#amount_spent ⇒ Object
Amount the user has spent in USD, up to two decimal places
69 70 71 |
# File 'lib/onesignal/models/player.rb', line 69 def amount_spent @amount_spent end |
#app_id ⇒ Object
Returns the value of attribute app_id.
24 25 26 |
# File 'lib/onesignal/models/player.rb', line 24 def app_id @app_id end |
#badge_count ⇒ Object
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 79 80 |
# File 'lib/onesignal/models/player.rb', line 78 def badge_count @badge_count end |
#country ⇒ Object
Country code in the ISO 3166-1 Alpha 2 format
96 97 98 |
# File 'lib/onesignal/models/player.rb', line 96 def country @country end |
#created_at ⇒ Object
Unixtime when the player joined the game
72 73 74 |
# File 'lib/onesignal/models/player.rb', line 72 def created_at @created_at end |
#device_model ⇒ Object
Device make and model. Example: iPhone5,1
51 52 53 |
# File 'lib/onesignal/models/player.rb', line 51 def device_model @device_model end |
#device_os ⇒ Object
Device operating system version. Example: 7.0.4
54 55 56 |
# File 'lib/onesignal/models/player.rb', line 54 def device_os @device_os end |
#device_type ⇒ Object
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 28 29 |
# File 'lib/onesignal/models/player.rb', line 27 def device_type @device_type end |
#email_auth_hash ⇒ Object
Email - Only required if you have enabled Identity Verification and device_type is email (11).
36 37 38 |
# File 'lib/onesignal/models/player.rb', line 36 def email_auth_hash @email_auth_hash end |
#external_user_id ⇒ Object
a custom user ID
30 31 32 |
# File 'lib/onesignal/models/player.rb', line 30 def external_user_id @external_user_id end |
#external_user_id_auth_hash ⇒ Object
Only required if you have enabled Identity Verification and device_type is NOT 11 email.
33 34 35 |
# File 'lib/onesignal/models/player.rb', line 33 def external_user_id_auth_hash @external_user_id_auth_hash end |
#game_version ⇒ Object
Version of your app. Example: 1.1
48 49 50 |
# File 'lib/onesignal/models/player.rb', line 48 def game_version @game_version end |
#id ⇒ Object
The device’s OneSignal ID
19 20 21 |
# File 'lib/onesignal/models/player.rb', line 19 def id @id end |
#identifier ⇒ Object
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 protected] and make sure to set device_type to 11.
39 40 41 |
# File 'lib/onesignal/models/player.rb', line 39 def identifier @identifier end |
#invalid_identifier ⇒ Object
If true, this is the equivalent of a user being Unsubscribed
22 23 24 |
# File 'lib/onesignal/models/player.rb', line 22 def invalid_identifier @invalid_identifier end |
#language ⇒ Object
Language code. Typically lower case two letters, except for Chinese where it must be one of zh-Hans or zh-Hant. Example: en
42 43 44 |
# File 'lib/onesignal/models/player.rb', line 42 def language @language end |
#last_active ⇒ Object
Unixtime when the player was last active
81 82 83 |
# File 'lib/onesignal/models/player.rb', line 81 def last_active @last_active end |
#lat ⇒ Object
Latitude of the device, used for geotagging to segment on.
93 94 95 |
# File 'lib/onesignal/models/player.rb', line 93 def lat @lat end |
#long ⇒ Object
Longitude of the device, used for geotagging to segment on.
90 91 92 |
# File 'lib/onesignal/models/player.rb', line 90 def long @long end |
#notification_types ⇒ Object
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 85 86 |
# File 'lib/onesignal/models/player.rb', line 84 def notification_types @notification_types end |
#playtime ⇒ Object
Seconds player was running your app.
75 76 77 |
# File 'lib/onesignal/models/player.rb', line 75 def playtime @playtime end |
#sdk ⇒ Object
Name and version of the sdk/plugin that’s calling this API method (if any)
60 61 62 |
# File 'lib/onesignal/models/player.rb', line 60 def sdk @sdk end |
#session_count ⇒ Object
Number of times the user has played the game, defaults to 1
63 64 65 |
# File 'lib/onesignal/models/player.rb', line 63 def session_count @session_count end |
#tags ⇒ Object
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 67 68 |
# File 'lib/onesignal/models/player.rb', line 66 def @tags end |
#test_type ⇒ Object
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 88 89 |
# File 'lib/onesignal/models/player.rb', line 87 def test_type @test_type end |
#timezone ⇒ Object
Number of seconds away from UTC. Example: -28800
45 46 47 |
# File 'lib/onesignal/models/player.rb', line 45 def timezone @timezone end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
132 133 134 |
# File 'lib/onesignal/models/player.rb', line 132 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/onesignal/models/player.rb', line 99 def self.attribute_map { :'id' => :'id', :'invalid_identifier' => :'invalid_identifier', :'app_id' => :'app_id', :'device_type' => :'device_type', :'external_user_id' => :'external_user_id', :'external_user_id_auth_hash' => :'external_user_id_auth_hash', :'email_auth_hash' => :'email_auth_hash', :'identifier' => :'identifier', :'language' => :'language', :'timezone' => :'timezone', :'game_version' => :'game_version', :'device_model' => :'device_model', :'device_os' => :'device_os', :'ad_id' => :'ad_id', :'sdk' => :'sdk', :'session_count' => :'session_count', :'tags' => :'tags', :'amount_spent' => :'amount_spent', :'created_at' => :'created_at', :'playtime' => :'playtime', :'badge_count' => :'badge_count', :'last_active' => :'last_active', :'notification_types' => :'notification_types', :'test_type' => :'test_type', :'long' => :'long', :'lat' => :'lat', :'country' => :'country' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
376 377 378 |
# File 'lib/onesignal/models/player.rb', line 376 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/onesignal/models/player.rb', line 170 def self.openapi_nullable Set.new([ :'external_user_id', :'identifier', :'timezone', :'game_version', :'device_model', :'device_os', :'ad_id', :'sdk', :'tags', :'test_type', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/onesignal/models/player.rb', line 137 def self.openapi_types { :'id' => :'String', :'invalid_identifier' => :'Boolean', :'app_id' => :'String', :'device_type' => :'Integer', :'external_user_id' => :'String', :'external_user_id_auth_hash' => :'String', :'email_auth_hash' => :'String', :'identifier' => :'String', :'language' => :'String', :'timezone' => :'Integer', :'game_version' => :'String', :'device_model' => :'String', :'device_os' => :'String', :'ad_id' => :'String', :'sdk' => :'String', :'session_count' => :'Integer', :'tags' => :'Object', :'amount_spent' => :'Float', :'created_at' => :'Integer', :'playtime' => :'Integer', :'badge_count' => :'Integer', :'last_active' => :'Integer', :'notification_types' => :'Integer', :'test_type' => :'Integer', :'long' => :'Float', :'lat' => :'Float', :'country' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/onesignal/models/player.rb', line 329 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && invalid_identifier == o.invalid_identifier && app_id == o.app_id && device_type == o.device_type && external_user_id == o.external_user_id && external_user_id_auth_hash == o.external_user_id_auth_hash && email_auth_hash == o.email_auth_hash && identifier == o.identifier && language == o.language && timezone == o.timezone && game_version == o.game_version && device_model == o.device_model && device_os == o.device_os && ad_id == o.ad_id && sdk == o.sdk && session_count == o.session_count && == o. && amount_spent == o.amount_spent && created_at == o.created_at && playtime == o.playtime && badge_count == o.badge_count && last_active == o.last_active && notification_types == o.notification_types && test_type == o.test_type && long == o.long && lat == o.lat && country == o.country end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/onesignal/models/player.rb', line 407 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = OneSignal.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/onesignal/models/player.rb', line 478 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/onesignal/models/player.rb', line 383 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
363 364 365 |
# File 'lib/onesignal/models/player.rb', line 363 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
369 370 371 |
# File 'lib/onesignal/models/player.rb', line 369 def hash [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, , amount_spent, created_at, playtime, badge_count, last_active, notification_types, test_type, long, lat, country].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
311 312 313 314 315 316 317 318 |
# File 'lib/onesignal/models/player.rb', line 311 def list_invalid_properties invalid_properties = Array.new if @device_type.nil? invalid_properties.push('invalid value for "device_type", device_type cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
454 455 456 |
# File 'lib/onesignal/models/player.rb', line 454 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/onesignal/models/player.rb', line 460 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
448 449 450 |
# File 'lib/onesignal/models/player.rb', line 448 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
322 323 324 325 |
# File 'lib/onesignal/models/player.rb', line 322 def valid? return false if @device_type.nil? true end |