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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

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

Returns a new instance of V3DeviceStatus.



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

def initialize(device_id:, status:, result_reason: SKIP, updated_time: SKIP,
               recent_attempt_time: SKIP, next_attempt_time: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @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
  @additional_properties = additional_properties
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.



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
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/verizon/models/v3_device_status.rb', line 80

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 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.
  V3DeviceStatus.new(device_id: device_id,
                     status: status,
                     result_reason: result_reason,
                     updated_time: updated_time,
                     recent_attempt_time: recent_attempt_time,
                     next_attempt_time: next_attempt_time,
                     additional_properties: additional_properties)
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

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
147
148
# File 'lib/verizon/models/v3_device_status.rb', line 142

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} device_id: #{@device_id.inspect}, status: #{@status.inspect},"\
  " result_reason: #{@result_reason.inspect}, updated_time: #{@updated_time.inspect},"\
  " recent_attempt_time: #{@recent_attempt_time.inspect}, next_attempt_time:"\
  " #{@next_attempt_time.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_next_attempt_timeObject



128
129
130
# File 'lib/verizon/models/v3_device_status.rb', line 128

def to_custom_next_attempt_time
  DateTimeHelper.to_rfc3339(next_attempt_time)
end

#to_custom_recent_attempt_timeObject



124
125
126
# File 'lib/verizon/models/v3_device_status.rb', line 124

def to_custom_recent_attempt_time
  DateTimeHelper.to_rfc3339(recent_attempt_time)
end

#to_custom_updated_timeObject



120
121
122
# File 'lib/verizon/models/v3_device_status.rb', line 120

def to_custom_updated_time
  DateTimeHelper.to_rfc3339(updated_time)
end

#to_sObject

Provides a human-readable string representation of the object.



133
134
135
136
137
138
139
# File 'lib/verizon/models/v3_device_status.rb', line 133

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} device_id: #{@device_id}, status: #{@status}, result_reason:"\
  " #{@result_reason}, updated_time: #{@updated_time}, recent_attempt_time:"\
  " #{@recent_attempt_time}, next_attempt_time: #{@next_attempt_time}, additional_properties:"\
  " #{@additional_properties}>"
end