Sha256: 66d6b31e9ef74f38e94cf8c1654f4966f6293a91922affd57c343912528e04e1
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
module FbGraph class AdGroup < Node include Connections::AdCreatives include Connections::ReachEstimates attr_accessor :ad_id, :campaign_id, :name, :adgroup_status, :bid_type, :max_bid, :targeting, :creative, :creative_ids, :adgroup_id, :end_time, :start_time, :updated_time, :bid_info, :disapprove_reason_descriptions def initialize(identifier, attributes = {}) super set_attrs(attributes) end # We override update to handle the "redownload" parameter # If redownload is specified, the FbGraph::AdGroup object will be updated with the data returned from Facebook. def update(options) response = super(options) if options[:redownload] attributes = options.merge(response[:data][:adgroups][identifier]).with_indifferent_access set_attrs(attributes) end response end def creatives(fetch = true) creative_ids.map { |creative_id| fetch ? AdCreative.fetch(creative_id) : AdCreative.new(creative_id) } end protected def set_attrs(attributes) %w(ad_id campaign_id name adgroup_status bid_type max_bid targeting creative creative_ids adgroup_id bid_info disapprove_reason_descriptions).each do |field| send("#{field}=", attributes[field.to_sym]) end # max_bid is string only when reloaded for some reason.. self.max_bid = max_bid.try(:to_i) %w(start_time end_time updated_time).each do |field| if val = attributes[field.to_sym] # Handles integer timestamps and ISO8601 strings time = Time.parse(val) rescue Time.at(val.to_i) send("#{field}=", time) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fb_graph-2.5.4 | lib/fb_graph/ad_group.rb |
fb_graph-2.5.3 | lib/fb_graph/ad_group.rb |
fb_graph-2.5.2 | lib/fb_graph/ad_group.rb |