All Projects → JeremyDunn → Php Fedex Api Wrapper

JeremyDunn / Php Fedex Api Wrapper

This library provides a fluid interface for constructing requests to the FedEx web service API.

Labels

Projects that are alternatives of or similar to Php Fedex Api Wrapper

Mercure
Server-sent live updates: protocol and reference implementation
Stars: ✭ 2,608 (+1113.02%)
Mutual labels:  api
Apiato
PHP Framework for building scalable API's on top of Laravel.
Stars: ✭ 2,564 (+1092.56%)
Mutual labels:  api
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (-7.44%)
Mutual labels:  api
Twitch4j
Modular Async/Sync/Reactive Twitch API Client / IRC Client
Stars: ✭ 209 (-2.79%)
Mutual labels:  api
Express Es6 Rest Api
🔋 Starter project for an ES6 RESTful Express API.
Stars: ✭ 2,401 (+1016.74%)
Mutual labels:  api
Haste
Haste: a fast, simple, and open RNN library
Stars: ✭ 214 (-0.47%)
Mutual labels:  api
Instagram Api Python
Unofficial instagram API, give you access to ALL instagram features (like, follow, upload photo and video and etc)! Write on python.
Stars: ✭ 2,357 (+996.28%)
Mutual labels:  api
Graphql Php
A PHP7 implementation of the GraphQL specification.
Stars: ✭ 217 (+0.93%)
Mutual labels:  api
Pokeapi
The Pokémon API
Stars: ✭ 2,695 (+1153.49%)
Mutual labels:  api
Crafatar
A blazing fast API for Minecraft faces
Stars: ✭ 212 (-1.4%)
Mutual labels:  api
Express Api Es6 Starter
Build APIs with Express.js in no time using ES6/ES7/ESNext goodness.
Stars: ✭ 212 (-1.4%)
Mutual labels:  api
Googleanalyticsr
Use the Google Analytics API from R
Stars: ✭ 213 (-0.93%)
Mutual labels:  api
Careyshop
采用前后端分离,支持分布式部署。框架内部使用面向对象模块化调用,在多终端、跨平台时采用 REST API 进行数据交互,可直接对接 PC商城、小程序商城、H5商城,构建 Android、IOS 的 APP。[微信商城 B2C商城 PHP商城系统 微信公众号商城]
Stars: ✭ 213 (-0.93%)
Mutual labels:  api
Taxize
A taxonomic toolbelt for R
Stars: ✭ 209 (-2.79%)
Mutual labels:  api
Ray
a framework that helps you to deliver well-designed python APIs
Stars: ✭ 215 (+0%)
Mutual labels:  api
Bilibili Api Collect
哔哩哔哩-API收集整理【不断更新中....】
Stars: ✭ 4,497 (+1991.63%)
Mutual labels:  api
Falco
A functional-first toolkit for building brilliant ASP.NET Core applications using F#.
Stars: ✭ 214 (-0.47%)
Mutual labels:  api
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+0.47%)
Mutual labels:  api
Pan Configurator
Framework and utilities to easily manage and edit Palo Alto Network PANOS devices
Stars: ✭ 216 (+0.47%)
Mutual labels:  api
Symfony Flex Backend
Symfony Flex REST API template project
Stars: ✭ 214 (-0.47%)
Mutual labels:  api

PHP FedEx API Wrapper

Latest Stable Version Total Downloads Build Status Codacy Badge

This library provides a fluid interface for constructing requests to the FedEx web service API.

General Information

All of the code under the FedEx namespace is generated using the generate-classes-from-wsdls.php script. Each web service has it's own class namespace. See the official FedEx web service API documentation for a description of these services.

Installation

composer require jeremy-dunn/php-fedex-api-wrapper

Using the library

The easiest way to get started constructing a web service request is to create an new Request object for the particular service you wish to use and then work backward by injecting the objects necessary to complete the request.

For example if we wish to get shipping rates, we'll create a new instance of FedEx\RateService\Request and call the getGetRatesReply() method. This method requires an instance of FedEx\RateService\ComplexType\RateRequest which itself requires instances of FedEx\RateService\ComplexType\RequestedShipment, FedEx\RateService\ComplexType\TransactionDetail, FedEx\RateService\ComplexType\WebAuthenticationDetail, FedEx\RateService\ComplexType\ClientDetail, and so on. See below for an example.

Rate Service request example

