Sha256: 5e67d5dcb9b0925bf6e3b5ae71d514eb9965919ac483b4be1fdcc9f0429ac1c4

Contents?: true

Size: 809 Bytes

Versions: 6

Compression:

Stored size: 809 Bytes

Contents

require 'blurb/request_collection_with_campaign_type'

class Blurb
  class CampaignRequests < RequestCollectionWithCampaignType
    def create_bulk(create_array)
      create_array = map_campaign_payload(create_array)
      super(create_array)
    end

    def update_bulk(update_array)
      update_array = map_campaign_payload(update_array)
      super(update_array)
    end

    private

      def map_campaign_payload(payload)
        campaign_type_string = "sponsoredProducts" if @campaign_type == CAMPAIGN_TYPE_CODES[:sp]
        campaign_type_string = "sponsoredBrands" if @campaign_type == CAMPAIGN_TYPE_CODES[:sb]
        campaign_type_string = "sponsoredDisplays" if @campaign_type == CAMPAIGN_TYPE_CODES[:sd]
        payload.each{ |p| p[:campaign_type] = campaign_type_string }
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blurb-0.5.9 lib/blurb/campaign_requests.rb
blurb-0.5.8 lib/blurb/campaign_requests.rb
blurb-0.5.6 lib/blurb/campaign_requests.rb
blurb-0.5.5 lib/blurb/campaign_requests.rb
blurb-0.5.2 lib/blurb/campaign_requests.rb
blurb-0.5.1 lib/blurb/campaign_requests.rb