mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Fixed lint issues, YOU'RE WELCOME TORSTEN
This commit is contained in:
parent
4f64c72d0d
commit
efbde82ca2
1 changed files with 17 additions and 17 deletions
|
|
@ -20,7 +20,7 @@ class Notion extends OAuth2
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $user = [];
|
protected $user = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
@ -49,14 +49,14 @@ class Notion extends OAuth2
|
||||||
"shops_r",
|
"shops_r",
|
||||||
"shops_w",
|
"shops_w",
|
||||||
"transactions_r",
|
"transactions_r",
|
||||||
"transactions_w",
|
"transactions_w",
|
||||||
];
|
];
|
||||||
|
|
||||||
private $pkce = '';
|
private $pkce = '';
|
||||||
|
|
||||||
private function getPKCE()
|
private function getPKCE()
|
||||||
{
|
{
|
||||||
if(empty($this->pkce)) {
|
if (empty($this->pkce)) {
|
||||||
$this->pkce = \bin2hex(\random_bytes(rand(43, 128)));
|
$this->pkce = \bin2hex(\random_bytes(rand(43, 128)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ class Notion extends OAuth2
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName():string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'etsy';
|
return 'etsy';
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +74,9 @@ class Notion extends OAuth2
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLoginURL():string
|
public function getLoginURL(): string
|
||||||
{
|
{
|
||||||
return 'https://www.etsy.com/oauth/connect/oauth/authorize?'. \http_build_query([
|
return 'https://www.etsy.com/oauth/connect/oauth/authorize?' . \http_build_query([
|
||||||
'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
'response_type' => 'code',
|
'response_type' => 'code',
|
||||||
|
|
@ -94,7 +94,7 @@ class Notion extends OAuth2
|
||||||
*/
|
*/
|
||||||
protected function getTokens(string $code): array
|
protected function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
if(empty($this->tokens)) {
|
if (empty($this->tokens)) {
|
||||||
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
|
|
||||||
$this->tokens = \json_decode($this->request(
|
$this->tokens = \json_decode($this->request(
|
||||||
|
|
@ -119,7 +119,7 @@ class Notion extends OAuth2
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function refreshTokens(string $refreshToken):array
|
public function refreshTokens(string $refreshToken): array
|
||||||
{
|
{
|
||||||
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ class Notion extends OAuth2
|
||||||
])
|
])
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
if(empty($this->tokens['refresh_token'])) {
|
if (empty($this->tokens['refresh_token'])) {
|
||||||
$this->tokens['refresh_token'] = $refreshToken;
|
$this->tokens['refresh_token'] = $refreshToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +146,7 @@ class Notion extends OAuth2
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUserID(string $accessToken):string
|
public function getUserID(string $accessToken): string
|
||||||
{
|
{
|
||||||
$components = explode('.', $accessToken);
|
$components = explode('.', $accessToken);
|
||||||
|
|
||||||
|
|
@ -158,7 +158,7 @@ class Notion extends OAuth2
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUserEmail(string $accessToken):string
|
public function getUserEmail(string $accessToken): string
|
||||||
{
|
{
|
||||||
return $this->getUser($accessToken)['primary_email'];
|
return $this->getUser($accessToken)['primary_email'];
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +168,7 @@ class Notion extends OAuth2
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUserName(string $accessToken):string
|
public function getUserName(string $accessToken): string
|
||||||
{
|
{
|
||||||
return $this->getUser($accessToken)['login_name'];
|
return $this->getUser($accessToken)['login_name'];
|
||||||
}
|
}
|
||||||
|
|
@ -180,15 +180,15 @@ class Notion extends OAuth2
|
||||||
*/
|
*/
|
||||||
protected function getUser(string $accessToken)
|
protected function getUser(string $accessToken)
|
||||||
{
|
{
|
||||||
if(!empty($this->user)) {
|
if (!empty($this->user)) {
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = ['Authorization: Bearer ' . $accessToken];
|
$headers = ['Authorization: Bearer ' . $accessToken];
|
||||||
|
|
||||||
$this->user = \json_decode($this->request(
|
$this->user = \json_decode($this->request(
|
||||||
'GET',
|
'GET',
|
||||||
'https://api.etsy.com/v3/application/users/' . $this->getUserID($accessToken),
|
'https://api.etsy.com/v3/application/users/' . $this->getUserID($accessToken),
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
return $this->user;
|
return $this->user;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue