class Bfwd::ProductCouponModifier
Attributes
{ "description" : "ID of the user who last updated the entity.", "verbs":[] }
{ "description" : "The unique ID of the coupon-definition associated with the coupon-modifier.", "verbs":["POST","PUT","GET"] }
{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }
{ "description" : "Has the coupon-modifier been deleted.", "verbs":["POST","PUT","GET"] }
{ "description" : "The domain of the coupon-modifier", "verbs":["POST","PUT","GET"] }
{ "description" : "The effect of the coupon-modifier. The coupon-modifier can affect first, last, and cheapest value of a specific unit-of-measure-id for a subscription. The coupon-modifier can also affect all of the values for a unit-of-measure-id, or can affect all of the subscription cost.", "verbs":["POST","PUT","GET"] }
{ "description" : "Specifies whether the coupon-modifier will be affecting only additional units. If this field is set, the coupon-instance-existing-values for the coupon-instance are observed, and any units of the unit-of-measure-id defined by the modifier below the coupon-instance-existing-values for that unit-of-measure-id will be ignored.", "verbs":["POST","PUT","GET"] }
{ "description" : "The effect amount for the coupon-modifier. This is affected by the operand field.", "verbs":["POST","PUT","GET"] }
{ "description" : "ID of the coupon-modifier.", "verbs":["POST","PUT","GET"] }
{ "description" : "The operand field affects the effect amount of the coupon-modifier. If the operand is fixed, it is an exact amount of the currency defined by the coupon-definition. If the operand is percent, this means the coupon will be affecting a percentage of the unaltered cost. E.g. a 25% modifier will apply a 25% discount on a subscription or a pricing-component.", "verbs":["POST","PUT","GET"] }
{ "description" : "ID of the organization associated with the coupon-modifier.", "verbs":["POST","PUT","GET"] }
{ "description" : "The precedence of the coupon-modifier. This is used to order application of coupon-modifiers. Higher precedence means the coupon-modifier will be applied before others.", "verbs":["POST","PUT","GET"] }
{ "description" : "The specifier is domain-specific. If the domain is uom, this field is used to limit the coupon-modifier to a specific unit-of-measure-id.", "verbs":["POST","PUT","GET"] }
{ "description" : "The number of units that will be affected by the coupon-modifier, if the domain is set to uom", "verbs":["POST","PUT","GET"] }
{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 86 def self.attribute_map { :'created' => :'created', :'changed_by' => :'changedBy', :'updated' => :'updated', :'id' => :'id', :'organization_id' => :'organizationID', :'coupon_definition_id' => :'couponDefinitionID', :'effect_amount' => :'effectAmount', :'operand' => :'operand', :'effect' => :'effect', :'effect_additional' => :'effectAdditional', :'specifier_amount' => :'specifierAmount', :'domain' => :'domain', :'specifier' => :'specifier', :'precedence' => :'precedence', :'deleted' => :'deleted' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 129 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'created') self.created = attributes[:'created'] end if attributes.has_key?(:'changedBy') self.changed_by = attributes[:'changedBy'] end if attributes.has_key?(:'updated') self.updated = attributes[:'updated'] end if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'organizationID') self.organization_id = attributes[:'organizationID'] end if attributes.has_key?(:'couponDefinitionID') self.coupon_definition_id = attributes[:'couponDefinitionID'] end if attributes.has_key?(:'effectAmount') self.effect_amount = attributes[:'effectAmount'] end if attributes.has_key?(:'operand') self.operand = attributes[:'operand'] end if attributes.has_key?(:'effect') self.effect = attributes[:'effect'] end if attributes.has_key?(:'effectAdditional') self.effect_additional = attributes[:'effectAdditional'] else self.effect_additional = false end if attributes.has_key?(:'specifierAmount') self.specifier_amount = attributes[:'specifierAmount'] end if attributes.has_key?(:'domain') self.domain = attributes[:'domain'] end if attributes.has_key?(:'specifier') self.specifier = attributes[:'specifier'] end if attributes.has_key?(:'precedence') self.precedence = attributes[:'precedence'] end if attributes.has_key?(:'deleted') self.deleted = attributes[:'deleted'] else self.deleted = false end end
Attribute type mapping.
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 107 def self.swagger_types { :'created' => :'DateTime', :'changed_by' => :'String', :'updated' => :'DateTime', :'id' => :'String', :'organization_id' => :'String', :'coupon_definition_id' => :'String', :'effect_amount' => :'Float', :'operand' => :'String', :'effect' => :'String', :'effect_additional' => :'BOOLEAN', :'specifier_amount' => :'Integer', :'domain' => :'String', :'specifier' => :'String', :'precedence' => :'Integer', :'deleted' => :'BOOLEAN' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 297 def ==(o) return true if self.equal?(o) self.class == o.class && created == o.created && changed_by == o.changed_by && updated == o.updated && id == o.id && organization_id == o.organization_id && coupon_definition_id == o.coupon_definition_id && effect_amount == o.effect_amount && operand == o.operand && effect == o.effect && effect_additional == o.effect_additional && specifier_amount == o.specifier_amount && domain == o.domain && specifier == o.specifier && precedence == o.precedence && deleted == o.deleted end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 353 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = Bfwd.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 419 def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 332 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
Custom attribute writer method checking allowed values (enum). @param [Object] domain Object to be assigned
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 287 def domain=(domain) validator = EnumAttributeValidator.new('String', ["product", "uom", "PricingComponent"]) unless validator.valid?(domain) fail ArgumentError, "invalid value for 'domain', must be one of #{validator.allowable_values}." end @domain = domain end
Custom attribute writer method checking allowed values (enum). @param [Object] effect Object to be assigned
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 277 def effect=(effect) validator = EnumAttributeValidator.new('String', ["discount_first_units", "discount_last_units", "discount_cheapest_units", "discount_all"]) unless validator.valid?(effect) fail ArgumentError, "invalid value for 'effect', must be one of #{validator.allowable_values}." end @effect = effect end
@see the `==` method @param [Object] Object to be compared
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 319 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 325 def hash [created, changed_by, updated, id, organization_id, coupon_definition_id, effect_amount, operand, effect, effect_additional, specifier_amount, domain, specifier, precedence, deleted].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properies with the reasons
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 203 def list_invalid_properties invalid_properties = Array.new if @organization_id.nil? invalid_properties.push("invalid value for 'organization_id', organization_id cannot be nil.") end if @effect_amount.nil? invalid_properties.push("invalid value for 'effect_amount', effect_amount cannot be nil.") end if @operand.nil? invalid_properties.push("invalid value for 'operand', operand cannot be nil.") end if @effect.nil? invalid_properties.push("invalid value for 'effect', effect cannot be nil.") end if @effect_additional.nil? invalid_properties.push("invalid value for 'effect_additional', effect_additional cannot be nil.") end if @specifier_amount.nil? invalid_properties.push("invalid value for 'specifier_amount', specifier_amount cannot be nil.") end if @domain.nil? invalid_properties.push("invalid value for 'domain', domain cannot be nil.") end if @precedence.nil? invalid_properties.push("invalid value for 'precedence', precedence cannot be nil.") end if @deleted.nil? invalid_properties.push("invalid value for 'deleted', deleted cannot be nil.") end return invalid_properties end
Custom attribute writer method checking allowed values (enum). @param [Object] operand Object to be assigned
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 267 def operand=(operand) validator = EnumAttributeValidator.new('String', ["fixed", "percent", "instance_fixed", "instance_percent"]) unless validator.valid?(operand) fail ArgumentError, "invalid value for 'operand', must be one of #{validator.allowable_values}." end @operand = operand end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 405 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 393 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/bf_ruby2/models/product_coupon_modifier.rb, line 246 def valid? return false if @organization_id.nil? return false if @effect_amount.nil? return false if @operand.nil? operand_validator = EnumAttributeValidator.new('String', ["fixed", "percent", "instance_fixed", "instance_percent"]) return false unless operand_validator.valid?(@operand) return false if @effect.nil? effect_validator = EnumAttributeValidator.new('String', ["discount_first_units", "discount_last_units", "discount_cheapest_units", "discount_all"]) return false unless effect_validator.valid?(@effect) return false if @effect_additional.nil? return false if @specifier_amount.nil? return false if @domain.nil? domain_validator = EnumAttributeValidator.new('String', ["product", "uom", "PricingComponent"]) return false unless domain_validator.valid?(@domain) return false if @precedence.nil? return false if @deleted.nil? return true end