| @@ 11-66 (lines=56) @@ | ||
| 8 | /** |
|
| 9 | * Login status for MobileId, SmartId, etc. |
|
| 10 | */ |
|
| 11 | abstract class AbstractStatus implements TokenizedQueryInterface |
|
| 12 | { |
|
| 13 | /** @var string unique resource identifier, received from mobile login request */ |
|
| 14 | protected $token; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @param string $token unique resource identifier, received from mobile login request |
|
| 18 | * @return self |
|
| 19 | */ |
|
| 20 | public function __construct($token) |
|
| 21 | { |
|
| 22 | $this->token = $token; |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Get token |
|
| 27 | * @return string |
|
| 28 | */ |
|
| 29 | public function getToken() |
|
| 30 | { |
|
| 31 | return $this->token; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Get fields |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | public function getFields() |
|
| 39 | { |
|
| 40 | return [ |
|
| 41 | 'token' => $this->token, |
|
| 42 | ]; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Validation constraints for request data validation |
|
| 47 | * @return Assert\Collection |
|
| 48 | */ |
|
| 49 | public function getValidationConstraints() |
|
| 50 | { |
|
| 51 | return new Assert\Collection([ |
|
| 52 | 'token' => new Assert\Required( |
|
| 53 | [new Assert\NotBlank()] |
|
| 54 | ) |
|
| 55 | ]); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * HTTP method to use |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | public function getMethod() |
|
| 63 | { |
|
| 64 | return QueryInterface::GET; |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| @@ 9-72 (lines=64) @@ | ||
| 6 | use Isign\QueryInterface; |
|
| 7 | use Symfony\Component\Validator\Constraints as Assert; |
|
| 8 | ||
| 9 | class Sc implements QueryInterface |
|
| 10 | { |
|
| 11 | /** @var string base64_encode(certificate) */ |
|
| 12 | private $certificate; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @param $certificate string base64_encode(certificate) |
|
| 16 | */ |
|
| 17 | public function __construct($certificate) |
|
| 18 | { |
|
| 19 | $this->certificate = $certificate; |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * API action name, part of full API request url |
|
| 24 | * @return string |
|
| 25 | */ |
|
| 26 | public function getAction() |
|
| 27 | { |
|
| 28 | return 'sc/login'; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Field and values association used in query |
|
| 33 | * @return array |
|
| 34 | */ |
|
| 35 | public function getFields() |
|
| 36 | { |
|
| 37 | return [ |
|
| 38 | 'certificate' => $this->certificate |
|
| 39 | ]; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Result object for this query result |
|
| 44 | * @return MobileResult |
|
| 45 | */ |
|
| 46 | public function createResult() |
|
| 47 | { |
|
| 48 | return new ScResult(); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Validation constraints for fields |
|
| 53 | * @return array |
|
| 54 | */ |
|
| 55 | public function getValidationConstraints() |
|
| 56 | { |
|
| 57 | return new Assert\Collection([ |
|
| 58 | 'certificate' => new Assert\Required([ |
|
| 59 | new Assert\NotBlank(), |
|
| 60 | ]) |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * HTTP method to use |
|
| 66 | * @return string |
|
| 67 | */ |
|
| 68 | public function getMethod() |
|
| 69 | { |
|
| 70 | return QueryInterface::POST; |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||