public function testCrudAccess()
 {
     $feed_name = $this->getConfig()->testRunId;
     $feed = new ProductFeed(null, $this->productCatalog->id);
     $feed->setData(array(ProductFeedFields::FILE_NAME => 'my_product_feed.tsv', ProductFeedFields::NAME => $feed_name));
     $this->assertCanCreate($feed);
     $this->assertCanRead($feed);
     $this->assertCanUpdate($feed, array(ProductFeedFields::NAME => $feed_name . ' updated'));
     $this->assertCanFetchConnection($feed, 'getProducts');
     $this->assertCanFetchConnection($feed, 'getUploads');
     $this->assertCanDelete($feed);
 }
 /**
  * @param array $fields
  * @param array $params
  * @return Cursor
  */
 public function getProductFeeds(array $fields = array(), array $params = array())
 {
     return $this->getManyByConnection(ProductFeed::className(), $fields, $params);
 }
예제 #3
0
 public function updateSelf(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('default_currency' => 'string', 'deletion_enabled' => 'bool', 'delimiter' => 'delimiter_enum', 'encoding' => 'encoding_enum', 'name' => 'string', 'quoted_fields' => 'bool', 'schedule' => 'string');
     $enums = array('delimiter_enum' => ProductFeedDelimiterValues::getInstance()->getValues(), 'encoding_enum' => ProductFeedEncodingValues::getInstance()->getValues());
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/', new ProductFeed(), 'NODE', ProductFeed::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
예제 #4
0
// _DOC close [ADCREATIVE_CREATE_GET_DIRECTIONS_VIDEO]
$creative->delete();
/** @var AdImage $image */
foreach ($images as $image) {
    $image->delete();
}
$link = $app_url;
$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};
$feed = new ProductFeed(null, $catalog_id);
$feed->setData(array(ProductFeedFields::FILE_NAME => 'my_product_feed.tsv', ProductFeedFields::NAME => 'Test Feed'));
$feed->create();
$feed_id = $feed->{ProductFeedFields::ID};
// _DOC open [ADCREATIVE_CREATE_DPA_CAROUSEL]
// _DOC vars [ad_account_id:s, page_id, link:s, product_set_id]
// use FacebookAds\Object\AdCreative;
// use FacebookAds\Object\ObjectStorySpec;
// use FacebookAds\Object\ObjectStory\TemplateData;
// use FacebookAds\Object\Fields\AdCreativeFields;
// use FacebookAds\Object\Fields\ObjectStorySpecFields;
$object_story_spec = new ObjectStorySpec();
$object_story_spec->setData(array(ObjectStorySpecFields::PAGE_ID => $page_id, ObjectStorySpecFields::TEMPLATE_DATA => (new TemplateData())->setData(array('message' => 'Test {{product.name | titleize}}', 'link' => $link, 'name' => 'Headline {{product.price}}', 'description' => 'Description {{product.description}}', 'max_product_count' => 3))));
$creative = new AdCreative(null, $ad_account_id);
$creative->setData(array(AdCreativeFields::NAME => 'Dynamic Ad Template Creative Sample', AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec, AdCreativeFields::PRODUCT_SET_ID => $product_set_id));
$creative->create();