Class: AdvancedBilling::CreateOrUpdateCoupon
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateOrUpdateCoupon
- Defined in:
- lib/advanced_billing/models/create_or_update_coupon.rb
Overview
CreateOrUpdateCoupon Model.
Instance Attribute Summary collapse
-
#coupon ⇒ Object
TODO: Write general description for this method.
-
#restricted_components ⇒ Hash[String, TrueClass | FalseClass]
An object where the keys are component_ids and the values are booleans indicating if the coupon should be applicable to the component.
-
#restricted_products ⇒ Hash[String, TrueClass | FalseClass]
An object where the keys are product_ids and the values are booleans indicating if the coupon should be applicable to the product.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) ⇒ CreateOrUpdateCoupon
constructor
A new instance of CreateOrUpdateCoupon.
Methods inherited from BaseModel
Constructor Details
#initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) ⇒ CreateOrUpdateCoupon
Returns a new instance of CreateOrUpdateCoupon.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 49 def initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) @coupon = coupon unless coupon == SKIP @restricted_products = restricted_products unless restricted_products == SKIP @restricted_components = restricted_components unless restricted_components == 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 ⇒ Object
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 14 def coupon @coupon end |
#restricted_components ⇒ Hash[String, TrueClass | FalseClass]
An object where the keys are component_ids and the values are booleans indicating if the coupon should be applicable to the component
24 25 26 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 24 def restricted_components @restricted_components end |
#restricted_products ⇒ Hash[String, TrueClass | FalseClass]
An object where the keys are product_ids and the values are booleans indicating if the coupon should be applicable to the product
19 20 21 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 19 def restricted_products @restricted_products end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. coupon = hash.key?('coupon') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:CreateOrUpdateCouponCoupon), hash['coupon'] ) : SKIP restricted_products = hash.key?('restricted_products') ? hash['restricted_products'] : SKIP restricted_components = hash.key?('restricted_components') ? hash['restricted_components'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateOrUpdateCoupon.new(coupon: coupon, restricted_products: restricted_products, restricted_components: restricted_components, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['coupon'] = 'coupon' @_hash['restricted_products'] = 'restricted_products' @_hash['restricted_components'] = 'restricted_components' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 41 42 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 36 def self.optionals %w[ coupon restricted_products restricted_components ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 86 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |