Class: Verizon::DailyUsageResponse

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

Overview

DailyUsageResponse Model.

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(has_more_data: SKIP, device_id: SKIP, usage_history: SKIP, additional_properties: nil) ⇒ DailyUsageResponse

Returns a new instance of DailyUsageResponse.



50
51
52
53
54
55
56
57
58
59
# File 'lib/verizon/models/daily_usage_response.rb', line 50

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

  @has_more_data = has_more_data unless has_more_data == SKIP
  @device_id = device_id unless device_id == SKIP
  @usage_history = usage_history unless usage_history == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#device_idGioDeviceId

A flag set to indicate if there is more than one page of data returned by the query (true) or if only one page of data returned (false)

Returns:



20
21
22
# File 'lib/verizon/models/daily_usage_response.rb', line 20

def device_id
  @device_id
end

#has_more_dataTrueClass | FalseClass

A flag set to indicate if there is more than one page of data returned by the query (true) or if only one page of data returned (false)

Returns:

  • (TrueClass | FalseClass)


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

def has_more_data
  @has_more_data
end

#usage_historyArray[DailyUsageHistory]

A flag set to indicate if there is more than one page of data returned by the query (true) or if only one page of data returned (false)

Returns:



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

def usage_history
  @usage_history
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
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
# File 'lib/verizon/models/daily_usage_response.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  has_more_data = hash.key?('hasMoreData') ? hash['hasMoreData'] : SKIP
  device_id = GioDeviceId.from_hash(hash['deviceId']) if hash['deviceId']
  # Parameter is an array, so we need to iterate through it
  usage_history = nil
  unless hash['usageHistory'].nil?
    usage_history = []
    hash['usageHistory'].each do |structure|
      usage_history << (DailyUsageHistory.from_hash(structure) if structure)
    end
  end

  usage_history = SKIP unless hash.key?('usageHistory')

  # 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.
  DailyUsageResponse.new(has_more_data: has_more_data,
                         device_id: device_id,
                         usage_history: usage_history,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/verizon/models/daily_usage_response.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['has_more_data'] = 'hasMoreData'
  @_hash['device_id'] = 'deviceId'
  @_hash['usage_history'] = 'usageHistory'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/verizon/models/daily_usage_response.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    has_more_data
    device_id
    usage_history
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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

#to_sObject

Provides a human-readable string representation of the object.



94
95
96
97
98
# File 'lib/verizon/models/daily_usage_response.rb', line 94

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