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(m_filter:, m_limit_number: SKIP, m_limit_time: SKIP, m_page: SKIP, additional_properties: nil) ⇒ HistorySearchRequest

Returns a new instance of HistorySearchRequest.



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

def initialize(m_filter:, m_limit_number: SKIP, m_limit_time: SKIP,
               m_page: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @m_filter = m_filter
  @m_limit_number = m_limit_number unless m_limit_number == SKIP
  @m_limit_time = m_limit_time unless m_limit_time == SKIP
  @m_page = m_page unless m_page == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#m_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 m_filter
  @m_filter
end

#m_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 m_limit_number
  @m_limit_number
end

#m_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 m_limit_time
  @m_limit_time
end

#m_pageString

Page number for pagination purposes.

Returns:

  • (String)


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

def m_page
  @m_page
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/verizon/models/history_search_request.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  m_filter = HistorySearchFilter.from_hash(hash['$filter']) if hash['$filter']
  m_limit_number = hash.key?('$limitNumber') ? hash['$limitNumber'] : SKIP
  m_limit_time = HistorySearchLimitTime.from_hash(hash['$limitTime']) if hash['$limitTime']
  m_page = hash.key?('$page') ? hash['$page'] : 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.
  HistorySearchRequest.new(m_filter: m_filter,
                           m_limit_number: m_limit_number,
                           m_limit_time: m_limit_time,
                           m_page: m_page,
                           additional_properties: additional_properties)
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['m_filter'] = '$filter'
  @_hash['m_limit_number'] = '$limitNumber'
  @_hash['m_limit_time'] = '$limitTime'
  @_hash['m_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[
    m_limit_number
    m_limit_time
    m_page
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
107
# File 'lib/verizon/models/history_search_request.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} m_filter: #{@m_filter.inspect}, m_limit_number: #{@m_limit_number.inspect},"\
  " m_limit_time: #{@m_limit_time.inspect}, m_page: #{@m_page.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
# File 'lib/verizon/models/history_search_request.rb', line 95

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} m_filter: #{@m_filter}, m_limit_number: #{@m_limit_number}, m_limit_time:"\
  " #{@m_limit_time}, m_page: #{@m_page}, additional_properties: #{@additional_properties}>"
end