Skip to content

Commit

Permalink
Большой рефакторинг; выпилен jms/serializer; WIP #10: создание и удал…
Browse files Browse the repository at this point in the history
…ение заказов
  • Loading branch information
jhaoda committed Sep 10, 2019
1 parent 37d52ef commit 88e0103
Show file tree
Hide file tree
Showing 34 changed files with 1,251 additions and 767 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"php": ">=7.1",
"ext-json": "*",
"ext-soap": "*",
"guzzlehttp/guzzle": "^6.3",
"jms/serializer": "^1.11"
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
Expand Down
19 changes: 19 additions & 0 deletions src/Dispatching/Contracts/DispatchingException.php
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
{
//
}
3 changes: 2 additions & 1 deletion src/Dispatching/DispatchingClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Appwilio\RussianPostSDK\Dispatching\Http\ApiClient;
use Appwilio\RussianPostSDK\Dispatching\Http\Authorization;
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Orders;
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Services;
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Settings\Settings;
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Documents\Documents;
Expand All @@ -31,7 +32,7 @@ public function __construct(string $login, string $password, string $token, arra

public function orders()
{

return new Orders($this->client);
}

public function batches()
Expand Down
9 changes: 9 additions & 0 deletions src/Dispatching/Endpoints/Documents/Documents.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?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\Endpoints\Documents;
Expand Down
100 changes: 100 additions & 0 deletions src/Dispatching/Endpoints/Orders/Entites/CustomsDeclaration.php
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;
}
}
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');
}
}
Loading

0 comments on commit 88e0103

Please sign in to comment.