Class: Verizon::V3DeviceStatus

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

Overview

Device status.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(device_id = nil, status = nil, result_reason = SKIP, updated_time = SKIP, recent_attempt_time = SKIP, next_attempt_time = SKIP) ⇒ V3DeviceStatus

Returns a new instance of V3DeviceStatus.



64
65
66
67
68
69
70
71
72
73
# File 'lib/verizon/models/v3_device_status.rb', line 64

def initialize(device_id = nil, status = nil, result_reason = SKIP,
               updated_time = SKIP, recent_attempt_time = SKIP,
               next_attempt_time = SKIP)
  @device_id = device_id
  @status = status
  @result_reason = result_reason unless result_reason == SKIP
  @updated_time = updated_time unless updated_time == SKIP
  @recent_attempt_time = recent_attempt_time unless recent_attempt_time == SKIP
  @next_attempt_time = next_attempt_time unless next_attempt_time == SKIP
end

Instance Attribute Details

#device_idString

Device IMEI.

Returns:

  • (String)


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

def device_id
  @device_id
end

#next_attempt_timeDateTime

Next attempt time.

Returns:

  • (DateTime)


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

def next_attempt_time
  @next_attempt_time
end

#recent_attempt_timeDateTime

The most recent attempt time.

Returns:

  • (DateTime)


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

def recent_attempt_time
  @recent_attempt_time
end

#result_reasonString

Result reason.

Returns:

  • (String)


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

def result_reason
  @result_reason
end

#statusString

Success or failure.

Returns:

  • (String)


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

def status
  @status
end

#updated_timeDateTime

Updated Time.

Returns:

  • (DateTime)


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

def updated_time
  @updated_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
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
# File 'lib/verizon/models/v3_device_status.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  device_id = hash.key?('deviceId') ? hash['deviceId'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  result_reason = hash.key?('resultReason') ? hash['resultReason'] : SKIP
  updated_time = if hash.key?('updatedTime')
                   (DateTimeHelper.from_rfc3339(hash['updatedTime']) if hash['updatedTime'])
                 else
                   SKIP
                 end
  recent_attempt_time = if hash.key?('recentAttemptTime')
                          (DateTimeHelper.from_rfc3339(hash['recentAttemptTime']) if hash['recentAttemptTime'])
                        else
                          SKIP
                        end
  next_attempt_time = if hash.key?('nextAttemptTime')
                        (DateTimeHelper.from_rfc3339(hash['nextAttemptTime']) if hash['nextAttemptTime'])
                      else
                        SKIP
                      end

  # Create object from extracted values.
  V3DeviceStatus.new(device_id,
                     status,
                     result_reason,
                     updated_time,
                     recent_attempt_time,
                     next_attempt_time)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/verizon/models/v3_device_status.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['device_id'] = 'deviceId'
  @_hash['status'] = 'status'
  @_hash['result_reason'] = 'resultReason'
  @_hash['updated_time'] = 'updatedTime'
  @_hash['recent_attempt_time'] = 'recentAttemptTime'
  @_hash['next_attempt_time'] = 'nextAttemptTime'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/verizon/models/v3_device_status.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    result_reason
    updated_time
    recent_attempt_time
    next_attempt_time
  ]
end

Instance Method Details

#to_custom_next_attempt_timeObject



116
117
118
# File 'lib/verizon/models/v3_device_status.rb', line 116

def to_custom_next_attempt_time
  DateTimeHelper.to_rfc3339(next_attempt_time)
end

#to_custom_recent_attempt_timeObject



112
113
114
# File 'lib/verizon/models/v3_device_status.rb', line 112

def to_custom_recent_attempt_time
  DateTimeHelper.to_rfc3339(recent_attempt_time)
end

#to_custom_updated_timeObject



108
109
110
# File 'lib/verizon/models/v3_device_status.rb', line 108

def to_custom_updated_time
  DateTimeHelper.to_rfc3339(updated_time)
end