gw2api icon indicating copy to clipboard operation
gw2api copied to clipboard

Add global authentication

Open darthmaim opened this issue 8 years ago • 1 comments

This PR removes the $apiKey from the specific endpoint implementation. Everything is handled by the AuthenticatedEndpoint trait now. The API key can be set in a parent endpoint and is inherited.

Examples:

// old
$api->account('API_KEY')->achievements()->get();
// new
$api->account()->achievements()->auth('API_KEY')->get()
// or
$api->auth('API_KEY')->account()->achievements()->get()

// old
$api->characters('API_KEY')->inventoryOf('Char Name')->get();
$api->characters('API_KEY')->equipmentOf('Char Name')->get();
$api->guild()->membersOf('API_KEY', 'GUILD_ID');
$api->pvp()->standings('DIFFERENT_API_KEY')->get();
// new
$api->auth('API_KEY');
$api->characters()->inventoryOf('Char Name')->get();
$api->characters()->equipmentOf('Char Name')->get();
$api->guild()->membersOf('GUILD_ID')->get();
$api->pvp()->standings()->auth('DIFFERENT_API_KEY')->get();

This is something that could be merged for version 4.0.0.

darthmaim avatar Sep 04 '16 11:09 darthmaim