Skip to content

Commit

Permalink
Merge pull request #221 from gsteel/renovate/all-minor-patch
Browse files Browse the repository at this point in the history
Update all non-major dependencies
  • Loading branch information
gsteel committed Jan 22, 2024
2 parents 3f973c9 + 39770c8 commit 026748e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: shivammathur/setup-php@2.28.0
- uses: shivammathur/setup-php@2.29.0
with:
php-version: ${{ env.stable_php }}
coverage: pcov
Expand All @@ -43,7 +43,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4.1.1
- uses: shivammathur/setup-php@2.28.0
- uses: shivammathur/setup-php@2.29.0
with:
php-version: ${{ env.stable_php }}
ini-values: memory_limit=-1
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"laminas/laminas-diactoros": "^3.3.0",
"php-http/curl-client": "^2.3.1",
"php-http/mock-client": "^1.6",
"phpunit/phpunit": "^10.5.5",
"phpunit/phpunit": "^10.5.9",
"psalm/plugin-phpunit": "^0.18.4",
"squizlabs/php_codesniffer": "^3.8.1",
"vimeo/psalm": "^5.19.0"
"vimeo/psalm": "^5.20.0"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Postmark/ClientBehaviour/PostmarkClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use function array_filter;
use function http_build_query;
use function is_string;
use function json_decode;
use function json_encode;
use function sprintf;
Expand Down Expand Up @@ -117,7 +118,7 @@ protected function processRestRequest(string $method, string $path, array $param
throw InvalidRequestMethod::with($method);
}

if (! empty($query)) {
if (is_string($query) && $query !== '') {
$target = $target->withQuery($query);
}

Expand Down
66 changes: 29 additions & 37 deletions src/Postmark/Exception/RequestFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,32 @@ public function __construct(string $message, private RequestInterface $request,

public static function with(RequestInterface $request, ResponseInterface $response): self
{
switch ($response->getStatusCode()) {
case 401:
return new self(
'Unauthorized: Missing or incorrect API token in header. '
. 'Please verify that you used the correct token when you constructed your client.',
$request,
$response,
);

case 500:
return new self(
'Internal Server Error: This is an issue with Postmark’s servers processing your request. '
. 'In most cases the message is lost during the process, '
. 'and Postmark is notified so that we can investigate the issue.',
$request,
$response,
);

case 503:
return new self(
'The Postmark API is currently unavailable, please try your request later.',
$request,
$response,
);

default:
return new self(
self::retrieveErrorMessage($response)
?: 'A request error occurred and there was no message encoded in the response.',
$request,
$response,
);
}
return match ($response->getStatusCode()) {
401 => new self(
'Unauthorized: Missing or incorrect API token in header. '
. 'Please verify that you used the correct token when you constructed your client.',
$request,
$response,
),
500 => new self(
'Internal Server Error: This is an issue with Postmark’s servers processing your request. '
. 'In most cases the message is lost during the process, '
. 'and Postmark is notified so that we can investigate the issue.',
$request,
$response,
),
503 => new self(
'The Postmark API is currently unavailable, please try your request later.',
$request,
$response,
),
default => new self(
self::retrieveErrorMessage($response)
?? 'A request error occurred and there was no message encoded in the response.',
$request,
$response,
),
};
}

public function request(): RequestInterface
Expand All @@ -77,11 +70,10 @@ public function postmarkErrorMessage(): string|null
public function postmarkErrorCode(): int|null
{
$body = self::responseBody($this->response);
$code = isset($body['ErrorCode']) && is_numeric($body['ErrorCode']) && ! empty($body['ErrorCode'])
? $body['ErrorCode']
: null;

return $code ? (int) $code : null;
return isset($body['ErrorCode']) && is_numeric($body['ErrorCode'])
? (int) $body['ErrorCode']
: null;
}

/** @return non-empty-string|null */
Expand Down
6 changes: 3 additions & 3 deletions src/Postmark/Models/PostmarkAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function __construct(
string|null $mimeType = null,
private string|null $contentId = null,
) {
$this->mimeType = $mimeType ?: self::DEFAULT_MIMETYPE;
$this->mimeType = $mimeType ?? self::DEFAULT_MIMETYPE;
}

/**
Expand Down Expand Up @@ -96,8 +96,8 @@ public function jsonSerialize(): array
return [
'Name' => $this->attachmentName,
'Content' => $this->base64EncodedData,
'ContentType' => $this->mimeType ?: 'application/octet-stream',
'ContentId' => $this->contentId ?: $this->attachmentName,
'ContentType' => $this->mimeType,
'ContentId' => $this->contentId ?? $this->attachmentName,
];
}
}

0 comments on commit 026748e

Please sign in to comment.