mchervenkov/sameday

Laravel Sameday API Wrapper

v1.0.3 2024-06-28 08:20 UTC

This package is auto-updated.

Last update: 2024-08-28 10:54:41 UTC


README

Latest Version on Packagist Total Downloads

Sameday JSON API Documentation

Installation

You can install the package via composer:

composer require mchervenkov/sameday

If you plan to use database for storing nomenclatures:

php artisan migrate

If you need to export configuration file:

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

If you need to export migrations:

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

If you need to export models:

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

If you need to export commands:

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

Configuration

SAMEDAY_ENV=test|production #default=test
SAMEDAY_AUTH_USERNAME= #default=test-sameday-username
SAMEDAY_AUTH_PASSWORD= #default=test-sameday-password
SAMEDAY_API_TEST_BASE_URI= #default=https://sameday-api-bg.demo.zitec.com
SAMEDAY_API_PRODUCTION_BASE_URI= #default=https://sameday-api.demo.zitec.com
SAMEDAY_API_TIMEOUT= #default=5

Usage

Methods

// Init Sameday Client
$sameday = new Sameday();

// Client endpoints
$sameday->getServices();
$sameday->getPickupPoints();
$sameday->getAwbStatus();
$sameday->syncStatus();

// Geolocation endpoints
$sameday->getCounties();
$sameday->getCities();

// Lockers endpoints
$sameday->getLockers();

Commands

#get counties with database (use -h to view options)
php artisan sameday:get-counties

#get cities with database (use -h to view options)
php artisan sameday:get-cities

#create cities map with other carriers in database  (use -h to view options)
php artisan sameday:map-cities

#get lockers with database (use -h to view options)
php artisan sameday:get-lockers 

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

Models

SamedayCity
SamedayCounty
SamedayApiStatus
SamedayLocker
CarrierCityMap

Examples

Without Params

$sameday = new Sameday();
$response = $sameday->getCities();
dd($response);

With Hydrator

$sameday = new Sameday();
$cityHydrator = new City(['countyCode' => 'BG']);
$response = $sameday->getCities($cityHydrator);
dd($response);

With Hydrator and Paginator

$sameday = new Sameday();
$cityHydrator = new City(['countyCode' => 'BG']);
$paginator = new Paginator(1, 50);
$response = $sameday->getCities($cityHydrator, $paginator);
dd($response);

Testing

Before running tests set your api credentials in sameday.php config file

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 mario.chervenkov@gmail.com instead of using the issue tracker.

Credits

License

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