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) ⇒ CreateOrUpdateCoupon
constructor
A new instance of CreateOrUpdateCoupon.
Methods inherited from BaseModel
Constructor Details
#initialize(coupon = SKIP, restricted_products = SKIP, restricted_components = SKIP) ⇒ CreateOrUpdateCoupon
Returns a new instance of CreateOrUpdateCoupon.
49 50 51 52 53 54 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 49 def initialize(coupon = SKIP, restricted_products = SKIP, restricted_components = SKIP) @coupon = coupon unless coupon == SKIP @restricted_products = restricted_products unless restricted_products == SKIP @restricted_components = restricted_components unless restricted_components == SKIP 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.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 57 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 # Create object from extracted values. CreateOrUpdateCoupon.new(coupon, restricted_products, restricted_components) 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.
77 78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/create_or_update_coupon.rb', line 77 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |