| @@ 64-84 (lines=21) @@ | ||
| 61 | * Saves or updates the current object instance depending on the |
|
| 62 | * presence of `object->getId()`. |
|
| 63 | */ |
|
| 64 | public function save() |
|
| 65 | { |
|
| 66 | $params = $this->toParams(); |
|
| 67 | if (isset($params[PromotedTweetFields::TWEET_ID])) { |
|
| 68 | $params[PromotedTweetFields::TWEET_IDS] = $params[PromotedTweetFields::TWEET_ID]; |
|
| 69 | unset($params[PromotedTweetFields::TWEET_ID]); |
|
| 70 | } |
|
| 71 | ||
| 72 | if ($this->getId()) { |
|
| 73 | $resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE); |
|
| 74 | $resource = str_replace(static::RESOURCE_ID_REPLACE, $this->getId(), $resource); |
|
| 75 | $response = $this->getTwitterAds()->put($resource, $params); |
|
| 76 | ||
| 77 | return $this->fromResponse($response->getBody()->data); |
|
| 78 | } |
|
| 79 | ||
| 80 | $resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE_COLLECTION); |
|
| 81 | $response = $this->getTwitterAds()->post($resource, $params); |
|
| 82 | ||
| 83 | return $this->fromResponse($response->getBody()->data[0]); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * @return mixed |
|
| @@ 62-82 (lines=21) @@ | ||
| 59 | * Saves or updates the current object instance depending on the |
|
| 60 | * presence of `object->getId()`. |
|
| 61 | */ |
|
| 62 | public function save() |
|
| 63 | { |
|
| 64 | $params = $this->toParams(); |
|
| 65 | if (isset($params[ScheduledPromotedTweetFields::TWEET_ID])) { |
|
| 66 | $params[ScheduledPromotedTweetFields::TWEET_IDS] = $params[ScheduledPromotedTweetFields::TWEET_ID]; |
|
| 67 | unset($params[ScheduledPromotedTweetFields::TWEET_ID]); |
|
| 68 | } |
|
| 69 | ||
| 70 | if ($this->getId()) { |
|
| 71 | $resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE); |
|
| 72 | $resource = str_replace(static::RESOURCE_ID_REPLACE, $this->getId(), $resource); |
|
| 73 | $response = $this->getTwitterAds()->put($resource, $params); |
|
| 74 | ||
| 75 | return $this->fromResponse($response->getBody()->data); |
|
| 76 | } |
|
| 77 | ||
| 78 | $resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE_COLLECTION); |
|
| 79 | $response = $this->getTwitterAds()->post($resource, $params); |
|
| 80 | ||
| 81 | return $this->fromResponse($response->getBody()->data[0]); |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * @return mixed |
|