Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job synchronize emails sf bong #38

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3046df2
Changed namespaces and PHP version (7.1 => 7.0)
tpellegatta Oct 11, 2018
5787863
Fix namespaces
tpellegatta Oct 12, 2018
0aeac6c
Add comments
tpellegatta Oct 15, 2018
de59412
Remove overriding of http_errors
tpellegatta Oct 15, 2018
97c36a2
Update OAuthRestClient.php
mventuravoyageprive Oct 25, 2018
122829c
Remove logs
mventuravoyageprive Nov 8, 2018
c31a8ba
Update Restforce - Add bulk support
tpellegatta Jul 29, 2019
d85e019
Add const Update operation
tpellegatta Jul 30, 2019
96caf5d
SF - Optimization bulks
tpellegatta Aug 13, 2019
f742603
Merge pull request #2 from vpg/tur_83386
mventuravoyageprive Aug 13, 2019
8f73a2e
refs #85488 - add create event on SF
blegouge Feb 14, 2020
925a2ab
Merge pull request #1 from vpg/19.34
blegouge Feb 14, 2020
9b5d213
Merge pull request #3 from vpg/85488_splSalesforceAutoUpdate
tpellegatta Feb 14, 2020
6dd2f9d
refs #85488 - sf operation is insert not create
blegouge Feb 21, 2020
2ccf839
add types to restforce api
Aug 12, 2021
7bfdbfe
update lib files
Aug 16, 2021
6fc75e2
update account property
Sep 1, 2021
85a07e8
update status
Sep 8, 2021
4b2d3e5
update SF dictionnary
Sep 27, 2021
444fbd5
update city def
Oct 1, 2021
c604012
update fields
Oct 6, 2021
a677e3e
add bong city model
Oct 13, 2021
a2e20f1
update property of account
Oct 25, 2021
197cd81
update product field
Oct 25, 2021
17bbab4
update field recuperation
Oct 26, 2021
ebe0156
wip bifu contact
nPeritore Oct 29, 2021
5fa529c
wip bifu contact
nPeritore Oct 29, 2021
d5c8ef5
sf product account WIP
nPeritore Nov 4, 2021
1a81534
sf product account WIP
nPeritore Nov 4, 2021
188465e
account fix
nPeritore Nov 9, 2021
8cf7a88
delete method
nPeritore Nov 10, 2021
ffe011f
add record name
Nov 15, 2021
b3ba764
Merge branch 'epic/bifu' of https://github.com/vpg/restforcephp into …
Nov 15, 2021
2275671
updatge mapping
Nov 18, 2021
d15c7b6
fix doc
nPeritore Nov 26, 2021
0600f12
fix doc
nPeritore Nov 26, 2021
09f0647
update fields for market score
Nov 26, 2021
6acefaf
Merge branch 'epic/bifu' of https://github.com/vpg/restforcephp into …
Nov 26, 2021
864ab55
Merge pull request #4 from vpg/epic/bifu
flobrflo Nov 26, 2021
4e0d3ce
fix doc
nPeritore Nov 26, 2021
2fa745a
Merge branch 'epic/bifu' of https://github.com/vpg/restforcephp into …
nPeritore Nov 26, 2021
162bdcf
Merge pull request #5 from vpg/epic/bifu
nPeritore Nov 26, 2021
85be46b
add constants
Dec 2, 2021
0aa56e1
Merge pull request #6 from vpg/bifu_contacts
nPeritore Dec 2, 2021
9a6f381
add field
Dec 3, 2021
04a8a62
Merge pull request #7 from vpg/addRowList
flobrflo Dec 3, 2021
3916f35
re add delete local file
Dec 6, 2021
4df7730
Merge pull request #8 from vpg/reAddUnlinkJob
flobrflo Dec 6, 2021
045bb1d
update relation name
Dec 27, 2021
ea17403
Merge pull request #9 from vpg/updateRelationName
flobrflo Dec 29, 2021
80bbef1
push new constants to vendor repository for task job synchronized emails
fabiovalho Oct 31, 2022
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
162 changes: 141 additions & 21 deletions src/Rest/GuzzleRestClient.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
namespace EventFarm\Restforce\Rest;

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

