jumpgategaming/wargaming

0.1.1 2018-09-18 15:44 UTC

This package is auto-updated.

Last update: 2024-10-27 22:25:29 UTC


README

Installation

composer require jummpgategaming/wargaming

Set up

API details

Update your config/services.php to include wargaming.

'wargaming' => [
    'client_id'     => null,
    'client_secret' => env('WARGAMING_API_KEY'),
    'redirect'      => env('WARGAMING_REDIRECT_URI'),
],

Service provider

You should add the provider to your providers[] array in config/app.php.

'providers' => [
    ...
    JumpGateGaming\Wargaming\Providers\WargamingServiceProvider::class,
    ...
],

Obviously you will need to add these keys to your .env file. You can register an application at their api dashboard.

Authentication

This package comes with support for authorization built in using Laravel Socialite Providers. You will need to do some extra set up if you want to use it.

  1. Remove Laravel\Socialite\SocialiteServiceProvider from your providers[] array in config\app.php if you have added it already.
  2. Add \SocialiteProviders\Manager\ServiceProvider::class to your providers[] array in config\app.php.
  3. Add SocialiteProviders\Manager\SocialiteWasCalled event to your listen[] array in app/Providers/EventServiceProvider.
  4. Add your listeners (i.e. the ones from the providers) to the SocialiteProviders\Manager\SocialiteWasCalled[] that you just created.
  5. The listener that you add for this provider is 'JumpGateGaming\\Wargaming\\Providers\\Socialite\\WargamingExtendSocialite@handle',.

Example:

/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        'JumpGateGaming\\Wargaming\\Providers\\Socialite\\WargamingExtendSocialite@handle',
    ],
];

Now to use it you would just call return Socialite::with('wargaming')->redirect();.

Available methods

To call anything at all you will need to begin with calling app('wargaming'). This is the entry point for everything else. From there you call to the API you want to interact with. That would be one of tanks(), warships() or warplanes(). Next you call the overall section you want then the method.

Here's an example call:

$wargaming = app('wargaming');
$tanks = $wargaming->tanks()->encyclopedia()->vehicles();

The below lists represent all working methods. Anything not listed here has not been added yet.

World of Tanks

World of Warships

World of Warplanes