1: <?php
2:
3: namespace ShippoClient;
4:
5: use ShippoClient\Entity\Address;
6: use ShippoClient\Http\Request;
7: use ShippoClient\Http\Request\Addresses\CreateObject;
8: use ShippoClient\Http\Response\AddressList;
9:
10: class Addresses
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('addresses', $createObj->toArray());
23:
24: return new Address($responseArray);
25: }
26:
27: public function retrieve($objectId)
28: {
29: $responseArray = $this->request->get("addresses/$objectId");
30:
31: return new Address($responseArray);
32: }
33:
34: public function validate($objectId)
35: {
36: $responseArray = $this->request->get("addresses/$objectId/validate");
37:
38: return new Address($responseArray);
39: }
40:
41: 42: 43: 44:
45: public function getList($results = null)
46: {
47: $responseArray = $this->request->get("addresses", ['results' => $results]);
48:
49: return new AddressList($responseArray);
50: }
51: }
52: