Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCP-4625] feat: support new additional billing information #185

Merged
merged 6 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
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
30 changes: 30 additions & 0 deletions src/Factory/Xml/Order/ExtraBillingAttributesFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Linio\SellerCenter\Factory\Xml\Order;

use Linio\SellerCenter\Model\Order\ExtraBillingAttributes;
use SimpleXMLElement;

class ExtraBillingAttributesFactory
{
public static function make(SimpleXMLElement $element): ExtraBillingAttributes
{
return new ExtraBillingAttributes(
(string) $element->LegalId,
(string) $element->FiscalPerson,
(string) $element->DocumentType,
(string) $element->ReceiverRegion,
(string) $element->ReceiverAddress,
(string) $element->ReceiverPostcode,
(string) $element->ReceiverLegalName,
(string) $element->ReceiverMunicipality,
(string) $element->ReceiverTypeRegimen,
(string) $element->CustomerVerifierDigit,
(string) $element->ReceiverLocality,
(string) $element->ReceiverEmail,
(string) $element->ReceiverPhonenumber
);
}
}
6 changes: 5 additions & 1 deletion src/Factory/Xml/Order/OrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static function make(SimpleXMLElement $element): Order
: null
);

$extraBillingAttributes = !empty($element->ExtraBillingAttributes) ?
ExtraBillingAttributesFactory::make($element->ExtraBillingAttributes) : null;

return Order::fromData(
(int) $element->OrderId,
$orderNumber,
Expand All @@ -106,7 +109,8 @@ public static function make(SimpleXMLElement $element): Order
$statuses,
$businessInvoiceRequired,
$shippingType,
$operatorCode
$operatorCode,
$extraBillingAttributes
);
}
}
191 changes: 191 additions & 0 deletions src/Model/Order/ExtraBillingAttributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?php

declare(strict_types=1);

namespace Linio\SellerCenter\Model\Order;

use JsonSerializable;
use stdClass;

