Class: Verizon::V3Device

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

Overview

Device information.

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, request_status = SKIP, result_reason = SKIP, mdn = SKIP, model = SKIP, make = SKIP, firmware = SKIP, fota_eligible = SKIP, status = SKIP, license_assigned = SKIP, protocol = SKIP, software_list = SKIP, file_list = SKIP, create_time = SKIP, status_time = SKIP, update_time = SKIP, refresh_time = SKIP, last_connection_time = SKIP) ⇒ V3Device

Returns a new instance of V3Device.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/verizon/models/v3_device.rb', line 138

def initialize(device_id = nil, request_status = SKIP, result_reason = SKIP,
               mdn = SKIP, model = SKIP, make = SKIP, firmware = SKIP,
               fota_eligible = SKIP, status = SKIP, license_assigned = SKIP,
               protocol = SKIP, software_list = SKIP, file_list = SKIP,
               create_time = SKIP, status_time = SKIP, update_time = SKIP,
               refresh_time = SKIP, last_connection_time = SKIP)
  @device_id = device_id
  @request_status = request_status unless request_status == SKIP
  @result_reason = result_reason unless result_reason == SKIP
  @mdn = mdn unless mdn == SKIP
  @model = model unless model == SKIP
  @make = make unless make == SKIP
  @firmware = firmware unless firmware == SKIP
  @fota_eligible = fota_eligible unless fota_eligible == SKIP
  @status = status unless status == SKIP
  @license_assigned = license_assigned unless license_assigned == SKIP
  @protocol = protocol unless protocol == SKIP
  @software_list = software_list unless software_list == SKIP
  @file_list = file_list unless file_list == SKIP
  @create_time = create_time unless create_time == SKIP
  @status_time = status_time unless status_time == SKIP
  @update_time = update_time unless update_time == SKIP
  @refresh_time = refresh_time unless refresh_time == SKIP
  @last_connection_time = last_connection_time unless last_connection_time == SKIP
end

Instance Attribute Details

#create_timeString

The date and time of when the device is created.

Returns:

  • (String)


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

def create_time
  @create_time
end

#device_idString

Device IMEI.

Returns:

  • (String)


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

def device_id
  @device_id
end

#file_listArray[V3SoftwareInfo]

List of files.

Returns:



64
65
66
# File 'lib/verizon/models/v3_device.rb', line 64

def file_list
  @file_list
end

#firmwareString

Device firmware version.

Returns:

  • (String)


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

def firmware
  @firmware
end

#fota_eligibleTrueClass | FalseClass

Value=true if the device software can be upgraded over the air using the Software Management Services API.

Returns:

  • (TrueClass | FalseClass)


44
45
46
# File 'lib/verizon/models/v3_device.rb', line 44

def fota_eligible
  @fota_eligible
end

#last_connection_timeDateTime

The date and time of when the device reachability is checked.

Returns:

  • (DateTime)


84
85
86
# File 'lib/verizon/models/v3_device.rb', line 84

def last_connection_time
  @last_connection_time
end

#license_assignedTrueClass | FalseClass

License assigned device.

Returns:

  • (TrueClass | FalseClass)


52
53
54
# File 'lib/verizon/models/v3_device.rb', line 52

def license_assigned
  @license_assigned
end

#makeString

Device make.

Returns:

  • (String)


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

def make
  @make
end

#mdnString

MDN.

Returns:

  • (String)


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

def mdn
  @mdn
end

#modelString

Device model.

Returns:

  • (String)


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

def model
  @model
end

#protocolString

Firmware protocol. Valid values include: LWM2M, OMADM, HTTP or NONE.

Returns:

  • (String)


56
57
58
# File 'lib/verizon/models/v3_device.rb', line 56

def protocol
  @protocol
end

#refresh_timeString

The date and time of when the device is refreshed.

Returns:

  • (String)


80
81
82
# File 'lib/verizon/models/v3_device.rb', line 80

def refresh_time
  @refresh_time
end

#request_statusString

Success or failure.

Returns:

  • (String)


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

def request_status
  @request_status
end

#result_reasonString

Success or failure.

Returns:

  • (String)


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

def result_reason
  @result_reason
end

#software_listArray[V3SoftwareInfo]

List of sofware.

Returns:



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

def software_list
  @software_list
end

#statusString

Device status.

Returns:

  • (String)


48
49
50
# File 'lib/verizon/models/v3_device.rb', line 48

def status
  @status
end

#status_timeString

The date and time of when the device firmware or software is updated.

