public function tearDown()
 {
     if ($this->productCatalog) {
         $this->productCatalog->delete();
         $this->productCatalog = null;
     }
     parent::tearDown();
 }
 public function testCrud()
 {
     $catalog_name = $this->getTestRunId();
     $catalog = new ProductCatalog(null, $this->getBusinessManagerId());
     $catalog->setData(array(ProductCatalogFields::NAME => $catalog_name));
     $this->assertCanCreate($catalog);
     $this->assertCanRead($catalog);
     $this->assertCanUpdate($catalog, array(ProductCatalogFields::NAME => $catalog_name . ' updated'));
     $this->assertCanFetchConnectionAsArray($catalog, 'getExternalEventSources');
     $this->assertCanFetchConnection($catalog, 'getProductSets');
     $this->assertCanFetchConnection($catalog, 'getProductFeeds');
     $this->assertCanDelete($catalog);
 }
 public function tearDown()
 {
     if ($this->productSet) {
         $this->productSet->delete();
         $this->productSet = null;
     }
     if ($this->productCatalog) {
         $this->productCatalog->delete();
         $this->productCatalog = null;
     }
     if ($this->productAudience) {
         $this->productAudience->delete();
         $this->productAudience = null;
     }
     if ($this->adCampaign) {
         $this->adCampaign->delete();
         $this->adCampaign = null;
     }
     if ($this->adSet) {
         $this->adSet->delete();
         $this->adSet = null;
     }
     if ($this->adGroup) {
         $this->adGroup->delete();
         $this->adGroup = null;
     }
     if ($this->creative) {
         $this->creative->delete();
         $this->creative = null;
     }
     parent::tearDown();
 }
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Video Views Campaign', AdCampaignFields::OBJECTIVE => AdObjectives::VIDEO_VIEWS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_VIDEO_VIEWS]
$campaign->delete();
// _DOC open [ADCAMPAIGN_CREATE_LOCAL_AWARENESS]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdCampaign;
// use FacebookAds\Object\AdCampaignFields;
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Local awareness campaign', AdCampaignFields::OBJECTIVE => AdObjectives::LOCAL_AWARENESS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_LOCAL_AWARENESS]
$campaign->delete();
$product_catalog = new ProductCatalog(null, $business_id);
$product_catalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog'));
$product_catalog->create();
$product_catalog_id = $product_catalog->{ProductCatalogFields::ID};
// _DOC open [ADCAMPAIGN_CREATE_OBJECTIVE_PRODUCT_CATELOG_SALES]
// _DOC vars [ad_account_id:s, product_catalog_id]
// use FacebookAds\Object\AdCampaign;
// use FacebookAds\Object\Fields\AdCampaignFields;
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Product Catalog Sales Campaign Group', AdCampaignFields::OBJECTIVE => AdObjectives::PRODUCT_CATALOG_SALES, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED, AdCampaignFields::PROMOTED_OBJECT => array('product_catalog_id' => $product_catalog_id)));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_OBJECTIVE_PRODUCT_CATELOG_SALES]
$campaign->delete();
$product_catalog->delete();
Example #5
0
 public function createProductCatalog(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('name' => 'string', 'vertical' => 'vertical_enum');
     $enums = array('vertical_enum' => ProductCatalogVerticalValues::getInstance()->getValues());
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/product_catalogs', new ProductCatalog(), 'EDGE', ProductCatalog::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
 public function updateSelf(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('name' => 'string');
     $enums = array();
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/', new ProductCatalog(), 'NODE', ProductCatalog::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }