File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1515use Imbue \SendCloud \Endpoints \ParcelStatusEndpoint ;
1616use Imbue \SendCloud \Endpoints \SenderAddressEndpoint ;
1717use Imbue \SendCloud \Endpoints \ShippingMethodEndpoint ;
18+ use Imbue \SendCloud \Endpoints \ShippingProductsEndpoint ;
1819use Imbue \SendCloud \Endpoints \UserEndpoint ;
1920use Imbue \SendCloud \Exceptions \ApiException ;
2021use 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 );
You can’t perform that action at this time.
0 commit comments