Returns:

  • (String)


72
73
74
# File 'lib/verizon/models/v3_device.rb', line 72

def status_time
  @status_time
end

#update_timeString

The date and time of when the device is updated.

Returns:

  • (String)


76
77
78
# File 'lib/verizon/models/v3_device.rb', line 76

def update_time
  @update_time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/verizon/models/v3_device.rb', line 165

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  device_id = hash.key?('deviceId') ? hash['deviceId'] : nil
  request_status = hash.key?('requestStatus') ? hash['requestStatus'] : SKIP
  result_reason = hash.key?('resultReason') ? hash['resultReason'] : SKIP
  mdn = hash.key?('mdn') ? hash['mdn'] : SKIP
  model = hash.key?('model') ? hash['model'] : SKIP
  make = hash.key?('make') ? hash['make'] : SKIP
  firmware = hash.key?('firmware') ? hash['firmware'] : SKIP
  fota_eligible = hash.key?('fotaEligible') ? hash['fotaEligible'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  license_assigned =
    hash.key?('licenseAssigned') ? hash['licenseAssigned'] : SKIP
  protocol = hash.key?('protocol') ? hash['protocol'] : SKIP
  # Parameter is an array, so we need to iterate through it
  software_list = nil
  unless hash['softwareList'].nil?
    software_list = []
    hash['softwareList'].each do |structure|
      software_list << (V3SoftwareInfo.from_hash(structure) if structure)
    end
  end

  software_list = SKIP unless hash.key?('softwareList')
  # Parameter is an array, so we need to iterate through it
  file_list = nil
  unless hash['fileList'].nil?
    file_list = []
    hash['fileList'].each do |structure|
      file_list << (V3SoftwareInfo.from_hash(structure) if structure)
    end
  end

  file_list = SKIP unless hash.key?('fileList')
  create_time = hash.key?('createTime') ? hash['createTime'] : SKIP
  status_time = hash.key?('statusTime') ? hash['statusTime'] : SKIP
  update_time = hash.key?('updateTime') ? hash['updateTime'] : SKIP
  refresh_time = hash.key?('refreshTime') ? hash['refreshTime'] : SKIP
  last_connection_time = if hash.key?('lastConnectionTime')
                           (DateTimeHelper.from_rfc3339(hash['lastConnectionTime']) if hash['lastConnectionTime'])
                         else
                           SKIP
                         end

  # Create object from extracted values.
  V3Device.new(device_id,
               request_status,
               result_reason,
               mdn,
               model,
               make,
               firmware,
               fota_eligible,
               status,
               license_assigned,
               protocol,
               software_list,
               file_list,
               create_time,
               status_time,
               update_time,
               refresh_time,
               last_connection_time)
end

.namesObject

A mapping from model property names to API property names.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/verizon/models/v3_device.rb', line 87

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['device_id'] = 'deviceId'
  @_hash['request_status'] = 'requestStatus'
  @_hash['result_reason'] = 'resultReason'
  @_hash['mdn'] = 'mdn'
  @_hash['model'] = 'model'
  @_hash['make'] = 'make'
  @_hash['firmware'] = 'firmware'
  @_hash['fota_eligible'] = 'fotaEligible'
  @_hash['status'] = 'status'
  @_hash['license_assigned'] = 'licenseAssigned'
  @_hash['protocol'] = 'protocol'
  @_hash['software_list'] = 'softwareList'
  @_hash['file_list'] = 'fileList'
  @_hash['create_time'] = 'createTime'
  @_hash['status_time'] = 'statusTime'
  @_hash['update_time'] = 'updateTime'
  @_hash['refresh_time'] = 'refreshTime'
  @_hash['last_connection_time'] = 'lastConnectionTime'
  @_hash
end

.nullablesObject

An array for nullable fields



134
135
136
# File 'lib/verizon/models/v3_device.rb', line 134

def self.nullables
  []
end

.optionalsObject

An array for optional fields



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/verizon/models/v3_device.rb', line 111

def self.optionals
  %w[
    request_status
    result_reason
    mdn
    model
    make
    firmware
    fota_eligible
    status
    license_assigned
    protocol
    software_list
    file_list
    create_time
    status_time
    update_time
    refresh_time
    last_connection_time
  ]
end

Instance Method Details

#to_custom_last_connection_timeObject



232
233
234
# File 'lib/verizon/models/v3_device.rb', line 232

def to_custom_last_connection_time
  DateTimeHelper.to_rfc3339(last_connection_time)
end