Class: Verizon::ChangePlan
- Defined in:
- lib/verizon/models/change_plan.rb
Overview
ChangePlan Model.
Instance Attribute Summary collapse
-
#share_plan ⇒ Array[SharePlan]
TODO: Write general description for this method.
-
#trigger_date ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(trigger_date = SKIP, share_plan = SKIP) ⇒ ChangePlan
constructor
A new instance of ChangePlan.
Methods inherited from BaseModel
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_plan ⇒ Array[SharePlan]
TODO: Write general description for this method
18 19 20 |
# File 'lib/verizon/models/change_plan.rb', line 18 def share_plan @share_plan end |
#trigger_date ⇒ String
TODO: Write general description for this method
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
37 38 39 |
# File 'lib/verizon/models/change_plan.rb', line 37 def self.nullables [] end |
.optionals ⇒ Object
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 |