File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,36 @@ protected function restCreate(array $body)
6666 return ResourceFactory::createFromApiResult ($ result , $ this ->getResourceObject (), $ this ->getSingleResourceKey ());
6767 }
6868
69+ /**
70+ * @param array $body
71+ * @return AbstractCollection
72+ * @throws ApiException
73+ */
74+ protected function restCreateCollection (array $ body )
75+ {
76+ $ result = $ this ->client ->performHttpCall (
77+ self ::REST_CREATE ,
78+ $ this ->getResourcePath (),
79+ $ this ->parseRequestBody ($ body )
80+ );
81+
82+ /** @var AbstractCollection $collection */
83+ $ collection = $ this ->getResourceCollectionObject (
84+ null ,
85+ null
86+ );
87+
88+ if (is_object ($ result )) {
89+ $ result = $ result ->{$ collection ->getCollectionResourceName ()};
90+ }
91+
92+ foreach ($ result as $ dataResult ) {
93+ $ collection [] = ResourceFactory::createFromApiResult ($ dataResult , $ this ->getResourceObject ());
94+ }
95+
96+ return $ collection ;
97+ }
98+
6999 /**
70100 * @param $id
71101 * @param array $filters
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 \Collections \ParcelCollection ;
7+ use Imbue \SendCloud \Resources \GenericStatus ;
8+ use Imbue \SendCloud \Resources \Parcel ;
9+ use Imbue \SendCloud \Resources \ParcelMulti ;
10+ use Imbue \SendCloud \Resources \ResourceFactory ;
11+
12+ class ParcelMultiEndpoint extends AbstractEndpoint
13+ {
14+ /** @var string */
15+ protected $ resourcePath = 'parcels ' ;
16+
17+ /**
18+ * @return Parcel
19+ */
20+ protected function getResourceObject (): Parcel
21+ {
22+ return new Parcel ($ this ->client );
23+ }
24+
25+ /**
26+ * @param $previous
27+ * @param $next
28+ * @return ParcelCollection
29+ */
30+ protected function getResourceCollectionObject ($ previous , $ next ): ParcelCollection
31+ {
32+ return new ParcelCollection ($ this ->client , $ previous , $ next );
33+ }
34+
35+ /**
36+ * @param array $data
37+ * @return ParcelCollection
38+ * @throws ApiException
39+ */
40+ public function create (array $ data = []): ParcelCollection
41+ {
42+ return $ this ->restCreateCollection ($ data );
43+ }
44+ }
Original file line number Diff line number Diff line change 1212use Imbue \SendCloud \Endpoints \InvoiceEndpoint ;
1313use Imbue \SendCloud \Endpoints \LabelEndpoint ;
1414use Imbue \SendCloud \Endpoints \ParcelEndpoint ;
15+ use Imbue \SendCloud \Endpoints \ParcelMultiEndpoint ;
1516use Imbue \SendCloud \Endpoints \ParcelStatusEndpoint ;
1617use Imbue \SendCloud \Endpoints \SenderAddressEndpoint ;
1718use Imbue \SendCloud \Endpoints \ShippingMethodEndpoint ;
@@ -55,6 +56,8 @@ class SendCloudApiClient
5556
5657 /** @var ParcelEndpoint */
5758 public $ parcels ;
59+ /** @var ParcelMultiEndpoint */
60+ public $ parcelsMulti ;
5861 /** @var ParcelStatusEndpoint */
5962 public $ parcelStatuses ;
6063 /** @var ShippingMethodEndpoint */
@@ -98,6 +101,7 @@ public function __construct(ClientInterface $httpClient = null)
98101 public function initializeEndpoints ()
99102 {
100103 $ this ->parcels = new ParcelEndpoint ($ this );
104+ $ this ->parcelsMulti = new ParcelMultiEndpoint ($ this );
101105 $ this ->parcelStatuses = new ParcelStatusEndpoint ($ this );
102106 $ this ->shippingMethods = new ShippingMethodEndpoint ($ this );
103107 $ this ->shippingProducts = new ShippingProductsEndpoint ($ this );
You can’t perform that action at this time.
0 commit comments