earnould / laravel-velo-api
laravel-velo-api is a package that allows you to connect to the Velo Antwerp API. The Velo Antwerp API is..
Requires
- guzzlehttp/guzzle: ^6.3.3
- laravel/framework: ~5.8.0
Requires (Dev)
- mockery/mockery: ^1.2
- orchestra/testbench: ^3.8
- php-vcr/phpunit-testlistener-vcr: ^3.2
- phpunit/phpunit: ^8.1
- systemhaus/guzzle-http-mock: ^2.0
This package is auto-updated.
Last update: 2024-10-29 05:34:38 UTC
README
NOTE
You will need to request a client_id
and a client_secret
at velo-antwerpen.be to actually use this package.
Installation
You can install the package via composer:
composer require earnould/laravel-velo-api
The package will automatically register itself.
You'll need to publish the config file with:
php artisan vendor:publish --provider="Earnould\LaravelVeloApi\VeloServiceProvider" --tag="config"
This allows you to define the client id and secret in your .env file like this:
VELO_CLIENT_ID = ''
VELO_CLIENT_SECRET = ''
This package allows you to connect to the Velo Antwerp API. For now there are only two sources available stations
and stationsStatuses
. The stations resource speaks for itself. The stationsStatuses resource returns the availability of all stations. The API requires a client_id and client_secret to fetch these results.
A quick overview:
You can retrieve all Velo station resources using the Earnould\LaravelVeloApi\Facades\VeloStations
facade.
Retrieves all Velo stations in Antwerp
VeloStations::all();
Returns:
Collection { array [ 0 => Earnould\LaravelVeloApi\Station { [ "id" => "036" "name" => "036- Bourla" "address" => "Schuttershofstraat n° 2" "addressNumber" => null "zipCode" => "2000" "districtCode" => null "districtName" => null "altitude" => null "location" => array:2 [ "lat" => "51.2163878210059" "lon" => "4.40593043087013" ] "stationType" => "BIKE" ] } ... => Earnould\LaravelVeloApi\Station {...}
Requests all Velo stations with their corresponding status
VeloStations::allWithStatuses();
Returns:
Collection { [ 0 => Earnould\LaravelVeloApi\Station { [ "id" => "036" "name" => "036- Bourla" "address" => "Schuttershofstraat n° 2" "addressNumber" => null "zipCode" => "2000" "districtCode" => null "districtName" => null "altitude" => null "location" => [ "lat" => "51.2163878210059", "lon" => "4.40593043087013" ] "stationType" => "BIKE" "status" => "OPN" "availability" => [ "bikes" => 19, "slots" => 1 ] ] ... => Earnould\LaravelVeloApi\Station {...} ] }
NOTE: The status will be OPN
for open stations and CLS
for Closed stations.
Documentation
Any bugs? Any suggestions or question? Shoot an issue on GitHub and let's have a look.
If you've found a security issue please mail contact@evertarnould.be instead of using the issue tracker.
Changelog
Please see CHANGELOG for more information about recent changes.
Testing
vendor/bin/phpunit
Security
If you discover any security related issues, please email contact@evertarnould.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.