PHP code example of tsukasa / fan-courier-api-client

1. Go to this page and download the library: Download tsukasa/fan-courier-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tsukasa / fan-courier-api-client example snippets


// default values for testing purposes
$clientId = '7032158';
$username = 'clienttest';
$password = 'testing';

// for all the methods available you can see the request params
// in the associated class
// e.g.
use Infifni\FanCourierApiClient\Client;
(new Client($clientId, $username, $password))->city();
// now check \Infifni\FanCourierApiClient\Request\City::getFieldRules
// to understand what params are 

// examples
use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\City;

// to fetch specific county
(new Client('7032158', 'clienttest', 'testing'))
    ->city([
        'judet' => 'Constanta', // optional
        'language' => City::LANGUAGE_RO_ALLOWED_VALUE // optional
    ]);

// or to fetch all cities
(new Client('7032158', 'clienttest', 'testing'))
    ->city();

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\Streets;

// To fetch specific county
(new Client('7032158', 'clienttest', 'testing'))
    ->streets([
        'judet' => 'Bucuresti', // optional
        'localitate' => 'Bucuresti', // optional
        'language' => Streets::LANGUAGE_RO_ALLOWED_VALUE // optional
    ]);
// or to fetch all streets from Romania
(new Client('7032158', 'clienttest', 'testing'))
    ->streets();

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\Price;

// standard service
(new Client('7032158', 'clienttest', 'testing'))
    ->price([
        'serviciu' => Price::SERVICE_ALLOWED_VALUES['standard'],
        'localitate_dest' => 'Targu Mures',
        'judet_dest' => 'Mures',
        'plicuri' => 1,
        'colete' => 2,
        'greutate' => 5,
        'lungime' => 10,
        'latime' => 10,
        'inaltime' => 10,
        'val_decl' => 600,
        'plata_ramburs' => Price::SENDER_ALLOWED_VALUE,
        'plata_la' => Price::RECIPIENT_ALLOWED_VALUE
    ]);

