Class: AdvancedBilling::CouponRequest
- Defined in:
- lib/advanced_billing/models/coupon_request.rb
Overview
CouponRequest Model.
Instance Attribute Summary collapse
-
#coupon ⇒ CouponPayload
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.
Instance Method Summary collapse
-
#initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) ⇒ CouponRequest
constructor
A new instance of CouponRequest.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) ⇒ CouponRequest
Returns a new instance of CouponRequest.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/coupon_request.rb', line 49 def initialize(coupon: SKIP, restricted_products: SKIP, restricted_components: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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 ⇒ CouponPayload
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/coupon_request.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/coupon_request.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/coupon_request.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 |
# File 'lib/advanced_billing/models/coupon_request.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. coupon = CouponPayload.from_hash(hash['coupon']) if hash['coupon'] 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. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CouponRequest.new(coupon: coupon, restricted_products: restricted_products, restricted_components: restricted_components, additional_properties: additional_properties) 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/coupon_request.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/coupon_request.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/coupon_request.rb', line 36 def self.optionals %w[ coupon restricted_products restricted_components ] end |