andyts93/brt-api-wrapper

PHP wrapper for BRT Rest API service

0.2.0 2023-02-07 17:44 UTC

This package is auto-updated.

Last update: 2024-06-07 20:53:32 UTC


README

Build codecov Codacy Badge GitHub code size in bytes

BRT API Wrapper

BRT API made easy

This package is a simple PHP wrapper for Bartolini Restful API

Installing

Install with composer

composer require andyts93/brt-api-wrapper

Features

  • Create shippings
  • Confirm shippings
  • Delete shippings

Usage

Create shipping

$request = new Andyts93\BrtApiWrapper\CreateRequest();
$request->setDepartureDepot(123)
    ->setSenderCustomerCode(1234567)
    ->setDeliveryFreightTypeCode('DAP')
    ->setConsigneeCompanyName('Fake Company Inc.')
    ->setConsigneeAddress('Fake street')
    ->setConsigneeZIPCode('00000')
    ->setConsigneeCity('Fake city')
    ->setConsigneeCountryAbbreviationISOAlpha2('IT')
    ->setNumberOfParcels(1)
    ->setWeightKG(1)
    ->setNumericSenderReference(123456)
    ->setIsCODMandatory(0)
    ->setIsLabelRequired(1)
    ->setLabelParameters(new Andyts93\BrtApiWrapper\LabelParameter());

$response = $request->call();

if ($response->hasErrorrs()) {
    echo $response->getExecutionMessage()->getMessage();
}

Confirm shipping

$request = new Andyts93\BrtApiWrapper\ConfirmRequest();
$request->setSenderCustomerCode(1234567)
    ->setNumericSenderReference(123456);

$response = $request->call();

if ($response->hasErrorrs()) {
    echo $response->getExecutionMessage()->getMessage();
}

Delete shipping

$request = new Andyts93\BrtApiWrapper\DeleteRequest();
$request->setSenderCustomerCode(1234567)
    ->setNumericSenderReference(123456);

$response = $request->call();

if ($response->hasErrorrs()) {
    echo $response->getExecutionMessage()->getMessage();
}

Buy Me A Coffee