Class: Adparlor::Facebook::GraphApi::AdAccount

Inherits:
GraphObject
  • Object
show all
Includes:
Fields::AdAccount, Traits::Methods
Defined in:
lib/adparlor/facebook/graph_api/ad_account.rb

Constant Summary

Constants included from Fields::AdAccount

Fields::AdAccount::CREATE_FIELDS, Fields::AdAccount::FIELDS, Fields::AdAccount::UPDATE_FIELDS

Constants included from Fields::FieldDecorator

Fields::FieldDecorator::GLOBAL_FIELDS

Instance Attribute Summary

Attributes inherited from GraphObject

#access_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Traits::Methods

#create, #destroy, included, #update

Methods inherited from GraphObject

#batch, create, #create, data_pass_through, destroy, #destroy, #initialize, read, respond_for_data, #to_hash, #to_json, update, #update

Methods included from Api

#base_uri, #conn, #conn_multi, #delete, #get, #post, #proxy_api_key

Methods included from Fields::FieldDecorator

included

Constructor Details

This class inherits a constructor from Adparlor::Facebook::GraphApi::GraphObject

Class Method Details

.get(path_or_account_id, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 11

def get(, options = {})
  path = 

  begin
     = Integer()
    path = "/#{()}"
  rescue
    STDERR.puts 'Invalid account id passed to get'
  end

  super(path, options)
end

.normalize_account_id(account_id) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 24

def ()
   = .to_s.downcase
  if .include?('act_')
     = 
  else
     = "act_#{}"
  end
  
end

.parse_data_for_collection(response) ⇒ Object



34
35
36
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 34

def parse_data_for_collection(response)
  response['data'].first.last
end

Instance Method Details

#activitiesObject



43
44
45
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 43

def activities
  @activities ||= CollectionProxy.new Activity, endpoint('activities'), access_token
end

#adcreativesObject



47
48
49
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 47

def adcreatives
  @adcreatives ||= CollectionProxy.new AdCreative, endpoint('adcreatives'), access_token
end

#adimagesObject



51
52
53
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 51

def adimages
  @adimages ||= CollectionProxy.new AdImage, endpoint('adimages'), access_token
end

#adlabelsObject



55
56
57
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 55

def adlabels
  @adlabels ||= CollectionProxy.new AdLabel, endpoint('adlabels'), access_token
end

#adsObject



59
60
61
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 59

def ads
  @ads ||= CollectionProxy.new Ad, endpoint('ads'), access_token
end

#adsetsObject



63
64
65
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 63

def adsets
  @adsets ||= CollectionProxy.new AdSet, endpoint('adsets'), access_token
end

#adspixelsObject



67
68
69
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 67

def adspixels
  @adspixels ||= CollectionProxy.new AdsPixel, endpoint('adspixels'), access_token
end

#advertisable_applicationsObject



71
72
73
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 71

def advertisable_applications
  @advertisable_applications ||= CollectionProxy.new AdvertisableApplication, endpoint('advertisable_applications'), access_token
end

#advideosObject



75
76
77
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 75

def advideos
  @advideos ||= CollectionProxy.new AdVideo, endpoint('advideos'), access_token
end

#applicationsObject



79
80
81
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 79

def applications
  @applications ||= CollectionProxy.new Application, endpoint('applications'), access_token
end

#broadtargetingcategoriesObject



83
84
85
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 83

def broadtargetingcategories
  @broadtargetingcategories ||= CollectionProxy.new BroadTargetingCategory, endpoint('broadtargetingcategories'), access_token
end

#campaignsObject



92
93
94
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 92

def campaigns
  @campaigns ||= CollectionProxy.new Campaign, endpoint('campaigns'), access_token
end

#connectionobjectsObject

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



88
89
90
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 88

def connectionobjects
  Kernel::fail("connectionobjects is deprecated in v2.6. Use advertisable_applications, pages, places endpoint instead")
end

#customaudiencesObject



96
97
98
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 96

def customaudiences
  @customaudiences ||= CollectionProxy.new CustomAudience, endpoint('customaudiences'), access_token
end

#customaudiencestosObject



100
101
102
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 100

def customaudiencestos
  @customaudiencestos ||= CollectionProxy.new CustomAudienceTos, endpoint('customaudiencestos'), access_token
end

#customconversionsObject



104
105
106
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 104

def customconversions
  @customconversions ||= CollectionProxy.new CustomConversion, endpoint('customconversions'), access_token
end

#delivery_estimateObject



108
109
110
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 108

def delivery_estimate
  @delivery_estimate ||= CollectionProxy.new DeliveryEstimate, endpoint('delivery_estimate'), access_token
end

#generatepreviewsObject



112
113
114
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 112

def generatepreviews
  @generatepreviews ||= CollectionProxy.new AdPreview, endpoint('generatepreviews'), access_token
end

#insightsObject



116
117
118
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 116

def insights
  @insights ||= CollectionProxy.new Insight, endpoint('insights'), access_token
end

#instagram_accountsObject



120
121
122
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 120

def instagram_accounts
  @instagram_accounts ||= CollectionProxy.new InstagramAccount, endpoint('instagram_accounts'), access_token
end

#normalized_account_id(account_id) ⇒ Object



39
40
41
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 39

def ()
  "act_#{}"
end

#offsitepixelsObject



124
125
126
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 124

def offsitepixels
  Kernel::fail("offsite_pixels is deprecated in v2.7 and above.")
end

#pagesObject



128
129
130
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 128

def pages
  @pages ||= CollectionProxy.new PageAndPlace, 'me/accounts', access_token
end

#partnercategoriesObject



136
137
138
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 136

def partnercategories
  @partnercategories ||= CollectionProxy.new PartnerCategory, endpoint('partnercategories'), access_token
end

#placesObject



132
133
134
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 132

def places
  @places ||= CollectionProxy.new PageAndPlace, 'me/accounts', access_token, nil, is_place: true
end

#reachestimateObject



140
141
142
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 140

def reachestimate
  @reachestimate ||= CollectionProxy.new ReachEstimate, endpoint('reachestimate'), access_token
end

#reachfrequencypredictionsObject



144
145
146
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 144

def reachfrequencypredictions
  @reachfrequencypredictions ||= CollectionProxy.new ReachFrequencyPrediction, endpoint('reachfrequencypredictions'), access_token
end

#targetingsentencelinesObject



148
149
150
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 148

def targetingsentencelines
  @targetingsentencelines ||= CollectionProxy.new TargetingSentenceLine, endpoint('targetingsentencelines'), access_token
end

#targetingsuggestionsObject



152
153
154
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 152

def targetingsuggestions
  @targetingsuggestions ||= CollectionProxy.new TargetingSuggestion, endpoint('targetingsuggestions'), access_token
end

#targetingvalidationObject



156
157
158
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 156

def targetingvalidation
  @targetingvalidation ||= CollectionProxy.new TargetingValidation, endpoint('targetingvalidation'), access_token
end