Skip to content

Commit

Permalink
fix RatePackage setField value and clean-up demos
Browse files Browse the repository at this point in the history
  • Loading branch information
GeNyaa committed Sep 8, 2022
1 parent 1396dbc commit c3c07ea
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 53 deletions.
22 changes: 11 additions & 11 deletions demos/domestic_rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
//$rate->setTestMode(true);

// Create new package object and assign the properties
// apartently the order you assign them is important so make sure
// apparently the order you assign them is important so make sure
// to set them as the example below
// set the RatePackage for more info about the constants
$package = new RatePackage();
$package->setService(RatePackage::SERVICE_FIRST_CLASS);
$package->setFirstClassMailType(RatePackage::MAIL_TYPE_LETTER);
$package->setZipOrigination(91601);
$package->setZipDestination(91730);
$package->setPounds(0);
$package->setOunces(3.5);
$package->setContainer('');
$package->setSize(RatePackage::SIZE_REGULAR);
$package->setField('Machinable', true);
$package = (new RatePackage())
->setService(RatePackage::SERVICE_FIRST_CLASS)
->setFirstClassMailType(RatePackage::MAIL_TYPE_LETTER)
->setZipOrigination(91601)
->setZipDestination(91730)
->setPounds(0)
->setOunces(3.5)
->setContainer('')
->setSize(RatePackage::SIZE_REGULAR)
->setField('Machinable', true);

// add the package to the rate stack
$rate->addPackage($package);
Expand Down
2 changes: 0 additions & 2 deletions demos/international_express_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
// Perform the request and return result
$label->createLabel();

//print_r($label->getArrayResponse());
print_r($label->getPostData());
//var_dump($label->isError());

// See if it was successful
if ($label->isSuccess()) {
Expand Down
42 changes: 21 additions & 21 deletions demos/international_rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
$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');
$package = (new RatePackage)
->setPounds(15.12345678)
->setOunces(0)
->setField('Machinable', 'True')
->setField('MailType', 'Package')
->setField('GXG', [
'POBoxFlag' => 'Y',
'GiftFlag' => 'Y'
])
->setField('ValueOfContents', 200)
->setField('Country', 'Australia')
->setField('Container', 'RECTANGULAR')
->setField('Size', 'LARGE')
->setField('Width', 10)
->setField('Length', 15)
->setField('Height', 10)
->setField('Girth', 0)
->setField('OriginZip', 18701)
->setField('CommercialFlag', 'N')
->setField('AcceptanceDateTime', '2016-07-05T13:15:00-06:00')
->setField('DestinationPostalCode', '2046');

// add the package to the rate stack
$rate->addPackage($package);
Expand Down
2 changes: 0 additions & 2 deletions demos/open_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// Perform the request and return result
$label->createLabel();

//print_r($label->getArrayResponse());
print_r($label->getPostData());
//var_dump($label->isError());

// See if it was successful
if ($label->isSuccess()) {
Expand Down
9 changes: 0 additions & 9 deletions demos/priority_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,11 @@
$label->setWeightOunces(1);
$label->setField(36, 'LabelDate', '03/12/2014');

//$label->setField(32, 'SeparateReceiptPage', 'true');

// Perform the request and return result
$label->createLabel();

//print_r($label->getArrayResponse());
//print_r($label->getPostData());
//var_dump($label->isError());

// See if it was successful
if ($label->isSuccess()) {
//echo 'Done';
//echo "\n Confirmation:" . $label->getConfirmationNumber();

$label = $label->getLabelContents();

if ($label) {
Expand Down
12 changes: 6 additions & 6 deletions demos/zipcodelookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
// Create new address object and assign the properties
// apartently the order you assign them is important so make sure
// to set them as the example below
$address = new \USPS\Address();
$address->setFirmName('Apartment');
$address->setApt('100');
$address->setAddress('9200 Milliken Ave');
$address->setCity('Rancho Cucomonga');
$address->setState('CA');
$address = (new \USPS\Address())
->setFirmName('Apartment')
->setApt('100')
->setAddress('9200 Milliken Ave')
->setCity('Rancho Cucomonga')
->setState('CA');

// Add the address object to the zipcode lookup class
$zipcode->addAddress($address);
Expand Down
4 changes: 2 additions & 2 deletions src/RatePackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ public function setSize(string|int $value): self
* Add an element to the stack.
*
* @param string|int $key
* @param string|int $value
* @param mixed $value
*
* @return RatePackage
*/
public function setField(string|int $key, string|int $value): self
public function setField(string|int $key, mixed $value): self
{
$this->packageInfo[ucwords($key)] = $value;

Expand Down

0 comments on commit c3c07ea

Please sign in to comment.