Skip to content

Commit

Permalink
Merge pull request #12 from MyParcelCOM/feature/customs
Browse files Browse the repository at this point in the history
Feature/customs
  • Loading branch information
SAMDevelopment authored Dec 6, 2017
2 parents a01655f + 972780d commit b1571f1
Show file tree
Hide file tree
Showing 17 changed files with 1,211 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Authentication/AuthenticatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface AuthenticatorInterface
const HEADER_ACCEPT = 'Accept';
const MIME_TYPE_JSONAPI = 'application/vnd.api+json';
const GRANT_CLIENT_CREDENTIALS = 'client_credentials';
const SCOPES = '';
const SCOPES = 'shipments.show shipments.manage shops.show';

/**
* Authenticate with the OAuth2 server and return the header to be used in
Expand Down
4 changes: 2 additions & 2 deletions src/MyParcelComApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\PromiseInterface;
use function GuzzleHttp\Psr7\parse_response;
use function GuzzleHttp\Psr7\str;
use GuzzleHttp\RequestOptions;
use MyParcelCom\Sdk\Authentication\AuthenticatorInterface;
use MyParcelCom\Sdk\Exceptions\InvalidResourceException;
Expand All @@ -29,6 +27,8 @@
use Symfony\Component\Cache\Simple\FilesystemCache;
use function GuzzleHttp\Promise\promise_for;
use function GuzzleHttp\Promise\unwrap;
use function GuzzleHttp\Psr7\parse_response;
use function GuzzleHttp\Psr7\str;

class MyParcelComApi implements MyParcelComApiInterface
{
Expand Down
127 changes: 127 additions & 0 deletions src/Resources/Customs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php

namespace MyParcelCom\Sdk\Resources;

use MyParcelCom\Sdk\Resources\Interfaces\CustomsInterface;
use MyParcelCom\Sdk\Resources\Interfaces\CustomsItemInterface;
use MyParcelCom\Sdk\Resources\Traits\JsonSerializable;

class Customs implements CustomsInterface
{
use JsonSerializable;

/** @var string */
private $contentType;
/** @var string */
private $invoiceNumber;
/** @var CustomsItemInterface[] */
private $items = [];
/** @var string */
private $nonDelivery;
/** @var string */
private $incoterm;

/**
* {@inheritdoc}
*/
public function getContentType()
{
return $this->contentType;
}

/**
* {@inheritdoc}
*/
public function setContentType($contentType)
{
$this->contentType = $contentType;

return $this;
}

/**
* {@inheritdoc}
*/
public function getInvoiceNumber()
{
return $this->invoiceNumber;
}

/**
* {@inheritdoc}
*/
public function setInvoiceNumber($invoiceNumber)
{
$this->invoiceNumber = $invoiceNumber;

return $this;
}

/**
* {@inheritdoc}
*/
public function getItems()
{
return $this->items;
}

/**
* {@inheritdoc}
*/
public function addItem(CustomsItemInterface $item)
{
$this->items[] = $item;

return $this;
}

/**
* {@inheritdoc}
*/
public function setItems(array $items)
{
$this->items = [];

array_walk($items, function (CustomsItemInterface $item) {
$this->addItem($item);
});

return $this;
}

/**
* {@inheritdoc}
*/
public function getNonDelivery()
{
return $this->nonDelivery;
}

/**
* {@inheritdoc}
*/
public function setNonDelivery($nonDelivery)
{
$this->nonDelivery = $nonDelivery;

return $this;
}

/**
* {@inheritdoc}
*/
public function getIncoterm()
{
return $this->incoterm;
}

/**
* {@inheritdoc}
*/
public function setIncoterm($incoterm)
{
$this->incoterm = $incoterm;

return $this;
}
}
163 changes: 163 additions & 0 deletions src/Resources/CustomsItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php

namespace MyParcelCom\Sdk\Resources;

use MyParcelCom\Sdk\Resources\Interfaces\CustomsItemInterface;
use MyParcelCom\Sdk\Resources\Traits\JsonSerializable;

class CustomsItem implements CustomsItemInterface
{
use JsonSerializable;

const AMOUNT = 'amount';
const CURRENCY = 'currency';

/** @var string */
private $sku;
/** @var string */
private $description;
/** @var string */
private $hsCode;
/** @var int */
private $quantity;
/** @var array */
private $itemValue = [
self::AMOUNT => null,
self::CURRENCY => null,
];
/** @var string */
private $originCountryCode;

/**
* @param string $sku
* @return $this
*/
public function setSku($sku)
{
$this->sku = $sku;

return $this;
}

/**
* @return string
*/
public function getSku()
{
return $this->sku;
}

/**
* @param string $description
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;

return $this;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}

/**
* @param string $hsCode
* @return $this
*/
public function setHsCode($hsCode)
{
$this->hsCode = $hsCode;

return $this;
}

/**
* @return string
*/
public function getHsCode()
{
return $this->hsCode;
}

/**
* @param int $quantity
* @return $this
*/
public function setQuantity($quantity)
{
$this->quantity = (int)$quantity;

return $this;
}

/**
* @return int
*/
public function getQuantity()
{
return $this->quantity;
}

/**
* @param int $value
* @return $this
*/
public function setItemValue($value)
{
$this->itemValue[self::AMOUNT] = (int)$value;

return $this;
}

/**
* @return int
*/
public function getItemValue()
{
return $this->itemValue[self::AMOUNT];
}

/**
* @param string $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->itemValue[self::CURRENCY] = $currency;

return $this;
}

/**
* @return string
*/
public function getCurrency()
{
return $this->itemValue[self::CURRENCY];
}

/**
* @param string $countryCode
* @return $this
*/
public function setOriginCountryCode($countryCode)
{
$this->originCountryCode = $countryCode;

return $this;
}

/**
* @return string
*/
public function getOriginCountryCode()
{
return $this->originCountryCode;
}
}
1 change: 0 additions & 1 deletion src/Resources/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use MyParcelCom\Sdk\Resources\Traits\JsonSerializable;
use Psr\Http\Message\StreamInterface;


class File implements FileInterface
{
use JsonSerializable;
Expand Down
Loading

0 comments on commit b1571f1

Please sign in to comment.