-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Большой рефакторинг; выпилен jms/serializer; WIP #10: создание и удал…
…ение заказов
- Loading branch information
Showing
34 changed files
with
1,251 additions
and
767 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
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,19 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of RussianPost SDK package. | ||
* | ||
* © Appwilio (http://appwilio.com), JhaoDa (https://github.com/jhaoda) | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Appwilio\RussianPostSDK\Dispatching\Contracts; | ||
|
||
interface DispatchingException | ||
{ | ||
// | ||
} |
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
100 changes: 100 additions & 0 deletions
100
src/Dispatching/Endpoints/Orders/Entites/CustomsDeclaration.php
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,100 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Entites; | ||
|
||
use Appwilio\RussianPostSDK\Dispatching\DataAware; | ||
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; | ||
|
||
final class CustomsDeclaration implements Arrayable | ||
{ | ||
use DataAware; | ||
|
||
/** @var CustomsDeclarationItem[] */ | ||
private $items; | ||
|
||
public function __construct($entriesType, $currency) | ||
{ | ||
$this->data['entries-type'] = $entriesType; | ||
$this->data['currency'] = $currency; | ||
} | ||
|
||
public function addItem(CustomsDeclarationItem $item): void | ||
{ | ||
$this->items[] = $item; | ||
} | ||
|
||
public function addInvoice(string $number) | ||
{ | ||
$this->data['with-invoice'] = true; | ||
$this->data['invoice-number'] = $number; | ||
|
||
return $this; | ||
} | ||
|
||
public function addCertificate(string $number) | ||
{ | ||
$this->data['with-certificate'] = true; | ||
$this->data['certificate-number'] = $number; | ||
|
||
return $this; | ||
} | ||
|
||
public function addLicense(string $number) | ||
{ | ||
$this->data['with-license'] = true; | ||
$this->data['license-number'] = $number; | ||
|
||
return $this; | ||
} | ||
|
||
public function getCurrency(): string | ||
{ | ||
return $this->get('entries-type'); | ||
} | ||
|
||
public function getEntriesType(): string | ||
{ | ||
return $this->get('invoice-number'); | ||
} | ||
|
||
public function getInvoice(): ?string | ||
{ | ||
return $this->get('invoice-number'); | ||
} | ||
|
||
public function getCertificate(): ?string | ||
{ | ||
return $this->get('certificate-number'); | ||
} | ||
|
||
public function getLicense(): ?string | ||
{ | ||
return $this->get('license-number'); | ||
} | ||
|
||
public function hasInvoice(): bool | ||
{ | ||
return (bool) $this->get('with-invoice'); | ||
} | ||
|
||
public function hasCertificate(): bool | ||
{ | ||
return (bool) $this->get('with-certificate'); | ||
} | ||
|
||
public function hasLicense(): bool | ||
{ | ||
return (bool) $this->get('with-license'); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
foreach ($this->items as $entry) { | ||
$this->data['customs-entries'][] = $entry->toArray(); | ||
} | ||
|
||
return $this->data; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/Dispatching/Endpoints/Orders/Entites/CustomsDeclarationItem.php
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Entites; | ||
|
||
use Appwilio\RussianPostSDK\Dispatching\DataAware; | ||
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; | ||
|
||
final class CustomsDeclarationItem implements Arrayable | ||
{ | ||
use DataAware; | ||
|
||
public function __construct( | ||
string $description, | ||
int $quantity, | ||
string $country, | ||
string $tnvedCode, | ||
int $value = null, | ||
int $weight = null | ||
) { | ||
$this->data['description'] = $description; | ||
$this->data['amount'] = $quantity; | ||
$this->data['country-code'] = $country; | ||
$this->data['tnved-code'] = $tnvedCode; | ||
$this->data['value'] = $value; | ||
$this->data['weight'] = $weight; | ||
} | ||
|
||
public function getDescription(): ?string | ||
{ | ||
return $this->get('description'); | ||
} | ||
|
||
public function getQuantity(): ?int | ||
{ | ||
return $this->get('amount'); | ||
} | ||
|
||
public function getCountryCode(): ?int | ||
{ | ||
return $this->get('country-code'); | ||
} | ||
|
||
public function getValue(): ?int | ||
{ | ||
return $this->get('value'); | ||
} | ||
|
||
public function getWeight(): ?int | ||
{ | ||
return $this->get('weight'); | ||
} | ||
|
||
public function getTnvedCode(): ?string | ||
{ | ||
return $this->get('tnved-code'); | ||
} | ||
} |
Oops, something went wrong.