Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
#30 - added example for international rate
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentavn committed Sep 8, 2016
1 parent 06480dd commit 48655be
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demos/autoload.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

require_once('../vendor/autoload.php');
require_once(dirname(dirname(__FILE__)) . '/vendor/autoload.php');
43 changes: 43 additions & 0 deletions demos/international_rate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

require_once('autoload.php');

use USPS\RatePackage;

$rate = new \USPS\Rate('xxxx');
$rate->setInternationalCall(true);
$rate->addExtraOption('Revision', 2);

$package = new RatePackage;
$package->setPounds(15.12345678);
$package->setOunces(0);
$package->setField('Machinable', 'True');
$package->setField('MailType', 'Package');
$package->setField('GXG', array(
'POBoxFlag' => 'Y',
'GiftFlag' => 'Y'
));
$package->setField('ValueOfContents', 200);
$package->setField('Country', 'Australia');
$package->setField('Container', 'RECTANGULAR');
$package->setField('Size', 'LARGE');
$package->setField('Width', 10);
$package->setField('Length', 15);
$package->setField('Height', 10);
$package->setField('Girth', 0);
$package->setField('OriginZip', 18701);
$package->setField('CommercialFlag', 'N');
$package->setField('AcceptanceDateTime', '2016-07-05T13:15:00-06:00');
$package->setField('DestinationPostalCode', '2046');

// add the package to the rate stack
$rate->addPackage($package);
// Perform the request and print out the result
print_r($rate->getRate());
print_r($rate->getArrayResponse());
// Was the call successful
if ($rate->isSuccess()) {
echo 'Done';
} else {
echo 'Error: ' . $rate->getErrorMessage();
}

0 comments on commit 48655be

Please sign in to comment.