Skip to content

Commit 8bf9299

Browse files
author
Ash
committed
Add ShippingProductsEndpoint to client.
1 parent 48b2d3c commit 8bf9299

3 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Imbue\SendCloud\Endpoints;
4+
5+
use Imbue\SendCloud\Exceptions\ApiException;
6+
use Imbue\SendCloud\Resources\AbstractResource;
7+
use Imbue\SendCloud\Resources\Collections\AbstractCollection;
8+
use Imbue\SendCloud\Resources\Collections\ShippingProductCollection;
9+
use Imbue\SendCloud\Resources\ShippingProduct;
10+
11+
class ShippingProductsEndpoint extends AbstractEndpoint
12+
{
13+
/** @var string */
14+
protected $resourcePath = 'shipping_products';
15+
/** @var string */
16+
protected $singleResourceKey = 'shipping_product';
17+
18+
/**
19+
* @return mixed
20+
*/
21+
protected function getResourceObject(): ShippingProduct
22+
{
23+
return new ShippingProduct($this->client);
24+
}
25+
26+
/**
27+
* @return ShippingProductCollection
28+
*/
29+
protected function getResourceCollectionObject(): ShippingProductCollection
30+
{
31+
return new ShippingProductCollection(null, null);
32+
}
33+
34+
/**
35+
* @param $id
36+
* @param array $filters
37+
* @return AbstractResource
38+
* @throws ApiException
39+
*/
40+
public function get($id, array $filters = [])
41+
{
42+
return $this->restRead($id, $filters);
43+
}
44+
45+
/**
46+
* @param $filters
47+
* @return array|AbstractCollection
48+
* @throws ApiException
49+
*/
50+
public function list(array $filters = [])
51+
{
52+
return $this->restList($filters);
53+
}
54+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Imbue\SendCloud\Resources\Collections;
4+
5+
use Imbue\SendCloud\Resources\ShippingProduct;
6+
7+
class ShippingProductCollection extends AbstractCollection
8+
{
9+
/**
10+
* @return string
11+
*/
12+
public function getCollectionResourceName()
13+
{
14+
return 'shipping_products';
15+
}
16+
17+
/**
18+
* @return ShippingProduct
19+
*/
20+
protected function createResourceObject(): ShippingProduct
21+
{
22+
return new ShippingProduct($this->client);
23+
}
24+
}

src/SendCloudApiClient.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Imbue\SendCloud\Endpoints\ParcelStatusEndpoint;
1616
use Imbue\SendCloud\Endpoints\SenderAddressEndpoint;
1717
use Imbue\SendCloud\Endpoints\ShippingMethodEndpoint;
18+
use Imbue\SendCloud\Endpoints\ShippingProductsEndpoint;
1819
use Imbue\SendCloud\Endpoints\UserEndpoint;
1920
use Imbue\SendCloud\Exceptions\ApiException;
2021
use Psr\Http\Message\ResponseInterface;
@@ -58,6 +59,8 @@ class SendCloudApiClient
5859
public $parcelStatuses;
5960
/** @var ShippingMethodEndpoint */
6061
public $shippingMethods;
62+
/** @var ShippingProductsEndpoint */
63+
public $shippingProducts;
6164
/** @var LabelEndpoint */
6265
public $labels;
6366
/** @var InvoiceEndpoint */
@@ -97,6 +100,7 @@ public function initializeEndpoints()
97100
$this->parcels = new ParcelEndpoint($this);
98101
$this->parcelStatuses = new ParcelStatusEndpoint($this);
99102
$this->shippingMethods = new ShippingMethodEndpoint($this);
103+
$this->shippingProducts = new ShippingProductsEndpoint($this);
100104
$this->senderAddresses = new SenderAddressEndpoint($this);
101105
$this->labels = new LabelEndpoint($this);
102106
$this->invoices = new InvoiceEndpoint($this);

0 commit comments

Comments
 (0)