Skip to content

Commit

Permalink
Merge pull request #6 from MyParcelCOM/feature/shipments
Browse files Browse the repository at this point in the history
✨ Implemented shipments endpoints
  • Loading branch information
SAMDevelopment authored Nov 14, 2017
2 parents 47e73ff + 4e692fe commit c6766ae
Show file tree
Hide file tree
Showing 25 changed files with 1,987 additions and 191 deletions.
288 changes: 147 additions & 141 deletions src/MyParcelComApi.php

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/MyParcelComApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface MyParcelComApiInterface
const PATH_PUDO_LOCATIONS = '/v1/carriers/{carrier_id}/pickup-dropoff-locations/{country_code}/{postal_code}';
const PATH_REGIONS = '/v1/regions';
const PATH_SERVICES = '/v1/services';
const PATH_SHIPMENTS = '/v1/shipments';
const PATH_SHOPS = '/v1/shops';

/**
Expand Down Expand Up @@ -141,4 +142,12 @@ public function createShipment(ShipmentInterface $shipment);
* @return ResourceInterface
*/
public function getResourceById($resourceType, $id);

/**
* Get an array of all the resources from given uri.
*
* @param string $uri
* @return ResourceInterface[]
*/
public function getResourcesFromUri($uri);
}
140 changes: 140 additions & 0 deletions src/Resources/Proxy/RegionProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php

namespace MyParcelCom\Sdk\Resources\Proxy;

use MyParcelCom\Sdk\Resources\Interfaces\RegionInterface;
use MyParcelCom\Sdk\Resources\Interfaces\ResourceInterface;
use MyParcelCom\Sdk\Resources\Interfaces\ResourceProxyInterface;
use MyParcelCom\Sdk\Resources\Traits\JsonSerializable;
use MyParcelCom\Sdk\Resources\Traits\ProxiesResource;

class RegionProxy implements RegionInterface, ResourceProxyInterface
{
use JsonSerializable;
use ProxiesResource;

/** @var string */
private $id;
/** @var string */
private $type = ResourceInterface::TYPE_REGION;

/**
* Set the identifier for this file.
*
* @param string $id
* @return $this
*/
public function setId($id)
{
$this->id = $id;

return $this;
}

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

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

/**
* @param string $countryCode
* @return $this
*/
public function setCountryCode($countryCode)
{
$this->getResource()->setCountryCode($countryCode);

return $this;
}

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

/**
* @param string $regionCode
* @return $this
*/
public function setRegionCode($regionCode)
{
$this->getResource()->setRegionCode($regionCode);

return $this;
}

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

/**
* @param string $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->getResource()->setCurrency($currency);

return $this;
}

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

/**
*
* @param string $name
* @return $this
*/
public function setName($name)
{
$this->getResource()->setName($name);

return $this;
}

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

/**
* This function puts all object properties in an array and returns it.
*
* @return array
*/
public function jsonSerialize()
{
$values = get_object_vars($this);
unset($values['resource']);
unset($values['api']);

return $this->arrayValuesToArray($values);
}
}
161 changes: 161 additions & 0 deletions src/Resources/Proxy/ShopProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php

namespace MyParcelCom\Sdk\Resources\Proxy;

use DateTime;
use MyParcelCom\Sdk\Resources\Interfaces\AddressInterface;
use MyParcelCom\Sdk\Resources\Interfaces\RegionInterface;
use MyParcelCom\Sdk\Resources\Interfaces\ResourceInterface;
use MyParcelCom\Sdk\Resources\Interfaces\ResourceProxyInterface;
use MyParcelCom\Sdk\Resources\Interfaces\ShopInterface;
use MyParcelCom\Sdk\Resources\Traits\JsonSerializable;
use MyParcelCom\Sdk\Resources\Traits\ProxiesResource;

class ShopProxy implements ShopInterface, ResourceProxyInterface
{
use JsonSerializable;
use ProxiesResource;

/** @var string */
private $id;
/** @var string */
private $type = ResourceInterface::TYPE_SHOP;

/**
* Set the identifier for this file.
*
* @param string $id
* @return $this
*/
public function setId($id)
{
$this->id = $id;

return $this;
}

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

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

/**
* @param $name
* @return $this
*/
public function setName($name)
{
$this->getResource()->setName($name);

return $this;
}

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

/**
* @param AddressInterface $billingAddress
* @return $this
*/
public function setBillingAddress(AddressInterface $billingAddress)
{
$this->getResource()->setBillingAddress($billingAddress);

return $this;
}

/**
* @return AddressInterface
*/
public function getBillingAddress()
{
return $this->getResource()->getBillingAddress();
}

/**
* @param AddressInterface $returnAddress
* @return $this
*/
public function setReturnAddress(AddressInterface $returnAddress)
{
$this->getResource()->setReturnAddress($returnAddress);

return $this;
}

/**
* @return AddressInterface
*/
public function getReturnAddress()
{
return $this->getResource()->getReturnAddress();
}

/**
* @param RegionInterface $region
* @return $this
*/
public function setRegion(RegionInterface $region)
{
$this->getResource()->setRegion($region);

return $this;
}

/**
* @return RegionInterface
*/
public function getRegion()
{
return $this->getResource()->getRegion();
}

/**
* @param int|DateTime $time
* @return $this
*/
public function setCreatedAt($time)
{
$this->getResource()->setCreatedAt($time);

return $this;
}

/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->getResource()->getCreatedAt();
}

/**
* This function puts all object properties in an array and returns it.
*
* @return array
*/
public function jsonSerialize()
{
$values = get_object_vars($this);
unset($values['resource']);
unset($values['api']);

return $this->arrayValuesToArray($values);
}
}
Loading

0 comments on commit c6766ae

Please sign in to comment.