Class: AdvancedBilling::CreateOffer
- Defined in:
- lib/advanced_billing/models/create_offer.rb
Overview
CreateOffer Model.
Instance Attribute Summary collapse
-
#components ⇒ Array[CreateOfferComponent]
TODO: Write general description for this method.
-
#coupons ⇒ Array[String]
TODO: Write general description for this method.
-
#description ⇒ String
TODO: Write general description for this method.
-
#handle ⇒ String
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#product_id ⇒ Integer
TODO: Write general description for this method.
-
#product_price_point_id ⇒ Integer
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(name = SKIP, handle = SKIP, description = SKIP, product_id = SKIP, product_price_point_id = SKIP, components = SKIP, coupons = SKIP) ⇒ CreateOffer
constructor
A new instance of CreateOffer.
Methods inherited from BaseModel
Constructor Details
#initialize(name = SKIP, handle = SKIP, description = SKIP, product_id = SKIP, product_price_point_id = SKIP, components = SKIP, coupons = SKIP) ⇒ CreateOffer
Returns a new instance of CreateOffer.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/advanced_billing/models/create_offer.rb', line 71 def initialize(name = SKIP, handle = SKIP, description = SKIP, product_id = SKIP, product_price_point_id = SKIP, components = SKIP, coupons = SKIP) @name = name unless name == SKIP @handle = handle unless handle == SKIP @description = description unless description == SKIP @product_id = product_id unless product_id == SKIP @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP @components = components unless components == SKIP @coupons = coupons unless coupons == SKIP end |
Instance Attribute Details
#components ⇒ Array[CreateOfferComponent]
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/create_offer.rb', line 34 def components @components end |
#coupons ⇒ Array[String]
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/create_offer.rb', line 38 def coupons @coupons end |
#description ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/create_offer.rb', line 22 def description @description end |
#handle ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/create_offer.rb', line 18 def handle @handle end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_offer.rb', line 14 def name @name end |
#product_id ⇒ Integer
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/create_offer.rb', line 26 def product_id @product_id end |
#product_price_point_id ⇒ Integer
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/create_offer.rb', line 30 def product_price_point_id @product_price_point_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/create_offer.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP product_id = hash.key?('product_id') ? hash['product_id'] : SKIP product_price_point_id = hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP # Parameter is an array, so we need to iterate through it components = nil unless hash['components'].nil? components = [] hash['components'].each do |structure| components << (CreateOfferComponent.from_hash(structure) if structure) end end components = SKIP unless hash.key?('components') coupons = hash.key?('coupons') ? hash['coupons'] : SKIP # Create object from extracted values. CreateOffer.new(name, handle, description, product_id, product_price_point_id, components, coupons) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/create_offer.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash['description'] = 'description' @_hash['product_id'] = 'product_id' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['components'] = 'components' @_hash['coupons'] = 'coupons' @_hash end |
.nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/advanced_billing/models/create_offer.rb', line 67 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/advanced_billing/models/create_offer.rb', line 54 def self.optionals %w[ name handle description product_id product_price_point_id components coupons ] end |