class ZanoxPublisher::IncentiveBase

Base class to hold the incentive attributes

@attr [Integer] id The incentiveItem's identifer from Zanox @attr [String] name The name for the incentive @attr [Program] program The program to which the incentive belongs @attr [Array<AdMedium>] admedium The ad medium that can be used for the incentive @attr [String] incentive_type The type of incentive @attr [Array<String>] regions The regions for the incentive @attr [DateTime] created_at The date the incentive is created at @attr [DateTime] modified_at The date the incentive is modified at @attr [DateTime] start_date The date the incentive will start @attr [DateTime] end_date The date the incentive will end @attr [String] info_for_publisher The information for the publisher @attr [String] info_for_customer The information for the customer @attr [String] coupon_code The coupon code assigned to the incentive @attr [Fixnum] total The total amount saved through the incentive @attr [String] currency The currency of money amounts @attr [Fixnum] percentage The rebate percentage given through the incentive @attr [String] restrictions Any restrictions associated with the incentive @attr [Boolean] new_customer_only States if the incentive is only for new customers @attr [Fixnum] minimum_basket_value The minimum basket value to trigger the incentive @attr [Array<Prize>] prizes The prizes given during the incentive

Attributes

admedia[RW]
admedium[RW]
couponCode[RW]
coupon_code[RW]
createDate[RW]
created_at[RW]
currency[RW]
endDate[RW]
end_date[RW]
exclusive[RW]
id[RW]
incentiveType[RW]
incentive_type[RW]
info4customer[RW]
info4publisher[RW]
info_for_customer[RW]
info_for_publisher[RW]
minimumBasketValue[RW]
minimum_basket_value[RW]
modifiedDate[RW]
modified_at[RW]
name[RW]
newCustomerOnly[RW]
new_customer_only[RW]
percentage[RW]
prizes[RW]
program[RW]
regions[RW]
restrictions[RW]
startDate[RW]
start_date[RW]
total[RW]

Public Class Methods

incentive_types() click to toggle source

Returns the Zanox API incentiveTypeEnum datatype

@return [Array<String>]

# File lib/zanox_publisher/incentive_base.rb, line 30
def self.incentive_types
  @@incentive_types
end
new(data = {}, exclusive = false) click to toggle source
# File lib/zanox_publisher/incentive_base.rb, line 34
def initialize(data = {}, exclusive = false)
  @id                   = data.fetch('@id')
  @name                 = data.fetch('name')
  @program              = Program.new(data.fetch('program'))
  @admedium             = AdMedium.new(data.fetch('admedia').fetch('admediumItem'))
  @incentive_type       = data.fetch('incentiveType')
  @regions              = data.fetch('regions', []).first
  @regions              = @regions.fetch('region') unless @regions.nil?
  @regions              = [@regions] if @regions.is_a? String
  @created_at           = data.fetch('createDate')
  @modified_at          = data.fetch('modifiedDate')
  @start_date           = data.fetch('startDate')
  @end_date             = data.fetch('endDate', nil)
  @info_for_publisher   = data.fetch('info4publisher', nil)
  @info_for_customer    = data.fetch('info4customer')
  @coupon_code          = data.fetch('couponCode', nil)
  @total                = data.fetch('total', nil)
  @currency             = data.fetch('currency', nil)
  @percentage           = data.fetch('percentage', nil)
  @restrictions         = data.fetch('restrictions', nil)
  @new_customer_only    = data.fetch('newCustomerOnly')
  @minimum_basket_value = data.fetch('minimumBasketValue', nil)
  @prizes               = data.fetch('prizes', '')
  @prizes               = nil if @prizes == ''
  @prizes               = @prizes.fetch('prize') unless @prizes.nil?
  @prizes               = @prizes.map{ |hash| Prize.new(hash) } unless @prizes.nil?
  @exclusive            = exclusive
end

Public Instance Methods

to_i() click to toggle source

Returns the incentiveItems' ID as integer representation

@return [Integer]

# File lib/zanox_publisher/incentive_base.rb, line 66
def to_i
  @id
end