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

#to_hash, #to_json

Constructor Details

#initialize(account_name = nil, device_list = nil, accuracy_mode = SKIP, cache_mode = SKIP) ⇒ LocationRequest

Returns a new instance of LocationRequest.



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

def initialize( = nil, device_list = nil, accuracy_mode = SKIP,
               cache_mode = SKIP)
  @account_name = 
  @device_list = device_list
  @accuracy_mode = accuracy_mode unless accuracy_mode == SKIP
  @cache_mode = cache_mode unless cache_mode == SKIP
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_modeAccuracyModeEnum

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_modeCacheModeEnum

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.



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

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 object from extracted values.
  LocationRequest.new(,
                      device_list,
                      accuracy_mode,
                      cache_mode)
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