Class: Verizon::Usage
- Defined in:
- lib/verizon/models/usage.rb
Overview
The daily network data usage of a single device during a specified time period.
Instance Attribute Summary collapse
-
#bytes_used ⇒ Integer
The number of bytes that the device sent or received on the report date.
-
#extended_attributes ⇒ Array[CustomFields]
The number of mobile-originated and mobile-terminated SMS messages on the report date.
-
#service_plan ⇒ String
The list of service plans associated with the device/account.
-
#sms_used ⇒ Integer
The number of SMS messages that were sent or received on the report date.
-
#source ⇒ String
The source of the information for the reported usage.
-
#timestamp ⇒ String
The date of the recorded usage.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(bytes_used = SKIP, extended_attributes = SKIP, service_plan = SKIP, sms_used = SKIP, source = SKIP, timestamp = SKIP) ⇒ Usage
constructor
A new instance of Usage.
Methods inherited from BaseModel
Constructor Details
#initialize(bytes_used = SKIP, extended_attributes = SKIP, service_plan = SKIP, sms_used = SKIP, source = SKIP, timestamp = SKIP) ⇒ Usage
Returns a new instance of Usage.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/verizon/models/usage.rb', line 67 def initialize(bytes_used = SKIP, extended_attributes = SKIP, service_plan = SKIP, sms_used = SKIP, source = SKIP, = SKIP) @bytes_used = bytes_used unless bytes_used == SKIP @extended_attributes = extended_attributes unless extended_attributes == SKIP @service_plan = service_plan unless service_plan == SKIP @sms_used = sms_used unless sms_used == SKIP @source = source unless source == SKIP @timestamp = unless == SKIP end |
Instance Attribute Details
#bytes_used ⇒ Integer
The number of bytes that the device sent or received on the report date.
15 16 17 |
# File 'lib/verizon/models/usage.rb', line 15 def bytes_used @bytes_used end |
#extended_attributes ⇒ Array[CustomFields]
The number of mobile-originated and mobile-terminated SMS messages on the report date.
20 21 22 |
# File 'lib/verizon/models/usage.rb', line 20 def extended_attributes @extended_attributes end |
#service_plan ⇒ String
The list of service plans associated with the device/account.
24 25 26 |
# File 'lib/verizon/models/usage.rb', line 24 def service_plan @service_plan end |
#sms_used ⇒ Integer
The number of SMS messages that were sent or received on the report date.
28 29 30 |
# File 'lib/verizon/models/usage.rb', line 28 def sms_used @sms_used end |
#source ⇒ String
The source of the information for the reported usage.
32 33 34 |
# File 'lib/verizon/models/usage.rb', line 32 def source @source end |
#timestamp ⇒ String
The date of the recorded usage.
36 37 38 |
# File 'lib/verizon/models/usage.rb', line 36 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
82 83 84 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.rb', line 82 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. bytes_used = hash.key?('bytesUsed') ? hash['bytesUsed'] : SKIP # Parameter is an array, so we need to iterate through it extended_attributes = nil unless hash['extendedAttributes'].nil? extended_attributes = [] hash['extendedAttributes'].each do |structure| extended_attributes << (CustomFields.from_hash(structure) if structure) end end extended_attributes = SKIP unless hash.key?('extendedAttributes') service_plan = hash.key?('servicePlan') ? hash['servicePlan'] : SKIP sms_used = hash.key?('smsUsed') ? hash['smsUsed'] : SKIP source = hash.key?('source') ? hash['source'] : SKIP = hash.key?('timestamp') ? hash['timestamp'] : SKIP # Create object from extracted values. Usage.new(bytes_used, extended_attributes, service_plan, sms_used, source, ) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/verizon/models/usage.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['bytes_used'] = 'bytesUsed' @_hash['extended_attributes'] = 'extendedAttributes' @_hash['service_plan'] = 'servicePlan' @_hash['sms_used'] = 'smsUsed' @_hash['source'] = 'source' @_hash['timestamp'] = 'timestamp' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 |
# File 'lib/verizon/models/usage.rb', line 63 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/verizon/models/usage.rb', line 51 def self.optionals %w[ bytes_used extended_attributes service_plan sms_used source timestamp ] end |