@@ 14-56 (lines=43) @@ | ||
11 | use Threema\MsgApi\Commands\Results\LookupIdResult; |
|
12 | use Threema\MsgApi\Tools\CryptTool; |
|
13 | ||
14 | class LookupEmail implements CommandInterface { |
|
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | private $emailAddress; |
|
19 | ||
20 | /** |
|
21 | * @param string $emailAddress |
|
22 | */ |
|
23 | public function __construct($emailAddress) { |
|
24 | $this->emailAddress = $emailAddress; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @return string |
|
29 | */ |
|
30 | public function getEmailAddress() { |
|
31 | return $this->emailAddress; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @return array |
|
36 | */ |
|
37 | public function getParams() { |
|
38 | return array(); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * @return string |
|
43 | */ |
|
44 | public function getPath() { |
|
45 | return 'lookup/email_hash/'.urlencode(CryptTool::getInstance()->hashEmail($this->emailAddress)); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @param int $httpCode |
|
50 | * @param object $res |
|
51 | * @return LookupIdResult |
|
52 | */ |
|
53 | public function parseResult($httpCode, $res){ |
|
54 | return new LookupIdResult($httpCode, $res); |
|
55 | } |
|
56 | } |
|
57 |
@@ 14-56 (lines=43) @@ | ||
11 | use Threema\MsgApi\Commands\Results\LookupIdResult; |
|
12 | use Threema\MsgApi\Tools\CryptTool; |
|
13 | ||
14 | class LookupPhone implements CommandInterface { |
|
15 | /** |
|
16 | * @var string |
|
17 | */ |
|
18 | private $phoneNumber; |
|
19 | ||
20 | /** |
|
21 | * @param string $phoneNumber |
|
22 | */ |
|
23 | public function __construct($phoneNumber) { |
|
24 | $this->phoneNumber = $phoneNumber; |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @return string |
|
29 | */ |
|
30 | public function getPhoneNumber() { |
|
31 | return $this->phoneNumber; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @return array |
|
36 | */ |
|
37 | public function getParams() { |
|
38 | return array(); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * @return string |
|
43 | */ |
|
44 | public function getPath() { |
|
45 | return 'lookup/phone_hash/'.urlencode(CryptTool::getInstance()->hashPhoneNo($this->phoneNumber)); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * @param int $httpCode |
|
50 | * @param object $res |
|
51 | * @return LookupIdResult |
|
52 | */ |
|
53 | public function parseResult($httpCode, $res){ |
|
54 | return new LookupIdResult($httpCode, $res); |
|
55 | } |
|
56 | } |
|
57 |