This assumes the FEDEX_KEY, FEDEX_PASSWORD, FEDEX_ACCOUNT_NUMBER, and FEDEX_METER_NUMBER are previously defined in your application. Also note that by default, the library will use the beta/testing server (wsbeta.fedex.com). To use the production server (ws.fedex.com), set the location on the \SoapClient returned from the Request. See below for an example of how to do this.

use FedEx\RateService\Request;
use FedEx\RateService\ComplexType;
use FedEx\RateService\SimpleType;

$rateRequest = new ComplexType\RateRequest();

//authentication & client details
$rateRequest->WebAuthenticationDetail->UserCredential->Key = FEDEX_KEY;
$rateRequest->WebAuthenticationDetail->UserCredential->Password = FEDEX_PASSWORD;
$rateRequest->ClientDetail->AccountNumber = FEDEX_ACCOUNT_NUMBER;
$rateRequest->ClientDetail->MeterNumber = FEDEX_METER_NUMBER;

$rateRequest->TransactionDetail->CustomerTransactionId = 'testing rate service request';

//version
$rateRequest->Version->ServiceId = 'crs';
$rateRequest->Version->Major = 24;
$rateRequest->Version->Minor = 0;
$rateRequest->Version->Intermediate = 0;

$rateRequest->ReturnTransitAndCommit = true;

//shipper
$rateRequest->RequestedShipment->PreferredCurrency = 'USD';
$rateRequest->RequestedShipment->Shipper->Address->StreetLines = ['10 Fed Ex Pkwy'];
$rateRequest->RequestedShipment->Shipper->Address->City = 'Memphis';
$rateRequest->RequestedShipment->Shipper->Address->StateOrProvinceCode = 'TN';
$rateRequest->RequestedShipment->Shipper->Address->PostalCode = 38115;
$rateRequest->RequestedShipment->Shipper->Address->CountryCode = 'US';

//recipient
$rateRequest->RequestedShipment->Recipient->Address->StreetLines = ['13450 Farmcrest Ct'];
$rateRequest->RequestedShipment->Recipient->Address->City = 'Herndon';
$rateRequest->RequestedShipment->Recipient->Address->StateOrProvinceCode = 'VA';
$rateRequest->RequestedShipment->Recipient->Address->PostalCode = 20171;
$rateRequest->RequestedShipment->Recipient->Address->CountryCode = 'US';

//shipping charges payment
$rateRequest->RequestedShipment->ShippingChargesPayment->PaymentType = SimpleType\PaymentType::_SENDER;

//rate request types
$rateRequest->RequestedShipment->RateRequestTypes = [SimpleType\RateRequestType::_PREFERRED, SimpleType\RateRequestType::_LIST];

$rateRequest->RequestedShipment->PackageCount = 2;

//create package line items
$rateRequest->RequestedShipment->RequestedPackageLineItems = [new ComplexType\RequestedPackageLineItem(), new ComplexType\RequestedPackageLineItem()];

//package 1
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Value = 2;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Weight->Units = SimpleType\WeightUnits::_LB;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Length = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Width = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Height = 3;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->Dimensions->Units = SimpleType\LinearUnits::_IN;
$rateRequest->RequestedShipment->RequestedPackageLineItems[0]->GroupPackageCount = 1;

//package 2
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Weight->Value = 5;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Weight->Units = SimpleType\WeightUnits::_LB;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Length = 20;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Width = 20;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Height = 10;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->Dimensions->Units = SimpleType\LinearUnits::_IN;
$rateRequest->RequestedShipment->RequestedPackageLineItems[1]->GroupPackageCount = 1;

$rateServiceRequest = new Request();
//$rateServiceRequest->getSoapClient()->__setLocation(Request::PRODUCTION_URL); //use production URL

$rateReply = $rateServiceRequest->getGetRatesReply($rateRequest); // send true as the 2nd argument to return the SoapClient's stdClass response.


if (!empty($rateReply->RateReplyDetails)) {
    foreach ($rateReply->RateReplyDetails as $rateReplyDetail) {
        var_dump($rateReplyDetail->ServiceType);
        if (!empty($rateReplyDetail->RatedShipmentDetails)) {
            foreach ($rateReplyDetail->RatedShipmentDetails as $ratedShipmentDetail) {
                var_dump($ratedShipmentDetail->ShipmentRateDetail->RateType . ": " . $ratedShipmentDetail->ShipmentRateDetail->TotalNetCharge->Amount);
            }
        }
        echo "<hr />";
    }
}

var_dump($rateReply);

More examples can be found in the examples folder.

Change Log

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].