mrgla55/tabapi is a Laravel package for an api wrapper for the tab studio.
It currently has 0 GitHub stars and 21 downloads on Packagist (latest version v0.1.1).
Install it with composer require mrgla55/tabapi.
Discover more Laravel packages by mrgla55
or browse all Laravel packages to compare alternatives.
Last updated
TAB Studio REST API Client for Laravel 5
TAB REST API client for Laravel.
While this package is built for Laravel, it has been decoupled so that it can be extended into any framework or vanilla PHP application. Currently the only support is for Laravel 4, 5 and Lumen.
Tabapi can be installed through composer. Open your composer.json file and add the following to the require key:
"mrgla55/tabapi": "0.*"
Next run composer update from the command line to install the package.
Add the service provider and alias to your config/app.php file:
mrgla55\Tabapi\Providers\Laravel\TabapiServiceProvider::class
'Tabapi' => mrgla55\Tabapi\Providers\Laravel\Facades\Tabapi::class
For Laravel 4, add
mrgla55\Tabapi\Providers\Laravel4\TabapiServiceProviderinapp/config/app.php. Alias will remain the same.
class_alias('mrgla55\Tabapi\Providers\Laravel\Facades\Tabapi', 'Tabapi');
$app->register(mrgla55\Tabapi\Providers\Lumen\TabapiServiceProvider::class);
$app->configure('Tabapi');
$app->withFacades();
Then you'll utilize the Lumen service provider by registering it in the bootstrap/app.php file.
You will need a configuration file to add your credentials. Publish a config file using the artisan command:
php artisan vendor:publish
You can find the config file in: config/tabapi.php
For Lumen, you should copy the config file from
src/config/config.phpand add it to aTabapi.phpconfiguration file under a config directory in the root of your application.
For Laravel 4, run
php artisan config:publish mrgla55/Tabapi. It will be found inapp/config/mrgla55/Tabapi/config.php
Creating routes
Route::get('/versions', function()
{
return Tabapi::versions();
});
All resources are requested dynamically using method overloading.
First, determine which resources you have access to by calling:
Tabapi::resources();
Result:
Array
(
[account:authenticate] => https://webapi.tab.com.au/v1/account-service/tab/authenticate
[account:balance] => https://webapi.tab.com.au/v1/account-service/tab/accounts/{accountNumber}/balance
...
)
Next, call resources by referring to the specified key. Replace the colon ':' with and underscore '_'. Embedded parameters in the base url are replaced with arguments. Any left over arguments are added to the query string.
For instance:
Tabapi::lookup_countries_allowed();
or
Tabapi::info_sports(['jurisdiction' => 'nsw']);
For nested links or to call direct, you can use the custom() method for consuming them.
Tabapi::custom('/myEndpoint');
Additional options and parameters can be passed in like this:
Tabapi::custom('https://api.beta.tab.com.au/v1/tab-info-service/racing/dates/2018-11-06/meetings/R/Racing%20-%20Futures/races/Melbourne%20Cup%20(All%20In)', [
'parameters' => ['jurisdiction' => 'VIC', 'fixedOdds' => 'true']
]);
Read Creating REST APIs using Apex REST for more information.
For more information about Guzzle responses and event listeners, refer to their documentation.