Class: FacebookAds::Ad
Overview
An ad belongs to an ad set. It is created using an ad creative. developers.facebook.com/docs/marketing-api/reference/adgroup
Constant Summary collapse
- FIELDS =
%w[id account_id campaign_id adset_id adlabels bid_amount bid_info bid_type configured_status conversion_specs created_time creative effective_status last_updated_by_app_id name tracking_specs updated_time ad_review_feedback].freeze
- STATUSES =
%w[ACTIVE PAUSED DELETED PENDING_REVIEW DISAPPROVED PREAPPROVED PENDING_BILLING_INFO CAMPAIGN_PAUSED ARCHIVED ADSET_PAUSED].freeze
Instance Method Summary collapse
-
#ad_account ⇒ Object
belongs_to ad_account.
-
#ad_campaign ⇒ Object
belongs_to ad_campaign.
-
#ad_creative ⇒ Object
belongs_to ad_creative.
-
#ad_insights(range: Date.today..Date.today, level: 'ad', time_increment: 1) ⇒ Object
has_many ad_insights.
-
#ad_set ⇒ Object
belongs_to ad_set.
Methods inherited from Base
all, delete, #destroy, find, find_by, get, paginate, post, #save, #update
Instance Method Details
#ad_account ⇒ Object
belongs_to ad_account
12 13 14 |
# File 'lib/facebook_ads/ad.rb', line 12 def ad_account @ad_account ||= AdAccount.find(account_id) end |
#ad_campaign ⇒ Object
belongs_to ad_campaign
18 19 20 |
# File 'lib/facebook_ads/ad.rb', line 18 def ad_campaign @ad_campaign ||= AdCampaign.find(campaign_id) end |
#ad_creative ⇒ Object
belongs_to ad_creative
30 31 32 |
# File 'lib/facebook_ads/ad.rb', line 30 def ad_creative @ad_creative ||= AdCreative.find(creative['id']) end |
#ad_insights(range: Date.today..Date.today, level: 'ad', time_increment: 1) ⇒ Object
has_many ad_insights
36 37 38 39 40 41 42 43 |
# File 'lib/facebook_ads/ad.rb', line 36 def ad_insights(range: Date.today..Date.today, level: 'ad', time_increment: 1) query = { level: level, time_increment: time_increment, time_range: { 'since': range.first.to_s, 'until': range.last.to_s } } AdInsight.paginate("/#{id}/insights", query: query) end |