Make sure to read the Innoship API Docs or Swagger Docs first.
- PHP >= 7.0
- curl extension
- json extension
Require the package via composer
composer require firewizard/innoship-sdk
To interact with the API, you need to create a new instance of Innoship\Innoship
, using your API key:
$innoship = new Innoship\Innoship('my-api-key-123');
This exposes several service objects, following the swagger grouping:
- courier
- feedback
- label
- location
- order
- price
- track
So, for instance, to get all client locations, the call would look like this:
$locations = $innoship->location()->clientLocations()->getContent();
All requests return an instance of Innoship\Response\Contract, which offers two public methods:
isSuccessful()
- to make sure the request was sucesseful and the content is not an error messagegetContent()
- to get the actual response
$countries = $innoship->location()->countries()->getContent();
$cities = $innoship->location()->cities('94')->getContent();
$innoship->location()->regions('HU')->getContent());
$innoship->feedback()->get('2021-12-01', '2021-12-10')->getContent();
- for a single AWB
$info = $innoship->track()->byAwb('3', '5749162310001')->getContent();
- for a list of AWB's
$info = $innoship->track()->byAwb('3', ['5749162310001', '5749162310002'])->getContent();
file_put_contents('awb-5749162310001.pdf', $innoship->label()->byCourierAwb('3', '5749162310001')->getContent();
$request = new Innoship\Request\GetFixedLocations();
$request
->setCourier('Sameday')
->setCountryCode('RO')
->setCountyName('Bucuresti')
->setLocalityName('Bucuresti')
->setFixedLocationType($request::TYPE_LOCKER);
$locations = $innoship->location()->fixedLocations($request);
$address = new Innoship\Request\CreateOrder\Address();
$address
->setName('Tester Testerson')
->setContactPerson('Tester Testerson')
->setPhone('0723000000')
->setEmail('[email protected]')
->setAddressText('Sos Principala nr 1')
->setLocalityName('Socolari')
->setCountyName('Caras-Severin')
->setCountry('RO');
$content = new Innoship\Request\CreateOrder\Content();
$content
->setParcelsCount(1)
->setTotalWeight(10)
->setContents('Obiecte de artă')
->setPackage('carton');
$extra = new Innoship\Request\CreateOrder\Extra();
$extra
//->setOpenPackage(true)
//->setSaturdayDelivery(true)
->setBankRepaymentAmount(125)
->setBankRepaymentCurrency('RON');
$request = new Innoship\Request\CreateOrder();
$request
->setServiceId(1)
->setShipmentDate(now())
->setAddressTo($address)
->paidBySender()
->setContent($content)
->setExtra($extra)
->setExternalClientLocation('Default')
->setExternalOrderId('10000001')
->setSourceChannel('website')
->setCustomAttributes(['x' => 1, 'y' => 2])
//->includePriceBreakdown()
//->includeCourierResponse()
;
$rates = $innoship->price()->get($request)->getContent();
Using the same request object as above, call:
$response = $innoship->order()->create($request);
Make sure that you set the courier id and the service id on this call, otherwise the request will fail.
$response = $innoship->order()->delete('3', '5749162310001');
Found a bug or have something you consider to be an improvement? Feel free to open a PR, all contributions are appreciated!
This package is open-source software licensed under the MIT license.