Class: AdvancedBilling::OfferDiscount
- Defined in:
- lib/advanced_billing/models/offer_discount.rb
Overview
OfferDiscount Model.
Instance Attribute Summary collapse
-
#coupon_code ⇒ String
TODO: Write general description for this method.
-
#coupon_id ⇒ Integer
TODO: Write general description for this method.
-
#coupon_name ⇒ 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(coupon_code: SKIP, coupon_id: SKIP, coupon_name: SKIP, additional_properties: {}) ⇒ OfferDiscount
constructor
A new instance of OfferDiscount.
Methods inherited from BaseModel
Constructor Details
#initialize(coupon_code: SKIP, coupon_id: SKIP, coupon_name: SKIP, additional_properties: {}) ⇒ OfferDiscount
Returns a new instance of OfferDiscount.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 47 def initialize(coupon_code: SKIP, coupon_id: SKIP, coupon_name: SKIP, additional_properties: {}) @coupon_code = coupon_code unless coupon_code == SKIP @coupon_id = coupon_id unless coupon_id == SKIP @coupon_name = coupon_name unless coupon_name == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#coupon_code ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 14 def coupon_code @coupon_code end |
#coupon_id ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 18 def coupon_id @coupon_id end |
#coupon_name ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 22 def coupon_name @coupon_name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP coupon_id = hash.key?('coupon_id') ? hash['coupon_id'] : SKIP coupon_name = hash.key?('coupon_name') ? hash['coupon_name'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. OfferDiscount.new(coupon_code: coupon_code, coupon_id: coupon_id, coupon_name: coupon_name, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['coupon_code'] = 'coupon_code' @_hash['coupon_id'] = 'coupon_id' @_hash['coupon_name'] = 'coupon_name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 39 40 |
# File 'lib/advanced_billing/models/offer_discount.rb', line 34 def self.optionals %w[ coupon_code coupon_id coupon_name ] end |