Skip to content
This repository has been archived by the owner on Feb 15, 2020. It is now read-only.

Commit

Permalink
get oauth token info methods, static stat lookup with access token
Browse files Browse the repository at this point in the history
  • Loading branch information
Tustin committed Feb 26, 2018
1 parent 24cc085 commit e5267c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ public static function refresh($refresh_token) {
* Returns current refresh token.
* @return string OAuth2 refresh token
*/
public function getRefreshToken() {
public function refreshToken() {
return $this->refresh_token;
}

/**
* Returns the current access token's expire time.
* @return string OAuth2 expire time
*/
public function expiresAt() {
return $this->expires_at;
}

/**
* Returns current access token.
* @return string OAuth2 access token
*/
public function accessToken() {
return $this->access_token;
}
}
12 changes: 12 additions & 0 deletions src/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public function lookup($username) {
}
}

//TODO (Tustin): Make this not redundant
public static function lookupWithToken($username, $access_token) {
try {
$data = FortniteClient::sendFortniteGetRequest(FortniteClient::FORTNITE_PERSONA_API . 'public/account/lookup?q=' . urlencode($username),
$access_token);
return new self($access_token, $data->id);
} catch (GuzzleException $e) {
if ($e->getResponse()->getStatusCode() == 404) throw new UserNotFoundException('User ' . $username . ' was not found.');
throw $e; //If we didn't get the user not found status code, just re-throw the error.
}
}

/**
* Parses a stat string into a mapped array.
* @param string $stat The stat string
Expand Down

0 comments on commit e5267c2

Please sign in to comment.