Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Live Request in Demo #22

Open
PeterTough2 opened this issue Aug 10, 2020 · 0 comments
Open

Making Live Request in Demo #22

PeterTough2 opened this issue Aug 10, 2020 · 0 comments

Comments

@PeterTough2
Copy link

Can you share a working example of live StubFedex returning realtime data from Fedex API

My code sample

require_once('vendor/autoload.php');

use pdt256\Shipping\Fedex;
use pdt256\Shipping\RateRequest;
use pdt256\Shipping\Shipment;
use pdt256\Shipping\Package;

$shipment = new Shipment;
$shipment
    ->setFromIsResidential(false)
    ->setFromStateProvinceCode('IN')
    ->setFromPostalCode('46205')
    ->setFromCountryCode('US')
    ->setToIsResidential(true)
    ->setToPostalCode('20101')
    ->setToCountryCode('US');

$package = new Package;
$package
    ->setLength(12)
    ->setWidth(4)
    ->setHeight(3)
    ->setWeight(3);

$shipment->addPackage($package);

$fedex = new Fedex\Rate([
	'prod'           => FALSE,
	'key'            => 'XXXX',
	'password'       => 'XXXX',
	'accountNumber' => 'XXXX',
	'meterNumber'   => 'XXXX',
	'dropOffType'  => 'BUSINESS_SERVICE_CENTER',
	'shipment'       => $shipment,
	'approvedCodes'  => [
		'FEDEX_EXPRESS_SAVER',  // 1-3 business days
		'FEDEX_GROUND',         // 1-5 business days
		'GROUND_HOME_DELIVERY', // 1-5 business days
		'FEDEX_2_DAY',          // 2 business days
		'STANDARD_OVERNIGHT',   // overnight
	],
	'requestAdapter' => new RateRequest\StubFedex(),
]);

$rates = $fedex->getRates();
var_dump($rates);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant