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\AddSignerResult; |
7
|
|
|
use Dokobit\Gateway\SigningPurposeProvider; |
8
|
|
|
use Dokobit\Gateway\Validator\Constraints as MyAssert; |
9
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Add new signers to signing. |
13
|
|
|
* @see https://gateway-sandbox.dokobit.com/api/doc#_api_signing_addsigner |
14
|
|
|
*/ |
15
|
|
|
class AddSigner implements QueryInterface |
16
|
|
|
{ |
17
|
|
|
/** @var string signing token */ |
18
|
|
|
private $token; |
19
|
|
|
|
20
|
|
|
/** @var array information about document signers */ |
21
|
|
|
private $signers; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param string $token signing token |
25
|
|
|
* @param array $signers information about document signers. Format: |
26
|
|
|
* [ |
27
|
|
|
* [ 'id' => 'signer1', 'name' => 'Kraft', 'surname' => 'Lawrence', ... ], |
28
|
|
|
* [ 'id' => 'signer2', 'name' => 'Fleur', 'surname' => 'Boland', ... ], |
29
|
|
|
* ... |
30
|
|
|
* ] |
31
|
|
|
* The value of id is entirely up to you. It is used to refer to the signer afterwards, |
32
|
|
|
* e.g. when checking signing status, or removing signer from the signing. |
33
|
|
|
* For all supported signer properties, check out the API method documentation. |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
string $token, |
37
|
|
|
array $signers |
38
|
|
|
) { |
39
|
|
|
$this->token = $token; |
40
|
|
|
$this->signers = $signers; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Field and values association used in query |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function getFields(): array |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'token' => $this->token, |
51
|
|
|
'signers' => $this->signers, |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Validation constraints for request data validation |
57
|
|
|
* @return Assert\Collection |
58
|
|
|
*/ |
59
|
|
|
public function getValidationConstraints(): Assert\Collection |
60
|
|
|
{ |
61
|
|
|
return new Assert\Collection([ |
62
|
|
|
'token' => new Assert\Required([ |
63
|
|
|
new Assert\NotBlank(), |
64
|
|
|
]), |
65
|
|
|
'signers' => new Assert\Required([ |
66
|
|
|
new Assert\NotBlank(), |
67
|
|
|
new Assert\All([ |
68
|
|
|
new Assert\Collection([ |
69
|
|
|
'id' => new Assert\Required([ |
70
|
|
|
new Assert\NotBlank(), |
71
|
|
|
]), |
72
|
|
|
'name' => new Assert\Required([ |
73
|
|
|
new Assert\NotBlank(), |
74
|
|
|
]), |
75
|
|
|
'surname' => new Assert\Required([ |
76
|
|
|
new Assert\NotBlank(), |
77
|
|
|
]), |
78
|
|
|
'code' => new Assert\Optional([ |
79
|
|
|
new Assert\NotBlank(), |
80
|
|
|
new MyAssert\Code(), |
81
|
|
|
]), |
82
|
|
|
'phone' => new Assert\Optional([ |
83
|
|
|
new Assert\NotBlank(), |
84
|
|
|
new MyAssert\Phone(), |
85
|
|
|
]), |
86
|
|
|
'company' => new Assert\Optional([ |
87
|
|
|
new Assert\NotBlank(), |
88
|
|
|
]), |
89
|
|
|
'country' => new Assert\Optional([ |
90
|
|
|
new Assert\NotBlank(), |
91
|
|
|
]), |
92
|
|
|
'country_code' => new Assert\Optional([ |
93
|
|
|
new Assert\NotBlank(), |
94
|
|
|
new Assert\Country(), |
95
|
|
|
]), |
96
|
|
|
'city' => new Assert\Optional([ |
97
|
|
|
new Assert\NotBlank(), |
98
|
|
|
]), |
99
|
|
|
'postal_code' => new Assert\Optional([ |
100
|
|
|
new Assert\NotBlank(), |
101
|
|
|
]), |
102
|
|
|
'position' => new Assert\Optional([ |
103
|
|
|
new Assert\NotBlank(), |
104
|
|
|
]), |
105
|
|
|
'structural_subdivision' => new Assert\Optional([ |
106
|
|
|
new Assert\NotBlank(), |
107
|
|
|
]), |
108
|
|
|
'signing_purpose' => new Assert\Optional([ |
109
|
|
|
new Assert\NotBlank(), |
110
|
|
|
new Assert\Choice([ |
111
|
|
|
'choices' => SigningPurposeProvider::getAllSigningPurposes(), |
112
|
|
|
]), |
113
|
|
|
]), |
114
|
|
|
'pdf' => new Assert\Optional(), |
115
|
|
|
'pdflt' => new Assert\Optional(), |
116
|
|
|
'adoc' => new Assert\Optional(), |
117
|
|
|
'mdoc' => new Assert\Optional(), |
118
|
|
|
]), |
119
|
|
|
]), |
120
|
|
|
]), |
121
|
|
|
]); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Result object for this query result |
126
|
|
|
* @return AddSignerResult |
127
|
|
|
*/ |
128
|
|
|
public function createResult(): ResultInterface |
129
|
|
|
{ |
130
|
|
|
return new AddSignerResult(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* API action name, part of full API request url |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getAction(): string |
138
|
|
|
{ |
139
|
|
|
return "signing/{$this->token}/addsigner"; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* HTTP method to use |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getMethod(): string |
147
|
|
|
{ |
148
|
|
|
return QueryInterface::POST; |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|