Class: Verizon::DeviceGroup

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

Overview

Returns a list of all device groups in a specified account.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(description = SKIP, extended_attributes = SKIP, is_default_group = SKIP, name = SKIP) ⇒ DeviceGroup

Returns a new instance of DeviceGroup.



53
54
55
56
57
58
59
# File 'lib/verizon/models/device_group.rb', line 53

def initialize(description = SKIP, extended_attributes = SKIP,
               is_default_group = SKIP, name = SKIP)
  @description = description unless description == SKIP
  @extended_attributes = extended_attributes unless extended_attributes == SKIP
  @is_default_group = is_default_group unless is_default_group == SKIP
  @name = name unless name == SKIP
end

Instance Attribute Details

#descriptionString

The description of the device group.

Returns:

  • (String)


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

def description
  @description
end

#extended_attributesArray[CustomFields]

Any extended attributes for the device group, as Key and Value pairs.

Returns:



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

def extended_attributes
  @extended_attributes
end

#is_default_groupTrueClass | FalseClass

Identifies the default device group.

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/verizon/models/device_group.rb', line 22

def is_default_group
  @is_default_group
end

#nameString

The name of the device group.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/device_group.rb', line 26

def name
  @name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/verizon/models/device_group.rb', line 62

def self.from_hash(hash)
  return nil unless hash

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

  extended_attributes = SKIP unless hash.key?('extendedAttributes')
  is_default_group =
    hash.key?('isDefaultGroup') ? hash['isDefaultGroup'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP

  # Create object from extracted values.
  DeviceGroup.new(description,
                  extended_attributes,
                  is_default_group,
                  name)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/verizon/models/device_group.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['description'] = 'description'
  @_hash['extended_attributes'] = 'extendedAttributes'
  @_hash['is_default_group'] = 'isDefaultGroup'
  @_hash['name'] = 'name'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/verizon/models/device_group.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/verizon/models/device_group.rb', line 39

def self.optionals
  %w[
    description
    extended_attributes
    is_default_group
    name
  ]
end