Class: Verizon::AddDevicesRequest

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

Overview

Request to add the devices.

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(state:, devices_to_add:, account_name: SKIP, custom_fields: SKIP, group_name: SKIP, sku_number: SKIP, smsr_oid: SKIP, additional_properties: nil) ⇒ AddDevicesRequest

Returns a new instance of AddDevicesRequest.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/verizon/models/add_devices_request.rb', line 74

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

  @state = state
  @devices_to_add = devices_to_add
  @account_name =  unless  == SKIP
  @custom_fields = custom_fields unless custom_fields == SKIP
  @group_name = group_name unless group_name == SKIP
  @sku_number = sku_number unless sku_number == SKIP
  @smsr_oid = smsr_oid unless smsr_oid == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

The billing account to which the devices are added.

Returns:

  • (String)


23
24
25
# File 'lib/verizon/models/add_devices_request.rb', line 23

def 
  @account_name
end

#custom_fieldsArray[CustomFields]

The names and values for any custom fields that you want set for the devices as they are added to the account.

Returns:



28
29
30
# File 'lib/verizon/models/add_devices_request.rb', line 28

def custom_fields
  @custom_fields
end

#devices_to_addArray[AccountDeviceList]

The devices that you want to add.

Returns:



19
20
21
# File 'lib/verizon/models/add_devices_request.rb', line 19

def devices_to_add
  @devices_to_add
end

#group_nameString

The name of a device group to add the devices to. They are added to the default device group if you don’t include this parameter.

Returns:

  • (String)


33
34
35
# File 'lib/verizon/models/add_devices_request.rb', line 33

def group_name
  @group_name
end

#sku_numberString

The Stock Keeping Unit (SKU) number of a 4G device type with an embedded SIM.

Returns:

  • (String)


38
39
40
# File 'lib/verizon/models/add_devices_request.rb', line 38

def sku_number
  @sku_number
end

#smsr_oidString

The Stock Keeping Unit (SKU) number of a 4G device type with an embedded SIM.

Returns:

  • (String)


43
44
45
# File 'lib/verizon/models/add_devices_request.rb', line 43

def smsr_oid
  @smsr_oid
end

#stateString

The initial service state for the devices. The only valid state is “Preactive.”

Returns:

  • (String)


15
16
17
# File 'lib/verizon/models/add_devices_request.rb', line 15

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/verizon/models/add_devices_request.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  state = hash.key?('state') ? hash['state'] : 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 << (AccountDeviceList.from_hash(structure) if structure)
    end
  end

  devices_to_add = nil unless hash.key?('devicesToAdd')
   = hash.key?('accountName') ? hash['accountName'] : SKIP
  # Parameter is an array, so we need to iterate through it
  custom_fields = nil
  unless hash['customFields'].nil?
    custom_fields = []
    hash['customFields'].each do |structure|
      custom_fields << (CustomFields.from_hash(structure) if structure)
    end
  end

  custom_fields = SKIP unless hash.key?('customFields')
  group_name = hash.key?('groupName') ? hash['groupName'] : SKIP
  sku_number = hash.key?('skuNumber') ? hash['skuNumber'] : SKIP
  smsr_oid = hash.key?('smsrOid') ? hash['smsrOid'] : 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.
  AddDevicesRequest.new(state: state,
                        devices_to_add: devices_to_add,
                        account_name: ,
                        custom_fields: custom_fields,
                        group_name: group_name,
                        sku_number: sku_number,
                        smsr_oid: smsr_oid,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/verizon/models/add_devices_request.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['state'] = 'state'
  @_hash['devices_to_add'] = 'devicesToAdd'
  @_hash['account_name'] = 'accountName'
  @_hash['custom_fields'] = 'customFields'
  @_hash['group_name'] = 'groupName'
  @_hash['sku_number'] = 'skuNumber'
  @_hash['smsr_oid'] = 'smsrOid'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/verizon/models/add_devices_request.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
# File 'lib/verizon/models/add_devices_request.rb', line 59

def self.optionals
  %w[
    account_name
    custom_fields
    group_name
    sku_number
    smsr_oid
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



149
150
151
152
153
154
155
# File 'lib/verizon/models/add_devices_request.rb', line 149

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} state: #{@state.inspect}, devices_to_add: #{@devices_to_add.inspect},"\
  " account_name: #{@account_name.inspect}, custom_fields: #{@custom_fields.inspect},"\
  " group_name: #{@group_name.inspect}, sku_number: #{@sku_number.inspect}, smsr_oid:"\
  " #{@smsr_oid.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



140
141
142
143
144
145
146
# File 'lib/verizon/models/add_devices_request.rb', line 140

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