Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
justijndepover committed Mar 31, 2021
1 parent 9687a2e commit 6857120
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Teamleader.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function setState($state): void
$this->state = $state;
}

public function getAuthorizationCode(): string
public function getAuthorizationCode(): ?string
{
return $this->authorizationCode;
}
Expand All @@ -136,7 +136,7 @@ public function setAuthorizationCode($authorizationCode): void
$this->authorizationCode = $authorizationCode;
}

public function getAccessToken(): string
public function getAccessToken(): ?string
{
return $this->accessToken;
}
Expand All @@ -146,7 +146,7 @@ public function setAccessToken($accessToken): void
$this->accessToken = $accessToken;
}

public function getRefreshToken(): string
public function getRefreshToken(): ?string
{
return $this->refreshToken;
}
Expand All @@ -156,7 +156,7 @@ public function setRefreshToken($refreshToken): void
$this->refreshToken = $refreshToken;
}

public function getTokenExpiresAt(): int
public function getTokenExpiresAt(): ?int
{
return $this->tokenExpiresAt;
}
Expand Down Expand Up @@ -317,8 +317,11 @@ private function acquireAccessToken(): void
$this->accessToken = $body['access_token'];
$this->refreshToken = $body['refresh_token'];
$this->tokenExpiresAt = time() + $body['expires_in'];
} catch (ClientException $e) {
$response = json_decode($e->getResponse()->getBody()->getContents());
throw CouldNotAquireAccessTokenException::make($response->errors[0]->status, $response->errors[0]->title);
} catch (Exception $e) {
throw CouldNotAquireAccessTokenException::make($e->getCode(), $e->getMessage());
throw ApiException::make($e->getCode(), $e->getMessage());
}
}
}

0 comments on commit 6857120

Please sign in to comment.