forked from ActiveCampaign/postmark-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from gsteel/client-clean-up
Client clean up
- Loading branch information
Showing
56 changed files
with
3,919 additions
and
3,224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ jobs: | |
|
||
- name: "Psalm" | ||
if: hashFiles('psalm.xml') != '' | ||
run: vendor/bin/psalm --output-format=github | ||
run: vendor/bin/psalm --shepherd --stats --output-format=github | ||
|
||
run-unit-tests: | ||
|
||
|
@@ -84,7 +84,7 @@ jobs: | |
composer-options: "${{ matrix.composer-options }}" | ||
|
||
- name: "Run Tests" | ||
run: php ./vendor/bin/phpunit --testsuite="Unit" --coverage-clover=coverage.xml | ||
run: php ./vendor/bin/phpunit --coverage-clover=coverage.xml | ||
|
||
- name: "Upload Coverage to CodeCov" | ||
uses: codecov/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<files psalm-version="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed"> | ||
<file src="src/Postmark/PostmarkAdminClient.php"> | ||
<MissingParamType occurrences="2"> | ||
<code>$offset</code> | ||
<code>$offset</code> | ||
</MissingParamType> | ||
<MixedAssignment occurrences="2"> | ||
<code>$query['offset']</code> | ||
<code>$query['offset']</code> | ||
</MixedAssignment> | ||
</file> | ||
<file src="src/Postmark/PostmarkClient.php"> | ||
<InvalidIterator occurrences="1"> | ||
<code>$metadata</code> | ||
</InvalidIterator> | ||
<InvalidParamDefault occurrences="2"> | ||
<code>string</code> | ||
<code>string</code> | ||
</InvalidParamDefault> | ||
<InvalidReturnStatement occurrences="1"> | ||
<code>new DynamicResponseModel($this->processRestRequest('GET', "/bounces/$id/dump"))</code> | ||
</InvalidReturnStatement> | ||
<InvalidReturnType occurrences="1"> | ||
<code>string</code> | ||
</InvalidReturnType> | ||
<MissingParamType occurrences="1"> | ||
<code>$headers</code> | ||
</MissingParamType> | ||
<MissingReturnType occurrences="1"> | ||
<code>fixHeaders</code> | ||
</MissingReturnType> | ||
<MixedArgument occurrences="2"> | ||
<code>$emailIdx</code> | ||
<code>$emailIdx</code> | ||
</MixedArgument> | ||
<MixedArrayAssignment occurrences="2"> | ||
<code>$email[$emailIdx]</code> | ||
<code>$email[$emailIdx]</code> | ||
</MixedArrayAssignment> | ||
<MixedAssignment occurrences="16"> | ||
<code>$body['Headers']</code> | ||
<code>$body['Headers']</code> | ||
<code>$email</code> | ||
<code>$email</code> | ||
<code>$emailIdx</code> | ||
<code>$emailIdx</code> | ||
<code>$emailValue</code> | ||
<code>$emailValue</code> | ||
<code>$email[$emailIdx]</code> | ||
<code>$email[$emailIdx]</code> | ||
<code>$final[]</code> | ||
<code>$key</code> | ||
<code>$key</code> | ||
<code>$query["metadata_$key"]</code> | ||
<code>$value</code> | ||
<code>$value</code> | ||
</MixedAssignment> | ||
<MixedInferredReturnType occurrences="2"> | ||
<code>DynamicResponseModel</code> | ||
<code>DynamicResponseModel</code> | ||
</MixedInferredReturnType> | ||
<UndefinedDocblockClass occurrences="4"> | ||
<code>HttpAuth</code> | ||
<code>HttpAuth</code> | ||
<code>WebhookConfigurationTriggers</code> | ||
<code>WebhookConfigurationTriggers</code> | ||
</UndefinedDocblockClass> | ||
</file> | ||
</files> | ||
<files psalm-version="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Postmark\ClientBehaviour; | ||
|
||
use Postmark\Models\DynamicResponseModel; | ||
|
||
use function sprintf; | ||
|
||
/** @internal \Postmark */ | ||
trait Bounces | ||
{ | ||
/** | ||
* Get a batch of bounces to be processed. | ||
* | ||
* @link http://developer.postmarkapp.com/developer-api-bounce.html#bounce-types) | ||
* | ||
* @param int $count Number of bounces to retrieve | ||
* @param int $offset How many bounces to skip (when paging through bounces.) | ||
* @param string|null $type The bounce type. | ||
* @param bool|null $inactive Specifies if the bounce caused Postmark to deactivate this email. | ||
* @param string|null $emailFilter Filter by email address | ||
* @param string|null $tag Filter by tag | ||
* @param string|null $messageID Filter by MessageID | ||
* @param string|null $fromdate Filter for bounces after is date. | ||
* @param string|null $todate Filter for bounces before this date. | ||
* @param string|null $messagestream Filter by Message Stream ID. If null, the default "outbound" | ||
* transactional stream will be used. | ||
*/ | ||
public function getBounces( | ||
int $count = 100, | ||
int $offset = 0, | ||
?string $type = null, | ||
?bool $inactive = null, | ||
?string $emailFilter = null, | ||
?string $tag = null, | ||
?string $messageID = null, | ||
?string $fromdate = null, | ||
?string $todate = null, | ||
?string $messagestream = null | ||
): DynamicResponseModel { | ||
$query = []; | ||
$query['type'] = $type; | ||
$query['inactive'] = $this->stringifyBoolean($inactive); | ||
$query['emailFilter'] = $emailFilter; | ||
$query['tag'] = $tag; | ||
$query['messageID'] = $messageID; | ||
$query['count'] = $count; | ||
$query['offset'] = $offset; | ||
$query['fromdate'] = $fromdate; | ||
$query['todate'] = $todate; | ||
$query['messagestream'] = $messagestream; | ||
|
||
return new DynamicResponseModel($this->processRestRequest('GET', '/bounces', $query)); | ||
} | ||
|
||
/** | ||
* Locate information on a specific email bounce. | ||
* | ||
* If the $id value is greater than PHP_INT_MAX, the ID can be passed as a string. | ||
* | ||
* @param int|numeric-string $id The ID of the bounce to get. | ||
*/ | ||
public function getBounce($id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('GET', sprintf('/bounces/%s', $id)) | ||
); | ||
} | ||
|
||
/** | ||
* Get a "dump" for a specific bounce. | ||
* | ||
* If the $id value is greater than PHP_INT_MAX, the ID can be passed as a string. | ||
* | ||
* @param int|numeric-string $id The ID of the bounce for which we want a dump. | ||
*/ | ||
public function getBounceDump($id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('GET', sprintf('/bounces/%s/dump', $id)) | ||
); | ||
} | ||
|
||
/** | ||
* Cause the email address associated with a Bounce to be reactivated. | ||
* | ||
* If the $id value is greater than PHP_INT_MAX, the ID can be passed as a string. | ||
* | ||
* @param int|numeric-string $id The bounce which has a deactivated email address. | ||
*/ | ||
public function activateBounce($id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('PUT', sprintf('/bounces/%s/activate', $id)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Postmark\ClientBehaviour; | ||
|
||
use Postmark\Models\DynamicResponseModel; | ||
|
||
use function sprintf; | ||
|
||
/** @internal \Postmark */ | ||
trait InboundMessages | ||
{ | ||
/** | ||
* Get messages sent to the inbound email address associated with this Server. | ||
* | ||
* @param int $count The number of inbound messages to retrieve in the request (defaults to 100) | ||
* @param int $offset The number of messages to 'skip' when 'paging' through messages (defaults to 0) | ||
* @param string|null $recipient Filter by the message recipient | ||
* @param string|null $fromEmail Filter by the message sender | ||
* @param string|null $tag Filter by the message tag | ||
* @param string|null $subject Filter by the message subject | ||
* @param string|null $mailboxHash Filter by the mailboxHash | ||
* @param string|null $status Filter by status ('blocked' or 'processed') | ||
* @param string|null $fromdate Filter to messages on or after YYYY-MM-DD | ||
* @param string|null $todate Filter to messages on or before YYYY-MM-DD | ||
*/ | ||
public function getInboundMessages( | ||
int $count = 100, | ||
int $offset = 0, | ||
?string $recipient = null, | ||
?string $fromEmail = null, | ||
?string $tag = null, | ||
?string $subject = null, | ||
?string $mailboxHash = null, | ||
?string $status = null, | ||
?string $fromdate = null, | ||
?string $todate = null | ||
): DynamicResponseModel { | ||
$query = []; | ||
$query['recipient'] = $recipient; | ||
$query['fromemail'] = $fromEmail; | ||
$query['tag'] = $tag; | ||
$query['subject'] = $subject; | ||
$query['mailboxhash'] = $mailboxHash; | ||
$query['count'] = $count; | ||
$query['status'] = $status; | ||
$query['offset'] = $offset; | ||
$query['fromdate'] = $fromdate; | ||
$query['todate'] = $todate; | ||
|
||
return new DynamicResponseModel($this->processRestRequest('GET', '/messages/inbound', $query)); | ||
} | ||
|
||
/** | ||
* Get details for a specific inbound message. | ||
* | ||
* @param string $id The ID of the message for which we went to get details. | ||
*/ | ||
public function getInboundMessageDetails(string $id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('GET', sprintf('/messages/inbound/%s/details', $id)) | ||
); | ||
} | ||
|
||
/** | ||
* Allow an inbound message to be processed, even though the filtering rules would normally | ||
* prevent it from being processed. | ||
* | ||
* @param string $id The ID for a message that we wish to unblock. | ||
*/ | ||
public function bypassInboundMessageRules(string $id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('PUT', sprintf('/messages/inbound/%s/bypass', $id)) | ||
); | ||
} | ||
|
||
/** | ||
* Request that Postmark retry POSTing the specified message to the Server's Inbound Hook. | ||
* | ||
* @param string $id The ID for a message that we wish retry the inbound hook for. | ||
*/ | ||
public function retryInboundMessageHook(string $id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('PUT', sprintf('/messages/inbound/%s/retry', $id)) | ||
); | ||
} | ||
|
||
/** | ||
* Create an Inbound Rule to block messages from a single email address, or an entire domain. | ||
* | ||
* @param string $rule The email address (or domain) that will be blocked. | ||
*/ | ||
public function createInboundRuleTrigger(string $rule): DynamicResponseModel | ||
{ | ||
$body = []; | ||
$body['Rule'] = $rule; | ||
|
||
return new DynamicResponseModel( | ||
$this->processRestRequest('POST', '/triggers/inboundrules', $body) | ||
); | ||
} | ||
|
||
/** | ||
* Get a list of all existing Inbound Rule Triggers. | ||
* | ||
* @param int $count The number of rule triggers to return with this request. | ||
* @param int $offset The number of triggers to 'skip' when 'paging' through rule triggers. | ||
*/ | ||
public function listInboundRuleTriggers(int $count = 100, int $offset = 0): DynamicResponseModel | ||
{ | ||
$query = []; | ||
|
||
$query['count'] = $count; | ||
$query['offset'] = $offset; | ||
|
||
return new DynamicResponseModel( | ||
$this->processRestRequest('GET', '/triggers/inboundrules', $query) | ||
); | ||
} | ||
|
||
/** | ||
* Delete an Inbound Rule Trigger. | ||
* | ||
* @param int $id The ID of the rule trigger we wish to delete. | ||
*/ | ||
public function deleteInboundRuleTrigger(int $id): DynamicResponseModel | ||
{ | ||
return new DynamicResponseModel( | ||
$this->processRestRequest('DELETE', sprintf('/triggers/inboundrules/%s', $id)) | ||
); | ||
} | ||
} |
Oops, something went wrong.