Module: FbGraph::Connections::AdCampaigns

Included in:
AdAccount, AdCampaignGroup
Defined in:
lib/fb_graph/connections/ad_campaigns.rb

Instance Method Summary collapse

Instance Method Details

#ad_campaign!(options = {}) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fb_graph/connections/ad_campaigns.rb', line 13

def ad_campaign!(options = {})
  ad_campaign = post options.merge(:connection => :adcampaigns)

  ad_campaign_id = ad_campaign[:id]

  merged_attrs = options.merge(
    :access_token => options[:access_token] || self.access_token
  )

  if options[:redownload]
    merged_attrs = merged_attrs.merge(ad_campaign[:data][:campaigns][ad_campaign_id]).with_indifferent_access
  end

  AdCampaign.new ad_campaign_id, merged_attrs
end

#ad_campaigns(options = {}) ⇒ Object


4
5
6
7
8
9
10
11
# File 'lib/fb_graph/connections/ad_campaigns.rb', line 4

def ad_campaigns(options = {})
  ad_campaigns = self.connection :adcampaigns, options
  ad_campaigns.map! do |ad_campaign|
    AdCampaign.new ad_campaign[:id], ad_campaign.merge(
      :access_token => options[:access_token] || self.access_token
    )
  end
end