1
|
|
|
<?php |
2
|
|
|
namespace Dokobit\Gateway\Query\Signing; |
3
|
|
|
|
4
|
|
|
use Dokobit\Gateway\Query\QueryInterface; |
5
|
|
|
use Dokobit\Gateway\Result\ResultInterface; |
6
|
|
|
use Dokobit\Gateway\Result\Signing\ArchiveResult; |
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Archive a signing. |
11
|
|
|
* @see https://gateway-sandbox.dokobit.com/api/doc#_api_signing_archive |
12
|
|
|
*/ |
13
|
|
|
class Archive implements QueryInterface |
14
|
|
|
{ |
15
|
|
|
/** @var string signing token */ |
16
|
|
|
private $token; |
17
|
|
|
|
18
|
|
|
/** @var string postback URL, if specified */ |
19
|
|
|
private $postbackUrl; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $token signing token |
23
|
|
|
* @param string|null $postbackUrl postback URL. If not specified here, |
24
|
|
|
* the one sent during signing creation will be used. |
25
|
|
|
*/ |
26
|
|
|
public function __construct( |
27
|
|
|
string $token, |
28
|
|
|
?string $postbackUrl = null |
29
|
|
|
) { |
30
|
|
|
$this->token = $token; |
31
|
|
|
$this->postbackUrl = $postbackUrl; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Field and values association used in query |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
|
|
public function getFields(): array |
39
|
|
|
{ |
40
|
|
|
$return = [ |
41
|
|
|
'token' => $this->token, |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
if ($this->postbackUrl !== null) { |
45
|
|
|
$return['postback_url'] = $this->postbackUrl; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Validation constraints for request data validation |
53
|
|
|
* @return Assert\Collection |
54
|
|
|
*/ |
55
|
|
|
public function getValidationConstraints(): Assert\Collection |
56
|
|
|
{ |
57
|
|
|
return new Assert\Collection([ |
58
|
|
|
'token' => new Assert\Required([ |
59
|
|
|
new Assert\NotBlank(), |
60
|
|
|
]), |
61
|
|
|
'postback_url' => new Assert\Optional([ |
62
|
|
|
new Assert\NotBlank(), |
63
|
|
|
new Assert\Url(), |
64
|
|
|
]), |
65
|
|
|
]); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Result object for this query result |
70
|
|
|
* @return ArchiveResult |
71
|
|
|
*/ |
72
|
|
|
public function createResult(): ResultInterface |
73
|
|
|
{ |
74
|
|
|
return new ArchiveResult(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* API action name, part of full API request url |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getAction(): string |
82
|
|
|
{ |
83
|
|
|
return "signing/{$this->token}/archive"; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* HTTP method to use |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getMethod(): string |
91
|
|
|
{ |
92
|
|
|
return QueryInterface::POST; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|