1: <?php
2:
3: namespace ShippoClient;
4:
5: use ShippoClient\Entity\Parcel;
6: use ShippoClient\Http\Request;
7: use ShippoClient\Http\Request\Parcels\CreateObject;
8: use ShippoClient\Http\Response\ParcelList;
9:
10: class Parcels
11: {
12: private $request;
13:
14: public function __construct(Request $request)
15: {
16: $this->request = $request;
17: }
18:
19: public function create(array $attributes)
20: {
21: $createObj = new CreateObject($attributes);
22: $responseArray = $this->request->post('parcels', $createObj->toArray());
23:
24: return new Parcel($responseArray);
25: }
26:
27: public function retrieve($objectId)
28: {
29: $responseArray = $this->request->get("parcels/$objectId");
30:
31: return new Parcel($responseArray);
32: }
33:
34: 35: 36: 37:
38: public function getList($results = null)
39: {
40: $responseArray = $this->request->get("parcels", ['results' => $results]);
41:
42: return new ParcelList($responseArray);
43: }
44: }
45: