-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAccount.php
More file actions
33 lines (25 loc) · 828 Bytes
/
Account.php
File metadata and controls
33 lines (25 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace ThothApi\GraphQL;
class Account
{
private Request $request;
public const THOTH_ACCOUNT_ENDPOINT = 'account';
public function __construct(Request $request)
{
$this->request = $request;
}
public function login(string $email, string $password): string
{
$response = $this->request->execute('POST', self::THOTH_ACCOUNT_ENDPOINT . '/login', ['json' => [
'email' => $email, 'password' => $password
]]);
return json_decode($response->getBody())->token;
}
public function details(string $token): array
{
$response = $this->request->execute('GET', self::THOTH_ACCOUNT_ENDPOINT, ['headers' => [
'Authorization' => 'Bearer ' . $token
]]);
return json_decode($response->getBody(), true);
}
}