firewizard/innoship-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

firewizard/innoship-sdk

最新稳定版本:v1.1.1

Composer 安装命令:

composer require firewizard/innoship-sdk

包简介

Consumer SDK for Innoship API

README 文档

README

Make sure to read the Innoship API Docs or Swagger Docs first.

Requirements

  • PHP >= 7.0
  • curl extension
  • json extension

Installation

Require the package via composer

composer require firewizard/innoship-sdk

Usage

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:

  1. isSuccessful() - to make sure the request was sucesseful and the content is not an error message
  2. getContent() - to get the actual response

Get a list of countries

$countries = $innoship->location()->countries()->getContent();

Get a list of cities in a giver region

$cities = $innoship->location()->cities('94')->getContent();

Get a list of regions for a given country

$innoship->location()->regions('HU')->getContent());

Get feedback for a given time period

$innoship->feedback()->get('2021-12-01', '2021-12-10')->getContent();

Get tracking info

  • 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();

Get PDF label for AWB

file_put_contents('awb-5749162310001.pdf', $innoship->label()->byCourierAwb('3', '5749162310001')->getContent();

Get a list of fixed locations

$request = new Innoship\Request\GetFixedLocations();
$request
    ->setCourier('Sameday')
    ->setCountryCode('RO')
    ->setCountyName('Bucuresti')
    ->setLocalityName('Bucuresti')
    ->setFixedLocationType($request::TYPE_LOCKER);

$locations = $innoship->location()->fixedLocations($request);

Get rates for shipment

$address = new Innoship\Request\CreateOrder\Address();
$address
    ->setName('Tester Testerson')
    ->setContactPerson('Tester Testerson')
    ->setPhone('0723000000')
    ->setEmail('tester.testerson@example.com')
    ->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();

Create new shipment AWB

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.

Delete an existing shipment AWB

$response = $innoship->order()->delete('3', '5749162310001');

Contributing

Found a bug or have something you consider to be an improvement? Feel free to open a PR, all contributions are appreciated!

License

This package is open-source software licensed under the MIT license.

统计信息

  • 总下载量: 1.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-12