1
|
|
|
<?php |
2
|
|
|
namespace Dokobit\Gateway\Query\File; |
3
|
|
|
|
4
|
|
|
use Dokobit\Gateway\DocumentTypeProvider; |
5
|
|
|
use Dokobit\Gateway\Query\QueryInterface; |
6
|
|
|
use Dokobit\Gateway\Result\File\UploadStatusResult; |
7
|
|
|
use Dokobit\Gateway\Result\ResultInterface; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Check upload status. |
12
|
|
|
* @see https://gateway-sandbox.dokobit.com/api/doc#_api_file_upload_status |
13
|
|
|
*/ |
14
|
|
|
class UploadStatus implements QueryInterface |
15
|
|
|
{ |
16
|
|
|
/** @var string uploaded file token */ |
17
|
|
|
private $token; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param string $token uploaded file token |
21
|
|
|
*/ |
22
|
|
|
public function __construct(string $token) |
23
|
|
|
{ |
24
|
|
|
$this->token = $token; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Field and values association used in query |
29
|
|
|
* @return array |
30
|
|
|
*/ |
31
|
|
|
public function getFields(): array |
32
|
|
|
{ |
33
|
|
|
return [ |
34
|
|
|
'token' => $this->token, |
35
|
|
|
]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Validation constraints for request data validation |
40
|
|
|
* @return Assert\Collection |
41
|
|
|
*/ |
42
|
|
|
public function getValidationConstraints(): Assert\Collection |
43
|
|
|
{ |
44
|
|
|
return new Assert\Collection([ |
45
|
|
|
'token' => new Assert\Required([ |
46
|
|
|
new Assert\NotBlank(), |
47
|
|
|
]), |
48
|
|
|
]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Result object for this query result |
53
|
|
|
* @return UploadStatusResult |
54
|
|
|
*/ |
55
|
|
|
public function createResult(): ResultInterface |
56
|
|
|
{ |
57
|
|
|
return new UploadStatusResult(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* API action name, part of full API request url |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getAction(): string |
65
|
|
|
{ |
66
|
|
|
return "file/upload/{$this->token}/status"; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* HTTP method to use |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getMethod(): string |
74
|
|
|
{ |
75
|
|
|
return QueryInterface::GET; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|