Class: Adparlor::Facebook::GraphApi::Campaign

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

Constant Summary

Constants included from Fields::Campaign

Fields::Campaign::CREATE_FIELDS, Fields::Campaign::FIELDS, Fields::Campaign::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, get, #initialize, parse_data_for_collection, read, respond_for_data, #to_hash, #to_json, update, #update

Methods included from Api

#base_uri, #conn, #conn_multi, #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

.destroy(attributes = {}, options = {}) ⇒ Object



13
14
15
16
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 13

def destroy(attributes = {}, options = {})
  obj = new(attributes.merge(status: 'DELETED'))
  obj.post(obj.update_path, options, 'DELETE')
end

Instance Method Details

#adsObject



33
34
35
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 33

def ads
  @ads ||= CollectionProxy.new(Ad, "/#{id}/ads", access_token)
end

#adsetsObject



37
38
39
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 37

def adsets
  @adsets ||= CollectionProxy.new(AdSet, "/#{id}/adsets", access_token)
end

#deleteObject

Raises:



29
30
31
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 29

def delete
  raise FbError.new('delete not available, use soft delete update', 500)
end

#pathObject

Raises:



19
20
21
22
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 19

def path
  raise FbError.new('required parameter account_id missing', 500) unless 
  "/act_#{}/campaigns"
end

#update_pathObject

Raises:



24
25
26
27
# File 'lib/adparlor/facebook/graph_api/campaign.rb', line 24

def update_path
  raise FbError.new('required parameter id missing', 500) unless id
  "/#{id}"
end