Class: OneSignal::App

Inherits:
Object
  • Object
show all
Defined in:
lib/onesignal/models/app.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ App

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/onesignal/models/app.rb', line 202

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OneSignal::App` 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::App`. 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?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'players')
    self.players = attributes[:'players']
  end

  if attributes.key?(:'messageable_players')
    self.messageable_players = attributes[:'messageable_players']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'android_gcm_sender_id')
    self.android_gcm_sender_id = attributes[:'android_gcm_sender_id']
  end

  if attributes.key?(:'gcm_key')
    self.gcm_key = attributes[:'gcm_key']
  end

  if attributes.key?(:'chrome_web_origin')
    self.chrome_web_origin = attributes[:'chrome_web_origin']
  end

  if attributes.key?(:'chrome_key')
    self.chrome_key = attributes[:'chrome_key']
  end

  if attributes.key?(:'chrome_web_default_notification_icon')
    self.chrome_web_default_notification_icon = attributes[:'chrome_web_default_notification_icon']
  end

  if attributes.key?(:'chrome_web_sub_domain')
    self.chrome_web_sub_domain = attributes[:'chrome_web_sub_domain']
  end

  if attributes.key?(:'apns_env')
    self.apns_env = attributes[:'apns_env']
  end

  if attributes.key?(:'apns_p12')
    self.apns_p12 = attributes[:'apns_p12']
  end

  if attributes.key?(:'apns_p12_password')
    self.apns_p12_password = attributes[:'apns_p12_password']
  end

  if attributes.key?(:'apns_certificates')
    self.apns_certificates = attributes[:'apns_certificates']
  end

  if attributes.key?(:'safari_apns_certificates')
    self.safari_apns_certificates = attributes[:'safari_apns_certificates']
  end

  if attributes.key?(:'safari_apns_p12')
    self.safari_apns_p12 = attributes[:'safari_apns_p12']
  end

  if attributes.key?(:'safari_apns_p12_password')
    self.safari_apns_p12_password = attributes[:'safari_apns_p12_password']
  end

  if attributes.key?(:'safari_site_origin')
    self.safari_site_origin = attributes[:'safari_site_origin']
  end

  if attributes.key?(:'safari_push_id')
    self.safari_push_id = attributes[:'safari_push_id']
  end

  if attributes.key?(:'safari_icon_16_16')
    self.safari_icon_16_16 = attributes[:'safari_icon_16_16']
  end

  if attributes.key?(:'safari_icon_32_32')
    self.safari_icon_32_32 = attributes[:'safari_icon_32_32']
  end

  if attributes.key?(:'safari_icon_64_64')
    self.safari_icon_64_64 = attributes[:'safari_icon_64_64']
  end

  if attributes.key?(:'safari_icon_128_128')
    self.safari_icon_128_128 = attributes[:'safari_icon_128_128']
  end

  if attributes.key?(:'safari_icon_256_256')
    self.safari_icon_256_256 = attributes[:'safari_icon_256_256']
  end

  if attributes.key?(:'site_name')
    self.site_name = attributes[:'site_name']
  end

  if attributes.key?(:'basic_auth_key')
    self.basic_auth_key = attributes[:'basic_auth_key']
  end

  if attributes.key?(:'organization_id')
    self.organization_id = attributes[:'organization_id']
  end

  if attributes.key?(:'additional_data_is_root_payload')
    self.additional_data_is_root_payload = attributes[:'additional_data_is_root_payload']
  end
end

Instance Attribute Details

#additional_data_is_root_payloadObject

iOS: Notification data (additional data) values will be added to the root of the apns payload when sent to the device. Ignore if you’re not using any other plugins, or not using OneSignal SDK methods to read the payload.



93
94
95
# File 'lib/onesignal/models/app.rb', line 93

def additional_data_is_root_payload
  @additional_data_is_root_payload
end

#android_gcm_sender_idObject

Android: Your Google Project number. Also known as Sender ID.



32
33
34
# File 'lib/onesignal/models/app.rb', line 32

def android_gcm_sender_id
  @android_gcm_sender_id
end

