Sha256: 7da7cf3fc3183a5d2bb0cd74ecd6dfddc3671b2594339f0c525d56b345396620

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

module OpenX
  module Services
    class Campaign < Base
      # Translate our property names to OpenX property names
      openx_accessor  :name               => :campaignName,
                      :advertiser_id      => :advertiserId,
                      :id                 => :campaignId,
                      :start_date         => :startDate,
                      :end_date           => :endDate,
                      :impressions        => :impressions,
                      :target_impressions => :targetImpressions,
                      :target_clicks      => :targetClicks,
                      :revenue            => :revenue,
                      :revenue_type       => :revenueType,
                      :impressions        => :impressions,
                      :clicks             => :clicks,
                      :priority           => :priority,
                      :weight             => :weight,
                      :campaign_type      => :campaignType,
                      :comments           => :comments

      has_one :advertiser

      self.create   = 'ox.addCampaign'
      self.update   = 'ox.modifyCampaign'
      self.delete   = 'ox.deleteCampaign'
      self.find_one = 'ox.getCampaign'
      self.find_all = 'ox.getCampaignListByAdvertiserId'

      # Revenue types
      CPM             = 1
      CPC             = 2
      CPA             = 3
      MONTHLY_TENANCY = 4

      # Campaign types
      REMNANT   = 1
      HIGH      = 2
      EXCLUSIVE = 3

      def initialize(params = {})
        raise ArgumentError.new("Missing advertiser_id") unless params[:advertiser_id] || params[:advertiser]
        params[:advertiser_id] ||= params[:advertiser].id
        super(params)
      end

      def banners
        Banner.find(:all, self.id)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bsm-openx-1.9.4 lib/openx/services/campaign.rb
bsm-openx-1.9.3 lib/openx/services/campaign.rb
bsm-openx-1.9.2 lib/openx/services/campaign.rb
bsm-openx-1.9.1 lib/openx/services/campaign.rb