gdinko/acs

Laravel ACS API Wrapper

v1.0.2 2022-05-27 11:11 UTC

This package is auto-updated.

Last update: 2024-04-27 15:37:17 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

ACS JSON API Documentation

ACS JSON API Swagger UI

Installation

You can install the package via composer:

composer require gdinko/acs

If you plan to use database for storing nomenclatures:

php artisan migrate

If you need to export configuration file:

php artisan vendor:publish --tag=acs-config

If you need to export migrations:

php artisan vendor:publish --tag=acs-migrations

If you need to export models:

php artisan vendor:publish --tag=acs-models

If you need to export commands:

php artisan vendor:publish --tag=acs-commands

Configuration

ACS_API_KEY=
ACS_COMPANY_ID=
ACS_COMPANY_PASSWORD=
ACS_USER_ID=
ACS_USER_PASSWORD=
ACS_BILLING_CODE=
ACS_API_BASE_URL= #default=https://webservices.acscourier.net/ACSRestServices/api/ACSAutoRest/
ACS_API_TIMEOUT= #default=5

Usage

Runtime Setup

Acs::setTimeout(99);
/**
 * You can call all methods from the API like this , there is no need
 * to pass company data every time. The data is injected automaticaly
 * on every request
 **/

dd(Acs::ACS_Address_Validation([
    'Address' => 'Address ...'
]));

dd(Acs::ACS_Trackingsummary([
    'Voucher_No' => '999999999'
]));

Commands

#get acs api status (use -h to view options)
php artisan acs:api-status

#track parcels (use -h to view options)
php artisan acs:track

Models

CarrierAcsTracking
CarrierAcsApiStatus

Events

CarrierAcsTrackingEvent

Parcels Tracking

  1. Subscribe to tracking event, you will recieve last tracking info, if tracking command is schduled
Event::listen(function (CarrierAcsTrackingEvent $event) {
    echo $event->account;
    dd($event->tracking);
});
  1. Before use of tracking command you need to create your own command and define setUp method
php artisan make:command TrackCarrierAcs
  1. In app/Console/Commands/TrackCarrierAcs define your logic for parcels to be tracked
use Gdinko\Acs\Commands\TrackCarrierAcsBase;

class TrackCarrierAcsSetup extends TrackCarrierAcsBase
{
    protected function setup()
    {
        //define parcel selection logic here
        // $this->parcels = [];
    }
}
  1. Use the command
php artisan acs:track

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email dinko359@gmail.com instead of using the issue tracker.

Credits

License

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