1: <?php
2:
3: namespace ShippoClient;
4:
5: use ShippoClient\Entity\Shipment;
6: use ShippoClient\Http\Request;
7: use ShippoClient\Http\Request\Shipments\CreateObject;
8: use ShippoClient\Http\Request\Shipments\CreateObjectByNested;
9: use ShippoClient\Http\Response\RateList;
10: use ShippoClient\Http\Response\ShipmentList;
11:
12: class Shipments
13: {
14: private $request;
15:
16: public function __construct(Request $request)
17: {
18: $this->request = $request;
19: }
20:
21: public function create(array $attributes)
22: {
23: $createObj = new CreateObject($attributes);
24: $responseArray = $this->request->post('shipments', $createObj->toArray());
25:
26: return new Shipment($responseArray);
27: }
28:
29: public function createByNestedCall(array $attributes)
30: {
31: $createObj = new CreateObjectByNested($attributes);
32: $responseArray = $this->request->postWithJsonBody('shipments', $createObj->toArray());
33:
34: return new Shipment($responseArray);
35: }
36:
37: public function createReturn()
38: {
39:
40: }
41:
42: public function retrieve($objectId)
43: {
44: $responseArray = $this->request->get("shipments/$objectId");
45:
46: return new Shipment($responseArray);
47: }
48:
49: 50: 51: 52:
53: public function getList($results = null)
54: {
55: $responseArray = $this->request->get("shipments", ['results' => $results]);
56:
57: return new ShipmentList($responseArray);
58: }
59:
60: public function getRateList($objectId, $currencyCode = '')
61: {
62: $responseArray = $this->request->get("shipments/$objectId/rates/$currencyCode");
63:
64: return new RateList($responseArray);
65: }
66: }
67: