Class: Verizon::ChangePlan

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

Overview

ChangePlan Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(trigger_date = SKIP, share_plan = SKIP) ⇒ ChangePlan

Returns a new instance of ChangePlan.



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

def initialize(trigger_date = SKIP, share_plan = SKIP)
  @trigger_date = trigger_date unless trigger_date == SKIP
  @share_plan = share_plan unless share_plan == SKIP
end

Instance Attribute Details

#share_planArray[SharePlan]

TODO: Write general description for this method

Returns:



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

def share_plan
  @share_plan
end

#trigger_dateString

TODO: Write general description for this method

Returns:

  • (String)


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

def trigger_date
  @trigger_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/verizon/models/change_plan.rb', line 47

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  trigger_date = hash.key?('triggerDate') ? hash['triggerDate'] : SKIP
  # Parameter is an array, so we need to iterate through it
  share_plan = nil
  unless hash['sharePlan'].nil?
    share_plan = []
    hash['sharePlan'].each do |structure|
      share_plan << (SharePlan.from_hash(structure) if structure)
    end
  end

  share_plan = SKIP unless hash.key?('sharePlan')

  # Create object from extracted values.
  ChangePlan.new(trigger_date,
                 share_plan)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/verizon/models/change_plan.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['trigger_date'] = 'triggerDate'
  @_hash['share_plan'] = 'sharePlan'
  @_hash
end

.nullablesObject

An array for nullable fields



37
38
39
# File 'lib/verizon/models/change_plan.rb', line 37

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
32
33
34
# File 'lib/verizon/models/change_plan.rb', line 29

def self.optionals
  %w[
    trigger_date
    share_plan
  ]
end