|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Nickcheek\USPSLookup\Service; |
|
4
|
|
|
|
|
5
|
|
|
use Nickcheek\USPSLookup\USPSLookup; |
|
6
|
|
|
|
|
7
|
|
|
class Price extends USPSLookup |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Check the price on package delivery depending on method. Available methods include: |
|
11
|
|
|
* First Class,First Class Commercial, First Class HFP Commercial,Priority,Priority Commercial |
|
12
|
|
|
* Priority Cpp,Priority HFP Commercial, Priority HFP CPP,Priority Mail Express,Priority Mail Express Commercial |
|
13
|
|
|
* Priority Mail Express CPP,Priority Mail Express Sh, Priority Mail Express Sh Commercial, Priority Mail Express HFP |
|
14
|
|
|
* Priority Mail Express HFP Commercial, Priority Mail Express HFP CPP, Priority Mail Cubic, Retail Ground, Media, Library, All, Online,Plus,BPM |
|
15
|
|
|
* @param $to |
|
16
|
|
|
* @param $from |
|
17
|
|
|
* @param $pounds |
|
18
|
|
|
* @param $ounces |
|
19
|
|
|
* @param $service |
|
20
|
|
|
* @return \SimpleXMLElement |
|
21
|
|
|
*/ |
|
22
|
|
|
public static function getRate($to,$from,$pounds,$ounces,$service) |
|
23
|
|
|
{ |
|
24
|
|
|
$rate = new \SimpleXMLElement("<RateV4Request></RateV4Request>"); |
|
25
|
|
|
$rate->addAttribute('USERID', self::$user); |
|
26
|
|
|
$rate->addChild("Revision",'2'); |
|
27
|
|
|
$pack = $rate->addChild('Package'); |
|
28
|
|
|
$pack->addAttribute('ID','0'); |
|
29
|
|
|
$pack->addChild('Service',$service); |
|
30
|
|
|
$pack->addChild('ZipOrigination',$from); |
|
31
|
|
|
$pack->addChild('ZipDestination',$to); |
|
32
|
|
|
$pack->addChild('Pounds',$pounds); |
|
33
|
|
|
$pack->addChild('Ounces',$ounces); |
|
34
|
|
|
$pack->addChild('Container','VARIABLE'); |
|
35
|
|
|
$pack->addChild('Size','Regular'); |
|
36
|
|
|
$url = self::$service . '&XML=' . $rate->asXML(); |
|
37
|
|
|
return simplexml_load_file($url); |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|