Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rimantas Ričkus committed May 6, 2024
1 parent 6fef6b1 commit faa4a11
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/Nodes/Order/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace Naugrim\OpenTrans\Nodes\Order;

use JMS\Serializer\Annotation as Serializer;
use Naugrim\OpenTrans\Nodes\Party;
use Naugrim\OpenTrans\Nodes\Remarks;
use Naugrim\BMEcat\Builder\NodeBuilder;
use Naugrim\BMEcat\Exception\InvalidSetterException;
use Naugrim\OpenTrans\Nodes\DeliveryDate;
use Naugrim\OpenTrans\Nodes\UdxAggregate;
use JMS\Serializer\Annotation as Serializer;
use Naugrim\OpenTrans\Nodes\Payment\Payment;
use Naugrim\BMEcat\Exception\UnknownKeyException;
use Naugrim\BMEcat\Nodes\Contracts\NodeInterface;
use Naugrim\OpenTrans\Nodes\Concerns\HasUdxItems;
use Naugrim\OpenTrans\Nodes\DeliveryDate;
use Naugrim\OpenTrans\Nodes\Party;
use Naugrim\OpenTrans\Nodes\Payment\Payment;
use Naugrim\OpenTrans\Nodes\UdxAggregate;
use Naugrim\BMEcat\Exception\InvalidSetterException;

class Info implements NodeInterface
{
Expand Down Expand Up @@ -93,7 +94,7 @@ class Info implements NodeInterface

/**
* @Serializer\Expose
* @Serializer\Type("array<Naugrim\OpenTrans\Nodes\Order\Remarks>")
* @Serializer\Type("array<Naugrim\OpenTrans\Nodes\Remarks>")
* @Serializer\SerializedName("REMARKS")
* @Serializer\XmlList(inline = true, entry = "REMARKS")
*
Expand Down
52 changes: 49 additions & 3 deletions src/Nodes/OrderChange/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace Naugrim\OpenTrans\Nodes\OrderChange;

use JMS\Serializer\Annotation as Serializer;
use Naugrim\OpenTrans\Nodes\Party;
use Naugrim\OpenTrans\Nodes\Remarks;
use Naugrim\BMEcat\Builder\NodeBuilder;
use Naugrim\BMEcat\Exception\InvalidSetterException;
use JMS\Serializer\Annotation as Serializer;
use Naugrim\BMEcat\Exception\UnknownKeyException;
use Naugrim\BMEcat\Nodes\Contracts\NodeInterface;
use Naugrim\OpenTrans\Nodes\Order\PartiesReference;
use Naugrim\OpenTrans\Nodes\Party;
use Naugrim\BMEcat\Exception\InvalidSetterException;

class Info implements NodeInterface
{
Expand Down Expand Up @@ -59,6 +60,16 @@ class Info implements NodeInterface
*/
protected $partiesReference;

/**
* @Serializer\Expose
* @Serializer\Type("array<Naugrim\OpenTrans\Nodes\Remarks>")
* @Serializer\SerializedName("REMARKS")
* @Serializer\XmlList(inline = true, entry = "REMARKS")
*
* @var Remarks[]
*/
protected $remarks;

/**
* @return string
*/
Expand Down Expand Up @@ -165,4 +176,39 @@ public function setPartiesReference(PartiesReference $partiesReference): Info
$this->partiesReference = $partiesReference;
return $this;
}

/**
* @return Remarks[]
*/
public function getRemarks(): array
{
return $this->remarks;
}

/**
* @param Remarks[] $remarks
* @return Info
* @throws InvalidSetterException
* @throws UnknownKeyException
*/
public function setRemarks(array $remarks): Info
{
foreach ($remarks as $remark) {
if (!$remark instanceof Remarks) {
$remark = NodeBuilder::fromArray($remark, new Remarks());
}
$this->addRemark($remark);
}
return $this;
}

/**
* @param Remarks $remark
* @return $this
*/
public function addRemark(Remarks $remark)
{
$this->remarks[] = $remark;
return $this;
}
}
2 changes: 1 addition & 1 deletion src/Nodes/Order/Remarks.php → src/Nodes/Remarks.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Naugrim\OpenTrans\Nodes\Order;
namespace Naugrim\OpenTrans\Nodes;

use JMS\Serializer\Annotation as Serializer;
use Naugrim\BMEcat\Nodes\Contracts\NodeInterface;
Expand Down

0 comments on commit faa4a11

Please sign in to comment.