PHP code example of floac / laravel-ukrpost

1. Go to this page and download the library: Download floac/laravel-ukrpost 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/ */

    

floac / laravel-ukrpost example snippets


Floac\Ukrpost\Facades\Dictionary::regions(string $region_ua = null);

Floac\Ukrpost\Facades\Dictionary::districts(string $district_ua = null, int $region_id = null);

Floac\Ukrpost\Facades\Dictionary::cities(string $city_ua = null, int $district_id = null, int $region_id = null);

Floac\Ukrpost\Facades\Dictionary::streets(string $street_ua = null, int $city_id = null, int $district_id = null, int $region_id = null);

Floac\Ukrpost\Facades\Dictionary::houses(int $street_id, string $housenumber = null);

Floac\Ukrpost\Facades\Dictionary::postOffices(string $zip_code = null, int $street_id = null, int $city_id = null, int $district_id = null, int $region_id = null);

Floac\Ukrpost\Facades\Dictionary::postOfficesOpenHours(string $zip_code, int $post_office_id = null);

Floac\Ukrpost\Facades\Dictionary::postOfficesByGeolocation(float $lat, float $long, int $maxdistance = 1);

Floac\Ukrpost\Facades\Dictionary::citiesByPostcode(string $postcode);

Floac\Ukrpost\Facades\Dictionary::addressesByPostcode(string $postcode);

    $api = new Floac\Ukrpost\Document\Api(
        'bearerToken',
        'counterpartyToken'
    );

    $address = new Floac\Ukrpost\Document\Models\Address($api);

    $address->set(
        postcode: '07401',
        country: 'UA',
        region: 'Київська',
        city: 'Бровари',
        district: 'Київський',
        street: 'Котляревського',
        houseNumber: '12',
        apartmentNumber: '33'
    );

    $address->save();

    $api = new Floac\Ukrpost\Document\Api(
        'bearerToken',
        'counterpartyToken'
    );

    $client = new Client($api);

    $client->set(
        firstName: 'Олександр',
        lastName: 'Петренко',
        phone: 380663443224,
        address: $address,
    );

    $client->save();

    $api = new Floac\Ukrpost\Document\Api(
        'bearerToken',
        'counterpartyToken'
    );

    $document = new Document($api);

    $document->save($senderClient, $recipientClient, $parcel);