Sha256: a50e4bc67e4d7254d6f29983e0496e363e49e872e21f51db08ca88573773f139

Contents?: true

Size: 1.04 KB

Versions: 55

Compression:

Stored size: 1.04 KB

Contents

module FbGraph
  module Connections
    module AdGroups
      def ad_groups(options = {})
        ad_groups = self.connection :adgroups, options
        ad_groups.map! do |ad_group|
          AdGroup.new ad_group[:id], ad_group.merge(
            :access_token => options[:access_token] || self.access_token
          )
        end
      end

      # Note: AdGroups can only be created via the AdAccount connection. Even though it makes sense, they
      # cannot be created via the AdCampaign connection
      def ad_group!(options = {})
        ad_group = post options.merge(:connection => :adgroups)

        adgroup_id = ad_group[:id]

        merged_attrs = options.merge(
          :access_token => options[:access_token] || self.access_token,
          :ad_id => adgroup_id.to_i,
          :adgroup_id => adgroup_id.to_i
        )

        if options[:redownload]
          merged_attrs = merged_attrs.merge(ad_group[:data][:adgroups][adgroup_id]).with_indifferent_access
        end

        AdGroup.new ad_group[:id], merged_attrs
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
fb_graph-2.7.17 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.16 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.15 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.14 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.13 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.12 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.11 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.10 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.9 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.8 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.7 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.6 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.5 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.4 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.3 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.2 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.1 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.7.0 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.6.7 lib/fb_graph/connections/ad_groups.rb
fb_graph-2.6.6 lib/fb_graph/connections/ad_groups.rb