-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccount.php
41 lines (31 loc) · 1017 Bytes
/
Account.php
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
34
35
36
37
38
39
40
41
<?php
namespace Ejetar\LeitorHospedagem;
use Ejetar\LeitorHospedagem\Traits\Domain;
use Ejetar\LeitorHospedagem\Traits\Process;
use Ejetar\LeitorHospedagem\Traits\Space;
use Httpful\Request;
class Account {
use Space, Domain, Process;
public string $name;
public array $domains;
public Session $session;
public function __construct($name, $session) {
$this->name = $name;
$this->session = $session;
}
public static function getList($session) {
$responseAccounts = Request::get($_ENV['CWP_URL']."/{$session->token}/admin/loader_ajax.php?ajax=list_accounts&tipo=all")
->expectsJson()
->addHeaders(array(
'Cookie' => "{$session->cookie} _firstImpression=true",
))
->send();
if ($responseAccounts->code !== 200)
return false;
return array_map(function ($item) use($session) {
//Captura o nome do usuário em meio a maçaroca de dados
preg_match("/^[^\s]*/", $item[0], $matches);
return new Account($matches[0], $session);
}, $responseAccounts->body->aaData);
}
}