Class: Verizon::CreateDeviceGroupRequest

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

Overview

Create request for a new device group and optionally add devices to the group.

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(account_name:, group_description:, group_name:, devices_to_add: SKIP, additional_properties: nil) ⇒ CreateDeviceGroupRequest

Returns a new instance of CreateDeviceGroupRequest.



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

def initialize(account_name:, group_description:, group_name:,
               devices_to_add: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_name = 
  @group_description = group_description
  @group_name = group_name
  @devices_to_add = devices_to_add unless devices_to_add == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

The Verizon billing account that the device group will belong to. An account name is usually numeric, and must include any leading zeros.

Returns:

  • (String)


16
17
18
# File 'lib/verizon/models/create_device_group_request.rb', line 16

def 
  @account_name
end

#devices_to_addArray[DeviceId]

Zero or more devices to add to the device group. You can use POST /devices/actions/list to get a list of all devices in the account.

Returns:



30
31
32
# File 'lib/verizon/models/create_device_group_request.rb', line 30

def devices_to_add
  @devices_to_add
end

#group_descriptionString

A description for the device group.

Returns:

  • (String)


20
21
22
# File 'lib/verizon/models/create_device_group_request.rb', line 20

def group_description
  @group_description
end

#group_nameString

The name for the new device group. This name must be unique within the specified account.

Returns:

  • (String)


25
26
27
# File 'lib/verizon/models/create_device_group_request.rb', line 25

def group_name
  @group_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/create_device_group_request.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : nil
  group_description =
    hash.key?('groupDescription') ? hash['groupDescription'] : nil
  group_name = hash.key?('groupName') ? hash['groupName'] : nil
  # Parameter is an array, so we need to iterate through it
  devices_to_add = nil
  unless hash['devicesToAdd'].nil?
    devices_to_add = []
    hash['devicesToAdd'].each do |structure|
      devices_to_add << (DeviceId.from_hash(structure) if structure)
    end
  end

  devices_to_add = SKIP unless hash.key?('devicesToAdd')

  # 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.
  CreateDeviceGroupRequest.new(account_name: ,
                               group_description: group_description,
                               group_name: group_name,
                               devices_to_add: devices_to_add,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
# File 'lib/verizon/models/create_device_group_request.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_name'] = 'accountName'
  @_hash['group_description'] = 'groupDescription'
  @_hash['group_name'] = 'groupName'
  @_hash['devices_to_add'] = 'devicesToAdd'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/verizon/models/create_device_group_request.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



43
44
45
46
47
# File 'lib/verizon/models/create_device_group_request.rb', line 43

def self.optionals
  %w[
    devices_to_add
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name.inspect}, group_description:"\
  " #{@group_description.inspect}, group_name: #{@group_name.inspect}, devices_to_add:"\
  " #{@devices_to_add.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/create_device_group_request.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name}, group_description: #{@group_description},"\
  " group_name: #{@group_name}, devices_to_add: #{@devices_to_add}, additional_properties:"\
  " #{@additional_properties}>"
end