Skip to content

Commit

Permalink
Dispatch Xml Parser : add batchid
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanV committed Mar 14, 2019
1 parent e834c4d commit 7aed6ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Esendex/Model/ResultItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ class ResultItem
{
private $id;
private $uri;
private $batchid;

/**
* @param $id
* @param $uri
* @param $batchid
*/
public function __construct($id, $uri)
public function __construct($id, $uri, $batchid = '')
{
$this->id = (string)$id;
$this->uri = (string)$uri;
$this->batchid = (string)$batchid;
}

/**
Expand All @@ -64,4 +67,12 @@ public function uri()
{
return $this->uri;
}

/**
* @return string
*/
public function batchid()
{
return $this->batchid;
}
}
4 changes: 3 additions & 1 deletion src/Esendex/Parser/DispatchXmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ public function parse($xml)
throw new XmlException("Xml is missing <messageheaders /> root element");

$results = array();
$batchid = $headers['batchid'];

foreach ($headers->messageheader as $header)
{
$results[] = new ResultItem($header["id"], $header["uri"]);
$results[] = new ResultItem($header["id"], $header["uri"], $batchid);
}

return $results;
Expand Down

0 comments on commit 7aed6ad

Please sign in to comment.