Module: Oass::Client::Creative

Included in:
Oass::Client
Defined in:
lib/oass/client/creative.rb

Instance Method Summary collapse

Instance Method Details

#create_creative(attributes) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/oass/client/creative.rb', line 15

def create_creative(attributes)
  request "Creative" do |xml|
    xml.Creative(:action => "add") do
      xml.CampaignId attributes[:campaign_id]
      xml.Id attributes[:id]
      xml.Name attributes[:name]
      xml.Description attributes[:description]
      xml.ClickUrl attributes[:click_url]
      xml.Positions do
        attributes[:positions].each do |position|
          xml.Position position
        end
      end if attributes[:positions]
      xml.CreativeTypesId attributes[:creative_types_id]
      xml.RedirectUrl attributes[:redirect_url]
      xml.Display attributes[:display]
      xml.Height attributes[:height]
      xml.Width attributes[:width]
      xml.TargetWindow attributes[:target_window]
      xml.AltText attributes[:alt_text]
      xml.DiscountImpressions attributes[:discount_impressions]
      xml.StartDate attributes[:start_date]
      xml.EndDate attributes[:end_date]
      xml.Weight attributes[:weight]
      xml.ExpireImmediately attributes[:expire_immediately]
      xml.NoCache attributes[:no_cache]
      xml.ExtraHTML attributes[:extra_html]
      xml.ExtraText attributes[:extra_text]
      xml.BrowserV do
        attributes[:browser_versions].each do |version|
          xml.Code version
        end
      end if attributes[:browser_versions]
      xml.SequenceNo attributes[:sequence_number]
      if attributes[:creative_file]
        xml.File(:fileType => "creative",
                 :contentType => attributes[:creative_file][:content_type],
                 :fileName => attributes[:creative_file][:name],
                 :encoding => "base64") do
          xml.text Base64.encode64(File.open(attributes[:creative_file][:file]).read)
        end
      end
      if attributes[:component_file]
        xml.File(:fileType => "component",
                 :contentType => attributes[:component_file][:content_type],
                 :fileName => attributes[:component_file][:name],
                 :encoding => "base64") do
          xml.text Base64.encode64(File.open(attributes[:component_file][:file]).read)
        end
      end
    end
  end
end

#read_creative(campaign_id, id) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/oass/client/creative.rb', line 6

def read_creative(campaign_id, id)
  request "Creative" do |xml|
    xml.Creative(:action => "read") do
      xml.CampaignId campaign_id
      xml.Id id
    end
  end
end