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:, handle:, product_id:, description: SKIP, product_price_point_id: SKIP, components: SKIP, coupons: SKIP, additional_properties: {}) ⇒ CreateOffer
constructor
A new instance of CreateOffer.
Methods inherited from BaseModel
Constructor Details
#initialize(name:, handle:, product_id:, description: SKIP, product_price_point_id: SKIP, components: SKIP, coupons: SKIP, additional_properties: {}) ⇒ CreateOffer
Returns a new instance of CreateOffer.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/create_offer.rb', line 68 def initialize(name:, handle:, product_id:, description: SKIP, product_price_point_id: SKIP, components: SKIP, coupons: SKIP, additional_properties: {}) @name = name @handle = handle @description = description unless description == SKIP @product_id = product_id @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP @components = components unless components == SKIP @coupons = coupons unless coupons == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end 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.
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 115 116 117 118 119 120 |
# File 'lib/advanced_billing/models/create_offer.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil handle = hash.key?('handle') ? hash['handle'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : nil description = hash.key?('description') ? hash['description'] : 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 # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateOffer.new(name: name, handle: handle, product_id: product_id, description: description, product_price_point_id: product_price_point_id, components: components, coupons: coupons, additional_properties: hash) 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
64 65 66 |
# File 'lib/advanced_billing/models/create_offer.rb', line 64 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 |
# File 'lib/advanced_billing/models/create_offer.rb', line 54 def self.optionals %w[ description product_price_point_id components coupons ] end |