class AcceptOn::PromoCode

Attributes

created_at[R]

@attr_reader created_at [DateTime] The time the promo code was created. @attr_reader original_name [String] The original promo code name, if the

name was modified.

@api public

name[RW]

@attr_accessor name [String] The promo code as given to a customer @attr_accessor promo_type [String] The type of promo code. One of:

"amount", "fixed_price", or
"percentage".

@attr_accessor value [Numeric] The amount of discount to apply, based on

the type. If promo_type is "amount" or
"fixed_price", an integer amount in
cents. If type is "percentage", a decimal
percentage.

@api public

original_name[R]

@attr_reader created_at [DateTime] The time the promo code was created. @attr_reader original_name [String] The original promo code name, if the

name was modified.

@api public

promo_type[RW]

@attr_accessor name [String] The promo code as given to a customer @attr_accessor promo_type [String] The type of promo code. One of:

"amount", "fixed_price", or
"percentage".

@attr_accessor value [Numeric] The amount of discount to apply, based on

the type. If promo_type is "amount" or
"fixed_price", an integer amount in
cents. If type is "percentage", a decimal
percentage.

@api public

value[RW]

@attr_accessor name [String] The promo code as given to a customer @attr_accessor promo_type [String] The type of promo code. One of:

"amount", "fixed_price", or
"percentage".

@attr_accessor value [Numeric] The amount of discount to apply, based on

the type. If promo_type is "amount" or
"fixed_price", an integer amount in
cents. If type is "percentage", a decimal
percentage.

@api public

Public Instance Methods

as_params() click to toggle source

Creates a hash representation of the promo code’s current values

@return [Hash] A hash representing the promo code.

# File lib/accepton/promo_code.rb, line 26
def as_params
  {name: name, promo_type: promo_type, value: value}
end
name=(name) click to toggle source

Sets the new name of the promo code and memorizes the original

@api public

@param name [String] The new name to set for the promo code.

# File lib/accepton/promo_code.rb, line 35
def name=(name)
  @original_name ||= @name
  @name = name
end