Class: Adparlor::Facebook::GraphApi::AdAccount
Constant Summary
Fields::AdAccount::CREATE_FIELDS, Fields::AdAccount::FIELDS, Fields::AdAccount::UPDATE_FIELDS
Fields::FieldDecorator::GLOBAL_FIELDS
Instance Attribute Summary
Attributes inherited from GraphObject
#access_token
Class Method Summary
collapse
Instance Method Summary
collapse
#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
included
Class Method Details
.get(path_or_account_id, options = {}) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 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) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# 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) ⇒ Object
35
36
37
38
39
40
41
|
# 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
|
Instance Method Details
#activities ⇒ Object
48
49
50
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 48
def activities
@activities ||= CollectionProxy.new Activity, endpoint('activities'), access_token
end
|
#adcreatives ⇒ Object
52
53
54
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 52
def adcreatives
@adcreatives ||= CollectionProxy.new AdCreative, endpoint('adcreatives'), access_token
end
|
#adimages ⇒ Object
56
57
58
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 56
def adimages
@adimages ||= CollectionProxy.new AdImage, endpoint('adimages'), access_token
end
|
#adlabels ⇒ Object
60
61
62
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 60
def adlabels
@adlabels ||= CollectionProxy.new AdLabel, endpoint('adlabels'), access_token
end
|
#ads ⇒ Object
64
65
66
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 64
def ads
@ads ||= CollectionProxy.new Ad, endpoint('ads'), access_token
end
|
#adsets ⇒ Object
68
69
70
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 68
def adsets
@adsets ||= CollectionProxy.new AdSet, endpoint('adsets'), access_token
end
|
#adspixels ⇒ Object
72
73
74
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 72
def adspixels
@adspixels ||= CollectionProxy.new AdsPixel, endpoint('adspixels'), access_token
end
|
#advertisable_applications ⇒ Object
76
77
78
|
# 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 ⇒ Object
80
81
82
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 80
def advideos
@advideos ||= CollectionProxy.new AdVideo, endpoint('advideos'), access_token
end
|
#applications ⇒ Object
84
85
86
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 84
def applications
@applications ||= CollectionProxy.new Application, endpoint('applications'), access_token
end
|
#broadtargetingcategories ⇒ Object
88
89
90
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 88
def broadtargetingcategories
@broadtargetingcategories ||= CollectionProxy.new BroadTargetingCategory, endpoint('broadtargetingcategories'), access_token
end
|
#campaigns ⇒ Object
97
98
99
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 97
def campaigns
@campaigns ||= CollectionProxy.new Campaign, endpoint('campaigns'), access_token
end
|
#connectionobjects ⇒ Object
Deprecated in v2.6. Please Use advertisable_applications, pages, places endpoint instead
93
94
95
|
# 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 ⇒ Object
101
102
103
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 101
def customaudiences
@customaudiences ||= CollectionProxy.new CustomAudience, endpoint('customaudiences'), access_token
end
|
#customaudiencestos ⇒ Object
105
106
107
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 105
def customaudiencestos
@customaudiencestos ||= CollectionProxy.new CustomAudienceTos, endpoint('customaudiencestos'), access_token
end
|
#customconversions ⇒ Object
109
110
111
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 109
def customconversions
@customconversions ||= CollectionProxy.new CustomConversion, endpoint('customconversions'), access_token
end
|
#delivery_estimate ⇒ Object
113
114
115
|
# 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 ⇒ Object
117
118
119
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 117
def generatepreviews
@generatepreviews ||= CollectionProxy.new AdPreview, endpoint('generatepreviews'), access_token
end
|
#insights ⇒ Object
121
122
123
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 121
def insights
@insights ||= CollectionProxy.new Insight, endpoint('insights'), access_token
end
|
#instagram_accounts ⇒ Object
125
126
127
|
# 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) ⇒ Object
44
45
46
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 44
def normalized_account_id(account_id)
"act_#{account_id}"
end
|
#offsitepixels ⇒ Object
129
130
131
|
# 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 ⇒ Object
133
134
135
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 133
def pages
@pages ||= CollectionProxy.new PageAndPlace, 'me/accounts', access_token
end
|
#partnercategories ⇒ Object
141
142
143
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 141
def partnercategories
@partnercategories ||= CollectionProxy.new PartnerCategory, endpoint('partnercategories'), access_token
end
|
#places ⇒ Object
137
138
139
|
# 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 ⇒ Object
145
146
147
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 145
def reachestimate
@reachestimate ||= CollectionProxy.new ReachEstimate, endpoint('reachestimate'), access_token
end
|
#reachfrequencypredictions ⇒ Object
149
150
151
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 149
def reachfrequencypredictions
@reachfrequencypredictions ||= CollectionProxy.new ReachFrequencyPrediction, endpoint('reachfrequencypredictions'), access_token
end
|
#targetingsentencelines ⇒ Object
153
154
155
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 153
def targetingsentencelines
@targetingsentencelines ||= CollectionProxy.new TargetingSentenceLine, endpoint('targetingsentencelines'), access_token
end
|
#targetingsuggestions ⇒ Object
157
158
159
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 157
def targetingsuggestions
@targetingsuggestions ||= CollectionProxy.new TargetingSuggestion, endpoint('targetingsuggestions'), access_token
end
|
#targetingvalidation ⇒ Object
161
162
163
|
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 161
def targetingvalidation
@targetingvalidation ||= CollectionProxy.new TargetingValidation, endpoint('targetingvalidation'), access_token
end
|