class Adparlor::Facebook::GraphApi::AdAccount

Public Class Methods

get(path_or_account_id, options = {}) click to toggle source
Calls superclass method
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 11
def get(path_or_account_id, options = {})
  path = path_or_account_id.to_s
  if !path.include?('adaccounts')
    begin
      account_id = Integer(path_or_account_id)
      path = "/#{normalize_account_id(account_id)}"
    rescue
      STDERR.puts 'Invalid account id passed to get'
    end
  end

  super(path, options)
end
normalize_account_id(account_id) click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 25
def normalize_account_id(account_id)
  account_id = account_id.to_s.downcase
  if account_id.include?('act_')
    account_id = account_id
  else
    account_id = "act_#{account_id}"
  end
  account_id
end
parse_data_for_collection(response) click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 35
def parse_data_for_collection(response)
  if !response['data'].first.is_a?(Hash)
    response['data'].first.last
  else
    response['data']
  end
end

Public Instance Methods

activities() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 48
def activities
  @activities ||= CollectionProxy.new Activity, endpoint('activities'), access_token
end
adcreatives() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 52
def adcreatives
  @adcreatives ||= CollectionProxy.new AdCreative, endpoint('adcreatives'), access_token
end
adimages() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 56
def adimages
  @adimages ||= CollectionProxy.new AdImage, endpoint('adimages'), access_token
end
adlabels() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 60
def adlabels
  @adlabels ||= CollectionProxy.new AdLabel, endpoint('adlabels'), access_token
end
ads() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 64
def ads
  @ads ||= CollectionProxy.new Ad, endpoint('ads'), access_token
end
adsets() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 68
def adsets
  @adsets ||= CollectionProxy.new AdSet, endpoint('adsets'), access_token
end
adspixels() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 72
def adspixels
  @adspixels ||= CollectionProxy.new AdsPixel, endpoint('adspixels'), access_token
end
advertisable_applications() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 76
def advertisable_applications
  @advertisable_applications ||= CollectionProxy.new AdvertisableApplication, endpoint('advertisable_applications'), access_token
end
advideos() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 80
def advideos
  @advideos ||= CollectionProxy.new AdVideo, endpoint('advideos'), access_token
end
applications() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 84
def applications
  @applications ||= CollectionProxy.new Application, endpoint('applications'), access_token
end
broadtargetingcategories() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 88
def broadtargetingcategories
  @broadtargetingcategories ||= CollectionProxy.new BroadTargetingCategory, endpoint('broadtargetingcategories'), access_token
end
campaigns() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 97
def campaigns
  @campaigns ||= CollectionProxy.new Campaign, endpoint('campaigns'), access_token
end
connectionobjects() click to toggle source

Deprecated in v2.6. Please Use advertisable_applications, pages, places endpoint instead

# File lib/adparlor/facebook/graph_api/ad_account.rb, line 93
def connectionobjects
  Kernel::fail("connectionobjects is deprecated in v2.6. Use advertisable_applications, pages, places endpoint instead")
end
customaudiences() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 101
def customaudiences
  @customaudiences ||= CollectionProxy.new CustomAudience, endpoint('customaudiences'), access_token
end
customaudiencestos() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 105
def customaudiencestos
  @customaudiencestos ||= CollectionProxy.new CustomAudienceTos, endpoint('customaudiencestos'), access_token
end
customconversions() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 109
def customconversions
  @customconversions ||= CollectionProxy.new CustomConversion, endpoint('customconversions'), access_token
end
delivery_estimate() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 113
def delivery_estimate
  @delivery_estimate ||= CollectionProxy.new DeliveryEstimate, endpoint('delivery_estimate'), access_token
end
generatepreviews() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 117
def generatepreviews
  @generatepreviews ||= CollectionProxy.new AdPreview, endpoint('generatepreviews'), access_token
end
insights() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 121
def insights
  @insights ||= CollectionProxy.new Insight, endpoint('insights'), access_token
end
instagram_accounts() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 125
def instagram_accounts
  @instagram_accounts ||= CollectionProxy.new InstagramAccount, endpoint('instagram_accounts'), access_token
end
normalized_account_id(account_id) click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 44
def normalized_account_id(account_id)
  "act_#{account_id}"
end
offsitepixels() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 129
def offsitepixels
  Kernel::fail("offsite_pixels is deprecated in v2.7 and above.")
end
pages() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 133
def pages
  @pages ||= CollectionProxy.new PageAndPlace, 'me/accounts', access_token
end
partnercategories() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 141
def partnercategories
  @partnercategories ||= CollectionProxy.new PartnerCategory, endpoint('partnercategories'), access_token
end
places() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 137
def places
  @places ||= CollectionProxy.new PageAndPlace, 'me/accounts', access_token, nil, is_place: true
end
reachestimate() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 145
def reachestimate
  @reachestimate ||= CollectionProxy.new ReachEstimate, endpoint('reachestimate'), access_token
end
reachfrequencypredictions() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 149
def reachfrequencypredictions
  @reachfrequencypredictions ||= CollectionProxy.new ReachFrequencyPrediction, endpoint('reachfrequencypredictions'), access_token
end
targetingsentencelines() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 153
def targetingsentencelines
  @targetingsentencelines ||= CollectionProxy.new TargetingSentenceLine, endpoint('targetingsentencelines'), access_token
end
targetingsuggestions() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 157
def targetingsuggestions
  @targetingsuggestions ||= CollectionProxy.new TargetingSuggestion, endpoint('targetingsuggestions'), access_token
end
targetingvalidation() click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 161
def targetingvalidation
  @targetingvalidation ||= CollectionProxy.new TargetingValidation, endpoint('targetingvalidation'), access_token
end

Private Instance Methods

endpoint(connection) click to toggle source
# File lib/adparlor/facebook/graph_api/ad_account.rb, line 167
def endpoint(connection)
  "/#{normalized_account_id(account_id)}/#{connection}"
end