Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Rest/OAuthRestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public function patchJson(
);
}

public function refreshToken(): OAuthAccessToken
{
$refreshToken = $this->oAuthAccessToken->getRefreshToken();
$refreshedToken = $this->getRefreshToken($refreshToken);
$this->oAuthAccessToken = $refreshedToken;
return $refreshedToken;
}


private function setParamsFromAccessToken(): void
{
$this->apiRestClient->setBaseUriForRestClient($this->getOAuthAccessToken()->getInstanceUrl());
Expand Down
2 changes: 2 additions & 0 deletions src/Rest/RestClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ public function patchJson(
array $headers = [],
?float $timeoutSeconds = null
): ResponseInterface;

public function refreshToken(): OAuthAccessToken;
}
5 changes: 5 additions & 0 deletions src/Restforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public function query(string $queryString): ResponseInterface
]);
}

public function refreshToken(): OAuthAccessToken
{
return $this->getOAuthRestClient()->refreshToken();
}

public function userInfo(): ResponseInterface
{
return $this->getOAuthRestClient()->get(self::USER_INFO_ENDPOINT);
Expand Down
2 changes: 2 additions & 0 deletions src/RestforceInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace EventFarm\Restforce;

use EventFarm\Restforce\Rest\OAuthAccessToken;
use Psr\Http\Message\ResponseInterface;

interface RestforceInterface
Expand All @@ -13,4 +14,5 @@ public function update(string $sobjectType, string $sobjectId, array $data): Res
public function describe(string $sobjectType): ResponseInterface;
public function find(string $sobjectType, string $sobjectId, array $fields = []): ResponseInterface;
public function getNext(string $url): ResponseInterface;
public function refreshToken(): OAuthAccessToken;
}