Class: Verizon::AccountLabels

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/account_labels.rb

Overview

Maximum of 2,000 objects are allowed in the array.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(devices = nil, label = SKIP) ⇒ AccountLabels

Returns a new instance of AccountLabels.



40
41
42
43
# File 'lib/verizon/models/account_labels.rb', line 40

def initialize(devices = nil, label = SKIP)
  @devices = devices
  @label = label unless label == SKIP
end

Instance Attribute Details

#devicesArray[DeviceList]

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/verizon/models/account_labels.rb', line 14

def devices
  @devices
end

#labelArray[DeviceLabels]

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/verizon/models/account_labels.rb', line 18

def label
  @label
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/verizon/models/account_labels.rb', line 46

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  devices = nil
  unless hash['devices'].nil?
    devices = []
    hash['devices'].each do |structure|
      devices << (DeviceList.from_hash(structure) if structure)
    end
  end

  devices = nil unless hash.key?('devices')
  # Parameter is an array, so we need to iterate through it
  label = nil
  unless hash['label'].nil?
    label = []
    hash['label'].each do |structure|
      label << (DeviceLabels.from_hash(structure) if structure)
    end
  end

  label = SKIP unless hash.key?('label')

  # Create object from extracted values.
  AccountLabels.new(devices,
                    label)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/verizon/models/account_labels.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['devices'] = 'devices'
  @_hash['label'] = 'label'
  @_hash
end

.nullablesObject

An array for nullable fields



36
37
38
# File 'lib/verizon/models/account_labels.rb', line 36

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
32
33
# File 'lib/verizon/models/account_labels.rb', line 29

def self.optionals
  %w[
    label
  ]
end