/**
* Class GuzzleRestClient
*
* @package EventFarm\Restforce\Rest
*/
class GuzzleRestClient implements RestClientInterface
{
const DEFAULT_TIMEOUT_SECONDS = 20.0;
Expand All @@ -12,6 +16,11 @@ class GuzzleRestClient implements RestClientInterface
/** @var bool */
private $enableDebugging;

/**
* GuzzleRestClient constructor.
* @param string $baseUri base uri
* @param bool $enableDebugging debugging status
*/
public function __construct(
string $baseUri,
bool $enableDebugging = false
Expand All @@ -20,7 +29,14 @@ public function __construct(
$this->setBaseUriForRestClient($baseUri);
}

public function setBaseUriForRestClient(string $baseUri): void
/**
* Set base uri for client
*
* @param string $baseUri base uri
*
* @return void
*/
public function setBaseUriForRestClient(string $baseUri)
{
if (!$this->containsTrailingSlash($baseUri)) {
$baseUri .= '/';
Expand All @@ -34,68 +50,136 @@ public function setBaseUriForRestClient(string $baseUri): void
$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
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function get(
string $path,
array $queryParameters = [],
array $headers = [],
?float $timeoutSeconds = null
): ResponseInterface {
float $timeoutSeconds = null
) {
return $this->client->request(
'GET',
$path,
[
'timeout' => $timeoutSeconds,
'headers' => $headers,
'query' => $queryParameters,
'http_errors' => false,
'query' => $queryParameters
]
);
}

/**
* 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 post(
string $path,
array $formParameters = [],
array $headers = [],
?float $timeoutSeconds = null
): ResponseInterface {
float $timeoutSeconds = null
) {
return $this->client->request(
'POST',
$path,
[
'timeout' => $timeoutSeconds,
'headers' => $headers,
'form_params' => $formParameters,
'http_errors' => false,
'form_params' => $formParameters
]
);
}

/**
* 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
*
* @param string $path path
* @param array $jsonArray parameters
* @param array $headers headers
* @param float|null $timeoutSeconds timeout
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
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,
[
'timeout' => $timeoutSeconds,
'headers' => $headers,
'json' => $jsonArray,
'http_errors' => false,
'json' => $jsonArray
]
);
}

/**
* Patch method JSON formatted
*
* @param string $path path
* @param array $jsonArray parameters
* @param array $headers headers
* @param float|null $timeoutSeconds timeout
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
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(
Expand All @@ -104,13 +188,49 @@ public function patchJson(
[
'timeout' => $timeoutSeconds,
'headers' => $headers,
'json' => $jsonArray,
'http_errors' => false,
'json' => $jsonArray
]
);
}

/**
* 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')
]
);
}

private function containsTrailingSlash(string $baseUri): bool
/**
* Check if contains trailing slash
*
* @param string $baseUri base uri
*
* @return bool
*/
private function containsTrailingSlash(string $baseUri)
{
return substr($baseUri, -1) === '/';
}
Expand Down
75 changes: 65 additions & 10 deletions src/Rest/OAuthAccessToken.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
namespace EventFarm\Restforce\Rest;

/**
* Class OAuthAccessToken
*
* @package EventFarm\Restforce\Rest
*/
class OAuthAccessToken
{
/** @var string */
Expand All @@ -16,13 +21,23 @@ class OAuthAccessToken
/** @var int|null */
private $expiresAt;

/**
* OAuthAccessToken constructor.
*
* @param string $tokenType token type (password, etc.)
* @param string $accessToken access token
* @param string $instanceUrl instance url
* @param string $resourceOwnerUrl resource owner url
* @param string|null $refreshToken refresh token
* @param int|null $expiresAt expires value
*/
public function __construct(
string $tokenType,
string $accessToken,
string $instanceUrl,
string $resourceOwnerUrl,
?string $refreshToken = null,
?int $expiresAt = null
string $refreshToken = null,
int $expiresAt = null
) {
$this->tokenType = $tokenType;
$this->accessToken = $accessToken;
Expand All @@ -32,42 +47,82 @@ public function __construct(
$this->expiresAt = $expiresAt;
}

public function getTokenType(): string
/**
* Get token type
*
* @return string
*/
public function getTokenType()
{
return $this->tokenType;
}

public function getAccessToken(): string
/**
* Get access token
*
* @return string
*/
public function getAccessToken()
{
return $this->accessToken;
}

public function getRefreshToken(): ?string
/**
* Get refresh token
*
* @return null|string
*/
public function getRefreshToken()
{
return $this->refreshToken;
}

public function getInstanceUrl(): string
/**
* Get instance url
*
* @return string
*/
public function getInstanceUrl()
{
return $this->instanceUrl;
}

public function getHeaderString(): string
/**
* Get header string
*
* @return string
*/
public function getHeaderString()
{
return $this->tokenType . ' ' . $this->accessToken;
}

public function getResourceOwnerUrl(): string
/**
* Get resource owner url
*
* @return string
*/
public function getResourceOwnerUrl()
{
return $this->resourceOwnerUrl;
}

public function getExpiresAt(): ?int
/**
* Get expires at value
*
* @return int|null
*/
public function getExpiresAt()
{
return $this->expiresAt;
}

public function isExpired(): bool
/**
* Check if expired
*
* @return bool
*/
public function isExpired()
{
if ($this->expiresAt === null) {
return false;
Expand Down
Loading