class ExtraBillingAttributes implements JsonSerializable
{
/**
* @var string|null
*/
protected $legalId;

/**
* @var string|null
*/
protected $fiscalPerson;

/**
* @var string|null
*/
protected $documentType;

/**
* @var string|null
*/
protected $receiverRegion;

/**
* @var string|null
*/
protected $receiverAddress;

/**
* @var string|null
*/
protected $receiverPostcode;

/**
* @var string|null
*/
protected $receiverLegalName;

/**
* @var string|null
*/
protected $receiverMunicipality;

/**
* @var string|null
*/
protected $receiverTypeRegimen;

/**
* @var string|null
*/
protected $customerVerifierDigit;

/**
* @var string|null
*/
protected $receiverLocality;

/**
* @var string|null
*/
protected $receiverEmail;

/**
* @var string|null
*/
protected $receiverPhonenumber;

public function __construct(
?string $legalId,
?string $fiscalPerson,
?string $documentType,
?string $receiverRegion,
?string $receiverAddress,
?string $receiverPostcode,
?string $receiverLegalName,
?string $receiverMunicipality,
?string $receiverTypeRegimen,
?string $customerVerifierDigit,
?string $receiverLocality,
?string $receiverEmail,
?string $receiverPhonenumber
) {
$this->legalId = !empty($legalId) ? $legalId : null;
$this->fiscalPerson = !empty($fiscalPerson) ? $fiscalPerson : null;
$this->documentType = !empty($documentType) ? $documentType : null;
$this->receiverRegion = !empty($receiverRegion) ? $receiverRegion : null;
$this->receiverAddress = !empty($receiverAddress) ? $receiverAddress : null;
$this->receiverPostcode = !empty($receiverPostcode) ? $receiverPostcode : null;
$this->receiverLegalName = !empty($receiverLegalName) ? $receiverLegalName : null;
$this->receiverMunicipality = !empty($receiverMunicipality) ? $receiverMunicipality : null;
$this->receiverTypeRegimen = !empty($receiverTypeRegimen) ? $receiverTypeRegimen : null;
$this->customerVerifierDigit = !empty($customerVerifierDigit) ? $customerVerifierDigit : null;
$this->receiverLocality = !empty($receiverLocality) ? $receiverLocality : null;
$this->receiverEmail = !empty($receiverEmail) ? $receiverEmail : null;
$this->receiverPhonenumber = !empty($receiverPhonenumber) ? $receiverPhonenumber : null;
}

public function getLegalId(): ?string
{
return $this->legalId;
}

public function getFiscalPerson(): ?string
{
return $this->fiscalPerson;
}

public function getDocumentType(): ?string
{
return $this->documentType;
}

public function getReceiverRegion(): ?string
{
return $this->receiverRegion;
}

public function getReceiverAddress(): ?string
{
return $this->receiverAddress;
}

public function getReceiverPostCode(): ?string
{
return $this->receiverPostcode;
}

public function getReceiverLegalName(): ?string
{
return $this->receiverLegalName;
}

public function getReceiverMunicipality(): ?string
{
return $this->receiverMunicipality;
}

public function getReceiverTypeRegimen(): ?string
{
return $this->receiverTypeRegimen;
}

public function getReceiverEmail(): ?string
{
return $this->receiverEmail;
}

public function getCustomerVerifierDigit(): ?string
{
return $this->customerVerifierDigit;
}

public function getReceiverLocality(): ?string
{
return $this->receiverLocality;
}

public function getReceiverPhoneNumber(): ?string
{
return $this->receiverPhonenumber;
}

public function jsonSerialize(): stdClass
{
$serialized = new stdClass();
$serialized->legalId = $this->legalId;
$serialized->fiscalPerson = $this->fiscalPerson;
$serialized->documentType = $this->documentType;
$serialized->receiverRegion = $this->receiverRegion;
$serialized->receiverAddress = $this->receiverAddress;
$serialized->receiverPostcode = $this->receiverPostcode;
$serialized->receiverLegalName = $this->receiverLegalName;
$serialized->receiverMunicipality = $this->receiverMunicipality;
$serialized->receiverTypeRegimen = $this->receiverTypeRegimen;
$serialized->customerVerifierDigit = $this->customerVerifierDigit;
$serialized->receiverLocality = $this->receiverLocality;
$serialized->receiverEmail = $this->receiverEmail;
$serialized->receiverPhonenumber = $this->receiverPhonenumber;

return $serialized;
}
}
15 changes: 14 additions & 1 deletion src/Model/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class Order implements JsonSerializable
*/
protected $shippingType;

/**
* @var ExtraBillingAttributes|null
*/
protected $extraBillingAttributes;

/**
* @param string[] $statuses
* @param string|int $orderNumber
Expand Down Expand Up @@ -163,7 +168,8 @@ public static function fromData(
array $statuses,
?bool $businessInvoiceRequired,
?string $shippingType,
?string $operatorCode = null
?string $operatorCode = null,
?ExtraBillingAttributes $extraBillingAttributes = null
): Order {
$order = new self();

Expand All @@ -190,6 +196,7 @@ public static function fromData(
$order->statuses = $statuses;
$order->businessInvoiceRequired = $businessInvoiceRequired;
$order->shippingType = $shippingType;
$order->extraBillingAttributes = $extraBillingAttributes;
$order->operatorCode = $operatorCode;

return $order;
Expand Down Expand Up @@ -340,6 +347,11 @@ public function getShippingType(): ?string
return $this->shippingType;
}

public function getExtraBillingAttributes(): ?ExtraBillingAttributes
{
return $this->extraBillingAttributes;
}

public function setOrderItems(OrderItems $orderItems): void
{
$this->orderItems = $orderItems;
Expand Down Expand Up @@ -372,6 +384,7 @@ public function jsonSerialize(): stdClass
$serialized->orderItems = $this->orderItems;
$serialized->businessInvoiceRequired = $this->businessInvoiceRequired;
$serialized->shippingType = $this->shippingType;
$serialized->extraBillingAttributes = $this->extraBillingAttributes;
$serialized->operatorCode = $this->operatorCode;

return $serialized;
Expand Down
Loading
Loading