1 | <?php |
||
19 | class Api |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Module class instance |
||
24 | * @var \gplcart\core\Module $module |
||
25 | */ |
||
26 | protected $module; |
||
27 | |||
28 | /** |
||
29 | * Library class instance |
||
30 | * @var \gplcart\core\Library $library |
||
31 | */ |
||
32 | protected $library; |
||
33 | |||
34 | /** |
||
35 | * @param Library $library |
||
36 | * @param Module $module |
||
37 | */ |
||
38 | public function __construct(Library $library, Module $module) |
||
43 | |||
44 | /** |
||
45 | * Returns either live or test token |
||
46 | * @return string |
||
47 | */ |
||
48 | protected function getToken() |
||
58 | |||
59 | /** |
||
60 | * Performs request to Shippo's API to get shipping rates |
||
61 | * @param array $from |
||
62 | * @param array $to |
||
63 | * @param array $parcel |
||
64 | * @return array |
||
65 | * @throws LogicException |
||
66 | */ |
||
67 | public function getRates(array $from, array $to, array $parcel) |
||
98 | |||
99 | /** |
||
100 | * Creates a Shippo address object |
||
101 | * @param array $address |
||
102 | * @param array $options |
||
103 | * @return array |
||
104 | * @throws LogicException |
||
105 | */ |
||
106 | public function createAddress(array $address, array $options = array()) |
||
124 | |||
125 | /** |
||
126 | * Validates an address |
||
127 | * @param array $address |
||
128 | * @return boolean|array |
||
129 | */ |
||
130 | public function isValidAddress(array $address) |
||
154 | |||
155 | /** |
||
156 | * Request shipping label and tracking number |
||
157 | * @param string $object_id |
||
158 | * @param array $options |
||
159 | * @return array |
||
160 | * @throws LogicException |
||
161 | */ |
||
162 | public function getLabel($object_id, array $options = array()) |
||
185 | |||
186 | } |
||
187 |