Class: Verizon::HistorySearchRequest

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

Overview

Used to filter data by time period or number of 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(filter = nil, limit_number = SKIP, limit_time = SKIP, page = SKIP) ⇒ HistorySearchRequest

Returns a new instance of HistorySearchRequest.



57
58
59
60
61
62
63
# File 'lib/verizon/models/history_search_request.rb', line 57

def initialize(filter = nil, limit_number = SKIP, limit_time = SKIP,
               page = SKIP)
  @filter = filter
  @limit_number = limit_number unless limit_number == SKIP
  @limit_time = limit_time unless limit_time == SKIP
  @page = page unless page == SKIP
end

Instance Attribute Details

#filterHistorySearchFilter

The selected device and attributes for which a request should retrieve data.

Returns:



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

def filter
  @filter
end

#limit_numberInteger

The maximum number of historical attributes to include in the response. If the request matches more than this number of attributes, the response will contain an X-Next value in the header that can be used as the page value in the next request to retrieve the next page of events.

Returns:

  • (Integer)


22
23
24
# File 'lib/verizon/models/history_search_request.rb', line 22

def limit_number
  @limit_number
end

#limit_timeHistorySearchLimitTime

The time period for which a request should retrieve data, beginning with the limitTime.startOn and proceeding with the limitTime.duration.



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

def limit_time
  @limit_time
end

#pageString

Page number for pagination purposes.

Returns:

  • (String)


31
32
33
# File 'lib/verizon/models/history_search_request.rb', line 31

def page
  @page
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/verizon/models/history_search_request.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  filter = HistorySearchFilter.from_hash(hash['$filter']) if hash['$filter']
  limit_number = hash.key?('$limitNumber') ? hash['$limitNumber'] : SKIP
  limit_time = HistorySearchLimitTime.from_hash(hash['$limitTime']) if hash['$limitTime']
  page = hash.key?('$page') ? hash['$page'] : SKIP

  # Create object from extracted values.
  HistorySearchRequest.new(filter,
                           limit_number,
                           limit_time,
                           page)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['filter'] = '$filter'
  @_hash['limit_number'] = '$limitNumber'
  @_hash['limit_time'] = '$limitTime'
  @_hash['page'] = '$page'
  @_hash
end

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/verizon/models/history_search_request.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
# File 'lib/verizon/models/history_search_request.rb', line 44

def self.optionals
  %w[
    limit_number
    limit_time
    page
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
94
# File 'lib/verizon/models/history_search_request.rb', line 90

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} filter: #{@filter.inspect}, limit_number: #{@limit_number.inspect},"\
  " limit_time: #{@limit_time.inspect}, page: #{@page.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



83
84
85
86
87
# File 'lib/verizon/models/history_search_request.rb', line 83

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} filter: #{@filter}, limit_number: #{@limit_number}, limit_time:"\
  " #{@limit_time}, page: #{@page}>"
end