-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add some meaning text to CXmlModelNotFoundException * +CommentsTrait *+QuoteMessage * dont check for 8.2 for now :(
- Loading branch information
Showing
23 changed files
with
7,806 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,7 @@ jobs: | |
php-version: [ | ||
'7.4', | ||
'8.0', | ||
'8.1', | ||
'8.2', | ||
'8.1' | ||
] | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace CXml\Model; | ||
|
||
use JMS\Serializer\Annotation as Ser; | ||
|
||
trait CommentsTrait | ||
{ | ||
/** | ||
* @Ser\XmlList(inline=true, entry="Comments") | ||
* @Ser\Type("array<CXml\Model\Comment>") | ||
* | ||
* @var Comment[] | ||
*/ | ||
private ?array $comments = null; | ||
|
||
public function addCommentAsString(string $comment, string $type = null, string $lang = null): self | ||
{ | ||
if (null === $this->comments) { | ||
$this->comments = []; | ||
} | ||
|
||
return $this->addComment(new Comment($comment, $type, $lang)); | ||
} | ||
|
||
public function addComment(Comment $comment): self | ||
{ | ||
if (null === $this->comments) { | ||
$this->comments = []; | ||
} | ||
|
||
$this->comments[] = $comment; | ||
|
||
return $this; | ||
} | ||
|
||
public function getComments(): ?array | ||
{ | ||
return $this->comments; | ||
} | ||
|
||
public function getCommentsAsString(): ?string | ||
{ | ||
$commentStrings = []; | ||
|
||
if ($comments = $this->getComments()) { | ||
foreach ($comments as $comment) { | ||
$commentStrings[] = $comment->getValue(); | ||
} | ||
} | ||
|
||
return empty($commentStrings) ? null : \implode("\n", $commentStrings); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace CXml\Model\Message; | ||
|
||
use CXml\Model\MoneyWrapper; | ||
use CXml\Model\OrganizationId; | ||
use JMS\Serializer\Annotation as Ser; | ||
|
||
class QuoteMessage implements MessagePayloadInterface | ||
{ | ||
/** | ||
* @Ser\SerializedName("QuoteMessageHeader") | ||
*/ | ||
private QuoteMessageHeader $quoteMessageHeader; | ||
|
||
private function __construct(QuoteMessageHeader $quoteMessageHeader) | ||
{ | ||
$this->quoteMessageHeader = $quoteMessageHeader; | ||
} | ||
|
||
public static function create(OrganizationId $organizationId, MoneyWrapper $total, string $type, string $quoteId, \DateTime $quoteDate, string $lang = 'en'): self | ||
{ | ||
return new self( | ||
new QuoteMessageHeader($organizationId, $total, $type, $quoteId, $quoteDate, $total->getMoney()->getCurrency(), $lang) | ||
); | ||
} | ||
|
||
public function getQuoteMessageHeader(): QuoteMessageHeader | ||
{ | ||
return $this->quoteMessageHeader; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace CXml\Model\Message; | ||
|
||
use Assert\Assertion; | ||
use CXml\Model\CommentsTrait; | ||
use CXml\Model\Contact; | ||
use CXml\Model\ExtrinsicsTrait; | ||
use CXml\Model\MoneyWrapper; | ||
use CXml\Model\OrganizationId; | ||
use CXml\Model\ShipTo; | ||
use JMS\Serializer\Annotation as Ser; | ||
|
||
class QuoteMessageHeader | ||
{ | ||
use CommentsTrait; | ||
use ExtrinsicsTrait; | ||
|
||
public const TYPE_ACCEPT = 'accept'; | ||
public const TYPE_REJECT = 'reject'; | ||
public const TYPE_UPDATE = 'update'; | ||
public const TYPE_FINAL = 'final'; | ||
public const TYPE_AWARD = 'award'; | ||
|
||
/** | ||
* @Ser\SerializedName("type") | ||
* @Ser\XmlAttribute | ||
*/ | ||
private string $type; | ||
|
||
/** | ||
* @Ser\SerializedName("quoteID") | ||
* @Ser\XmlAttribute | ||
*/ | ||
private string $quoteId; | ||
|
||
/** | ||
* @Ser\XmlAttribute | ||
*/ | ||
private \DateTimeInterface $quoteDate; | ||
|
||
/** | ||
* @Ser\XmlAttribute | ||
*/ | ||
private string $currency; | ||
|
||
/** | ||
* @Ser\XmlAttribute(namespace="http://www.w3.org/XML/1998/namespace") | ||
*/ | ||
private string $lang; | ||
|
||
/** | ||
* @Ser\SerializedName("OrganizationID") | ||
* @Ser\XmlElement (cdata=false) | ||
*/ | ||
private OrganizationId $organizationId; | ||
|
||
/** | ||
* @Ser\SerializedName("Total") | ||
* @Ser\XmlElement (cdata=false) | ||
*/ | ||
private MoneyWrapper $total; | ||
|
||
/** | ||
* @Ser\SerializedName("ShipTo") | ||
* @Ser\XmlElement (cdata=false) | ||
*/ | ||
private ShipTo $shipTo; | ||
|
||
/** | ||
* @Ser\SerializedName("Contact") | ||
* @Ser\XmlElement (cdata=false) | ||
*/ | ||
private Contact $contact; | ||
|
||
public function __construct(OrganizationId $organizationId, MoneyWrapper $total, string $type, string $quoteId, \DateTime $quoteDate, string $currency, string $lang = 'en') | ||
{ | ||
Assertion::inArray($type, [ | ||
self::TYPE_ACCEPT, | ||
self::TYPE_REJECT, | ||
self::TYPE_UPDATE, | ||
self::TYPE_FINAL, | ||
self::TYPE_AWARD, | ||
]); | ||
|
||
$this->organizationId = $organizationId; | ||
$this->total = $total; | ||
$this->type = $type; | ||
$this->quoteId = $quoteId; | ||
$this->quoteDate = $quoteDate; | ||
$this->currency = $currency; | ||
$this->lang = $lang; | ||
} | ||
|
||
public function setShipTo(ShipTo $shipTo): self | ||
{ | ||
$this->shipTo = $shipTo; | ||
|
||
return $this; | ||
} | ||
|
||
public function setContact(Contact $contact): self | ||
{ | ||
$this->contact = $contact; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace CXml\Model; | ||
|
||
use JMS\Serializer\Annotation as Ser; | ||
|
||
class OrganizationId | ||
{ | ||
/** | ||
* @Ser\SerializedName("Credential") | ||
*/ | ||
private Credential $credential; | ||
|
||
public function __construct(Credential $credential) | ||
{ | ||
$this->credential = $credential; | ||
} | ||
|
||
public function getCredential(): Credential | ||
{ | ||
return $this->credential; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.