Class: Verizon::LocationReport

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

Overview

Location information for up to 1,000 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(dev_location_list: SKIP, has_more_data: SKIP, start_index: SKIP, total_count: SKIP, txid: SKIP, additional_properties: nil) ⇒ LocationReport

Returns a new instance of LocationReport.



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/verizon/models/location_report.rb', line 62

def initialize(dev_location_list: SKIP, has_more_data: SKIP,
               start_index: SKIP, total_count: SKIP, txid: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @dev_location_list = dev_location_list unless dev_location_list == SKIP
  @has_more_data = has_more_data unless has_more_data == SKIP
  @start_index = start_index unless start_index == SKIP
  @total_count = total_count unless total_count == SKIP
  @txid = txid unless txid == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#dev_location_listArray[Location]

Device location information.

Returns:



14
15
16
# File 'lib/verizon/models/location_report.rb', line 14

def dev_location_list
  @dev_location_list
end

#has_more_dataTrueClass | FalseClass

True if there are more device locations to retrieve.

Returns:

  • (TrueClass | FalseClass)


18
19
20
# File 'lib/verizon/models/location_report.rb', line 18

def has_more_data
  @has_more_data
end

#start_indexString

The zero-based number of the first record to return. Set startIndex=0 for the first request. If there are more than 1,000 devices to be returned (hasMoreData=true), set startIndex=1000 for the second request, 2000 for the third request, etc.

Returns:

  • (String)


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

def start_index
  @start_index
end

#total_countInteger

The total number of devices in the original request and in the report.

Returns:

  • (Integer)


29
30
31
# File 'lib/verizon/models/location_report.rb', line 29

def total_count
  @total_count
end

#txidString

The transaction ID of the report.

Returns:

  • (String)


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

def txid
  @txid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/verizon/models/location_report.rb', line 77

def self.from_hash(hash)
  return nil unless hash

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

  dev_location_list = SKIP unless hash.key?('devLocationList')
  has_more_data = hash.key?('hasMoreData') ? hash['hasMoreData'] : SKIP
  start_index = hash.key?('startIndex') ? hash['startIndex'] : SKIP
  total_count = hash.key?('totalCount') ? hash['totalCount'] : SKIP
  txid = hash.key?('txid') ? hash['txid'] : 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.
  LocationReport.new(dev_location_list: dev_location_list,
                     has_more_data: has_more_data,
                     start_index: start_index,
                     total_count: total_count,
                     txid: txid,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/verizon/models/location_report.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dev_location_list'] = 'devLocationList'
  @_hash['has_more_data'] = 'hasMoreData'
  @_hash['start_index'] = 'startIndex'
  @_hash['total_count'] = 'totalCount'
  @_hash['txid'] = 'txid'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/verizon/models/location_report.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    dev_location_list
    has_more_data
    start_index
    total_count
    txid
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



121
122
123
124
125
126
127
# File 'lib/verizon/models/location_report.rb', line 121

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} dev_location_list: #{@dev_location_list.inspect}, has_more_data:"\
  " #{@has_more_data.inspect}, start_index: #{@start_index.inspect}, total_count:"\
  " #{@total_count.inspect}, txid: #{@txid.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



113
114
115
116
117
118
# File 'lib/verizon/models/location_report.rb', line 113

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dev_location_list: #{@dev_location_list}, has_more_data: #{@has_more_data},"\
  " start_index: #{@start_index}, total_count: #{@total_count}, txid: #{@txid},"\
  " additional_properties: #{@additional_properties}>"
end