From 06e33db1b817c0065757106b69065fa9b3582fdb Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Thu, 2 Sep 2021 17:44:51 -0700 Subject: [PATCH] Add fields required for ExpectedDeliveryDate to be returned https://www.usps.com/business/web-tools-apis/track-and-confirm-api.htm https://stackoverflow.com/questions/23902091/usps-tracking-api-expected-delivery-date --- src/TrackConfirm.php | 61 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/TrackConfirm.php b/src/TrackConfirm.php index bebaa59..b96277e 100644 --- a/src/TrackConfirm.php +++ b/src/TrackConfirm.php @@ -11,6 +11,18 @@ class TrackConfirm extends USPSBase * @var string - the api version used for this type of call */ protected $apiVersion = 'TrackV2'; + /** + * @var string - revision version for including additional response fields + */ + protected $revision = ''; + /** + * @var string - User IP address. Required when TrackFieldRequest[Revision=’1’]. + */ + protected $clientIp = ''; + /** + * @var string - Internal User Identification. Required when TrackFieldRequest[Revision=’1’]. + */ + protected $sourceId = ''; /** * @var array - list of all packages added so far */ @@ -38,7 +50,12 @@ public function getTracking() */ public function getPostFields() { - return $this->packages; + $postFields = array(); + if ( !empty($this->revision) ) { $postFields['Revision'] = $this->revision; } + if ( !empty($this->revision) ) { $postFields['ClientIp'] = $this->clientIp; } + if ( !empty($this->revision) ) { $postFields['SourceId'] = $this->sourceId; } + + return array_merge($postFields, $this->packages); } /** @@ -52,4 +69,46 @@ public function addPackage($id) { $this->packages['TrackID'][] = ['@attributes' => ['ID' => $id]]; } + + /** + * Set the revision value + * + * @param string|int $value + * + * @return object AddressVerify + */ + public function setRevision($value) + { + $this->revision = (string)$value; + + return $this; + } + + /** + * Set the ClientIp value + * + * @param string $value + * + * @return object AddressVerify + */ + public function setClientIp($value) + { + $this->clientIp = (string)$value; + + return $this; + } + + /** + * Set the SourceId value + * + * @param string $value + * + * @return object AddressVerify + */ + public function setSourceId($value) + { + $this->sourceId = (string)$value; + + return $this; + } }