commit b116b9e546287499592c014b292c44cec1539a9f Author: Beu Date: Thu Jun 23 09:37:52 2022 +0200 Initial commit diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7fc1fcf --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "beu/oauth2-trackmania", + "description": "A TrackMania 2020 provider for league/oauth2-client", + "authors": [ + { + "name": "Beu", + "email": "benoit+symfonybundle@virtit.fr", + "homepage": "http://virtit.fr", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "Beu\\TrackMania\\OAuth2\\Client\\": "src/" + } + }, + "require": { + "php": ">=7.4.0", + "league/oauth2-client": "^2.2" + } +} diff --git a/src/Provider/TrackManiaProvider.php b/src/Provider/TrackManiaProvider.php new file mode 100644 index 0000000..1643f4a --- /dev/null +++ b/src/Provider/TrackManiaProvider.php @@ -0,0 +1,94 @@ +getReasonPhrase(), + $response->getStatusCode(), + $response->getBody() + ); + } + } + + /** + * Generates a resource owner object from a successful resource owner + * details request. + * + * @param array $response + * @param AccessToken $token + * @return ResourceOwnerInterface + */ + protected function createResourceOwner(array $response, AccessToken $token) + { + return new TrackManiaProviderOwner($response); + } +} diff --git a/src/Provider/TrackManiaProviderOwner.php b/src/Provider/TrackManiaProviderOwner.php new file mode 100644 index 0000000..0ccff7a --- /dev/null +++ b/src/Provider/TrackManiaProviderOwner.php @@ -0,0 +1,56 @@ +response = $response; + } + + /** + * Returns the Account Id of the player + * + * @return string + */ + public function getId() + { + return $this->getValueByKey($this->response, 'accountId'); + } + + /** + * Returns the Nickname of the Player + * + * @return string + */ + public function getDisplayName() + { + return $this->getValueByKey($this->response, 'displayName'); + } + + /** + * Return all of the owner details available as an array. + * + * @return array + */ + public function toArray() + { + return $this->response; + } +}