From 3046df2f8e25c16fdb26b421302c49bc75673570 Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Thu, 11 Oct 2018 17:31:30 +0200 Subject: [PATCH 01/38] Changed namespaces and PHP version (7.1 => 7.0) --- composer.json | 2 +- src/Rest/GuzzleRestClient.php | 19 ++++---- src/Rest/OAuthAccessToken.php | 8 ++-- src/Rest/OAuthRestClient.php | 29 ++++++------ src/Rest/RestClientInterface.php | 16 +++---- src/Rest/SalesforceRestClient.php | 22 ++++----- src/Rest/SalesforceRestClientInterface.php | 20 ++++---- src/Restforce.php | 55 +++++++++++++++------- src/RestforceInterface.php | 22 +++++---- 9 files changed, 108 insertions(+), 85 deletions(-) diff --git a/composer.json b/composer.json index 9a5ba6b..7004637 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "codeclimate/php-test-reporter": "dev-master" }, "require": { - "php": ">=7.1", + "php": ">=7.0", "psr/http-message": "^1.0", "guzzlehttp/guzzle": "^6.3", "guzzlehttp/psr7": "^1.4" diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index 4a6c016..88742a3 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -20,7 +20,7 @@ public function __construct( $this->setBaseUriForRestClient($baseUri); } - public function setBaseUriForRestClient(string $baseUri): void + public function setBaseUriForRestClient(string $baseUri) { if (!$this->containsTrailingSlash($baseUri)) { $baseUri .= '/'; @@ -38,8 +38,8 @@ public function get( string $path, array $queryParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->client->request( 'GET', $path, @@ -56,8 +56,8 @@ public function post( string $path, array $formParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->client->request( 'POST', $path, @@ -74,10 +74,9 @@ public function postJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $headers['Content-Type'] = 'application/json'; - return $this->client->request( 'POST', $path, @@ -94,8 +93,8 @@ public function patchJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $headers['Content-Type'] = 'application/json'; return $this->client->request( diff --git a/src/Rest/OAuthAccessToken.php b/src/Rest/OAuthAccessToken.php index 6a55a5b..e8a6c0b 100644 --- a/src/Rest/OAuthAccessToken.php +++ b/src/Rest/OAuthAccessToken.php @@ -21,8 +21,8 @@ public function __construct( string $accessToken, string $instanceUrl, string $resourceOwnerUrl, - ?string $refreshToken = null, - ?int $expiresAt = null + string $refreshToken = null, + int $expiresAt = null ) { $this->tokenType = $tokenType; $this->accessToken = $accessToken; @@ -42,7 +42,7 @@ public function getAccessToken(): string return $this->accessToken; } - public function getRefreshToken(): ?string + public function getRefreshToken() { return $this->refreshToken; } @@ -62,7 +62,7 @@ public function getResourceOwnerUrl(): string return $this->resourceOwnerUrl; } - public function getExpiresAt(): ?int + public function getExpiresAt() { return $this->expiresAt; } diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 0f3c0c8..4fccfac 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -27,9 +27,9 @@ public function __construct( RestClientInterface $authRestClient, string $clientId, string $clientSecret, - ?string $username = null, - ?string $password = null, - ?OAuthAccessToken $oAuthAccessToken = null + string $username = null, + string $password = null, + OAuthAccessToken $oAuthAccessToken = null ) { $this->apiRestClient = $apiRestClient; $this->authRestClient = $authRestClient; @@ -44,8 +44,8 @@ public function get( string $path, array $queryParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $this->setParamsFromAccessToken(); return $this->apiRestClient->get( $path, @@ -59,8 +59,8 @@ public function post( string $path, array $formParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $this->setParamsFromAccessToken(); return $this->apiRestClient->post( $path, @@ -74,8 +74,8 @@ public function postJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $this->setParamsFromAccessToken(); return $this->apiRestClient->postJson( $path, @@ -89,8 +89,8 @@ public function patchJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { $this->setParamsFromAccessToken(); return $this->apiRestClient->patchJson( $path, @@ -100,7 +100,7 @@ public function patchJson( ); } - private function setParamsFromAccessToken(): void + private function setParamsFromAccessToken() { $this->apiRestClient->setBaseUriForRestClient($this->getOAuthAccessToken()->getInstanceUrl()); $this->apiRestClient->setResourceOwnerUrl($this->getOAuthAccessToken()->getResourceOwnerUrl()); @@ -108,6 +108,7 @@ private function setParamsFromAccessToken(): void private function getOAuthAccessToken(): OAuthAccessToken { + //error_log('getting token'); if ($this->oAuthAccessToken === null) { $this->oAuthAccessToken = $this->getNewToken(); } @@ -125,7 +126,6 @@ private function getOAuthAccessToken(): OAuthAccessToken $this->oAuthAccessToken = $this->getNewToken(); } } - return $this->oAuthAccessToken; } @@ -186,11 +186,10 @@ private function getOAuthAccessTokenFromResponse(ResponseInterface $response): O throw OAuthRestClientException::unableToLoadAccessToken(); } - $response = json_decode($response->getBody()->__toString(), true); + $response = json_decode($response->getBody(), true); try { $resourceOwnerUrl = $response['id']; - return new OAuthAccessToken( self::TOKEN_TYPE, $response['access_token'], diff --git a/src/Rest/RestClientInterface.php b/src/Rest/RestClientInterface.php index f3530ce..2c98baa 100644 --- a/src/Rest/RestClientInterface.php +++ b/src/Rest/RestClientInterface.php @@ -9,27 +9,27 @@ public function get( string $path, array $queryParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function post( string $path, array $formParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function postJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function patchJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); } diff --git a/src/Rest/SalesforceRestClient.php b/src/Rest/SalesforceRestClient.php index 54ed336..7f53996 100644 --- a/src/Rest/SalesforceRestClient.php +++ b/src/Rest/SalesforceRestClient.php @@ -1,7 +1,7 @@ apiVersion = $apiVersion; } - public function setResourceOwnerUrl(string $resourceOwnerUrl): void + public function setResourceOwnerUrl(string $resourceOwnerUrl) { $this->resourceOwnerUrl = $resourceOwnerUrl; } - public function setBaseUriForRestClient(string $baseUri): void + public function setBaseUriForRestClient(string $baseUri) { $this->restClient->setBaseUriForRestClient($baseUri); } @@ -33,8 +33,8 @@ public function get( string $path, array $queryParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->restClient->get( $this->constructUrl($path), $queryParameters, @@ -47,8 +47,8 @@ public function post( string $path, array $formParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->restClient->post( $this->constructUrl($path), $formParameters, @@ -61,8 +61,8 @@ public function postJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->restClient->postJson( $this->constructUrl($path), $jsonArray, @@ -75,8 +75,8 @@ public function patchJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface { + float $timeoutSeconds = null + ) { return $this->restClient->patchJson( $this->constructUrl($path), $jsonArray, diff --git a/src/Rest/SalesforceRestClientInterface.php b/src/Rest/SalesforceRestClientInterface.php index ae783e5..18f5b91 100644 --- a/src/Rest/SalesforceRestClientInterface.php +++ b/src/Rest/SalesforceRestClientInterface.php @@ -5,34 +5,34 @@ interface SalesforceRestClientInterface extends RestClientInterface { - public function setResourceOwnerUrl(string $resourceOwnerUrl): void; - public function setBaseUriForRestClient(string $baseUri): void; + public function setResourceOwnerUrl(string $resourceOwnerUrl); + public function setBaseUriForRestClient(string $baseUri); public function get( string $path, array $queryParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function post( string $path, array $formParameters = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function postJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); public function patchJson( string $path, array $jsonArray = [], array $headers = [], - ?float $timeoutSeconds = null - ): ResponseInterface; + float $timeoutSeconds = null + ); } diff --git a/src/Restforce.php b/src/Restforce.php index 3975712..2934e7a 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -10,9 +10,9 @@ class Restforce implements RestforceInterface { - public const USER_INFO_ENDPOINT = 'RESOURCE_OWNER'; - - private const DEFAULT_API_VERSION = 'v38.0'; + const USER_INFO_ENDPOINT = 'RESOURCE_OWNER'; + const SALESFORCE_API_ENDPOINT = 'https://voyageprive--preprod.cs100.my.salesforce.com'; + const DEFAULT_API_VERSION = 'v41.0'; /** @var string */ private $clientId; @@ -32,10 +32,10 @@ class Restforce implements RestforceInterface public function __construct( string $clientId, string $clientSecret, - ?OAuthAccessToken $accessToken = null, - ?string $username = null, - ?string $password = null, - ?string $apiVersion = null + OAuthAccessToken $accessToken = null, + string $username = null, + string $password = null, + string $apiVersion = null ) { if ($accessToken === null && $username === null && $password === null) { throw RestforceException::minimumRequiredFieldsNotMet(); @@ -53,28 +53,28 @@ public function __construct( $this->password = $password; } - public function create(string $sobjectType, array $data): ResponseInterface + public function create(string $sobjectType, array $data) { $uri = 'sobjects/' . $sobjectType; return $this->getOAuthRestClient()->postJson($uri, $data); } - public function update(string $sobjectType, string $sobjectId, array $data): ResponseInterface + public function update(string $sobjectType, string $sobjectId, array $data) { $uri = 'sobjects/' . $sobjectType . '/' . $sobjectId; return $this->getOAuthRestClient()->patchJson($uri, $data); } - public function describe(string $sobject): ResponseInterface + public function describe(string $sobject) { $uri = 'sobjects/' . $sobject . '/describe'; return $this->getOAuthRestClient()->get($uri); } - public function find(string $sobjectType, string $sobjectId, array $fields = []): ResponseInterface + public function find(string $sobjectType, string $sobjectId, array $fields = []) { $uri = 'sobjects/' . $sobjectType . '/' . $sobjectId; @@ -88,24 +88,44 @@ public function find(string $sobjectType, string $sobjectId, array $fields = []) return $this->getOAuthRestClient()->get($uri, $queryParams); } - public function limits(): ResponseInterface + public function parameterizedSearch( + string $sobjectType, + string $search, + array $fields = [], + string $whereQuery = null + ) { + $uri = 'parameterizedSearch'; + + return $this->getOAuthRestClient()->postJson($uri, [ + "q" => $search, + "fields" => $fields, + "sobjects" => [ + [ + "name" => $sobjectType, + "where" => "Open_Date__c>=2018-10-10" + ] + ] + ]); + } + + public function limits() { return $this->getOAuthRestClient()->get('/limits'); } - public function getNext(string $url): ResponseInterface + public function getNext(string $url) { return $this->getOAuthRestClient()->get($url); } - public function query(string $queryString): ResponseInterface + public function query(string $queryString) { return $this->getOAuthRestClient()->get('query', [ 'q' => $queryString, ]); } - public function userInfo(): ResponseInterface + public function userInfo() { return $this->getOAuthRestClient()->get(self::USER_INFO_ENDPOINT); } @@ -115,10 +135,10 @@ private function getOAuthRestClient(): RestClientInterface if ($this->oAuthRestClient === null) { $this->oAuthRestClient = new OAuthRestClient( new SalesforceRestClient( - new GuzzleRestClient('https://na1.salesforce.com'), + new GuzzleRestClient(self::SALESFORCE_API_ENDPOINT), $this->apiVersion ), - new GuzzleRestClient('https://login.salesforce.com'), + new GuzzleRestClient(self::SALESFORCE_API_ENDPOINT), $this->clientId, $this->clientSecret, $this->username, @@ -126,7 +146,6 @@ private function getOAuthRestClient(): RestClientInterface $this->accessToken ); } - return $this->oAuthRestClient; } } diff --git a/src/RestforceInterface.php b/src/RestforceInterface.php index c13b4dd..7669690 100644 --- a/src/RestforceInterface.php +++ b/src/RestforceInterface.php @@ -5,12 +5,18 @@ interface RestforceInterface { - public function userInfo(): ResponseInterface; - public function limits(): ResponseInterface; - public function query(string $soqlQuery): ResponseInterface; - public function create(string $sobjectType, array $data): ResponseInterface; - public function update(string $sobjectType, string $sobjectId, array $data): ResponseInterface; - public function describe(string $sobjectType): ResponseInterface; - public function find(string $sobjectType, string $sobjectId, array $fields = []): ResponseInterface; - public function getNext(string $url): ResponseInterface; + public function userInfo(); + public function limits(); + public function query(string $soqlQuery); + public function create(string $sobjectType, array $data); + public function update(string $sobjectType, string $sobjectId, array $data); + public function describe(string $sobjectType); + public function find(string $sobjectType, string $sobjectId, array $fields = []); + public function getNext(string $url); + public function parameterizedSearch( + string $sobjectType, + string $search, + array $fields = [], + string $whereQuery = null + ); } From 5787863ac7179f20f293e7769e5df27078fa8f00 Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Fri, 12 Oct 2018 14:43:33 +0200 Subject: [PATCH 02/38] Fix namespaces --- src/Rest/GuzzleRestClient.php | 2 +- src/Rest/OAuthAccessToken.php | 12 ++++++------ src/Rest/OAuthRestClient.php | 13 ++++++------- src/Rest/SalesforceRestClient.php | 4 ++-- src/Restforce.php | 18 +++++++++++++----- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index 88742a3..471e277 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -109,7 +109,7 @@ public function patchJson( ); } - private function containsTrailingSlash(string $baseUri): bool + private function containsTrailingSlash(string $baseUri) { return substr($baseUri, -1) === '/'; } diff --git a/src/Rest/OAuthAccessToken.php b/src/Rest/OAuthAccessToken.php index e8a6c0b..a88f80d 100644 --- a/src/Rest/OAuthAccessToken.php +++ b/src/Rest/OAuthAccessToken.php @@ -32,12 +32,12 @@ public function __construct( $this->expiresAt = $expiresAt; } - public function getTokenType(): string + public function getTokenType() { return $this->tokenType; } - public function getAccessToken(): string + public function getAccessToken() { return $this->accessToken; } @@ -47,17 +47,17 @@ public function getRefreshToken() return $this->refreshToken; } - public function getInstanceUrl(): string + public function getInstanceUrl() { return $this->instanceUrl; } - public function getHeaderString(): string + public function getHeaderString() { return $this->tokenType . ' ' . $this->accessToken; } - public function getResourceOwnerUrl(): string + public function getResourceOwnerUrl() { return $this->resourceOwnerUrl; } @@ -67,7 +67,7 @@ public function getExpiresAt() return $this->expiresAt; } - public function isExpired(): bool + public function isExpired() { if ($this->expiresAt === null) { return false; diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 4fccfac..c97f601 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -106,9 +106,8 @@ private function setParamsFromAccessToken() $this->apiRestClient->setResourceOwnerUrl($this->getOAuthAccessToken()->getResourceOwnerUrl()); } - private function getOAuthAccessToken(): OAuthAccessToken + private function getOAuthAccessToken() { - //error_log('getting token'); if ($this->oAuthAccessToken === null) { $this->oAuthAccessToken = $this->getNewToken(); } @@ -139,7 +138,7 @@ private function getAuthorizationHeader(array $headers = []) ); } - private function getClientCredentialsAccessToken(): OAuthAccessToken + private function getClientCredentialsAccessToken() { $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'client_credentials', @@ -150,7 +149,7 @@ private function getClientCredentialsAccessToken(): OAuthAccessToken return $this->getOAuthAccessTokenFromResponse($response); } - private function getPasswordAccessToken(): OAuthAccessToken + private function getPasswordAccessToken() { $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'password', @@ -163,7 +162,7 @@ private function getPasswordAccessToken(): OAuthAccessToken return $this->getOAuthAccessTokenFromResponse($response); } - private function getRefreshToken(string $refreshToken): OAuthAccessToken + private function getRefreshToken(string $refreshToken) { $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'refresh_token', @@ -180,7 +179,7 @@ private function getRefreshToken(string $refreshToken): OAuthAccessToken * @return OAuthAccessToken * @throws OAuthRestClientException */ - private function getOAuthAccessTokenFromResponse(ResponseInterface $response): OAuthAccessToken + private function getOAuthAccessTokenFromResponse(ResponseInterface $response) { if ($response->getStatusCode() !== 200) { throw OAuthRestClientException::unableToLoadAccessToken(); @@ -203,7 +202,7 @@ private function getOAuthAccessTokenFromResponse(ResponseInterface $response): O } } - private function getNewToken(): OAuthAccessToken + private function getNewToken() { if ($this->username === null && $this->password === null) { return $this->getClientCredentialsAccessToken(); diff --git a/src/Rest/SalesforceRestClient.php b/src/Rest/SalesforceRestClient.php index 7f53996..47ab8d0 100644 --- a/src/Rest/SalesforceRestClient.php +++ b/src/Rest/SalesforceRestClient.php @@ -1,7 +1,7 @@ resourceOwnerUrl; diff --git a/src/Restforce.php b/src/Restforce.php index 2934e7a..71acea5 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -28,6 +28,8 @@ class Restforce implements RestforceInterface private $apiVersion; /** @var OAuthRestClient|null */ private $oAuthRestClient; + /** @var string */ + private $apiEndpoint; public function __construct( string $clientId, @@ -35,7 +37,8 @@ public function __construct( OAuthAccessToken $accessToken = null, string $username = null, string $password = null, - string $apiVersion = null + string $apiVersion = null, + string $apiEndpoint = null ) { if ($accessToken === null && $username === null && $password === null) { throw RestforceException::minimumRequiredFieldsNotMet(); @@ -45,6 +48,11 @@ public function __construct( $apiVersion = self::DEFAULT_API_VERSION; } + if ($apiEndpoint == null) { + $apiEndpoint = self::SALESFORCE_API_ENDPOINT; + } + + $this->apiEndpoint = $apiEndpoint; $this->apiVersion = $apiVersion; $this->clientId = $clientId; $this->clientSecret = $clientSecret; @@ -102,7 +110,7 @@ public function parameterizedSearch( "sobjects" => [ [ "name" => $sobjectType, - "where" => "Open_Date__c>=2018-10-10" + "where" => $whereQuery ] ] ]); @@ -130,15 +138,15 @@ public function userInfo() return $this->getOAuthRestClient()->get(self::USER_INFO_ENDPOINT); } - private function getOAuthRestClient(): RestClientInterface + private function getOAuthRestClient() { if ($this->oAuthRestClient === null) { $this->oAuthRestClient = new OAuthRestClient( new SalesforceRestClient( - new GuzzleRestClient(self::SALESFORCE_API_ENDPOINT), + new GuzzleRestClient($this->apiEndpoint), $this->apiVersion ), - new GuzzleRestClient(self::SALESFORCE_API_ENDPOINT), + new GuzzleRestClient($this->apiEndpoint), $this->clientId, $this->clientSecret, $this->username, From 0aeac6ccf09c6a31e1c211b8333b942e5ff92fb3 Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Mon, 15 Oct 2018 12:14:21 +0200 Subject: [PATCH 03/38] Add comments --- src/Rest/GuzzleRestClient.php | 65 ++++++++++++++ src/Rest/OAuthAccessToken.php | 55 ++++++++++++ src/Rest/OAuthRestClient.php | 100 ++++++++++++++++++++- src/Rest/OAuthRestClientException.php | 10 +++ src/Rest/RestClientInterface.php | 45 ++++++++++ src/Rest/SalesforceRestClient.php | 72 +++++++++++++++ src/Rest/SalesforceRestClientInterface.php | 60 +++++++++++++ src/Restforce.php | 88 ++++++++++++++++++ src/RestforceException.php | 17 ++++ src/RestforceInterface.php | 80 +++++++++++++++++ 10 files changed, 591 insertions(+), 1 deletion(-) diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index 471e277..04f44fc 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -1,8 +1,14 @@ setBaseUriForRestClient($baseUri); } + /** + * Set base uri for client + * + * @param string $baseUri base uri + * + * @return void + */ public function setBaseUriForRestClient(string $baseUri) { if (!$this->containsTrailingSlash($baseUri)) { @@ -34,6 +52,16 @@ public function setBaseUriForRestClient(string $baseUri) $this->client = new \GuzzleHttp\Client($config); } + /** + * Get method + * + * @param string $path path + * @param array $queryParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function get( string $path, array $queryParameters = [], @@ -52,6 +80,16 @@ public function get( ); } + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function post( string $path, array $formParameters = [], @@ -70,6 +108,16 @@ public function post( ); } + /** + * Post method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function postJson( string $path, array $jsonArray = [], @@ -89,6 +137,16 @@ public function postJson( ); } + /** + * Patch method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function patchJson( string $path, array $jsonArray = [], @@ -109,6 +167,13 @@ public function patchJson( ); } + /** + * Check if contains trailing slash + * + * @param string $baseUri base uri + * + * @return bool + */ private function containsTrailingSlash(string $baseUri) { return substr($baseUri, -1) === '/'; diff --git a/src/Rest/OAuthAccessToken.php b/src/Rest/OAuthAccessToken.php index a88f80d..2917e19 100644 --- a/src/Rest/OAuthAccessToken.php +++ b/src/Rest/OAuthAccessToken.php @@ -1,6 +1,11 @@ expiresAt = $expiresAt; } + /** + * Get token type + * + * @return string + */ public function getTokenType() { return $this->tokenType; } + /** + * Get access token + * + * @return string + */ public function getAccessToken() { return $this->accessToken; } + /** + * Get refresh token + * + * @return null|string + */ public function getRefreshToken() { return $this->refreshToken; } + /** + * Get instance url + * + * @return string + */ public function getInstanceUrl() { return $this->instanceUrl; } + /** + * Get header string + * + * @return string + */ public function getHeaderString() { return $this->tokenType . ' ' . $this->accessToken; } + /** + * Get resource owner url + * + * @return string + */ public function getResourceOwnerUrl() { return $this->resourceOwnerUrl; } + /** + * Get expires at value + * + * @return int|null + */ public function getExpiresAt() { return $this->expiresAt; } + /** + * Check if expired + * + * @return bool + */ public function isExpired() { if ($this->expiresAt === null) { diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index c97f601..2db0b7a 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -4,6 +4,11 @@ use Psr\Http\Message\ResponseInterface; use Throwable; +/** + * Class OAuthRestClient + * + * @package EventFarm\Restforce\Rest + */ final class OAuthRestClient implements RestClientInterface { const TOKEN_TYPE = 'Bearer'; @@ -22,6 +27,17 @@ final class OAuthRestClient implements RestClientInterface /** @var null|string */ private $password; + /** + * OAuthRestClient constructor. + * + * @param SalesforceRestClientInterface $apiRestClient api rest client + * @param RestClientInterface $authRestClient auth rest client + * @param string $clientId client id + * @param string $clientSecret client secret + * @param string|null $username username + * @param string|null $password password + * @param OAuthAccessToken|null $oAuthAccessToken access token + */ public function __construct( SalesforceRestClientInterface $apiRestClient, RestClientInterface $authRestClient, @@ -40,6 +56,16 @@ public function __construct( $this->password = $password; } + /** + * Get method + * + * @param string $path path + * @param array $queryParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function get( string $path, array $queryParameters = [], @@ -55,6 +81,16 @@ public function get( ); } + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function post( string $path, array $formParameters = [], @@ -70,6 +106,16 @@ public function post( ); } + /** + * Post method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function postJson( string $path, array $jsonArray = [], @@ -85,6 +131,16 @@ public function postJson( ); } + /** + * Patch method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function patchJson( string $path, array $jsonArray = [], @@ -100,12 +156,22 @@ public function patchJson( ); } + /** + * Set params from access token + * + * @return void + */ private function setParamsFromAccessToken() { $this->apiRestClient->setBaseUriForRestClient($this->getOAuthAccessToken()->getInstanceUrl()); $this->apiRestClient->setResourceOwnerUrl($this->getOAuthAccessToken()->getResourceOwnerUrl()); } + /** + * Get OAuth access token + * + * @return OAuthAccessToken + */ private function getOAuthAccessToken() { if ($this->oAuthAccessToken === null) { @@ -128,6 +194,13 @@ private function getOAuthAccessToken() return $this->oAuthAccessToken; } + /** + * Get authorization header + * + * @param array $headers headers + * + * @return array + */ private function getAuthorizationHeader(array $headers = []) { return array_merge( @@ -138,6 +211,11 @@ private function getAuthorizationHeader(array $headers = []) ); } + /** + * Get client credentials access token + * + * @return OAuthAccessToken + */ private function getClientCredentialsAccessToken() { $response = $this->authRestClient->post('/services/oauth2/token', [ @@ -149,6 +227,11 @@ private function getClientCredentialsAccessToken() return $this->getOAuthAccessTokenFromResponse($response); } + /** + * Get password access token + * + * @return OAuthAccessToken + */ private function getPasswordAccessToken() { $response = $this->authRestClient->post('/services/oauth2/token', [ @@ -162,6 +245,13 @@ private function getPasswordAccessToken() return $this->getOAuthAccessTokenFromResponse($response); } + /** + * Get refresh token + * + * @param string $refreshToken refresh token + * + * @return OAuthAccessToken + */ private function getRefreshToken(string $refreshToken) { $response = $this->authRestClient->post('/services/oauth2/token', [ @@ -175,7 +265,10 @@ private function getRefreshToken(string $refreshToken) } /** - * @param ResponseInterface $response + * Get OAuth access token from response + * + * @param ResponseInterface $response response + * * @return OAuthAccessToken * @throws OAuthRestClientException */ @@ -202,6 +295,11 @@ private function getOAuthAccessTokenFromResponse(ResponseInterface $response) } } + /** + * Get new token + * + * @return OAuthAccessToken + */ private function getNewToken() { if ($this->username === null && $this->password === null) { diff --git a/src/Rest/OAuthRestClientException.php b/src/Rest/OAuthRestClientException.php index a535690..9114177 100644 --- a/src/Rest/OAuthRestClientException.php +++ b/src/Rest/OAuthRestClientException.php @@ -3,8 +3,18 @@ use Exception; +/** + * Class OAuthRestClientException + * + * @package EventFarm\Restforce\Rest + */ class OAuthRestClientException extends Exception { + /** + * Triggered when access token can't be loaded + * + * @return OAuthRestClientException + */ public static function unableToLoadAccessToken() { return new self('Unable to load access token'); diff --git a/src/Rest/RestClientInterface.php b/src/Rest/RestClientInterface.php index 2c98baa..3d3d8f8 100644 --- a/src/Rest/RestClientInterface.php +++ b/src/Rest/RestClientInterface.php @@ -3,8 +3,23 @@ use Psr\Http\Message\ResponseInterface; +/** + * Interface RestClientInterface + * + * @package EventFarm\Restforce\Rest + */ interface RestClientInterface { + /** + * Get method + * + * @param string $path path + * @param array $queryParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function get( string $path, array $queryParameters = [], @@ -12,6 +27,16 @@ public function get( float $timeoutSeconds = null ); + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function post( string $path, array $formParameters = [], @@ -19,6 +44,16 @@ public function post( float $timeoutSeconds = null ); + /** + * Post method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function postJson( string $path, array $jsonArray = [], @@ -26,6 +61,16 @@ public function postJson( float $timeoutSeconds = null ); + /** + * Patch method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function patchJson( string $path, array $jsonArray = [], diff --git a/src/Rest/SalesforceRestClient.php b/src/Rest/SalesforceRestClient.php index 47ab8d0..ae6bdc7 100644 --- a/src/Rest/SalesforceRestClient.php +++ b/src/Rest/SalesforceRestClient.php @@ -4,6 +4,11 @@ use EventFarm\Restforce\Restforce; use Psr\Http\Message\ResponseInterface; +/** + * Class SalesforceRestClient + * + * @package EventFarm\Restforce\Rest + */ class SalesforceRestClient implements SalesforceRestClientInterface { /** @var GuzzleRestClient */ @@ -13,22 +18,52 @@ class SalesforceRestClient implements SalesforceRestClientInterface /** @var string */ private $resourceOwnerUrl; + /** + * SalesforceRestClient constructor. + * + * @param GuzzleRestClient $restClient rest client + * @param string $apiVersion api version + */ public function __construct(GuzzleRestClient $restClient, string $apiVersion) { $this->restClient = $restClient; $this->apiVersion = $apiVersion; } + /** + * Set resource owner url + * + * @param string $resourceOwnerUrl resource owner url + * + * @return void + */ public function setResourceOwnerUrl(string $resourceOwnerUrl) { $this->resourceOwnerUrl = $resourceOwnerUrl; } + /** + * Set base uri for rest client + * + * @param string $baseUri base uri + * + * @return void + */ public function setBaseUriForRestClient(string $baseUri) { $this->restClient->setBaseUriForRestClient($baseUri); } + /** + * Get method + * + * @param string $path path + * @param array $queryParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function get( string $path, array $queryParameters = [], @@ -43,6 +78,16 @@ public function get( ); } + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function post( string $path, array $formParameters = [], @@ -57,6 +102,16 @@ public function post( ); } + /** + * Post method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function postJson( string $path, array $jsonArray = [], @@ -71,6 +126,16 @@ public function postJson( ); } + /** + * Patch method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function patchJson( string $path, array $jsonArray = [], @@ -85,6 +150,13 @@ public function patchJson( ); } + /** + * Construct url for salesforce + * + * @param string $endpoint endpoint + * + * @return bool|string + */ private function constructUrl(string $endpoint) { if ($endpoint === Restforce::USER_INFO_ENDPOINT) { diff --git a/src/Rest/SalesforceRestClientInterface.php b/src/Rest/SalesforceRestClientInterface.php index 18f5b91..7baffcd 100644 --- a/src/Rest/SalesforceRestClientInterface.php +++ b/src/Rest/SalesforceRestClientInterface.php @@ -3,11 +3,41 @@ use Psr\Http\Message\ResponseInterface; +/** + * Interface SalesforceRestClientInterface + * + * @package EventFarm\Restforce\Rest + */ interface SalesforceRestClientInterface extends RestClientInterface { + /** + * Set resource owner url + * + * @param string $resourceOwnerUrl resource owner url + * + * @return mixed + */ public function setResourceOwnerUrl(string $resourceOwnerUrl); + + /** + * Set base uri for rest client + * + * @param string $baseUri base uri + * + * @return mixed + */ public function setBaseUriForRestClient(string $baseUri); + /** + * Get method + * + * @param string $path path + * @param array $queryParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function get( string $path, array $queryParameters = [], @@ -15,6 +45,16 @@ public function get( float $timeoutSeconds = null ); + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function post( string $path, array $formParameters = [], @@ -22,6 +62,16 @@ public function post( float $timeoutSeconds = null ); + /** + * Post method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function postJson( string $path, array $jsonArray = [], @@ -29,6 +79,16 @@ public function postJson( float $timeoutSeconds = null ); + /** + * Patch method JSON formatted + * + * @param string $path path + * @param array $jsonArray parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ public function patchJson( string $path, array $jsonArray = [], diff --git a/src/Restforce.php b/src/Restforce.php index 71acea5..f0923b5 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -8,6 +8,11 @@ use EventFarm\Restforce\Rest\SalesforceRestClient; use Psr\Http\Message\ResponseInterface; +/** + * Class Restforce + * + * @package EventFarm\Restforce + */ class Restforce implements RestforceInterface { const USER_INFO_ENDPOINT = 'RESOURCE_OWNER'; @@ -31,6 +36,17 @@ class Restforce implements RestforceInterface /** @var string */ private $apiEndpoint; + /** + * Restforce constructor. + * + * @param string $clientId client id + * @param string $clientSecret client secret + * @param OAuthAccessToken|null $accessToken access token + * @param string|null $username username + * @param string|null $password password + * @param string|null $apiVersion api version + * @param string|null $apiEndpoint api endpoint + */ public function __construct( string $clientId, string $clientSecret, @@ -61,6 +77,14 @@ public function __construct( $this->password = $password; } + /** + * Create method + * + * @param string $sobjectType object type + * @param array $data data + * + * @return mixed + */ public function create(string $sobjectType, array $data) { $uri = 'sobjects/' . $sobjectType; @@ -68,6 +92,15 @@ public function create(string $sobjectType, array $data) return $this->getOAuthRestClient()->postJson($uri, $data); } + /** + * Update method + * + * @param string $sobjectType object type + * @param string $sobjectId object id + * @param array $data data + * + * @return mixed + */ public function update(string $sobjectType, string $sobjectId, array $data) { $uri = 'sobjects/' . $sobjectType . '/' . $sobjectId; @@ -75,6 +108,13 @@ public function update(string $sobjectType, string $sobjectId, array $data) return $this->getOAuthRestClient()->patchJson($uri, $data); } + /** + * Describe method + * + * @param string $sobject object + * + * @return mixed + */ public function describe(string $sobject) { $uri = 'sobjects/' . $sobject . '/describe'; @@ -82,6 +122,15 @@ public function describe(string $sobject) return $this->getOAuthRestClient()->get($uri); } + /** + * Find method + * + * @param string $sobjectType object type + * @param string $sobjectId object id + * @param array $fields fields + * + * @return mixed + */ public function find(string $sobjectType, string $sobjectId, array $fields = []) { $uri = 'sobjects/' . $sobjectType . '/' . $sobjectId; @@ -96,6 +145,16 @@ public function find(string $sobjectType, string $sobjectId, array $fields = []) return $this->getOAuthRestClient()->get($uri, $queryParams); } + /** + * Parameterized search method + * + * @param string $sobjectType object type + * @param string $search search query + * @param array $fields fields + * @param string|null $whereQuery where query + * + * @return mixed + */ public function parameterizedSearch( string $sobjectType, string $search, @@ -116,16 +175,35 @@ public function parameterizedSearch( ]); } + /** + * Limits method + * + * @return mixed + */ public function limits() { return $this->getOAuthRestClient()->get('/limits'); } + /** + * GetNext method + * + * @param string $url url + * + * @return mixed + */ public function getNext(string $url) { return $this->getOAuthRestClient()->get($url); } + /** + * Query method + * + * @param string $queryString query string + * + * @return mixed + */ public function query(string $queryString) { return $this->getOAuthRestClient()->get('query', [ @@ -133,11 +211,21 @@ public function query(string $queryString) ]); } + /** + * UserInfo method + * + * @return mixed + */ public function userInfo() { return $this->getOAuthRestClient()->get(self::USER_INFO_ENDPOINT); } + /** + * Get OAuth rest client + * + * @return OAuthRestClient|null + */ private function getOAuthRestClient() { if ($this->oAuthRestClient === null) { diff --git a/src/RestforceException.php b/src/RestforceException.php index f866c8d..cf52522 100644 --- a/src/RestforceException.php +++ b/src/RestforceException.php @@ -3,13 +3,30 @@ use Throwable; +/** + * Class RestforceException + * + * @package EventFarm\Restforce + */ class RestforceException extends \Exception { + /** + * RestforceException constructor. + * + * @param string $message message + * @param int $code error code + * @param Throwable|null $previous previous + */ public function __construct(string $message, int $code = 500, Throwable $previous = null) { parent::__construct($message, $code, $previous); } + /** + * Triggered when missing required fields + * + * @return RestforceException + */ public static function minimumRequiredFieldsNotMet() { return new self('Restforce needs either an OAuthToken or User/PW combo to start authenticate'); diff --git a/src/RestforceInterface.php b/src/RestforceInterface.php index 7669690..5cd7ce1 100644 --- a/src/RestforceInterface.php +++ b/src/RestforceInterface.php @@ -3,16 +3,96 @@ use Psr\Http\Message\ResponseInterface; +/** + * Interface RestforceInterface + * + * @package EventFarm\Restforce + */ interface RestforceInterface { + /** + * UserInfo method + * + * @return mixed + */ public function userInfo(); + + /** + * Limits method + * + * @return mixed + */ public function limits(); + + /** + * Query method + * + * @param string $soqlQuery query + * + * @return mixed + */ public function query(string $soqlQuery); + + /** + * Create method + * + * @param string $sobjectType object type + * @param array $data data + * + * @return mixed + */ public function create(string $sobjectType, array $data); + + /** + * Update method + * + * @param string $sobjectType object type + * @param string $sobjectId object id + * @param array $data data + * + * @return mixed + */ public function update(string $sobjectType, string $sobjectId, array $data); + + /** + * Describe method + * + * @param string $sobjectType object type + * + * @return mixed + */ public function describe(string $sobjectType); + + /** + * Find method + * + * @param string $sobjectType object type + * @param string $sobjectId object id + * @param array $fields fields + * + * @return mixed + */ public function find(string $sobjectType, string $sobjectId, array $fields = []); + + /** + * GetNext method + * + * @param string $url url + * + * @return mixed + */ public function getNext(string $url); + + /** + * ParameterizedSearch method + * + * @param string $sobjectType object type + * @param string $search search query + * @param array $fields fields + * @param string|null $whereQuery where query + * + * @return mixed + */ public function parameterizedSearch( string $sobjectType, string $search, From de59412425072faf12442ee9ebc545748a0e6dae Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Mon, 15 Oct 2018 16:13:42 +0200 Subject: [PATCH 04/38] Remove overriding of http_errors --- src/Rest/GuzzleRestClient.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index 04f44fc..104c1df 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -74,8 +74,7 @@ public function get( [ 'timeout' => $timeoutSeconds, 'headers' => $headers, - 'query' => $queryParameters, - 'http_errors' => false, + 'query' => $queryParameters ] ); } @@ -102,8 +101,7 @@ public function post( [ 'timeout' => $timeoutSeconds, 'headers' => $headers, - 'form_params' => $formParameters, - 'http_errors' => false, + 'form_params' => $formParameters ] ); } @@ -131,8 +129,7 @@ public function postJson( [ 'timeout' => $timeoutSeconds, 'headers' => $headers, - 'json' => $jsonArray, - 'http_errors' => false, + 'json' => $jsonArray ] ); } @@ -161,8 +158,7 @@ public function patchJson( [ 'timeout' => $timeoutSeconds, 'headers' => $headers, - 'json' => $jsonArray, - 'http_errors' => false, + 'json' => $jsonArray ] ); } From 97c36a256ca1455c63fbec83f849d424bcf012cf Mon Sep 17 00:00:00 2001 From: Matthieu Ventura Date: Thu, 25 Oct 2018 13:57:22 +0200 Subject: [PATCH 05/38] Update OAuthRestClient.php --- src/Rest/OAuthRestClient.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 2db0b7a..0f2a440 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -218,6 +218,12 @@ private function getAuthorizationHeader(array $headers = []) */ private function getClientCredentialsAccessToken() { + error_log(print_r([ + 'grant_type' => 'client_credentials', + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, + ], true)); + $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'client_credentials', 'client_id' => $this->clientId, @@ -234,6 +240,15 @@ private function getClientCredentialsAccessToken() */ private function getPasswordAccessToken() { + + error_log(print_r([ + 'grant_type' => 'password', + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, + 'username' => $this->username, + 'password' => $this->password + ], true)); + $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'password', 'client_id' => $this->clientId, From 122829c4d8d9a135b7706bff98cc9923e842c505 Mon Sep 17 00:00:00 2001 From: mventura Date: Thu, 8 Nov 2018 10:31:53 +0100 Subject: [PATCH 06/38] Remove logs --- src/Rest/OAuthRestClient.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 0f2a440..2db0b7a 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -218,12 +218,6 @@ private function getAuthorizationHeader(array $headers = []) */ private function getClientCredentialsAccessToken() { - error_log(print_r([ - 'grant_type' => 'client_credentials', - 'client_id' => $this->clientId, - 'client_secret' => $this->clientSecret, - ], true)); - $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'client_credentials', 'client_id' => $this->clientId, @@ -240,15 +234,6 @@ private function getClientCredentialsAccessToken() */ private function getPasswordAccessToken() { - - error_log(print_r([ - 'grant_type' => 'password', - 'client_id' => $this->clientId, - 'client_secret' => $this->clientSecret, - 'username' => $this->username, - 'password' => $this->password - ], true)); - $response = $this->authRestClient->post('/services/oauth2/token', [ 'grant_type' => 'password', 'client_id' => $this->clientId, From c31a8ba085e1d68c011c859a852804e25a3054fa Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Mon, 29 Jul 2019 15:24:08 +0200 Subject: [PATCH 07/38] Update Restforce - Add bulk support --- src/Rest/GuzzleRestClient.php | 36 +++++- src/Rest/OAuthRestClient.php | 26 +++++ src/Rest/RestClientInterface.php | 19 ++- src/Rest/SalesforceRestClient.php | 30 +++++ src/Rest/SalesforceRestClientInterface.php | 17 +++ src/Restforce.php | 127 +++++++++++++++++++-- 6 files changed, 244 insertions(+), 11 deletions(-) diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index 104c1df..f8aa9e4 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -2,8 +2,6 @@ namespace EventFarm\Restforce\Rest; -use Psr\Http\Message\ResponseInterface; - /** * Class GuzzleRestClient * @@ -61,6 +59,7 @@ public function setBaseUriForRestClient(string $baseUri) * @param float|null $timeoutSeconds timeout * * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException */ public function get( string $path, @@ -88,6 +87,7 @@ public function get( * @param float|null $timeoutSeconds timeout * * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException */ public function post( string $path, @@ -115,6 +115,7 @@ public function post( * @param float|null $timeoutSeconds timeout * * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException */ public function postJson( string $path, @@ -143,6 +144,7 @@ public function postJson( * @param float|null $timeoutSeconds timeout * * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException */ public function patchJson( string $path, @@ -163,6 +165,36 @@ public function patchJson( ); } + /** + * Put method CSV formatted + * + * @param string $path path + * @param string $filePath file path + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function putCsv( + string $path, + string $filePath, + array $headers = [], + float $timeoutSeconds = null + ) { + $headers['Content-Type'] = 'text/csv'; + + return $this->client->request( + 'PUT', + $path, + [ + 'timeout' => $timeoutSeconds, + 'headers' => $headers, + 'body' => fopen($filePath, 'r') + ] + ); + } + /** * Check if contains trailing slash * diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 2db0b7a..8cc8040 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -156,6 +156,32 @@ public function patchJson( ); } + /** + * Put method CSV formatted + * + * @param string $path path + * @param string $filePath file path + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ + public function putCsv( + string $path, + string $filePath, + array $headers = [], + float $timeoutSeconds = null + ) + { + $this->setParamsFromAccessToken(); + return $this->apiRestClient->putCsv( + $path, + $filePath, + $this->getAuthorizationHeader($headers), + $timeoutSeconds + ); + } + /** * Set params from access token * diff --git a/src/Rest/RestClientInterface.php b/src/Rest/RestClientInterface.php index 3d3d8f8..7d87426 100644 --- a/src/Rest/RestClientInterface.php +++ b/src/Rest/RestClientInterface.php @@ -1,8 +1,6 @@ restClient->putCsv( + $this->constructUrl($path), + $filePath, + $headers, + $timeoutSeconds + ); + } + /** * Construct url for salesforce * diff --git a/src/Rest/SalesforceRestClientInterface.php b/src/Rest/SalesforceRestClientInterface.php index 7baffcd..9c289c3 100644 --- a/src/Rest/SalesforceRestClientInterface.php +++ b/src/Rest/SalesforceRestClientInterface.php @@ -95,4 +95,21 @@ public function patchJson( array $headers = [], float $timeoutSeconds = null ); + + /** + * Put method CSV formatted + * + * @param string $path path + * @param string $filePath file path + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ + public function putCsv( + string $path, + string $filePath, + array $headers = [], + float $timeoutSeconds = null + ); } diff --git a/src/Restforce.php b/src/Restforce.php index f0923b5..86fe201 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -1,12 +1,11 @@ getOAuthRestClient()->postJson($uri, $data); } + /** + * Create bulk job + * + * @param string $object object to work with + * @param string $operation operation + * + * @return string + * @throws Exception + */ + public function createJob(string $object, string $operation) + { + $uri = 'jobs/ingest'; + + $job = $this->getOAuthRestClient()->postJson($uri, [ + 'operation' => $operation, + 'object' => $object, + 'contentType' => 'CSV' + ]); + + $jobResponse = json_decode($job->getBody()); + + if (!$jobResponse->id) { + throw new Exception( + 'An error occurred while creating bulk job of type ' . $operation . ' on object ' . $object + ); + } + + fopen($jobResponse->id . self::CSV_EXTENSION, self::FILE_WRITE); + + return $jobResponse->id; + } + + /** + * Add batch to bulk job + * + * @param string $jobId job id + * @param array $dataHash data hash + * @param bool $newFile is it a new file? + * + * @return void + * @throws Exception + */ + public function addBatchToJob(string $jobId, array $dataHash, bool $newFile = false) + { + $filePath = $jobId . self::CSV_EXTENSION; + + if (!file_exists($filePath)) { + throw new Exception('File ' . $filePath . ' has not been found. Cannot add batch to job ' . $jobId); + } + + $fp = fopen($filePath, self::FILE_APPEND); + + // Add fields as the first line only once + if ($newFile) { + $lines[] = array_keys($dataHash); + } + + $lines[] = array_values($dataHash); + foreach ($lines as $line) { + fputcsv($fp, $line); + } + fclose($fp); + } + + /** + * Execute bulk job + * + * @param string $jobId job id + * + * @return mixed + */ + public function executeJob(string $jobId) + { + $uri = 'jobs/ingest/' . $jobId . '/batches'; + return $this->getOAuthRestClient()->putCsv($uri, $jobId . self::CSV_EXTENSION); + } + + /** + * Check bulk job status + * + * @param string $jobId job id + * + * @return mixed + */ + public function checkJob(string $jobId) + { + $uri = 'jobs/ingest/' . $jobId; + return $this->getOAuthRestClient()->get($uri); + } + + /** + * Close bulk job + * + * @param string $jobId job id + * + * @return void + */ + public function closeJob(string $jobId) + { + $uri = 'jobs/ingest/' . $jobId; + + $this->getOAuthRestClient()->patchJson($uri, [ + 'state' => 'UploadComplete' + ]); + + unlink($jobId . self::CSV_EXTENSION); + } + /** * Update method * From d85e0193289b23f784e06174f52e79b6887f66e0 Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Tue, 30 Jul 2019 16:31:58 +0200 Subject: [PATCH 08/38] Add const Update operation --- src/Restforce.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Restforce.php b/src/Restforce.php index 86fe201..90d931e 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -21,6 +21,7 @@ class Restforce implements RestforceInterface const FILE_APPEND = 'a'; const FILE_READONLY = 'r'; const FILE_WRITE = 'w'; + const BULK_JOB_OPERATION_UPDATE = 'update'; /** @var string */ private $clientId; From 96caf5d8e0f8e60dc2ab45a22cecd2a1a1677544 Mon Sep 17 00:00:00 2001 From: tpellegatta Date: Tue, 13 Aug 2019 18:21:10 +0200 Subject: [PATCH 09/38] SF - Optimization bulks --- src/Restforce.php | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Restforce.php b/src/Restforce.php index 90d931e..2decef6 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -5,7 +5,6 @@ use \EventFarm\Restforce\Rest\OAuthAccessToken; use \EventFarm\Restforce\Rest\OAuthRestClient; use \EventFarm\Restforce\Rest\SalesforceRestClient; -use \Vpg\Exception; /** * Class Restforce @@ -101,14 +100,20 @@ public function create(string $sobjectType, array $data) /** * Create bulk job * - * @param string $object object to work with - * @param string $operation operation + * @param string $object object to work with + * @param string $operation operation + * @param array $headerColumnList column names for header * * @return string - * @throws Exception + * @throws \Exception */ - public function createJob(string $object, string $operation) + public function createJob(string $object, string $operation, $headerColumnList) { + if (empty($headerColumnList)) { + throw new \Exception( + 'header columns are missing on csv file for operation ' . $operation . ' on object ' . $object + ); + } $uri = 'jobs/ingest'; $job = $this->getOAuthRestClient()->postJson($uri, [ @@ -120,45 +125,38 @@ public function createJob(string $object, string $operation) $jobResponse = json_decode($job->getBody()); if (!$jobResponse->id) { - throw new Exception( + throw new \Exception( 'An error occurred while creating bulk job of type ' . $operation . ' on object ' . $object ); } - fopen($jobResponse->id . self::CSV_EXTENSION, self::FILE_WRITE); + $fp = fopen($jobResponse->id . self::CSV_EXTENSION, self::FILE_WRITE); + fputcsv($fp, $headerColumnList); + fclose($fp); return $jobResponse->id; } /** - * Add batch to bulk job + * Add record to bulk job (csv file) * * @param string $jobId job id * @param array $dataHash data hash - * @param bool $newFile is it a new file? * * @return void - * @throws Exception + * @throws \Exception */ - public function addBatchToJob(string $jobId, array $dataHash, bool $newFile = false) + public function addRecordLineToJob(string $jobId, array $dataHash) { $filePath = $jobId . self::CSV_EXTENSION; if (!file_exists($filePath)) { - throw new Exception('File ' . $filePath . ' has not been found. Cannot add batch to job ' . $jobId); + throw new \Exception('File ' . $filePath . ' has not been found. Cannot add batch to job ' . $jobId); } $fp = fopen($filePath, self::FILE_APPEND); + fputcsv($fp, array_values($dataHash)); - // Add fields as the first line only once - if ($newFile) { - $lines[] = array_keys($dataHash); - } - - $lines[] = array_values($dataHash); - foreach ($lines as $line) { - fputcsv($fp, $line); - } fclose($fp); } From 8f73a2e1c5220cb048454f148c512d271d2ee2e7 Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 14 Feb 2020 14:49:31 +0100 Subject: [PATCH 10/38] refs #85488 - add create event on SF --- src/Restforce.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Restforce.php b/src/Restforce.php index 2decef6..a41f37b 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -21,6 +21,7 @@ class Restforce implements RestforceInterface const FILE_READONLY = 'r'; const FILE_WRITE = 'w'; const BULK_JOB_OPERATION_UPDATE = 'update'; + const BULK_JOB_OPERATION_CREATE = 'create'; /** @var string */ private $clientId; From 6dd2f9d9b836e0679db8bc54cb2ea5434e9ce17e Mon Sep 17 00:00:00 2001 From: Boris Date: Fri, 21 Feb 2020 10:33:09 +0100 Subject: [PATCH 11/38] refs #85488 - sf operation is insert not create --- src/Restforce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Restforce.php b/src/Restforce.php index a41f37b..52061d4 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -21,7 +21,7 @@ class Restforce implements RestforceInterface const FILE_READONLY = 'r'; const FILE_WRITE = 'w'; const BULK_JOB_OPERATION_UPDATE = 'update'; - const BULK_JOB_OPERATION_CREATE = 'create'; + const BULK_JOB_OPERATION_INSERT = 'insert'; /** @var string */ private $clientId; From 2ccf8392a3abb11b7a052d7614b758a0db9ad6f8 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Thu, 12 Aug 2021 10:34:29 +0200 Subject: [PATCH 12/38] add types to restforce api --- src/Types/Account.php | 33 +++++++++++++++++++++++++++++++++ src/Types/City.php | 25 +++++++++++++++++++++++++ src/Types/Country.php | 25 +++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 src/Types/Account.php create mode 100644 src/Types/City.php create mode 100644 src/Types/Country.php diff --git a/src/Types/Account.php b/src/Types/Account.php new file mode 100644 index 0000000..3b21655 --- /dev/null +++ b/src/Types/Account.php @@ -0,0 +1,33 @@ + + */ +class Account +{ + const SF_OBJECT = 'Account'; + + const SF_ACCOUNT_ID = 'Id'; + const SF_ACCOUNT_NAME = 'Name'; + const SF_ACCOUNT_COUNTRY = 'Account_Country__c'; + const SF_ACCOUNT_CITY = 'Account_City__c'; + const SF_ACCOUNT_STREET = 'Account_Street__c'; + const SF_ACCOUNT_ZIPCODE = 'Account_Zip_Postal_code__c'; + + /** + * Query fields available in SF for an Account + */ + const SF_FIELD_LIST = [ + self::SF_ACCOUNT_ID, + self::SF_ACCOUNT_NAME, + self::SF_ACCOUNT_COUNTRY, + self::SF_ACCOUNT_CITY, + self::SF_ACCOUNT_STREET, + self::SF_ACCOUNT_ZIPCODE + ]; +} \ No newline at end of file diff --git a/src/Types/City.php b/src/Types/City.php new file mode 100644 index 0000000..436595f --- /dev/null +++ b/src/Types/City.php @@ -0,0 +1,25 @@ + + */ +class City +{ + const SF_OBJECT = 'City__c'; + + const SF_ACCOUNT_ID = 'Id'; + const SF_ACCOUNT_NAME = 'Name'; + + /** + * Query fields available in SF for a City + */ + const SF_FIELD_LIST = [ + self::SF_ACCOUNT_ID, + self::SF_ACCOUNT_NAME, + ]; +} \ No newline at end of file diff --git a/src/Types/Country.php b/src/Types/Country.php new file mode 100644 index 0000000..4260a50 --- /dev/null +++ b/src/Types/Country.php @@ -0,0 +1,25 @@ + + */ +class Country +{ + const SF_OBJECT = 'Country__c'; + + const SF_ACCOUNT_ID = 'Id'; + const SF_ACCOUNT_NAME = 'Name'; + + /** + * Query fields available in SF for a City + */ + const SF_FIELD_LIST = [ + self::SF_ACCOUNT_ID, + self::SF_ACCOUNT_NAME, + ]; +} \ No newline at end of file From 7bfdbfe60b32f6077b998fdd44423946d83f6b3d Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 16 Aug 2021 17:09:14 +0200 Subject: [PATCH 13/38] update lib files --- src/Types/Account.php | 24 ++++++++++++------------ src/Types/City.php | 8 ++++---- src/Types/Country.php | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Types/Account.php b/src/Types/Account.php index 3b21655..37b508f 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -12,22 +12,22 @@ class Account { const SF_OBJECT = 'Account'; - const SF_ACCOUNT_ID = 'Id'; - const SF_ACCOUNT_NAME = 'Name'; - const SF_ACCOUNT_COUNTRY = 'Account_Country__c'; - const SF_ACCOUNT_CITY = 'Account_City__c'; - const SF_ACCOUNT_STREET = 'Account_Street__c'; - const SF_ACCOUNT_ZIPCODE = 'Account_Zip_Postal_code__c'; + const SF_ID = 'Id'; + const SF_NAME = 'Name'; + const SF_COUNTRY = 'Account_Country__c'; + const SF_CITY = 'Account_City__c'; + const SF_STREET = 'Account_Street__c'; + const SF_ZIPCODE = 'Account_Zip_Postal_code__c'; /** * Query fields available in SF for an Account */ const SF_FIELD_LIST = [ - self::SF_ACCOUNT_ID, - self::SF_ACCOUNT_NAME, - self::SF_ACCOUNT_COUNTRY, - self::SF_ACCOUNT_CITY, - self::SF_ACCOUNT_STREET, - self::SF_ACCOUNT_ZIPCODE + self::SF_ID, + self::SF_NAME, + self::SF_COUNTRY, + self::SF_CITY, + self::SF_STREET, + self::SF_ZIPCODE ]; } \ No newline at end of file diff --git a/src/Types/City.php b/src/Types/City.php index 436595f..cc8c072 100644 --- a/src/Types/City.php +++ b/src/Types/City.php @@ -12,14 +12,14 @@ class City { const SF_OBJECT = 'City__c'; - const SF_ACCOUNT_ID = 'Id'; - const SF_ACCOUNT_NAME = 'Name'; + const SF_ID = 'Id'; + const SF_NAME = 'Name'; /** * Query fields available in SF for a City */ const SF_FIELD_LIST = [ - self::SF_ACCOUNT_ID, - self::SF_ACCOUNT_NAME, + self::SF_ID, + self::SF_NAME, ]; } \ No newline at end of file diff --git a/src/Types/Country.php b/src/Types/Country.php index 4260a50..395806b 100644 --- a/src/Types/Country.php +++ b/src/Types/Country.php @@ -12,14 +12,14 @@ class Country { const SF_OBJECT = 'Country__c'; - const SF_ACCOUNT_ID = 'Id'; - const SF_ACCOUNT_NAME = 'Name'; + const SF_ID = 'Id'; + const SF_NAME = 'Name'; /** * Query fields available in SF for a City */ const SF_FIELD_LIST = [ - self::SF_ACCOUNT_ID, - self::SF_ACCOUNT_NAME, + self::SF_ID, + self::SF_NAME, ]; } \ No newline at end of file From 6fc75e29257720b310fd62c74bc0e7a4b33e4d90 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Wed, 1 Sep 2021 16:18:43 +0200 Subject: [PATCH 14/38] update account property --- src/Types/Account.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Types/Account.php b/src/Types/Account.php index 37b508f..a7f2fe2 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -18,6 +18,9 @@ class Account const SF_CITY = 'Account_City__c'; const SF_STREET = 'Account_Street__c'; const SF_ZIPCODE = 'Account_Zip_Postal_code__c'; + const SF_STATUS = 'Global_Account_Status'; + + const SF_ACTIVE_STATUS = 'Active Account'; /** * Query fields available in SF for an Account From 85a07e8f5cdfea1e371039b2f189b83f0e6abff9 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Wed, 8 Sep 2021 09:31:17 +0200 Subject: [PATCH 15/38] update status --- src/Types/Account.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Types/Account.php b/src/Types/Account.php index a7f2fe2..caff0c9 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -21,6 +21,7 @@ class Account const SF_STATUS = 'Global_Account_Status'; const SF_ACTIVE_STATUS = 'Active Account'; + const SF_INACTIVE_STATUS = 'Inactive Account'; /** * Query fields available in SF for an Account From 4b2d3e58e819aaf6ef11cb34a02fa33a67f57fd0 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 27 Sep 2021 10:02:05 +0200 Subject: [PATCH 16/38] update SF dictionnary --- src/Types/City.php | 2 ++ src/Types/Product.php | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/Types/Product.php diff --git a/src/Types/City.php b/src/Types/City.php index cc8c072..d2ccc1d 100644 --- a/src/Types/City.php +++ b/src/Types/City.php @@ -14,6 +14,7 @@ class City const SF_ID = 'Id'; const SF_NAME = 'Name'; + const SF_COUNTRY = 'Country__c'; /** * Query fields available in SF for a City @@ -21,5 +22,6 @@ class City const SF_FIELD_LIST = [ self::SF_ID, self::SF_NAME, + self::SF_COUNTRY, ]; } \ No newline at end of file diff --git a/src/Types/Product.php b/src/Types/Product.php new file mode 100644 index 0000000..63d62a4 --- /dev/null +++ b/src/Types/Product.php @@ -0,0 +1,55 @@ + + */ +class Product +{ + const SF_OBJECT = 'Product__c'; + + const SF_ID = 'ID_Product__c'; + const SF_NAME = 'Name'; + const SF_COUNTRY = 'Product_Country__c'; + const SF_CITY = 'Product_City__c'; + const SF_STREET = 'Product_Street__c'; + const SF_ZIPCODE = 'Product_Zip_Postal_code__c'; + const SF_STATUS = 'Validation_Status__c'; + const SF_CAPACITY = 'Capacity__c'; + const SF_TYPE = 'RecordTypeId'; + const SF_FRONT_EMAIL = 'Front_Desk_Email__c'; + const SF_FRONT_PHONE = 'Front_Desk_Phone__c'; + const SF_COORDINATE = 'GPS_coordinates__c'; + const SF_CATEGORY = 'Category__c'; + const SF_ATH_ID = 'Product_ATH_id__c'; + const SF_GPS_LAT = 'GPS_coordinates__Latitude__s'; + const SF_GPS_LNG = 'GPS_coordinates__Longitude__s'; + const SF_ACCOUNT = 'Account__c'; + + const SF_PENDING_STATUS = 'Pending'; + const SF_ACTIVE_STATUS = 'Approved'; + const SF_INACTIVE_STATUS = 'Refused'; + + /** + * Query fields available in SF for a Product + */ + const SF_FIELD_LIST = [ + self::SF_ID, + self::SF_NAME, + self::SF_COUNTRY, + self::SF_CITY, + self::SF_STREET, + self::SF_ZIPCODE, + self::SF_STATUS, + self::SF_CAPACITY, + self::SF_TYPE, + self::SF_FRONT_EMAIL, + self::SF_FRONT_PHONE, + self::SF_COORDINATE, + self::SF_CATEGORY + ]; +} \ No newline at end of file From 444fbd5bd93b17d869ab69fb538bb6642a641955 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Fri, 1 Oct 2021 18:55:22 +0200 Subject: [PATCH 17/38] update city def --- src/Types/City.php | 1 + src/Types/Product.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Types/City.php b/src/Types/City.php index d2ccc1d..0757394 100644 --- a/src/Types/City.php +++ b/src/Types/City.php @@ -15,6 +15,7 @@ class City const SF_ID = 'Id'; const SF_NAME = 'Name'; const SF_COUNTRY = 'Country__c'; + const SF_COUNTRY_NAME = 'Country__r.Name'; /** * Query fields available in SF for a City diff --git a/src/Types/Product.php b/src/Types/Product.php index 63d62a4..92ff0d1 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -12,7 +12,7 @@ class Product { const SF_OBJECT = 'Product__c'; - const SF_ID = 'ID_Product__c'; + const SF_ID = 'Id'; const SF_NAME = 'Name'; const SF_COUNTRY = 'Product_Country__c'; const SF_CITY = 'Product_City__c'; From c60401292db8edb4ada915e8b1a2beec4512f454 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Wed, 6 Oct 2021 22:18:02 +0200 Subject: [PATCH 18/38] update fields --- src/Types/Account.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Types/Account.php b/src/Types/Account.php index caff0c9..9693958 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -14,6 +14,7 @@ class Account const SF_ID = 'Id'; const SF_NAME = 'Name'; + const SF_CORPORATE_NAME = 'Company_s_Corporate_Name__c'; const SF_COUNTRY = 'Account_Country__c'; const SF_CITY = 'Account_City__c'; const SF_STREET = 'Account_Street__c'; From a677e3e98734a1b8d92acb0f63292469721afd3b Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Wed, 13 Oct 2021 18:26:19 +0200 Subject: [PATCH 19/38] add bong city model --- src/Types/BongCity.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Types/BongCity.php diff --git a/src/Types/BongCity.php b/src/Types/BongCity.php new file mode 100644 index 0000000..7bff47b --- /dev/null +++ b/src/Types/BongCity.php @@ -0,0 +1,28 @@ + + */ +class BongCity +{ + const SF_OBJECT = 'BongCity__c'; + + const SF_ID = 'Id'; + const SF_NAME = 'Name'; + const SF_ID_BONG = 'ID_BONG__c'; + const SF_COUNTRY_NAME = 'CountryName__c'; + + /** + * Query fields available in SF for a BongCity + */ + const SF_FIELD_LIST = [ + self::SF_ID, + self::SF_NAME, + self::SF_ID_BONG + ]; +} \ No newline at end of file From a2e20f121ddab8ab68fd9001e51c7da8b5e76f6b Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 25 Oct 2021 21:39:46 +0200 Subject: [PATCH 20/38] update property of account --- src/Types/Account.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Types/Account.php b/src/Types/Account.php index 9693958..4514218 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -20,10 +20,14 @@ class Account const SF_STREET = 'Account_Street__c'; const SF_ZIPCODE = 'Account_Zip_Postal_code__c'; const SF_STATUS = 'Global_Account_Status'; + const SF_SAT_STATUS = 'SAT_validation__c'; const SF_ACTIVE_STATUS = 'Active Account'; const SF_INACTIVE_STATUS = 'Inactive Account'; + const SF_SAT_ACTIVE_STATUS = 'Approved'; + const SF_SAT_INACTIVE_STATUS = 'Refused'; + /** * Query fields available in SF for an Account */ From 197cd81bf2182950cea439e3b070b960884aa406 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 25 Oct 2021 22:37:25 +0200 Subject: [PATCH 21/38] update product field --- src/Types/Product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Types/Product.php b/src/Types/Product.php index 92ff0d1..d6ec956 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -29,6 +29,7 @@ class Product const SF_GPS_LAT = 'GPS_coordinates__Latitude__s'; const SF_GPS_LNG = 'GPS_coordinates__Longitude__s'; const SF_ACCOUNT = 'Account__c'; + const SF_BOOKING_OR_TRIP_URL = 'Booking_or_Trip__c'; const SF_PENDING_STATUS = 'Pending'; const SF_ACTIVE_STATUS = 'Approved'; From 17bbab45e3e365dad04d53ef10f2ae55cad5e9cd Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Tue, 26 Oct 2021 09:33:35 +0200 Subject: [PATCH 22/38] update field recuperation --- src/Types/BongCity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Types/BongCity.php b/src/Types/BongCity.php index 7bff47b..d4c7e95 100644 --- a/src/Types/BongCity.php +++ b/src/Types/BongCity.php @@ -23,6 +23,7 @@ class BongCity const SF_FIELD_LIST = [ self::SF_ID, self::SF_NAME, - self::SF_ID_BONG + self::SF_ID_BONG, + self::SF_COUNTRY_NAME, ]; } \ No newline at end of file From ebe0156592038a59da07e338ddccc0436c6e8c7d Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Fri, 29 Oct 2021 15:09:36 +0200 Subject: [PATCH 23/38] wip bifu contact --- src/Types/Contact.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Types/Contact.php diff --git a/src/Types/Contact.php b/src/Types/Contact.php new file mode 100644 index 0000000..220e222 --- /dev/null +++ b/src/Types/Contact.php @@ -0,0 +1,27 @@ + + */ +class Contact +{ + const SF_OBJECT = 'Contact'; + + const SF_FIRST_NAME = 'Name__firstName'; + const SF_LAST_NAME = 'Name__lastName'; + const SF_EMAIL = 'Email'; + const SF_PHONE = 'Phone'; + + /** + * Query fields available in SF for a Contact + */ + const SF_FIELD_LIST = [ + self::SF_ID, + self::SF_NAME, + ]; +} \ No newline at end of file From 5fa529c0083ba32a7413b6aa7e4d1f1ba35b218b Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Fri, 29 Oct 2021 18:19:08 +0200 Subject: [PATCH 24/38] wip bifu contact --- src/Restforce.php | 2 +- src/Types/Contact.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Restforce.php b/src/Restforce.php index 52061d4..e056b3c 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -202,7 +202,7 @@ public function closeJob(string $jobId) 'state' => 'UploadComplete' ]); - unlink($jobId . self::CSV_EXTENSION); + //unlink($jobId . self::CSV_EXTENSION); } /** diff --git a/src/Types/Contact.php b/src/Types/Contact.php index 220e222..bfb9b14 100644 --- a/src/Types/Contact.php +++ b/src/Types/Contact.php @@ -12,8 +12,9 @@ class Contact { const SF_OBJECT = 'Contact'; - const SF_FIRST_NAME = 'Name__firstName'; - const SF_LAST_NAME = 'Name__lastName'; + const SF_ID = 'Id'; + const SF_FIRST_NAME = 'FirstName'; + const SF_LAST_NAME = 'LastName'; const SF_EMAIL = 'Email'; const SF_PHONE = 'Phone'; @@ -22,6 +23,9 @@ class Contact */ const SF_FIELD_LIST = [ self::SF_ID, - self::SF_NAME, + self::SF_FIRST_NAME, + self::SF_LAST_NAME, + self::SF_EMAIL, + self::SF_PHONE ]; } \ No newline at end of file From d5c8ef5aa3ca63a8035cc3abb8797bcac3f2c83b Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Thu, 4 Nov 2021 11:22:35 +0100 Subject: [PATCH 25/38] sf product account WIP --- src/Types/ContactRelationshipAccount.php | 32 ++++++++++++++++++++++++ src/Types/ContactRelationshipProduct.php | 32 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/Types/ContactRelationshipAccount.php create mode 100644 src/Types/ContactRelationshipProduct.php diff --git a/src/Types/ContactRelationshipAccount.php b/src/Types/ContactRelationshipAccount.php new file mode 100644 index 0000000..3bfeb49 --- /dev/null +++ b/src/Types/ContactRelationshipAccount.php @@ -0,0 +1,32 @@ + + */ +class ContactRelationshipAccount +{ + const SF_OBJECT = 'Account_Contact_Relationship__c'; + + const SF_ID = 'Id'; + const SF_ACCOUNT = 'Account__c'; + const SF_NAME = 'Name'; + const SF_CONTACT = 'Contact__c'; + const SF_ROLE = 'Contact_Roles__c'; + + /** + * Query fields available in SF for a Contact + */ + const SF_FIELD_LIST = [ + self::SF_ID, + self::SF_ACCOUNT, + self::SF_NAME, + self::SF_CONTACT, + self::SF_ROLE + ]; +} \ No newline at end of file diff --git a/src/Types/ContactRelationshipProduct.php b/src/Types/ContactRelationshipProduct.php new file mode 100644 index 0000000..dac2d85 --- /dev/null +++ b/src/Types/ContactRelationshipProduct.php @@ -0,0 +1,32 @@ + + */ +class ContactRelationshipAccount +{ + const SF_OBJECT = 'ProductVP_Contact_Relationship__c'; + + const SF_ID = 'Id'; + const SF_PRODUCT = 'Product_VP__c'; + const SF_NAME = 'Name'; + const SF_CONTACT = 'Contact__c'; + const SF_ROLE = 'Contact_Roles__c'; + + /** + * Query fields available in SF for a Contact + */ + const SF_FIELD_LIST = [ + self::SF_ID, + self::SF_PRODUCT, + self::SF_NAME, + self::SF_CONTACT, + self::SF_ROLE + ]; +} \ No newline at end of file From 1a81534f7dbfbd6ddd75002b8f0275326964831e Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Thu, 4 Nov 2021 11:25:30 +0100 Subject: [PATCH 26/38] sf product account WIP --- src/Types/ContactRelationshipProduct.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/ContactRelationshipProduct.php b/src/Types/ContactRelationshipProduct.php index dac2d85..95b4497 100644 --- a/src/Types/ContactRelationshipProduct.php +++ b/src/Types/ContactRelationshipProduct.php @@ -9,7 +9,7 @@ * @package EventFarm\Restforce\Types * @author Nils Peritore */ -class ContactRelationshipAccount +class ContactRelationshipProduct { const SF_OBJECT = 'ProductVP_Contact_Relationship__c'; From 188465e6b4e35afdce3c1e83539606ba6f6dfba4 Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Tue, 9 Nov 2021 18:50:27 +0100 Subject: [PATCH 27/38] account fix --- src/Types/Account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/Account.php b/src/Types/Account.php index 4514218..635c771 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -19,7 +19,7 @@ class Account const SF_CITY = 'Account_City__c'; const SF_STREET = 'Account_Street__c'; const SF_ZIPCODE = 'Account_Zip_Postal_code__c'; - const SF_STATUS = 'Global_Account_Status'; + const SF_STATUS = 'Global_Account_Status__c'; const SF_SAT_STATUS = 'SAT_validation__c'; const SF_ACTIVE_STATUS = 'Active Account'; From 8cf7a88d31b8ad01ccdfa0880e564234defdd960 Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Wed, 10 Nov 2021 18:20:55 +0100 Subject: [PATCH 28/38] delete method --- src/Rest/GuzzleRestClient.php | 28 ++++++++++++++++++++++ src/Rest/OAuthRestClient.php | 25 +++++++++++++++++++ src/Rest/SalesforceRestClient.php | 25 +++++++++++++++++++ src/Rest/SalesforceRestClientInterface.php | 17 +++++++++++++ src/Restforce.php | 13 ++++++++++ 5 files changed, 108 insertions(+) diff --git a/src/Rest/GuzzleRestClient.php b/src/Rest/GuzzleRestClient.php index f8aa9e4..97f996e 100644 --- a/src/Rest/GuzzleRestClient.php +++ b/src/Rest/GuzzleRestClient.php @@ -106,6 +106,34 @@ public function post( ); } + /** + * Delete method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete( + string $path, + array $formParameters = [], + array $headers = [], + float $timeoutSeconds = null + ) { + return $this->client->request( + 'DELETE', + $path, + [ + 'timeout' => $timeoutSeconds, + 'headers' => $headers, + 'form_params' => $formParameters + ] + ); + } + /** * Post method JSON formatted * diff --git a/src/Rest/OAuthRestClient.php b/src/Rest/OAuthRestClient.php index 8cc8040..5e1a5c7 100644 --- a/src/Rest/OAuthRestClient.php +++ b/src/Rest/OAuthRestClient.php @@ -106,6 +106,31 @@ public function post( ); } + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ + public function delete( + string $path, + array $formParameters = [], + array $headers = [], + float $timeoutSeconds = null + ) { + $this->setParamsFromAccessToken(); + return $this->apiRestClient->delete( + $path, + $formParameters, + $this->getAuthorizationHeader($headers), + $timeoutSeconds + ); + } + /** * Post method JSON formatted * diff --git a/src/Rest/SalesforceRestClient.php b/src/Rest/SalesforceRestClient.php index b51816e..cb3f324 100644 --- a/src/Rest/SalesforceRestClient.php +++ b/src/Rest/SalesforceRestClient.php @@ -104,6 +104,31 @@ public function post( ); } + /** + * Post method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function delete( + string $path, + array $formParameters = [], + array $headers = [], + float $timeoutSeconds = null + ) { + return $this->restClient->delete( + $this->constructUrl($path), + $formParameters, + $headers, + $timeoutSeconds + ); + } + /** * Post method JSON formatted * diff --git a/src/Rest/SalesforceRestClientInterface.php b/src/Rest/SalesforceRestClientInterface.php index 9c289c3..cb80227 100644 --- a/src/Rest/SalesforceRestClientInterface.php +++ b/src/Rest/SalesforceRestClientInterface.php @@ -62,6 +62,23 @@ public function post( float $timeoutSeconds = null ); + /** + * Delete method + * + * @param string $path path + * @param array $formParameters parameters + * @param array $headers headers + * @param float|null $timeoutSeconds timeout + * + * @return mixed + */ + public function delete( + string $path, + array $formParameters = [], + array $headers = [], + float $timeoutSeconds = null + ); + /** * Post method JSON formatted * diff --git a/src/Restforce.php b/src/Restforce.php index e056b3c..f346926 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -20,6 +20,7 @@ class Restforce implements RestforceInterface const FILE_APPEND = 'a'; const FILE_READONLY = 'r'; const FILE_WRITE = 'w'; + const BULK_JOB_OPERATION_DELETE = 'delete'; const BULK_JOB_OPERATION_UPDATE = 'update'; const BULK_JOB_OPERATION_INSERT = 'insert'; @@ -324,6 +325,18 @@ public function query(string $queryString) ]); } + /** + * Query method + * + * @param string $queryString query string + * + * @return mixed + */ + public function delete(string $queryString) + { + return $this->getOAuthRestClient()->delete('sobjects/' . $queryString); + } + /** * UserInfo method * From ffe011f967593209cde85dddad0d51397f147aa8 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 15 Nov 2021 12:09:23 +0100 Subject: [PATCH 29/38] add record name --- src/Types/Product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Types/Product.php b/src/Types/Product.php index d6ec956..00942c0 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -19,6 +19,7 @@ class Product const SF_STREET = 'Product_Street__c'; const SF_ZIPCODE = 'Product_Zip_Postal_code__c'; const SF_STATUS = 'Validation_Status__c'; + const SF_RECORD_TYPE = 'RecordType.Name'; const SF_CAPACITY = 'Capacity__c'; const SF_TYPE = 'RecordTypeId'; const SF_FRONT_EMAIL = 'Front_Desk_Email__c'; From 227567115c6285f0f2fd924646e3810cdcd5071f Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Thu, 18 Nov 2021 17:41:29 +0100 Subject: [PATCH 30/38] updatge mapping --- src/Types/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/Product.php b/src/Types/Product.php index 00942c0..0ff2b96 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -19,7 +19,7 @@ class Product const SF_STREET = 'Product_Street__c'; const SF_ZIPCODE = 'Product_Zip_Postal_code__c'; const SF_STATUS = 'Validation_Status__c'; - const SF_RECORD_TYPE = 'RecordType.Name'; + const SF_RECORD_TYPE = 'RecordTypeId'; const SF_CAPACITY = 'Capacity__c'; const SF_TYPE = 'RecordTypeId'; const SF_FRONT_EMAIL = 'Front_Desk_Email__c'; From d15c7b635b0be98a695b1cd8c9e2e9ff73439131 Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Fri, 26 Nov 2021 10:07:17 +0100 Subject: [PATCH 31/38] fix doc --- src/Types/ContactRelationshipAccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types/ContactRelationshipAccount.php b/src/Types/ContactRelationshipAccount.php index 3bfeb49..33abe51 100644 --- a/src/Types/ContactRelationshipAccount.php +++ b/src/Types/ContactRelationshipAccount.php @@ -15,7 +15,7 @@ class ContactRelationshipAccount const SF_ID = 'Id'; const SF_ACCOUNT = 'Account__c'; - const SF_NAME = 'Name'; + const SF_NAME = 'Relation_Name__c'; const SF_CONTACT = 'Contact__c'; const SF_ROLE = 'Contact_Roles__c'; From 09f0647d53b89eec6c79a97c399a40db6c0f8af2 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Fri, 26 Nov 2021 11:22:39 +0100 Subject: [PATCH 32/38] update fields for market score --- src/Types/Product.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Types/Product.php b/src/Types/Product.php index 0ff2b96..29f647e 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -30,7 +30,10 @@ class Product const SF_GPS_LAT = 'GPS_coordinates__Latitude__s'; const SF_GPS_LNG = 'GPS_coordinates__Longitude__s'; const SF_ACCOUNT = 'Account__c'; - const SF_BOOKING_OR_TRIP_URL = 'Booking_or_Trip__c'; + const SF_BOOKING_URL = 'Booking_or_Trip__c'; + const SF_TRIPADVISOR_URL = 'Tripadvisor_link__c'; + const SF_BOOKING_SCORE = 'Market_Score__c'; + const SF_TRIPDVISOR_SCORE = 'Market_Score_TripAdvisor__c'; const SF_PENDING_STATUS = 'Pending'; const SF_ACTIVE_STATUS = 'Approved'; From 4e0d3ce004f5b93b969440b3dcb5a3c73569b4a3 Mon Sep 17 00:00:00 2001 From: Nils Peritore Date: Fri, 26 Nov 2021 12:21:37 +0100 Subject: [PATCH 33/38] fix doc --- src/Types/Contact.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Types/Contact.php b/src/Types/Contact.php index bfb9b14..4f4e1ab 100644 --- a/src/Types/Contact.php +++ b/src/Types/Contact.php @@ -13,6 +13,7 @@ class Contact const SF_OBJECT = 'Contact'; const SF_ID = 'Id'; + const SF_TITLE = 'Title'; const SF_FIRST_NAME = 'FirstName'; const SF_LAST_NAME = 'LastName'; const SF_EMAIL = 'Email'; @@ -23,6 +24,7 @@ class Contact */ const SF_FIELD_LIST = [ self::SF_ID, + self::SF_TITLE, self::SF_FIRST_NAME, self::SF_LAST_NAME, self::SF_EMAIL, From 85be46b67d7d4ccc9b4280ee3dc5920fda00ce31 Mon Sep 17 00:00:00 2001 From: christophe13012 Date: Thu, 2 Dec 2021 18:47:40 +0100 Subject: [PATCH 34/38] add constants --- src/Types/Account.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Types/Account.php b/src/Types/Account.php index 635c771..f3819a0 100644 --- a/src/Types/Account.php +++ b/src/Types/Account.php @@ -21,6 +21,8 @@ class Account const SF_ZIPCODE = 'Account_Zip_Postal_code__c'; const SF_STATUS = 'Global_Account_Status__c'; const SF_SAT_STATUS = 'SAT_validation__c'; + const SF_NUMBER_ROOMING_LIST_CONTACT = 'Number_of_Rooming_List_Contact__c'; + const SF_NUMBER_COMMERCIAL_CONTACT = 'Number_of_commercial_contact__c'; const SF_ACTIVE_STATUS = 'Active Account'; const SF_INACTIVE_STATUS = 'Inactive Account'; From 9a6f381a5bc6f22d047a21cbcea25782de5faf9e Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Fri, 3 Dec 2021 14:35:17 +0100 Subject: [PATCH 35/38] add field --- src/Types/Product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Types/Product.php b/src/Types/Product.php index 29f647e..cec5b2e 100644 --- a/src/Types/Product.php +++ b/src/Types/Product.php @@ -34,6 +34,7 @@ class Product const SF_TRIPADVISOR_URL = 'Tripadvisor_link__c'; const SF_BOOKING_SCORE = 'Market_Score__c'; const SF_TRIPDVISOR_SCORE = 'Market_Score_TripAdvisor__c'; + const SF_ROOMING_LIST_CONTACT = 'Number_of_Rooming_List_Contact__c'; const SF_PENDING_STATUS = 'Pending'; const SF_ACTIVE_STATUS = 'Approved'; From 3916f357a091008edb14c7ccd56e87b70e21ce56 Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 6 Dec 2021 15:53:09 +0100 Subject: [PATCH 36/38] re add delete local file --- src/Restforce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Restforce.php b/src/Restforce.php index f346926..6237954 100644 --- a/src/Restforce.php +++ b/src/Restforce.php @@ -203,7 +203,7 @@ public function closeJob(string $jobId) 'state' => 'UploadComplete' ]); - //unlink($jobId . self::CSV_EXTENSION); + unlink($jobId . self::CSV_EXTENSION); } /** From 045bb1dfc4aa096ab2636e822db1195cd2d7ed0b Mon Sep 17 00:00:00 2001 From: Florian Duc Date: Mon, 27 Dec 2021 12:00:48 +0100 Subject: [PATCH 37/38] update relation name --- src/Types/ContactRelationshipAccount.php | 3 ++- src/Types/ContactRelationshipProduct.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Types/ContactRelationshipAccount.php b/src/Types/ContactRelationshipAccount.php index 33abe51..d1c7086 100644 --- a/src/Types/ContactRelationshipAccount.php +++ b/src/Types/ContactRelationshipAccount.php @@ -15,9 +15,10 @@ class ContactRelationshipAccount const SF_ID = 'Id'; const SF_ACCOUNT = 'Account__c'; - const SF_NAME = 'Relation_Name__c'; + const SF_NAME = 'Name'; const SF_CONTACT = 'Contact__c'; const SF_ROLE = 'Contact_Roles__c'; + const SF_LONG_NAME = 'Relation_Name__c'; /** * Query fields available in SF for a Contact diff --git a/src/Types/ContactRelationshipProduct.php b/src/Types/ContactRelationshipProduct.php index 95b4497..359b6c0 100644 --- a/src/Types/ContactRelationshipProduct.php +++ b/src/Types/ContactRelationshipProduct.php @@ -15,9 +15,10 @@ class ContactRelationshipProduct const SF_ID = 'Id'; const SF_PRODUCT = 'Product_VP__c'; - const SF_NAME = 'Name'; + const SF_NAME = 'Relation_Name__c'; const SF_CONTACT = 'Contact__c'; const SF_ROLE = 'Contact_Roles__c'; + const SF_LONG_NAME = 'Relation_Name__c'; /** * Query fields available in SF for a Contact From 80bbef139ee48dac202454f98ed14ac390bded20 Mon Sep 17 00:00:00 2001 From: fabiovalho Date: Mon, 31 Oct 2022 12:00:25 +0100 Subject: [PATCH 38/38] push new constants to vendor repository for task job synchronized emails --- src/Types/ContactRelationshipAccount.php | 2 ++ src/Types/ContactRelationshipProduct.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Types/ContactRelationshipAccount.php b/src/Types/ContactRelationshipAccount.php index d1c7086..2c97d2c 100644 --- a/src/Types/ContactRelationshipAccount.php +++ b/src/Types/ContactRelationshipAccount.php @@ -15,10 +15,12 @@ class ContactRelationshipAccount const SF_ID = 'Id'; const SF_ACCOUNT = 'Account__c'; + const SF_ACCOUNT_ID = 'Account__r.Id'; const SF_NAME = 'Name'; const SF_CONTACT = 'Contact__c'; const SF_ROLE = 'Contact_Roles__c'; const SF_LONG_NAME = 'Relation_Name__c'; + const SF_EMAIL = 'Contact__r.Email'; /** * Query fields available in SF for a Contact diff --git a/src/Types/ContactRelationshipProduct.php b/src/Types/ContactRelationshipProduct.php index 359b6c0..2d6826e 100644 --- a/src/Types/ContactRelationshipProduct.php +++ b/src/Types/ContactRelationshipProduct.php @@ -17,6 +17,7 @@ class ContactRelationshipProduct const SF_PRODUCT = 'Product_VP__c'; const SF_NAME = 'Relation_Name__c'; const SF_CONTACT = 'Contact__c'; + const SF_CONTACT_EMAIL = 'Contact__r.Email'; const SF_ROLE = 'Contact_Roles__c'; const SF_LONG_NAME = 'Relation_Name__c'; @@ -28,6 +29,7 @@ class ContactRelationshipProduct self::SF_PRODUCT, self::SF_NAME, self::SF_CONTACT, + self::SF_CONTACT_EMAIL, self::SF_ROLE ]; } \ No newline at end of file