-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rate.php
37 lines (34 loc) · 1.05 KB
/
Rate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace flydreamers\shipwire;
use flydreamers\shipwire\base\ShipwireComponent;
class Rate extends ShipwireComponent
{
/**
* Get a quote for a shippment of $items to $address. $options could be changed for different use cases.
*
* @param Address $address
* @param array $items [['sku' => 'CAPTRACKERBLUE', 'quantity' => 3]]
* @param array $options for example: ["currency" => "USD", "groupBy" => "all", "canSplit" => 1, "warehouseArea" => "US"]
*
* @return array
*/
public function quote(Address $address, $items = [], $options = [])
{
if (count($options)==0) {
$options = [
"currency" => "USD",
"groupBy" => "all",
"canSplit" => 1,
"warehouseArea" => "US"
];
}
$json = json_encode([
'options' => $options,
'order'=>[
'shipTo'=>$address->asArray(),
'items'=>$items,
]
]);
return $this->post('rate', [], $json);
}
}