Class: AdvancedBilling::CouponRestriction
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CouponRestriction
- Defined in:
- lib/advanced_billing/models/coupon_restriction.rb
Overview
CouponRestriction Model.
Instance Attribute Summary collapse
-
#handle ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#item_id ⇒ Integer
TODO: Write general description for this method.
-
#item_type ⇒ RestrictionType
TODO: Write general description for this method.
-
#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(id: SKIP, item_type: SKIP, item_id: SKIP, name: SKIP, handle: SKIP, additional_properties: {}) ⇒ CouponRestriction
constructor
A new instance of CouponRestriction.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id: SKIP, item_type: SKIP, item_id: SKIP, name: SKIP, handle: SKIP, additional_properties: {}) ⇒ CouponRestriction
Returns a new instance of CouponRestriction.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 61 def initialize(id: SKIP, item_type: SKIP, item_id: SKIP, name: SKIP, handle: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @id = id unless id == SKIP @item_type = item_type unless item_type == SKIP @item_id = item_id unless item_id == SKIP @name = name unless name == SKIP @handle = handle unless handle == SKIP end |
Instance Attribute Details
#handle ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 30 def handle @handle end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 14 def id @id end |
#item_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 22 def item_id @item_id end |
#item_type ⇒ RestrictionType
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 18 def item_type @item_type end |
#name ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 26 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP item_type = hash.key?('item_type') ? hash['item_type'] : SKIP item_id = hash.key?('item_id') ? hash['item_id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP handle = hash.key?('handle') ? hash['handle'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CouponRestriction.new(id: id, item_type: item_type, item_id: item_id, name: name, handle: handle, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['item_type'] = 'item_type' @_hash['item_id'] = 'item_id' @_hash['name'] = 'name' @_hash['handle'] = 'handle' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 58 59 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 55 def self.nullables %w[ handle ] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/coupon_restriction.rb', line 44 def self.optionals %w[ id item_type item_id name handle ] end |