Exemplo n.º 1
0
 /**
  * Deletes the current object instance depending on the
  * presence of `object->getId()`.
  */
 public function delete()
 {
     $resource = str_replace(static::RESOURCE_REPLACE, $this->account->getId(), static::RESOURCE);
     $resource = str_replace(static::RESOURCE_ID_REPLACE, $this->getId(), $resource);
     $response = $this->account->getTwitterAds()->delete($resource);
     $this->fromResponse($response->getBody()->data);
 }
Exemplo n.º 2
0
 /**
  * Creates a "Promoted-Only" Tweet using the specialized Ads API end point.
  *
  * @param Account $account
  * @param $status
  * @param array $params
  *
  * @return mixed
  */
 public static function create(Account $account, $status, $params = [])
 {
     $params['status'] = $status;
     if (isset($params['media_ids']) && is_array($params['media_ids'])) {
         $params['media_ids'] = implode(',', $params['media_ids']);
     }
     $resource = str_replace(Resource::RESOURCE_REPLACE, $account->getId(), self::TWEET_CREATE);
     $response = $account->getTwitterAds()->post($resource, $params);
     return $response->getBody()->data;
 }
 public function testHackedUrlWillGenerateTheExpectedRoute()
 {
     $this->markTestSkipped("Not prepared");
     $twitterAds = $this->getMockBuilder(TwitterAds::class)->disableOriginalConstructor()->getMock();
     $account = new Account($twitterAds);
     $url = sprintf('accounts/%s/tailored_audiences/global_opt_out', $account->getId());
     $optPut = new GlobalOptOut($account);
     $optPut->setListType(TailoredAudience::LIST_TYPE_EMAIL);
     $data = (object) ['data' => (object) ['input_file_path' => 'test', 'list_type' => TailoredAudience::LIST_TYPE_EMAIL]];
     $twitterAds->expects($this->once())->method('put')->with($url, $optPut->toParams())->willReturn($data);
     $optPut->save();
 }