Skip to content

Commit

Permalink
fixed incorrect services tags generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurimas Baubkus committed Jul 16, 2018
1 parent 96f6d41 commit 759981b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function getName(): string
return $this->name;
}

public function setPhone(string $phone): self
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}

public function getPhone(): string
public function getPhone(): ?string
{
return $this->phone;
}
Expand Down
19 changes: 13 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(string $username, string $password)

/**
* returned object structure:
*
*
* object(stdClass)#11 (4) {
* ["partner"]=> "string"
* ["provider"]=> "string, example: EEPOST"
Expand Down Expand Up @@ -79,7 +79,9 @@ public function createShipment(Parcel $parcel): stdClass
if ($parcel->hasServices()) {
$writer->startElement('add_service');
foreach ($parcel->getServices() as $service) {
$writer->writeElement('option', $service->getValue());
$writer->startElement('option');
$writer->writeAttribute('code', $service->getValue());
$writer->endElement();
}
$writer->endElement();
}
Expand All @@ -90,8 +92,13 @@ public function createShipment(Parcel $parcel): stdClass

if ($parcel->getCodAmount()) {
$writer->startElement('monetary_values');
$writer->writeElement('item_value', $parcel->getCodAmount());
$writer->endDocument();

$writer->startElement('values');
$writer->writeAttribute('code', 'item_value');
$writer->writeAttribute('amount', $parcel->getCodAmount());
$writer->endElement();

$writer->endElement();

$writer->writeElement('account', $parcel->getBankAccount());
}
Expand Down Expand Up @@ -165,10 +172,10 @@ public function createShipment(Parcel $parcel): stdClass
new SoapVar($writer->outputMemory(), XSD_ANYXML)
);
}

/**
* response structure
*
*
* object(stdClass)#8 (3) {
* ["partner"]=> "string"
* ["failedAddressCards"]=> object(stdClass)#9 (0) {}
Expand Down

0 comments on commit 759981b

Please sign in to comment.