Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Add fields required for ExpectedDeliveryDate to be returned #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
61 changes: 60 additions & 1 deletion src/TrackConfirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
}
}