public function testCrudAccess()
 {
     $feed_name = $this->getTestRunId();
     $product_set = new ProductSet(null, $this->productCatalog->id);
     $product_set->setData(array(ProductSetFields::NAME => $feed_name, ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2')))));
     $this->assertCanCreate($product_set);
     $this->assertCanRead($product_set);
     $this->assertCanUpdate($product_set, array(ProductSetFields::NAME => $feed_name . ' updated'));
     $this->assertCanFetchConnection($product_set, 'getProductGroups');
     $this->assertCanDelete($product_set);
 }
 public function tearDown()
 {
     if ($this->productSet) {
         $this->productSet->delete();
         $this->productSet = null;
     }
     if ($this->productCatalog) {
         $this->productCatalog->delete();
         $this->productCatalog = null;
     }
     parent::tearDown();
 }
 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();
 }
 public function getProductSets(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array();
     $enums = array();
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_GET, '/product_sets', new ProductSet(), 'EDGE', ProductSet::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
 /**
  * @param array $fields
  * @param array $params
  * @return Cursor
  */
 public function getProductSets(array $fields = array(), array $params = array())
 {
     return $this->getManyByConnection(ProductSet::className(), $fields, $params, 'product_sets');
 }
Esempio n. 6
0
 public function updateSelf(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('filter' => 'Object', 'name' => 'string');
     $enums = array();
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/', new ProductSet(), 'NODE', ProductSet::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
Esempio n. 7
0
$adset = new AdSet(null, $ad_account_id);
$adset->setData(array(AdSetFields::NAME => 'Local awareness adset', AdSetFields::DAILY_BUDGET => 10000, AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_PAUSED, AdSetFields::CAMPAIGN_GROUP_ID => $campaign_group_id, AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::REACH, AdSetFields::BILLING_EVENT => BillingEvents::IMPRESSIONS, AdSetFields::BID_AMOUNT => 300, AdSetFields::TARGETING => (new TargetingSpecs())->setData(array(TargetingSpecsFields::PAGE_TYPES => array(PageTypes::MOBILE_FEED), TargetingSpecsFields::GEO_LOCATIONS => array('custom_locations' => array(array('latitude' => 37.48327, 'longitude' => -122.15033, 'radius' => 10, 'distance_unit' => 'mile', 'address_string' => '1601 Willow Road, Menlo Park, CA 94025')), 'location_types' => array('home', 'recent')), TargetingSpecsFields::EXCLUDED_GEO_LOCATIONS => array('zips' => array(array('key' => 'US:94040')))))));
$adset->create();
// _DOC close [ADSET_CREATE_LOCAL_AWARENESS]
$adset->delete();
$campaign->delete();
// Create AdCampaign
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'My First Campaign', AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED));
$campaign->create();
$campaign_group_id = $campaign->{AdCampaignFields::ID};
$product_catalog = new ProductCatalog(null, $business_id);
$product_catalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog'));
$product_catalog->create();
$catalog_id = $product_catalog->{ProductCatalogFields::ID};
$product_set = new ProductSet(null, $catalog_id);
$product_set->setData(array(ProductSetFields::NAME => 'Test Catalog Set'));
$product_set->create();
$product_set_id = $product_set->{ProductSetFields::ID};
$product_audience = new ProductAudience(null, $ad_account_id);
$product_audience->setData(array(ProductAudienceFields::NAME => 'Test Custom Audience', ProductAudienceFields::PRODUCT_SET_ID => $product_set_id, ProductAudienceFields::INCLUSIONS => array(array('retention_seconds' => 86400, 'rule' => array('event' => array('eq' => 'AddToCart'))))));
$product_audience->create();
$dynamic_audience_id = $product_audience->{ProductAudienceFields::ID};
// _DOC open [ADSET_CREATE_PRODUCT_CATALOG_SALES]
// _DOC vars [ad_account_id:s, campaign_group_id, dynamic_audience_id, product_set_id]
// use FacebookAds\Object\AdSet;
// use FacebookAds\Object\Fields\AdSetFields;
// use FacebookAds\Object\Fields\TargetingSpecsFields;
$adset = new AdSet(null, $ad_account_id);
$adset->setData(array(AdSetFields::NAME => 'Product Catalog Sales Adset', AdSetFields::BID_AMOUNT => 3000, AdSetFields::BILLING_EVENT => BillingEvents::LINK_CLICKS, AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::LINK_CLICKS, AdSetFields::CAMPAIGN_STATUS => AdCampaign::STATUS_ACTIVE, AdSetFields::DAILY_BUDGET => 15000, AdSetFields::CAMPAIGN_GROUP_ID => $campaign_group_id, AdSetFields::TARGETING => array(TargetingSpecsFields::GEO_LOCATIONS => array('countries' => array('US')), TargetingSpecsFields::DYNAMIC_AUDIENCE_IDS => array($dynamic_audience_id)), AdSetFields::PROMOTED_OBJECT => array('product_set_id' => $product_set_id)));
$adset->create();