#apns_certificatesObject

Returns the value of attribute apns_certificates.



58
59
60
# File 'lib/onesignal/models/app.rb', line 58

def apns_certificates
  @apns_certificates
end

#apns_envObject

iOS: Either sandbox or production



50
51
52
# File 'lib/onesignal/models/app.rb', line 50

def apns_env
  @apns_env
end

#apns_p12Object

iOS: Your apple push notification p12 certificate file, converted to a string and Base64 encoded.



53
54
55
# File 'lib/onesignal/models/app.rb', line 53

def apns_p12
  @apns_p12
end

#apns_p12_passwordObject

iOS: Required if using p12 certificate. Password for the apns_p12 file.



56
57
58
# File 'lib/onesignal/models/app.rb', line 56

def apns_p12_password
  @apns_p12_password
end

#basic_auth_keyObject

Returns the value of attribute basic_auth_key.



87
88
89
# File 'lib/onesignal/models/app.rb', line 87

def basic_auth_key
  @basic_auth_key
end

#chrome_keyObject

Not for web push. Your Google Push Messaging Auth Key if you use Chrome Apps / Extensions.



41
42
43
# File 'lib/onesignal/models/app.rb', line 41

def chrome_key
  @chrome_key
end

#chrome_web_default_notification_iconObject

Chrome (All Browsers except Safari): Your default notification icon. Should be 256x256 pixels, min 80x80.



44
45
46
# File 'lib/onesignal/models/app.rb', line 44

def chrome_web_default_notification_icon
  @chrome_web_default_notification_icon
end

#chrome_web_originObject

Chrome (All Browsers except Safari) (Recommended): The URL to your website. This field is required if you wish to enable web push and specify other web push parameters.



38
39
40
# File 'lib/onesignal/models/app.rb', line 38

def chrome_web_origin
  @chrome_web_origin
end

#chrome_web_sub_domainObject

Chrome (All Browsers except Safari): A subdomain of your choice in order to support Web Push on non-HTTPS websites. This field must be set in order for the chrome_web_gcm_sender_id property to be processed.



47
48
49
# File 'lib/onesignal/models/app.rb', line 47

def chrome_web_sub_domain
  @chrome_web_sub_domain
end

#created_atObject

Returns the value of attribute created_at.



29
30
31
# File 'lib/onesignal/models/app.rb', line 29

def created_at
  @created_at
end

#gcm_keyObject

Android: Your Google Push Messaging Auth Key



35
36
37
# File 'lib/onesignal/models/app.rb', line 35

def gcm_key
  @gcm_key
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/onesignal/models/app.rb', line 18

def id
  @id
end

#messageable_playersObject

Returns the value of attribute messageable_players.



25
26
27
# File 'lib/onesignal/models/app.rb', line 25

def messageable_players
  @messageable_players
end

#nameObject

The name of your app, as displayed on your apps list on the dashboard. This can be renamed.



21
22
23
# File 'lib/onesignal/models/app.rb', line 21

def name
  @name
end

#organization_idObject

The Id of the Organization you would like to add this app to.



90
91
92
# File 'lib/onesignal/models/app.rb', line 90

def organization_id
  @organization_id
end

#playersObject

Returns the value of attribute players.



23
24
25
# File 'lib/onesignal/models/app.rb', line 23

def players
  @players
end

#safari_apns_certificatesObject

Returns the value of attribute safari_apns_certificates.



60
61
62
# File 'lib/onesignal/models/app.rb', line 60

def safari_apns_certificates
  @safari_apns_certificates
end

#safari_apns_p12Object

Safari: Your apple push notification p12 certificate file for Safari Push Notifications, converted to a string and Base64 encoded.



63
64
65
# File 'lib/onesignal/models/app.rb', line 63

def safari_apns_p12
  @safari_apns_p12
end

#safari_apns_p12_passwordObject

Safari: Password for safari_apns_p12 file



66
67
68
# File 'lib/onesignal/models/app.rb', line 66

def safari_apns_p12_password
  @safari_apns_p12_password
end

#safari_icon_128_128Object

Returns the value of attribute safari_icon_128_128.



79
80
81
# File 'lib/onesignal/models/app.rb', line 79

def safari_icon_128_128
  @safari_icon_128_128
end

#safari_icon_16_16Object

Returns the value of attribute safari_icon_16_16.



73
74
75
# File 'lib/onesignal/models/app.rb', line 73

def safari_icon_16_16
  @safari_icon_16_16
end

#safari_icon_256_256Object

Safari: A url for a 256x256 png notification icon. This is the only Safari icon URL you need to provide.



82
83
84
# File 'lib/onesignal/models/app.rb', line 82

def safari_icon_256_256
  @safari_icon_256_256
end

#safari_icon_32_32Object

Returns the value of attribute safari_icon_32_32.



75
76
77
# File 'lib/onesignal/models/app.rb', line 75

def safari_icon_32_32
  @safari_icon_32_32
end

#safari_icon_64_64Object

Returns the value of attribute safari_icon_64_64.



77
78
79
# File 'lib/onesignal/models/app.rb', line 77

def safari_icon_64_64
  @safari_icon_64_64
end

#safari_push_idObject

Returns the value of attribute safari_push_id.



71
72
73
# File 'lib/onesignal/models/app.rb', line 71

def safari_push_id
  @safari_push_id
end

#safari_site_originObject

Safari (Recommended): The hostname to your website including http(s)://



69
70
71
# File 'lib/onesignal/models/app.rb', line 69

def safari_site_origin
  @safari_site_origin
end

#site_nameObject

All Browsers (Recommended): The Site Name. Requires both chrome_web_origin and safari_site_origin to be set to add or update it.



85
86
87
# File 'lib/onesignal/models/app.rb', line 85

def site_name
  @site_name
end

#updated_atObject

Returns the value of attribute updated_at.



27
28
29
# File 'lib/onesignal/models/app.rb', line 27

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



154
155
156
# File 'lib/onesignal/models/app.rb', line 154

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/onesignal/models/app.rb', line 118

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'players' => :'players',
    :'messageable_players' => :'messageable_players',
    :'updated_at' => :'updated_at',
    :'created_at' => :'created_at',
    :'android_gcm_sender_id' => :'android_gcm_sender_id',
    :'gcm_key' => :'gcm_key',
    :'chrome_web_origin' => :'chrome_web_origin',
    :'chrome_key' => :'chrome_key',
    :'chrome_web_default_notification_icon' => :'chrome_web_default_notification_icon',
    :'chrome_web_sub_domain' => :'chrome_web_sub_domain',
    :'apns_env' => :'apns_env',
    :'apns_p12' => :'apns_p12',
    :'apns_p12_password' => :'apns_p12_password',
    :'apns_certificates' => :'apns_certificates',
    :'safari_apns_certificates' => :'safari_apns_certificates',
    :'safari_apns_p12' => :'safari_apns_p12',
    :'safari_apns_p12_password' => :'safari_apns_p12_password',
    :'safari_site_origin' => :'safari_site_origin',
    :'safari_push_id' => :'safari_push_id',
    :'safari_icon_16_16' => :'safari_icon_16_16',
    :'safari_icon_32_32' => :'safari_icon_32_32',
    :'safari_icon_64_64' => :'safari_icon_64_64',
    :'safari_icon_128_128' => :'safari_icon_128_128',
    :'safari_icon_256_256' => :'safari_icon_256_256',
    :'site_name' => :'site_name',
    :'basic_auth_key' => :'basic_auth_key',
    :'organization_id' => :'organization_id',
    :'additional_data_is_root_payload' => :'additional_data_is_root_payload'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



418
419
420
# File 'lib/onesignal/models/app.rb', line 418

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



195
196
197
198
# File 'lib/onesignal/models/app.rb', line 195

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/onesignal/models/app.rb', line 159

