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\CreateBatchResult; |
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Create a batch signing. |
11
|
|
|
* @see https://gateway-sandbox.dokobit.com/api/doc#_api_signing_createbatch |
12
|
|
|
*/ |
13
|
|
|
class CreateBatch implements QueryInterface |
14
|
|
|
{ |
15
|
|
|
/** @var array an array of associative arrays of signing and signer tokens */ |
16
|
|
|
private $signings; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param array $signings an array of associative arrays of signing and signer tokens. Format: |
20
|
|
|
* [ |
21
|
|
|
* ['token' => 'signingToken1', 'signer_token' => 'signerToken1'], |
22
|
|
|
* ['token' => 'signingToken2', 'signer_token' => 'signerToken2'], |
23
|
|
|
* ... |
24
|
|
|
* ] |
25
|
|
|
*/ |
26
|
|
|
public function __construct(array $signings) |
27
|
|
|
{ |
28
|
|
|
$this->signings = $signings; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Field and values association used in query |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
|
public function getFields(): array |
36
|
|
|
{ |
37
|
|
|
$return = [ |
38
|
|
|
'signings' => $this->signings, |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
return $return; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Validation constraints for request data validation |
46
|
|
|
* @return Assert\Collection |
47
|
|
|
*/ |
48
|
|
|
public function getValidationConstraints(): Assert\Collection |
49
|
|
|
{ |
50
|
|
|
return new Assert\Collection([ |
51
|
|
|
'signings' => new Assert\All([ |
52
|
|
|
new Assert\Collection([ |
53
|
|
|
'token' => new Assert\Required([ |
54
|
|
|
new Assert\NotBlank() |
55
|
|
|
]), |
56
|
|
|
'signer_token' => new Assert\Optional([ |
57
|
|
|
new Assert\NotBlank(), |
58
|
|
|
]), |
59
|
|
|
]), |
60
|
|
|
]), |
61
|
|
|
]); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Result object for this query result |
66
|
|
|
* @return CreateBatchResult |
67
|
|
|
*/ |
68
|
|
|
public function createResult(): ResultInterface |
69
|
|
|
{ |
70
|
|
|
return new CreateBatchResult(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* API action name, part of full API request url |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
|
|
public function getAction(): string |
78
|
|
|
{ |
79
|
|
|
return 'signing/createbatch'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* HTTP method to use |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function getMethod(): string |
87
|
|
|
{ |
88
|
|
|
return QueryInterface::POST; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|