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
23
# File 'lib/adparlor/facebook/graph_api/ad_account.rb', line 11

def get(, options = {})
  path = .to_s
  if !path.include?('adaccounts')
    begin
       = Integer()
      path = "/#{()}"
    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 ()
   = .to_s.downcase
  if .include?('act_')
     = 
  else
     = "act_#{}"
  end
  
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

#activitiesObject



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

#adcreativesObject



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

#adimagesObject



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

#adlabelsObject



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

#adsObject



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

#adsetsObject



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

#adspixelsObject



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_applicationsObject



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

#advideosObject



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

#applicationsObject



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

#broadtargetingcategoriesObject



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

#campaignsObject



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

#connectionobjectsObject

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

#customaudiencesObject



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

#customaudiencestosObject



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

#customconversionsObject



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_estimateObject



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

#generatepreviewsObject



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

#insightsObject



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_accountsObject



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 ()
  "act_#{}"
end

#offsitepixelsObject



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

#pagesObject



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

#partnercategoriesObject



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

#placesObject



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

#reachestimateObject



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

#reachfrequencypredictionsObject



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

#targetingsentencelinesObject



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

#targetingsuggestionsObject



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

#targetingvalidationObject



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