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
Public Class Methods
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
# 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
Returns the incentiveItems' ID as integer representation
@return [Integer]
# File lib/zanox_publisher/incentive_base.rb, line 66 def to_i @id end