Total Complexity | 7 |
Total Lines | 85 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Me extends ApiNfeFasa |
||
10 | { |
||
11 | private $headers; |
||
12 | public $token; |
||
13 | |||
14 | /** |
||
15 | * Me constructor |
||
16 | * @param string $apiUrl |
||
17 | */ |
||
18 | public function __construct(string $apiUrl) |
||
19 | { |
||
20 | parent::__construct($apiUrl); |
||
21 | $this->token = null; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return Me |
||
26 | */ |
||
27 | public function register(array $fields): Me |
||
28 | { |
||
29 | $this->request( |
||
30 | "POST", |
||
31 | "/auth/register", |
||
32 | $fields |
||
33 | ); |
||
34 | |||
35 | return $this; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return Me |
||
40 | */ |
||
41 | public function me(): Me |
||
42 | { |
||
43 | $this->request( |
||
44 | "GET", |
||
45 | "/auth/me", |
||
46 | null, |
||
47 | $this->headers |
||
48 | ); |
||
49 | |||
50 | return $this; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return Me |
||
55 | */ |
||
56 | public function auth(string $email, string $password): Me |
||
57 | { |
||
58 | $this->request( |
||
59 | "POST", |
||
60 | "/auth/token", |
||
61 | array("email" => $email, "password" => $password) |
||
62 | ); |
||
63 | |||
64 | $this->token(); |
||
65 | |||
66 | return $this; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return Me |
||
71 | */ |
||
72 | public function logout(): Me |
||
73 | { |
||
74 | $this->request( |
||
75 | "POST", |
||
76 | "/auth/logout", |
||
77 | null, |
||
78 | $this->headers |
||
79 | ); |
||
80 | |||
81 | return $this; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @return Me |
||
86 | */ |
||
87 | public function token(): Me |
||
94 | } |
||
95 | |||
96 | } |