// export service
(new Client('7032158', 'clienttest', 'testing'))
    ->price([
        'serviciu' => Price::SERVICE_ALLOWED_VALUES['export'],
        'modtrim' => Price::SEND_MODE_BY_AIR_ALLOWED_VALUE,
        'greutate' => 10.22,
        'pliccolet' => 3,
        's_inaltime' => 50,
        's_latime' => 67,
        's_lungime' => 48,
        'volum' => 400,
        'dest_tara' => 'Bulgaria',
        'tipcontinut' => 1,
        'km_ext' => 400,
        'plata_la' => Price::RECIPIENT_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\TrackAwb;

(new Client('7032158', 'clienttest', 'testing'))
    ->trackAwb([
        'AWB' => '2337600120003', // 

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\GenerateAwb;

(new Client('7032158', 'clienttest', 'testing'))
    ->generateAwb([
        'fisier' => [
            [
                'tip_serviciu' => GenerateAwb::SERVICE_ALLOWED_VALUES['standard'], 
                'banca' => '',
                'iban' =>  '',
                'nr_plicuri' => 1,
                'nr_colete' => 0,
                'greutate' => 1,
                'plata_expeditie' => 'ramburs',
                'ramburs_bani' => 100,
                'plata_ramburs_la' => GenerateAwb::RECIPIENT_ALLOWED_VALUE,
                'valoare_declarata' => 400,
                'persoana_contact_expeditor' => 'Test User',
                'observatii' => 'Lorem ipsum',
                'continut' => '',
                'nume_destinar' => 'Test',
                'persoana_contact' => 'Test',
                'telefon' => '123456789',
                'fax' => '123456789',
                'email' => '[email protected]',
                'judet' => 'Galati',
                'localitate' => 'Tecuci',
                'strada' => 'Lorem',
                'nr' => '2',
                'cod_postal' => '123456',
                'bl' => '',
                'scara' => '',
                'etaj'  => '',
                'apartament' => '',
                'inaltime_pachet' => '',
                'lungime_pachet' => '',
                'restituire' => '',
                'centru_cost' => '',
                'optiuni' => '',
                'packing' => '',
                'date_personale' => ''
            ],
            [
                'tip_serviciu' => GenerateAwb::SERVICE_ALLOWED_VALUES['collector_account'],
                'banca' => 'Test',
                'iban' =>  'XXXXXX',
                'nr_plicuri' => 0,
                'nr_colete' => 1,
                'greutate' => 1,
                'plata_expeditie' => 'ramburs',
                'ramburs_bani' => 400,
                'plata_ramburs_la' => GenerateAwb::RECIPIENT_ALLOWED_VALUE,
                'valoare_declarata' => 400,
                'persoana_contact_expeditor' => 'Test User',
                'observatii' => 'Lorem ipsum',
                'continut' => 'Fragil',
                'nume_destinar' => 'Test',
                'persoana_contact' => 'Test',
                'telefon' => '123456789',
                'fax' => '123456789',
                'email' => '[email protected]',
                'judet' => 'Galati',
                'localitate' => 'Tecuci',
                'strada' => 'Lorem',
                'nr' => '2',
                'cod_postal' => '123456',
                'bl' => '',
                'scara' => '',
                'etaj'  => '',
                'apartament' => '',
                'inaltime_pachet' => '',
                'lungime_pachet' => '',
                'restituire' => '',
                'centru_cost' => '',
                'optiuni' => '',
                'packing' => '',
                'date_personale' => ''
            ]
        ]]);

use Infifni\FanCourierApiClient\Client;

(new Client('7032158', 'clienttest', 'testing'))
    ->order([
        'nr_colete' => 1,
        'pers_contact' => 'Test',
        'tel' => 123456789,
        'email' => '[email protected]',
        'greutate' => 1,
        'inaltime' => 10,
        'lungime' => 10,
        'latime' => 10,
        'ora_ridicare' => '18:00',
        'observatii' => '',
        'client_exp' => 'Test',
        'strada' => 'Test',
        'nr' => 1,
        'bloc' => 2,
        'scara' => 3,
        'etaj' => 7,
        'ap' => 78,
        'localitate' => 'Constanta',
        'judet' => 'Constanta',
    ]);

use Infifni\FanCourierApiClient\Client;

(new Client('7032158', 'clienttest', 'testing'))
    ->exportAwbErrors();

use Infifni\FanCourierApiClient\Client;

(new Client('7032158', 'clienttest', 'testing'))
    ->deleteAwb([
        'AWB' => '2337600120003'
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\GetAwb;

(new Client('7032158', 'clienttest', 'testing'))
    ->getAwb([
        'nr' => '2337600120003',
        'page' => GetAwb::PAGE_A4_ALLOWED_VALUE,
        'ln' => GetAwb::LANGUAGE_RO_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\DownloadAwb;

(new Client('7032158', 'clienttest', 'testing'))
    ->downloadAwb([
        'AWB'=>'2337600120003',
        'language' => DownloadAwb::LANGUAGE_RO_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\ExportOrders;

(new Client('7032158', 'clienttest', 'testing'))
    ->exportOrders([
        'data' => '22.05.2020',
        'language' => ExportOrders::LANGUAGE_RO_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\ExportBordereau;

(new Client('7032158', 'clienttest', 'testing'))
    ->exportBordereau([
        'data' => '22.05.2020',
        'language' => ExportBordereau::LANGUAGE_RO_ALLOWED_VALUE,
        'mode' => ExportBordereau::MODE_ALL_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;
use Infifni\FanCourierApiClient\Request\ExportReports;

(new Client('7032158', 'clienttest', 'testing'))
    ->exportReports([
        'data' => '22.05.2020',
        'language' => ExportReports::LANGUAGE_RO_ALLOWED_VALUE
    ]);

use Infifni\FanCourierApiClient\Client;

(new Client('7032158', 'clienttest', 'testing'))
    ->exportObservations();

use Infifni\FanCourierApiClient\Client;

(new Client('7032158', 'clienttest', 'testing'))
    ->endBordereau();