Skip to content

Commit

Permalink
Merge pull request #61 from raultcj/allow-jobs-to-use-different-accou…
Browse files Browse the repository at this point in the history
…nt-ids

Now allows Jobs to be read from multiple accounts.
  • Loading branch information
hborras authored Jul 30, 2019
2 parents 42dd840 + d5ad8ff commit 600f6d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/TwitterAds/Analytics/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ class Job extends Analytics

public function read($params = [])
{
$resource = str_replace(static::RESOURCE_REPLACE, $this->getTwitterAds()->getAccountId(), static::RESOURCE);
if (isset($params[JobFields::ACCOUNT_ID])) {
$account_id = $params[JobFields::ACCOUNT_ID];
} else {
$account_id = $this->getTwitterAds()->getAccountId();
}

$resource = str_replace(static::RESOURCE_REPLACE, $account_id, static::RESOURCE);
$params[JobFields::JOB_IDS] = $this->id;
$response = $this->getTwitterAds()->get($resource, $params);
if (isset($response->getBody()->data[0])) {
Expand Down

0 comments on commit 600f6d9

Please sign in to comment.