Class: Verizon::Campaign

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

Overview

Firmware upgrade information.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, account_name = nil, protocol = 'LWM2M', make = nil, model = nil, start_date = nil, end_date = nil, status = nil, auto_assign_license_flag = nil, auto_add_devices_flag = nil, campaign_name = SKIP, firmware_name = SKIP, firmware_from = SKIP, firmware_to = SKIP, campaign_time_window_list = SKIP) ⇒ Campaign

Returns a new instance of Campaign.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/verizon/models/campaign.rb', line 114

def initialize(id = nil,  = nil, protocol = 'LWM2M', make = nil,
               model = nil, start_date = nil, end_date = nil, status = nil,
               auto_assign_license_flag = nil, auto_add_devices_flag = nil,
               campaign_name = SKIP, firmware_name = SKIP,
               firmware_from = SKIP, firmware_to = SKIP,
               campaign_time_window_list = SKIP)
  @id = id
  @account_name = 
  @campaign_name = campaign_name unless campaign_name == SKIP
  @firmware_name = firmware_name unless firmware_name == SKIP
  @firmware_from = firmware_from unless firmware_from == SKIP
  @firmware_to = firmware_to unless firmware_to == SKIP
  @protocol = protocol
  @make = make
  @model = model
  @start_date = start_date
  @end_date = end_date
  unless campaign_time_window_list == SKIP
    @campaign_time_window_list =
      campaign_time_window_list
  end
  @status = status
  @auto_assign_license_flag = auto_assign_license_flag
  @auto_add_devices_flag = auto_add_devices_flag
end

Instance Attribute Details

#account_nameString

Account identifier.

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/campaign.rb', line 18

def 
  @account_name
end

#auto_add_devices_flagTrueClass | FalseClass

Beyond the devices included on the device list, any other device(s) which matches the eligibility criteria (same make, model, current firmware, protocol, billing account) will automatically be added to the campaign list during the life of the campaign when set to true.

Returns:

  • (TrueClass | FalseClass)


75
76
77
# File 'lib/verizon/models/campaign.rb', line 75

def auto_add_devices_flag
  @auto_add_devices_flag
end

#auto_assign_license_flagTrueClass | FalseClass

Any device included in the device list which does not have a license will automatically be assigned a FOTA license, assuming there are enough FOTA licenses available, when set to true.

Returns:

  • (TrueClass | FalseClass)


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

def auto_assign_license_flag
  @auto_assign_license_flag
end

#campaign_nameString

Campaign name.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/campaign.rb', line 22

def campaign_name
  @campaign_name
end

#campaign_time_window_listArray[V3TimeWindow]

List of allowed campaign time windows.

Returns:



58
59
60
# File 'lib/verizon/models/campaign.rb', line 58

def campaign_time_window_list
  @campaign_time_window_list
end

#end_dateDate

Campaign end date.

Returns:

  • (Date)


54
55
56
# File 'lib/verizon/models/campaign.rb', line 54

def end_date
  @end_date
end

#firmware_fromString

Old firmware version.

Returns:

  • (String)


30
31
32
# File 'lib/verizon/models/campaign.rb', line 30

def firmware_from
  @firmware_from
end

#firmware_nameString

Name of firmware.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/campaign.rb', line 26

def firmware_name
  @firmware_name
end

#firmware_toString

New firmware version.

Returns:

  • (String)


34
35
36
# File 'lib/verizon/models/campaign.rb', line 34

def firmware_to
  @firmware_to
end

#idString

Upgrade identifier.

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/campaign.rb', line 14

def id
  @id
end

#makeString

Applicable make.

Returns:

  • (String)


42
43
44
# File 'lib/verizon/models/campaign.rb', line 42

def make
  @make
end

#modelString

Applicable model.

Returns:

  • (String)


46
47
48
# File 'lib/verizon/models/campaign.rb', line 46

def model
  @model
end

#protocolString

The protocol of the firmware distribution. Default: LWM2M.

Returns:

  • (String)


38
39
40
# File 'lib/verizon/models/campaign.rb', line 38

def protocol
  @protocol
end

#start_dateDate

Campaign start date.

Returns:

  • (Date)


50
51
52
# File 'lib/verizon/models/campaign.rb', line 50

def start_date
  @start_date
end

#statusString

Firmware upgrade status.

Returns:

  • (String)


62
63
64
# File 'lib/verizon/models/campaign.rb', line 62

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/verizon/models/campaign.rb', line 141

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
   = hash.key?('accountName') ? hash['accountName'] : nil
  protocol = hash['protocol'] ||= 'LWM2M'
  make = hash.key?('make') ? hash['make'] : nil
  model = hash.key?('model') ? hash['model'] : nil
  start_date = hash.key?('startDate') ? hash['startDate'] : nil
  end_date = hash.key?('endDate') ? hash['endDate'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  auto_assign_license_flag =
    hash.key?('autoAssignLicenseFlag') ? hash['autoAssignLicenseFlag'] : nil
  auto_add_devices_flag =
    hash.key?('autoAddDevicesFlag') ? hash['autoAddDevicesFlag'] : nil
  campaign_name = hash.key?('campaignName') ? hash['campaignName'] : SKIP
  firmware_name = hash.key?('firmwareName') ? hash['firmwareName'] : SKIP
  firmware_from = hash.key?('firmwareFrom') ? hash['firmwareFrom'] : SKIP
  firmware_to = hash.key?('firmwareTo') ? hash['firmwareTo'] : SKIP
  # Parameter is an array, so we need to iterate through it
  campaign_time_window_list = nil
  unless hash['campaignTimeWindowList'].nil?
    campaign_time_window_list = []
    hash['campaignTimeWindowList'].each do |structure|
      campaign_time_window_list << (V3TimeWindow.from_hash(structure) if structure)
    end
  end

  campaign_time_window_list = SKIP unless hash.key?('campaignTimeWindowList')

  # Create object from extracted values.
  Campaign.new(id,
               ,
               protocol,
               make,
               model,
               start_date,
               end_date,
               status,
               auto_assign_license_flag,
               auto_add_devices_flag,
               campaign_name,
               firmware_name,
               firmware_from,
               firmware_to,
               campaign_time_window_list)
end

.namesObject

A mapping from model property names to API property names.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/verizon/models/campaign.rb', line 78

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['account_name'] = 'accountName'
  @_hash['campaign_name'] = 'campaignName'
  @_hash['firmware_name'] = 'firmwareName'
  @_hash['firmware_from'] = 'firmwareFrom'
  @_hash['firmware_to'] = 'firmwareTo'
  @_hash['protocol'] = 'protocol'
  @_hash['make'] = 'make'
  @_hash['model'] = 'model'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['campaign_time_window_list'] = 'campaignTimeWindowList'
  @_hash['status'] = 'status'
  @_hash['auto_assign_license_flag'] = 'autoAssignLicenseFlag'
  @_hash['auto_add_devices_flag'] = 'autoAddDevicesFlag'
  @_hash
end

.nullablesObject

An array for nullable fields



110
111
112
# File 'lib/verizon/models/campaign.rb', line 110

def self.nullables
  []
end

.optionalsObject

An array for optional fields



99
100
101
102
103
104
105
106
107
# File 'lib/verizon/models/campaign.rb', line 99

def self.optionals
  %w[
    campaign_name
    firmware_name
    firmware_from
    firmware_to
    campaign_time_window_list
  ]
end