| @@ 17-102 (lines=86) @@ | ||
| 14 | * |
|
| 15 | * @package Isign\Document |
|
| 16 | */ |
|
| 17 | class Check implements QueryInterface |
|
| 18 | { |
|
| 19 | use FileFieldsTrait; |
|
| 20 | ||
| 21 | /** @var string Possible values: pdf, adoc, mdoc */ |
|
| 22 | private $type; |
|
| 23 | ||
| 24 | /** @var string file path */ |
|
| 25 | private $path; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param string $type |
|
| 29 | * @param string $path |
|
| 30 | */ |
|
| 31 | public function __construct($type, $path) |
|
| 32 | { |
|
| 33 | $this->type = $type; |
|
| 34 | $this->path = $path; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * API action name, part of full API request url |
|
| 39 | * @return string |
|
| 40 | */ |
|
| 41 | public function getAction() |
|
| 42 | { |
|
| 43 | return 'check'; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * Field and values association used in query |
|
| 48 | * @return array |
|
| 49 | */ |
|
| 50 | public function getFields() |
|
| 51 | { |
|
| 52 | return [ |
|
| 53 | 'type' => $this->type, |
|
| 54 | 'file' => $this->getFileFields($this->path), |
|
| 55 | ]; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Result object for this query result |
|
| 60 | * @return ResultInterface |
|
| 61 | */ |
|
| 62 | public function createResult() |
|
| 63 | { |
|
| 64 | return new CheckResult(); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Validation constraints for fields |
|
| 69 | * @return array |
|
| 70 | */ |
|
| 71 | public function getValidationConstraints() |
|
| 72 | { |
|
| 73 | return new Assert\Collection([ |
|
| 74 | 'type' => new Assert\Required([ |
|
| 75 | new Assert\NotBlank(), |
|
| 76 | new Assert\Choice([ |
|
| 77 | 'choices' => DocumentTypeProvider::getPrimaryDocumentTypes() |
|
| 78 | ]) |
|
| 79 | ]), |
|
| 80 | 'file' => new Assert\Collection([ |
|
| 81 | 'name' => new Assert\Required([ |
|
| 82 | new Assert\NotBlank() |
|
| 83 | ]), |
|
| 84 | 'content' => new Assert\Required([ |
|
| 85 | new Assert\NotBlank(), |
|
| 86 | ]), |
|
| 87 | 'digest' => new Assert\Required([ |
|
| 88 | new Assert\NotBlank() |
|
| 89 | ]), |
|
| 90 | ]) |
|
| 91 | ]); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * HTTP method to use |
|
| 96 | * @return string |
|
| 97 | */ |
|
| 98 | public function getMethod() |
|
| 99 | { |
|
| 100 | return QueryInterface::POST; |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||
| @@ 16-101 (lines=86) @@ | ||
| 13 | * |
|
| 14 | * @package Isign\Document |
|
| 15 | */ |
|
| 16 | class Timestamp implements QueryInterface |
|
| 17 | { |
|
| 18 | use FileFieldsTrait; |
|
| 19 | ||
| 20 | /** @var string Possible values: pdf, adoc, mdoc */ |
|
| 21 | private $type; |
|
| 22 | ||
| 23 | /** @var string file path */ |
|
| 24 | private $path; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param string $type Possible values: pdf, adoc, mdoc |
|
| 28 | * @param string $path |
|
| 29 | */ |
|
| 30 | public function __construct($type, $path) |
|
| 31 | { |
|
| 32 | $this->type = $type; |
|
| 33 | $this->path = $path; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * API action name, part of full API request url |
|
| 38 | * @return string |
|
| 39 | */ |
|
| 40 | public function getAction() |
|
| 41 | { |
|
| 42 | return 'timestamp'; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Field and values association used in query |
|
| 47 | * @return array |
|
| 48 | */ |
|
| 49 | public function getFields() |
|
| 50 | { |
|
| 51 | return [ |
|
| 52 | 'type' => $this->type, |
|
| 53 | 'file' => $this->getFileFields($this->path), |
|
| 54 | ]; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Result object for this query result |
|
| 59 | * @return ResultInterface |
|
| 60 | */ |
|
| 61 | public function createResult() |
|
| 62 | { |
|
| 63 | return new TimestampResult(); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Validation constraints for fields |
|
| 68 | * @return array |
|
| 69 | */ |
|
| 70 | public function getValidationConstraints() |
|
| 71 | { |
|
| 72 | return new Assert\Collection([ |
|
| 73 | 'type' => new Assert\Required([ |
|
| 74 | new Assert\NotBlank(), |
|
| 75 | new Assert\Choice([ |
|
| 76 | 'choices' => DocumentTypeProvider::getPrimaryDocumentTypes() |
|
| 77 | ]) |
|
| 78 | ]), |
|
| 79 | 'file' => new Assert\Collection([ |
|
| 80 | 'name' => new Assert\Required([ |
|
| 81 | new Assert\NotBlank() |
|
| 82 | ]), |
|
| 83 | 'content' => new Assert\Required([ |
|
| 84 | new Assert\NotBlank(), |
|
| 85 | ]), |
|
| 86 | 'digest' => new Assert\Required([ |
|
| 87 | new Assert\NotBlank() |
|
| 88 | ]), |
|
| 89 | ]), |
|
| 90 | ]); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * HTTP method to use |
|
| 95 | * @return string |
|
| 96 | */ |
|
| 97 | public function getMethod() |
|
| 98 | { |
|
| 99 | return QueryInterface::POST; |
|
| 100 | } |
|
| 101 | } |
|
| 102 | ||