Skip to content

webapix/laravel-mygls

Repository files navigation

Laravel MyGLS JSON REST API

Tests StyleCI MIT Licensed

This is the Laravel version of our MyGLS REST API integration.

Installation

You can install the package via composer:

composer require webapix/laravel-mygls

Configuration

Publish package

Create config/my-gls.php configuration file using the following artisan command:

php artisan vendor:publish --provider="Webapix\GLS\Laravel\MyGlsServiceProvider"

Add your account

Open .env file and set:

MYGLS_API_URL
MYGLS_CLIENT_NUMBER
MYGLS_USERNAME
MYGLS_PASSWORD

Usage

use \Webapix\GLS\Requests\GetParcelStatuses;

$request = new GetParcelStatuses(12345678);

/** @var \Webapix\GLS\Responses\GetParcelStatuses $response */
$response = app(\Webapix\GLS\Laravel\Client::class)->request($request);
// Or use the facade: $response = MyGls::request($request);

if ($response->successfull()) {

    /** @var \Webapix\GLS\Models\ParcelStatus[] */
    $parcelStatusList = $response->parcelStatusList();

    foreach ($parcelStatusList as $parcelStatus) {
        $parcelStatus->depotCity();
        $parcelStatus->depotNumber();
        $parcelStatus->statusCode();
        $parcelStatus->statusDate();
        $parcelStatus->statusDescription();
        $parcelStatus->statusInfo();
    }

}

You can find more information and examples in our wiki.

Accounts

By default, the MyGLS client use the default account.

You can use multiple accounts:

// add your new account to config/my-gls.php
[
    'accounts' => [
        'my-new-account' => [
            'api_url' => '',
            'client_number' => '',
            'username' => '',
            'password' => '',
        ]
    ]
]

MyGls::on('my-new-account')->request(...);

Docs

Package docs
Official GLS Docs

Testing

composer test

Postcardware

According to the postcardware concept, if you use the software for your project(s) we would appreciate to receive a postcard of your hometown.

Please send it to:

WEBAPIX KFT. Kőris utca 2/E, 2/1
2051 Biatorbágy
Hungary

Support us

If you find our packages useful and would like to support our work in maintaining and regularly updating them, consider becoming a patron. Any size of donation is welcome and highly appreciated.

Contributing

Contributions are welcome! When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email pdo@webapix.hu instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.