Class: Verizon::UsageHistory

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

Overview

UsageHistory Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(bytes_used = SKIP, serviceplan = SKIP, sms_used = SKIP, mo_sms = SKIP, mt_sms = SKIP, source = SKIP, event_date_time = SKIP) ⇒ UsageHistory

Returns a new instance of UsageHistory.



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/verizon/models/usage_history.rb', line 72

def initialize(bytes_used = SKIP, serviceplan = SKIP, sms_used = SKIP,
               mo_sms = SKIP, mt_sms = SKIP, source = SKIP,
               event_date_time = SKIP)
  @bytes_used = bytes_used unless bytes_used == SKIP
  @serviceplan = serviceplan unless serviceplan == SKIP
  @sms_used = sms_used unless sms_used == SKIP
  @mo_sms = mo_sms unless mo_sms == SKIP
  @mt_sms = mt_sms unless mt_sms == SKIP
  @source = source unless source == SKIP
  @event_date_time = event_date_time unless event_date_time == SKIP
end

Instance Attribute Details

#bytes_usedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def bytes_used
  @bytes_used
end

#event_date_timeDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


39
40
41
# File 'lib/verizon/models/usage_history.rb', line 39

def event_date_time
  @event_date_time
end

#mo_smsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def mo_sms
  @mo_sms
end

#mt_smsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def mt_sms
  @mt_sms
end

#serviceplanString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/verizon/models/usage_history.rb', line 19

def serviceplan
  @serviceplan
end

#sms_usedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


23
24
25
# File 'lib/verizon/models/usage_history.rb', line 23

def sms_used
  @sms_used
end

#sourceString

TODO: Write general description for this method

Returns:

  • (String)


35
36
37
# File 'lib/verizon/models/usage_history.rb', line 35

def source
  @source
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/verizon/models/usage_history.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  bytes_used = hash.key?('bytesUsed') ? hash['bytesUsed'] : SKIP
  serviceplan = hash.key?('serviceplan') ? hash['serviceplan'] : SKIP
  sms_used = hash.key?('smsUsed') ? hash['smsUsed'] : SKIP
  mo_sms = hash.key?('moSMS') ? hash['moSMS'] : SKIP
  mt_sms = hash.key?('mtSMS') ? hash['mtSMS'] : SKIP
  source = hash.key?('source') ? hash['source'] : SKIP
  event_date_time = if hash.key?('eventDateTime')
                      (DateTimeHelper.from_rfc3339(hash['eventDateTime']) if hash['eventDateTime'])
                    else
                      SKIP
                    end

  # Create object from extracted values.
  UsageHistory.new(bytes_used,
                   serviceplan,
                   sms_used,
                   mo_sms,
                   mt_sms,
                   source,
                   event_date_time)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/verizon/models/usage_history.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['bytes_used'] = 'bytesUsed'
  @_hash['serviceplan'] = 'serviceplan'
  @_hash['sms_used'] = 'smsUsed'
  @_hash['mo_sms'] = 'moSMS'
  @_hash['mt_sms'] = 'mtSMS'
  @_hash['source'] = 'source'
  @_hash['event_date_time'] = 'eventDateTime'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/verizon/models/usage_history.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/verizon/models/usage_history.rb', line 55

def self.optionals
  %w[
    bytes_used
    serviceplan
    sms_used
    mo_sms
    mt_sms
    source
    event_date_time
  ]
end

Instance Method Details

#to_custom_event_date_timeObject



111
112
113
# File 'lib/verizon/models/usage_history.rb', line 111

def to_custom_event_date_time
  DateTimeHelper.to_rfc3339(event_date_time)
end