1 | <?php |
||
10 | class Api |
||
11 | { |
||
12 | const AHGORA_BASE_URL = 'https://www.ahgora.com.br/'; |
||
13 | |||
14 | /** @var \Katapoka\Ahgora\IHttpClient */ |
||
15 | private $httpClient; |
||
16 | /** @var string */ |
||
17 | private $password; |
||
18 | /** @var string */ |
||
19 | private $companyId; |
||
20 | /** @var string */ |
||
21 | private $username; |
||
22 | /** @var bool */ |
||
23 | private $loggedIn = false; |
||
24 | |||
25 | /** |
||
26 | * Api constructor. |
||
27 | * |
||
28 | * @param IHttpClient $httpClient |
||
29 | */ |
||
30 | 1 | public function __construct(IHttpClient $httpClient) |
|
34 | |||
35 | /** |
||
36 | * Set the company id of the ahgora system. |
||
37 | * |
||
38 | * @param string $companyId |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function setCompanyId($companyId) |
||
48 | |||
49 | /** |
||
50 | * Set the username of the employee, from the company set at the setCompanyId. |
||
51 | * |
||
52 | * @param string $username |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function setUsername($username) |
||
62 | |||
63 | /** |
||
64 | * Set the password of the employee, from the company set at the setCompanyId. |
||
65 | * |
||
66 | * @param string $password |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function setPassword($password) |
||
76 | |||
77 | /** |
||
78 | * Try to execute the login on the page. |
||
79 | * To execute some actions the user needs to be loggedin. |
||
80 | * After a successful login, the status loggedin is saved as true. |
||
81 | * |
||
82 | * @return bool Returns true if the login was successful and false otherwise |
||
83 | */ |
||
84 | public function doLogin() |
||
90 | |||
91 | /** |
||
92 | * Safely set if the user is loggedin or not. |
||
93 | * Did a separate method do eventually trigger events, if necessary. |
||
94 | * |
||
95 | * @param bool $loggedIn |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | private function setLoggedIn($loggedIn = true) |
||
108 | } |
||
109 |