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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(description: SKIP, extended_attributes: SKIP, is_default_group: SKIP, name: SKIP, additional_properties: nil) ⇒ DeviceGroup

Returns a new instance of DeviceGroup.



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/verizon/models/device_group.rb', line 53

def initialize(description: SKIP, extended_attributes: SKIP,
               is_default_group: SKIP, name: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @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
  @additional_properties = additional_properties
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.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/verizon/models/device_group.rb', line 67

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 a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  DeviceGroup.new(description: description,
                  extended_attributes: extended_attributes,
                  is_default_group: is_default_group,
                  name: name,
                  additional_properties: additional_properties)
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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/verizon/models/device_group.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description.inspect}, extended_attributes:"\
  " #{@extended_attributes.inspect}, is_default_group: #{@is_default_group.inspect}, name:"\
  " #{@name.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
107
# File 'lib/verizon/models/device_group.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} description: #{@description}, extended_attributes: #{@extended_attributes},"\
  " is_default_group: #{@is_default_group}, name: #{@name}, additional_properties:"\
  " #{@additional_properties}>"
end