Class: Verizon::LocationRequest

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

Overview

The body contains the the account name and list of devices that you want to locate, plus other options.

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:, device_list:, accuracy_mode: SKIP, cache_mode: SKIP, additional_properties: nil) ⇒ LocationRequest

Returns a new instance of LocationRequest.



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

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

  @account_name = 
  @device_list = device_list
  @accuracy_mode = accuracy_mode unless accuracy_mode == SKIP
  @cache_mode = cache_mode unless cache_mode == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

Account identifier in “##########-#####”.

Returns:

  • (String)


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

def 
  @account_name
end

#accuracy_modeAccuracyMode

Accurary, currently only 0-coarse supported.

Returns:



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

def accuracy_mode
  @accuracy_mode
end

#cache_modeCacheMode

Location cache mode.

Returns:



27
28
29
# File 'lib/verizon/models/location_request.rb', line 27

def cache_mode
  @cache_mode
end

#device_listArray[DeviceInfo]

Device list.

Returns:



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

def device_list
  @device_list
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
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
# File 'lib/verizon/models/location_request.rb', line 65

def self.from_hash(hash)
  return nil unless hash

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

  device_list = nil unless hash.key?('deviceList')
  accuracy_mode = hash.key?('accuracyMode') ? hash['accuracyMode'] : SKIP
  cache_mode = hash.key?('cacheMode') ? hash['cacheMode'] : 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.
  LocationRequest.new(account_name: ,
                      device_list: device_list,
                      accuracy_mode: accuracy_mode,
                      cache_mode: cache_mode,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_name'] = 'accountName'
  @_hash['device_list'] = 'deviceList'
  @_hash['accuracy_mode'] = 'accuracyMode'
  @_hash['cache_mode'] = 'cacheMode'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/verizon/models/location_request.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    accuracy_mode
    cache_mode
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
112
# File 'lib/verizon/models/location_request.rb', line 107

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name.inspect}, device_list:"\
  " #{@device_list.inspect}, accuracy_mode: #{@accuracy_mode.inspect}, cache_mode:"\
  " #{@cache_mode.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
104
# File 'lib/verizon/models/location_request.rb', line 99

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