Class: Verizon::Firmware

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

Overview

Firmware information.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(firmware_name = SKIP, participant_name = SKIP, launch_date = SKIP, release_note = SKIP, model = SKIP, make = SKIP, from_version = SKIP, to_version = SKIP) ⇒ Firmware

Returns a new instance of Firmware.



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/verizon/models/firmware.rb', line 78

def initialize(firmware_name = SKIP, participant_name = SKIP,
               launch_date = SKIP, release_note = SKIP, model = SKIP,
               make = SKIP, from_version = SKIP, to_version = SKIP)
  @firmware_name = firmware_name unless firmware_name == SKIP
  @participant_name = participant_name unless participant_name == SKIP
  @launch_date = launch_date unless launch_date == SKIP
  @release_note = release_note unless release_note == SKIP
  @model = model unless model == SKIP
  @make = make unless make == SKIP
  @from_version = from_version unless from_version == SKIP
  @to_version = to_version unless to_version == SKIP
end

Instance Attribute Details

#firmware_nameString

The name of the firmware image, provided by the device manufacturer.

Returns:

  • (String)


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

def firmware_name
  @firmware_name
end

#from_versionString

The firmware version that must currently be on the device to upgrade.

Returns:

  • (String)


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

def from_version
  @from_version
end

#launch_dateDateTime

The release date of the firmware image.

Returns:

  • (DateTime)


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

def launch_date
  @launch_date
end

#makeString

The device make that the firmware applies to.

Returns:

  • (String)


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

def make
  @make
end

#modelString

The device model that the firmware applies to.

Returns:

  • (String)


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

def model
  @model
end

#participant_nameString

Internal reference; can be ignored.

Returns:

  • (String)


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

def participant_name
  @participant_name
end

#release_noteString

Additional information about the release.

Returns:

  • (String)


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

def release_note
  @release_note
end

#to_versionString

The firmware version that will be on the device after an upgrade.

Returns:

  • (String)


43
44
45
# File 'lib/verizon/models/firmware.rb', line 43

def to_version
  @to_version
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
119
# File 'lib/verizon/models/firmware.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  firmware_name = hash.key?('firmwareName') ? hash['firmwareName'] : SKIP
  participant_name =
    hash.key?('participantName') ? hash['participantName'] : SKIP
  launch_date = if hash.key?('launchDate')
                  (DateTimeHelper.from_rfc3339(hash['launchDate']) if hash['launchDate'])
                else
                  SKIP
                end
  release_note = hash.key?('releaseNote') ? hash['releaseNote'] : SKIP
  model = hash.key?('model') ? hash['model'] : SKIP
  make = hash.key?('make') ? hash['make'] : SKIP
  from_version = hash.key?('fromVersion') ? hash['fromVersion'] : SKIP
  to_version = hash.key?('toVersion') ? hash['toVersion'] : SKIP

  # Create object from extracted values.
  Firmware.new(firmware_name,
               participant_name,
               launch_date,
               release_note,
               model,
               make,
               from_version,
               to_version)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/verizon/models/firmware.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['firmware_name'] = 'firmwareName'
  @_hash['participant_name'] = 'participantName'
  @_hash['launch_date'] = 'launchDate'
  @_hash['release_note'] = 'releaseNote'
  @_hash['model'] = 'model'
  @_hash['make'] = 'make'
  @_hash['from_version'] = 'fromVersion'
  @_hash['to_version'] = 'toVersion'
  @_hash
end

.nullablesObject

An array for nullable fields



74
75
76
# File 'lib/verizon/models/firmware.rb', line 74

def self.nullables
  []
end

.optionalsObject

An array for optional fields



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/verizon/models/firmware.rb', line 60

def self.optionals
  %w[
    firmware_name
    participant_name
    launch_date
    release_note
    model
    make
    from_version
    to_version
  ]
end

Instance Method Details

#to_custom_launch_dateObject



121
122
123
# File 'lib/verizon/models/firmware.rb', line 121

def to_custom_launch_date
  DateTimeHelper.to_rfc3339(launch_date)
end