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

#to_hash, #to_json

Constructor Details

#initialize(has_more_data = SKIP, device_id = SKIP, usage_history = SKIP) ⇒ DailyUsageResponse

Returns a new instance of DailyUsageResponse.



50
51
52
53
54
# File 'lib/verizon/models/daily_usage_response.rb', line 50

def initialize(has_more_data = SKIP, device_id = SKIP, usage_history = SKIP)
  @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
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.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/verizon/models/daily_usage_response.rb', line 57

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 object from extracted values.
  DailyUsageResponse.new(has_more_data,
                         device_id,
                         usage_history)
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