Skip to content

Commit

Permalink
switch to php enums
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomail-cz committed Aug 29, 2024
1 parent 4bb4503 commit f5d39c5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"MIT"
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down
36 changes: 18 additions & 18 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function isAllowedChangesApi(): bool
{
return $this->httpClient->request(
$this->queryBuilder->createChangesStatusUrl(),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -52,7 +52,7 @@ public function getChangesApiForEvidence(string $evidenceName): Response
{
return $this->httpClient->request(
$this->queryBuilder->createChangesUrl(['evidence' => $evidenceName]),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -64,7 +64,7 @@ public function getPropertiesForEvidence(): Response
{
return $this->httpClient->request(
$this->queryBuilder->createUri('properties', []),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -76,7 +76,7 @@ public function getAllApiChanges(?string $fromVersion): Response
{
return $this->httpClient->request(
$this->queryBuilder->createChangesUrl(['start' => $fromVersion]),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -88,7 +88,7 @@ public function getCompanies(): Response
{
return $this->httpClient->request(
$this->queryBuilder->createCompanyUrl(),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand Down Expand Up @@ -125,7 +125,7 @@ public function getAuthAndRefreshToken(): Response
{
return $this->httpClient->request(
$this->queryBuilder->createAuthTokenUrl(),
Method::get(Method::POST),
Method::POST,
[],
[
'username' => $this->config->getUser(),
Expand All @@ -144,7 +144,7 @@ public function deleteById(int $id, bool $dryRun = false): Response

return $this->httpClient->request(
$this->queryBuilder->createUri($id, $uriParameters),
Method::get(Method::DELETE),
Method::DELETE,
[],
[],
[],
Expand All @@ -157,7 +157,7 @@ public function deleteByCode(string $id, bool $dryRun = false): void
$uriParameters = $dryRun ? ['dry-run' => 'true'] : [];
$this->httpClient->request(
$this->queryBuilder->createUri(sprintf('code:%s', $id), $uriParameters),
Method::get(Method::DELETE),
Method::DELETE,
[],
[],
[],
Expand Down Expand Up @@ -199,7 +199,7 @@ public function getByCode(string $code, array $uriParameters = []): EvidenceResu
return $this->responseHydrator->convertResponseToEvidenceResult(
$this->httpClient->request(
$this->queryBuilder->createUriByCodeOnly($code, $uriParameters),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -224,7 +224,7 @@ public function getById(int $id, array $uriParameters = []): EvidenceResult
return $this->responseHydrator->convertResponseToEvidenceResult(
$this->httpClient->request(
$this->queryBuilder->createUri($id, $uriParameters),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand Down Expand Up @@ -276,7 +276,7 @@ public function save(array $evidenceData, ?int $id, bool $dryRun = false, array
? array_merge($uriParameters, ['dry-run' => 'true'])
: $uriParameters;
/** @var \EcomailFlexibee\Result\EvidenceResult $response */
$response = $this->callRequest(Method::get(Method::PUT), null, $uriParameters, $postData, [])[0];
$response = $this->callRequest(Method::PUT, null, $uriParameters, $postData, [])[0];
$data = $response->getData();

if (
Expand Down Expand Up @@ -345,7 +345,7 @@ public function allInEvidence(): array
{
$response = $this->httpClient->request(
$this->queryBuilder->createUriByEvidenceOnly(['limit' => 0]),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -359,7 +359,7 @@ public function countInEvidence(): int
{
$response = $this->httpClient->request(
$this->queryBuilder->createUriByEvidenceOnly(['add-row-count' => 'true']),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -382,7 +382,7 @@ public function chunkInEvidence(int $start, int $limit): array
{
$response = $this->httpClient->request(
$this->queryBuilder->createUriByEvidenceOnly(['limit' => $limit, 'start' => $start]),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -406,7 +406,7 @@ public function searchInEvidence(string $query, array $uriParameters): array
{
$response = $this->httpClient->request(
$this->queryBuilder->createFilterQuery($query, $uriParameters),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -431,7 +431,7 @@ public function searchInEvidencePaginated(string $query, array $uriParameters):
$uriParameters = array_merge($uriParameters, ['add-row-count' => 'true']);
$response = $this->httpClient->request(
$this->queryBuilder->createFilterQuery($query, $uriParameters),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand Down Expand Up @@ -480,7 +480,7 @@ public function getPdfById(int $id, array $uriParameters): Response
{
return $this->httpClient->request(
$this->queryBuilder->createPdfUrl($id, $uriParameters),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand All @@ -494,7 +494,7 @@ public function findLastInEvidence(bool $fullDetail): Response
$this->queryBuilder->createUriByEvidenceOnly(
['order' => 'id', 'limit' => 1, 'detail' => $fullDetail ? 'full' : 'summary'],
),
Method::get(Method::GET),
Method::GET,
[],
[],
[],
Expand Down
2 changes: 1 addition & 1 deletion src/Http/HttpCurlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function build(string $url, Method $httpMethod, array $postFields, array
}

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod->getValue());
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod->value);
curl_setopt($ch, CURLOPT_USERAGENT, 'Ecomail.cz Flexibee client (https://github.com/Ecomailcz/flexibee-client)');
$verifySSLCertificate = $config->verifySSLCertificate() && $config->getAuthSessionId() === null;
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifySSLCertificate);
Expand Down
2 changes: 1 addition & 1 deletion src/Http/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function createFromOutput(string $url, Method $httpMethod, ?string
}

// Backup content
if ($httpMethod->equalsValue(Method::GET) && mb_stripos($url, '/backup') !== false) {
if ($httpMethod === Method::GET && mb_stripos($url, '/backup') !== false) {
return new FlexibeeBackupResponse($responseContent);
}

Expand Down

0 comments on commit f5d39c5

Please sign in to comment.