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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ version: 2.1
workflows:
php-tests:
jobs:
- unit-tests:
name: php81
version: "8.1"
- unit-tests:
name: php82
version: "8.2"
requires:
- php81
- unit-tests:
name: php83
version: "8.3"
Expand All @@ -23,6 +18,11 @@ workflows:
version: "8.4"
requires:
- php83
- unit-tests:
name: php85
version: "8.5"
requires:
- php84

jobs:
unit-tests:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "MIT",
"description": "The officially supported client for Postmark (https://postmarkapp.com)",
"require": {
"php": "~8.1 || ~8.2|| ~8.3 || ~8.4",
"php": "~8.2|| ~8.3 || ~8.4 || ~8.5",
"guzzlehttp/guzzle": "^7.8"
},
"require-dev": {
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 @@ -20,17 +20,17 @@ private function __construct($base64EncodedData, $attachmentName, $mimeType = 'a
$this->contentId = $contentId;
}

public static function fromRawData($data, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
public static function fromRawData(string $data, string $attachmentName, ?string $mimeType = null, ?string $contentId = null): PostmarkAttachment
{
return new PostmarkAttachment(base64_encode($data), $attachmentName, $mimeType, $contentId);
}

public static function fromBase64EncodedData($base64EncodedData, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
public static function fromBase64EncodedData(string $base64EncodedData, string $attachmentName, ?string $mimeType = null, ?string $contentId = null): PostmarkAttachment
{
return new PostmarkAttachment($base64EncodedData, $attachmentName, $mimeType, $contentId);
}

public static function fromFile($filePath, $attachmentName, ?string $mimeType = null, ?string $contentId = null)
public static function fromFile(string $filePath, string $attachmentName, ?string $mimeType = null, ?string $contentId = null): PostmarkAttachment
{
return new PostmarkAttachment(base64_encode(file_get_contents($filePath)), $attachmentName, $mimeType, $contentId);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Postmark/Models/PostmarkBounceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public function __construct(array $values)
{
$this->TotalCount = !empty($values['TotalCount']) ? $values['TotalCount'] : 0;
$tempBounce = [];
foreach ($values['Bounces'] as $bounce) {
$bounces = $values['Bounces'] ?? [];
foreach ($bounces as $bounce) {
$obj = json_decode(json_encode($bounce));
$postmarkBounce = new PostmarkBounce((array) $obj);

Expand Down
3 changes: 2 additions & 1 deletion src/Postmark/Models/PostmarkInboundMessageList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public function __construct(array $values)
{
$this->TotalCount = !empty($values['TotalCount']) ? $values['TotalCount'] : 0;
$tempInboundMessages = [];
foreach ($values['InboundMessages'] as $message) {
$inboundMessages = $values['InboundMessages'] ?? [];
foreach ($inboundMessages as $message) {
$obj = json_decode(json_encode($message));
$postmarkMessage = new PostmarkInboundMessage((array) $obj);

Expand Down
6 changes: 3 additions & 3 deletions src/Postmark/Models/PostmarkOpen.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function setUserAgent(string $UserAgent): PostmarkOpen
return $this;
}

public function getGeo(): PostmarkGeographyInfo
public function getGeo(): ?PostmarkGeographyInfo
{
return $this->Geo;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public function setReceivedAt(string $ReceivedAt): PostmarkOpen
return $this;
}

public function getClient(): PostmarkAgentInfo
public function getClient(): ?PostmarkAgentInfo
{
return $this->Client;
}
Expand All @@ -129,7 +129,7 @@ public function setClient(mixed $Client): PostmarkOpen
return $this;
}

public function getOS(): PostmarkAgentInfo
public function getOS(): ?PostmarkAgentInfo
{
return $this->OS;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Postmark/Models/PostmarkOutboundMessageList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public function __construct(array $values)
{
$this->TotalCount = !empty($values['TotalCount']) ? $values['TotalCount'] : 0;
$tempMessages = [];
foreach ($values['Messages'] as $message) {
$messages = $values['Messages'] ?? [];
foreach ($messages as $message) {
$obj = json_decode(json_encode($message));
$postmarkMessage = new PostmarkOutboundMessage((array) $obj);

Expand Down
3 changes: 2 additions & 1 deletion src/Postmark/Models/Suppressions/PostmarkSuppressionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class PostmarkSuppressionList
public function __construct(array $values)
{
$tempSuppressions = [];
foreach ($values['Suppressions'] as $sups) {
$suppressions = $values['Suppressions'] ?? [];
foreach ($suppressions as $sups) {
$obj = json_decode(json_encode($sups));
$postmarkSup = new PostmarkSuppression((array) $obj);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class PostmarkSuppressionResultList
public function __construct(array $values)
{
$tempSuppressions = [];
foreach ($values['Suppressions'] as $sups) {
$suppressions = $values['Suppressions'] ?? [];
foreach ($suppressions as $sups) {
$obj = json_decode(json_encode($sups));
$postmarkSup = new PostmarkSuppressionRequestResult((array) $obj);

Expand Down
4 changes: 2 additions & 2 deletions src/Postmark/PostmarkClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function getDeliveryStatistics(): PostmarkDeliveryStats
* @param null|bool $inactive specifies if the bounce caused Postmark to deactivate this email
* @param null|string $emailFilter Filter by email address
* @param null|string $tag Filter by tag
* @param null|int $messageID Filter by MessageID
* @param null|string $messageID Filter by MessageID
* @param null|string $fromdate filter for bounces after is date
* @param null|string $todate filter for bounces before this date
* @param null|string $messagestream Filter by Message Stream ID. If null, the default "outbound" transactional stream will be used.
Expand All @@ -320,7 +320,7 @@ public function getBounces(
?bool $inactive = null,
?string $emailFilter = null,
?string $tag = null,
?int $messageID = null,
?string $messageID = null,
?string $fromdate = null,
?string $todate = null,
?string $messagestream = null
Expand Down
71 changes: 43 additions & 28 deletions tests/PostmarkClientBounceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ public static function setUpBeforeClass(): void
PostmarkClientSuppressionsTest::tearDownAfterClass();
}

/**
* @depends testClientCanActivateBounce
*/
public function testClientCanGetBounce()
{
$tk = parent::$testKeys;
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
$bounces = $client->getBounces(10, 0);
$bounceList = $bounces->getBounces();

if (empty($bounceList)) {
$this->markTestSkipped('No bounces available for testing');
return;
}

$id = $bounceList[0]->getID();
$bounce = $client->getBounce($id);
$this->assertNotEmpty($bounce);
$this->assertEquals($id, $bounce->getID());
}

/**
* @depends testClientCanActivateBounce
*/
public function testClientCanGetBounceDump()
{
$tk = parent::$testKeys;
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
$bounces = $client->getBounces(10, 0);
$bounceList = $bounces->getBounces();

if (empty($bounceList)) {
$this->markTestSkipped('No bounces available for testing');
return;
}

$id = $bounceList[0]->getID();
$dump = $client->getBounceDump($id);
$this->assertNotEmpty($dump);
$this->assertNotEmpty($dump->getBody());
}

public function testClientCanActivateBounce()
{
$tk = parent::$testKeys;
Expand Down Expand Up @@ -105,32 +147,5 @@ public function testClientCanGetBounces()
$bounces = $client->getBounces(10, 0);
$this->assertNotEmpty($bounces);
}

/**
* @depends testClientCanActivateBounce
*/
public function testClientCanGetBounce()
{
$tk = parent::$testKeys;
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
$bounces = $client->getBounces(10, 0);
$id = $bounces->getBounces()[0]->getID();
$bounce = $client->getBounce($id);
$this->assertNotEmpty($bounce);
$this->assertEquals($id, $bounce->getID());
}

/**
* @depends testClientCanActivateBounce
*/
public function testClientCanGetBounceDump()
{
$tk = parent::$testKeys;
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);
$bounces = $client->getBounces(10, 0);
$id = $bounces->Bounces[0]->getID();
$dump = $client->getBounceDump($id);
$this->assertNotEmpty($dump);
$this->assertNotEmpty($dump->getBody());
}

}
9 changes: 8 additions & 1 deletion tests/PostmarkClientInboundMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ public function testClientCanGetInboundMessageDetails()
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);

$retrievedMessages = $client->getInboundMessages(10);
$baseMessageId = $retrievedMessages->getInboundMessages()[0]->getMessageID();
$inboundMessages = $retrievedMessages->getInboundMessages();

if (empty($inboundMessages)) {
$this->markTestSkipped('No inbound messages available for testing');
return;
}

$baseMessageId = $inboundMessages[0]->getMessageID();
$message = $client->getInboundMessageDetails($baseMessageId);

$this->assertNotEmpty($message);
Expand Down
19 changes: 16 additions & 3 deletions tests/PostmarkClientOutboundMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ public function testClientCanGetOutboundMessageDetails()
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);

$retrievedMessages = $client->getOutboundMessages(1, 50);

$baseMessageId = $retrievedMessages->getMessages()[0]->getMessageID();
$messages = $retrievedMessages->getMessages();

if (empty($messages)) {
$this->markTestSkipped('No outbound messages available for testing');
return;
}

$baseMessageId = $messages[0]->getMessageID();
$message = $client->getOutboundMessageDetails($baseMessageId);

$this->assertNotEmpty($message);
Expand All @@ -42,7 +48,14 @@ public function testClientCanGetOutboundMessageDump()
$client = new PostmarkClient($tk->READ_SELENIUM_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);

$retrievedMessages = $client->getOutboundMessages(1, 50);
$baseMessageId = $retrievedMessages->getMessages()[0]->getMessageID();
$messages = $retrievedMessages->getMessages();

if (empty($messages)) {
$this->markTestSkipped('No outbound messages available for testing');
return;
}

$baseMessageId = $messages[0]->getMessageID();
$message = $client->getOutboundMessageDump($baseMessageId);

$this->assertNotEmpty($message);
Expand Down
17 changes: 12 additions & 5 deletions tests/PostmarkClientSuppressionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ public static function tearDownAfterClass(): void
$client = new PostmarkClient($tk->WRITE_TEST_SERVER_TOKEN, $tk->TEST_TIMEOUT);

// remove all suppressions on the default stream
$sups = $client->getSuppressions();
foreach ($sups->getSuppressions() as $sup) {
$suppressionChanges = [new SuppressionChangeRequest($sup->getEmailAddress())];
$messageStream = 'outbound';
$client->deleteSuppressions($suppressionChanges, $messageStream);
try {
$sups = $client->getSuppressions();
$suppressions = $sups->getSuppressions();
if (!empty($suppressions)) {
foreach ($suppressions as $sup) {
$suppressionChanges = [new SuppressionChangeRequest($sup->getEmailAddress())];
$messageStream = 'outbound';
$client->deleteSuppressions($suppressionChanges, $messageStream);
}
}
} catch (PostmarkException $e) {
// Ignore errors during cleanup
}
}

Expand Down