From a2ff4541b902d00e0be0480841d5f3f363976b35 Mon Sep 17 00:00:00 2001 From: Andrew Theken Date: Mon, 3 Aug 2015 15:24:19 -0400 Subject: [PATCH] Adding filtering and retry for inbound/outbound messages. --- src/Postmark/PostmarkClient.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Postmark/PostmarkClient.php b/src/Postmark/PostmarkClient.php index 277c4512..2b82b637 100644 --- a/src/Postmark/PostmarkClient.php +++ b/src/Postmark/PostmarkClient.php @@ -278,10 +278,14 @@ function editServer($name = NULL, $color = NULL, $rawEmailEnabled = NULL, * @param string $fromEmail Filter by sender email address. * @param string $tag Filter by tag. * @param string $subject Filter by subject. + * @param string $status The current status for the outbound messages to return defaults to 'sent' + * @param string $fromdate Filter to messages on or after YYYY-MM-DD + * @param string $todate Filter to messages on or before YYYY-MM-DD * @return DyanamicResponseModel */ function getOutboundMessages($count = 100, $offset = 0, $recipient = NULL, - $fromEmail = NULL, $tag = NULL, $subject = NULL) { + $fromEmail = NULL, $tag = NULL, $subject = NULL, $status = NULL, + $fromdate = NULL, $todate = NULL) { $query = array(); $query["recipient"] = $recipient; @@ -290,6 +294,9 @@ function getOutboundMessages($count = 100, $offset = 0, $recipient = NULL, $query["subject"] = $subject; $query["count"] = $count; $query["offset"] = $offset; + $query["status"] = $status; + $query["fromdate"] = $fromdate; + $query["todate"] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/outbound', $query)); } @@ -325,10 +332,13 @@ function getOutboundMessageDump($id) { * @param string $subject Filter by the message subject * @param string $mailboxHash Filter by the mailboxHash * @param string $status Filter by status ('blocked' or 'processed') + * @param string $fromdate Filter to messages on or after YYYY-MM-DD + * @param string $todate Filter to messages on or before YYYY-MM-DD * @return DynamicResponseModel */ function getInboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromEmail = NULL, - $tag = NULL, $subject = NULL, $mailboxHash = NULL, $status = NULL) { + $tag = NULL, $subject = NULL, $mailboxHash = NULL, $status = NULL, $fromdate = NULL, + $todate = NULL) { $query = array(); $query['recipient'] = $recipient; @@ -339,6 +349,8 @@ function getInboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromE $query['count'] = $count; $query['status'] = $status; $query['offset'] = $offset; + $query['fromdate'] = $fromdate; + $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/inbound', $query)); } @@ -364,6 +376,16 @@ function bypassInboundMessageRules($id) { return new DynamicResponseModel($this->processRestRequest('PUT', "/messages/inbound/$id/bypass")); } + /** + * Request that Postmark retry POSTing the specified message to the Server's Inbound Hook. + * + * @param integer $id The ID for a message that we wish retry the inbound hook for. + * @return DynamicResponseModel + */ + function retryInboundMessageHook($id) { + return new DynamicResponseModel($this->processRestRequest('PUT', "/messages/inbound/$id/retry")); + } + /** * Get statistics for tracked messages, optionally filtering by various open event properties. *