def self.openapi_types
  {
    :'id' => :'String',
    :'name' => :'String',
    :'players' => :'Integer',
    :'messageable_players' => :'Integer',
    :'updated_at' => :'Time',
    :'created_at' => :'Time',
    :'android_gcm_sender_id' => :'String',
    :'gcm_key' => :'String',
    :'chrome_web_origin' => :'String',
    :'chrome_key' => :'String',
    :'chrome_web_default_notification_icon' => :'String',
    :'chrome_web_sub_domain' => :'String',
    :'apns_env' => :'String',
    :'apns_p12' => :'String',
    :'apns_p12_password' => :'String',
    :'apns_certificates' => :'String',
    :'safari_apns_certificates' => :'String',
    :'safari_apns_p12' => :'String',
    :'safari_apns_p12_password' => :'String',
    :'safari_site_origin' => :'String',
    :'safari_push_id' => :'String',
    :'safari_icon_16_16' => :'String',
    :'safari_icon_32_32' => :'String',
    :'safari_icon_64_64' => :'String',
    :'safari_icon_128_128' => :'String',
    :'safari_icon_256_256' => :'String',
    :'site_name' => :'String',
    :'basic_auth_key' => :'String',
    :'organization_id' => :'String',
    :'additional_data_is_root_payload' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/onesignal/models/app.rb', line 368

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      players == o.players &&
      messageable_players == o.messageable_players &&
      updated_at == o.updated_at &&
      created_at == o.created_at &&
      android_gcm_sender_id == o.android_gcm_sender_id &&
      gcm_key == o.gcm_key &&
      chrome_web_origin == o.chrome_web_origin &&
      chrome_key == o.chrome_key &&
      chrome_web_default_notification_icon == o.chrome_web_default_notification_icon &&
      chrome_web_sub_domain == o.chrome_web_sub_domain &&
      apns_env == o.apns_env &&
      apns_p12 == o.apns_p12 &&
      apns_p12_password == o.apns_p12_password &&
      apns_certificates == o.apns_certificates &&
      safari_apns_certificates == o.safari_apns_certificates &&
      safari_apns_p12 == o.safari_apns_p12 &&
      safari_apns_p12_password == o.safari_apns_p12_password &&
      safari_site_origin == o.safari_site_origin &&
      safari_push_id == o.safari_push_id &&
      safari_icon_16_16 == o.safari_icon_16_16 &&
      safari_icon_32_32 == o.safari_icon_32_32 &&
      safari_icon_64_64 == o.safari_icon_64_64 &&
      safari_icon_128_128 == o.safari_icon_128_128 &&
      safari_icon_256_256 == o.safari_icon_256_256 &&
      site_name == o.site_name &&
      basic_auth_key == o.basic_auth_key &&
      organization_id == o.organization_id &&
      additional_data_is_root_payload == o.additional_data_is_root_payload
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/onesignal/models/app.rb', line 449

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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/onesignal/models/app.rb', line 520

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/onesignal/models/app.rb', line 425

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


405
406
407
# File 'lib/onesignal/models/app.rb', line 405

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



411
412
413
# File 'lib/onesignal/models/app.rb', line 411

def hash
  [id, name, players, messageable_players, updated_at, created_at, android_gcm_sender_id, gcm_key, chrome_web_origin, chrome_key, chrome_web_default_notification_icon, chrome_web_sub_domain, apns_env, apns_p12, apns_p12_password, apns_certificates, safari_apns_certificates, safari_apns_p12, safari_apns_p12_password, safari_site_origin, safari_push_id, safari_icon_16_16, safari_icon_32_32, safari_icon_64_64, safari_icon_128_128, safari_icon_256_256, site_name, basic_auth_key, organization_id, additional_data_is_root_payload].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



338
339
340
341
342
343
344
345
# File 'lib/onesignal/models/app.rb', line 338

def list_invalid_properties
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



496
497
498
# File 'lib/onesignal/models/app.rb', line 496

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/onesignal/models/app.rb', line 502

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



490
491
492
# File 'lib/onesignal/models/app.rb', line 490

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



349
350
351
352
353
354
# File 'lib/onesignal/models/app.rb', line 349

def valid?
  return false if @id.nil?
  apns_env_validator = EnumAttributeValidator.new('String', ["sandbox", "production"])
  return false unless apns_env_validator.valid?(@apns_env)
  true
end