2
2
3
3
namespace SHL \SdiClient ;
4
4
5
+ use JsonSerializable ;
5
6
use SHL \SdiClient \Exceptions \RequestFailureException ;
7
+ use SHL \SdiClient \Types \DocumentInfo ;
8
+ use SHL \SdiClient \Types \DocumentReceived ;
9
+ use SHL \SdiClient \Types \DocumentSent ;
10
+ use SHL \SdiClient \Types \DocumentSentNotification ;
6
11
use SHL \SdiClient \Types \ErrorMessage ;
12
+ use SHL \SdiClient \Types \File ;
13
+ use SHL \SdiClient \Types \OutcomeSent ;
14
+ use SHL \SdiClient \Types \User ;
15
+ use SHL \SdiClient \Types \UserInfo ;
7
16
8
17
class Client {
9
18
/**
@@ -30,6 +39,11 @@ class Client {
30
39
*/
31
40
private $ TryConnectionTimeout = 120 ;
32
41
42
+ /**
43
+ * @var bool
44
+ */
45
+ private $ VerifyCertificate = true ;
46
+
33
47
34
48
/**
35
49
* Costruisce il client con i parametri di connessione
@@ -49,6 +63,7 @@ public function __construct( $endpoint, $username, $apiToken ) {
49
63
*/
50
64
public function setTimeout ( int $ timeout ) {
51
65
$ this ->Timeout = $ timeout ;
66
+ return $ this ;
52
67
}
53
68
54
69
@@ -58,18 +73,25 @@ public function setTimeout( int $timeout ) {
58
73
*/
59
74
public function setTryConnectionTimeout ( int $ tryConnectionTimeout ) {
60
75
$ this ->TryConnectionTimeout = $ tryConnectionTimeout ;
76
+ return $ this ;
61
77
}
62
-
78
+
79
+
80
+ public function disableCertificateCheck () {
81
+ $ this ->VerifyCertificate = false ;
82
+ return $ this ;
83
+ }
84
+
63
85
64
86
/**
65
87
* Effettua la richiesta tramite curl
66
88
* @param string $verb Il verbo http
67
89
* @param string $request La richiesta
68
- * @param \ JsonSerializable $json I dati da inviare convertiti in json
90
+ * @param JsonSerializable $json I dati da inviare convertiti in json
69
91
* @return string
70
92
* @throws RequestFailureException
71
93
*/
72
- private function curl ( string $ verb , string $ request , \ JsonSerializable $ json = null ) {
94
+ private function curl ( string $ verb , string $ request , JsonSerializable $ json = null ) {
73
95
$ ch = curl_init ();
74
96
curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ verb );
75
97
curl_setopt ( $ ch , CURLOPT_URL , $ this ->Endpoint . $ request );
@@ -84,8 +106,8 @@ private function curl( string $verb, string $request, \JsonSerializable $json =
84
106
'Authorization: ' . $ this ->Token ,
85
107
]);
86
108
87
- curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false );
88
- curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 2 );
109
+ curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> VerifyCertificate );
110
+ curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , $ this -> VerifyCertificate ? 2 : 0 );
89
111
curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 );
90
112
curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 );
91
113
curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this ->Timeout );
@@ -127,7 +149,7 @@ public function getUserList() {
127
149
/**
128
150
* Ritorna i dettagli di un utente in gestione
129
151
* @param int $id
130
- * @return \SHL\SdiClient\Types\ User
152
+ * @return User
131
153
*/
132
154
public function getUser ( $ id ) {
133
155
return new Types \User (
@@ -138,8 +160,8 @@ public function getUser( $id ) {
138
160
139
161
/**
140
162
* Crea un nuovo utente
141
- * @param \SHL\SdiClient\Types\ UserInfo $user
142
- * @return \SHL\SdiClient\Types\ User
163
+ * @param UserInfo $user
164
+ * @return User
143
165
*/
144
166
public function createUser ( Types \UserInfo $ user ) {
145
167
return new Types \User (
@@ -151,8 +173,8 @@ public function createUser( Types\UserInfo $user ) {
151
173
/**
152
174
* Modifica un utente in gestione
153
175
* @param int $userId
154
- * @param \SHL\SdiClient\Types\ UserInfo $user
155
- * @return \SHL\SdiClient\Types\ User
176
+ * @param UserInfo $user
177
+ * @return User
156
178
*/
157
179
public function editUser ( $ userId , Types \UserInfo $ user ) {
158
180
return new Types \User (
@@ -165,7 +187,7 @@ public function editUser( $userId, Types\UserInfo $user ) {
165
187
* Modifica lo stato di attivazione di un utente in gestione
166
188
* @param int $userId
167
189
* @param bool $activeStatus
168
- * @return \SHL\SdiClient\Types\ User
190
+ * @return User
169
191
*/
170
192
public function editUserActiveStatus ( $ userId , bool $ activeStatus ) {
171
193
$ params = new Types \GenericType ();
@@ -197,7 +219,7 @@ public function getDocumentSentList( $userId = null ) {
197
219
/**
198
220
* Ritorna i dettagli di un documento inviato
199
221
* @param int $id
200
- * @return \SHL\SdiClient\Types\ DocumentSent
222
+ * @return DocumentSent
201
223
*/
202
224
public function getDocumentSent ( $ id ) {
203
225
return new Types \DocumentSent (
@@ -208,8 +230,8 @@ public function getDocumentSent( $id ) {
208
230
209
231
/**
210
232
* Crea un nuovo documento da inviare allo sdi
211
- * @param \SHL\SdiClient\Types\ DocumentInfo $document
212
- * @return \SHL\SdiClient\Types\ DocumentSent
233
+ * @param DocumentInfo $document
234
+ * @return DocumentSent
213
235
*/
214
236
public function sendDocument ( Types \DocumentInfo $ document ) {
215
237
return new Types \DocumentSent (
@@ -233,7 +255,7 @@ public function getDocumentSentNotificationList( $documentId ) {
233
255
/**
234
256
* Ritorna i dettagli di una notifica di un documento
235
257
* @param int $id
236
- * @return \SHL\SdiClient\Types\ DocumentSentNotification
258
+ * @return DocumentSentNotification
237
259
*/
238
260
public function getDocumentSentNotification ( $ id ) {
239
261
return new Types \DocumentSentNotification (
@@ -245,7 +267,7 @@ public function getDocumentSentNotification( $id ) {
245
267
/**
246
268
* Ritorna l'allegato di una notifica
247
269
* @param int $id
248
- * @return \SHL\SdiClient\Types\ File
270
+ * @return File
249
271
*/
250
272
public function getDocumentSentNotificationFile ( $ id ) {
251
273
return new Types \File (
@@ -274,7 +296,7 @@ public function getDocumentReceivedList( $userId = null ) {
274
296
/**
275
297
* Ritorna i dettagli di un documento ricevuto
276
298
* @param int $id
277
- * @return \SHL\SdiClient\Types\ DocumentReceived
299
+ * @return DocumentReceived
278
300
*/
279
301
public function getDocumentReceived ( $ id ) {
280
302
return new Types \DocumentReceived (
@@ -286,7 +308,7 @@ public function getDocumentReceived( $id ) {
286
308
/**
287
309
* Ritorna il file del documento ricevuto
288
310
* @param int $id
289
- * @return \SHL\SdiClient\Types\ File
311
+ * @return File
290
312
*/
291
313
public function getDocumentReceivedFile ( $ id ) {
292
314
return new Types \File (
@@ -298,7 +320,7 @@ public function getDocumentReceivedFile( $id ) {
298
320
/**
299
321
* Ritorna il metafile del documento ricevuto
300
322
* @param int $id
301
- * @return \SHL\SdiClient\Types\ File
323
+ * @return File
302
324
*/
303
325
public function getDocumentReceivedMetafile ( $ id ) {
304
326
return new Types \File (
@@ -334,7 +356,7 @@ public function getDocumentReceivedNotification( $id ) {
334
356
/**
335
357
* Ritorna l'allegato di una notifica di un documento ricevuto
336
358
* @param int $id
337
- * @return \SHL\SdiClient\Types\ File
359
+ * @return File
338
360
*/
339
361
public function getDocumentReceivedNotificationFile ( $ id ) {
340
362
return new Types \File (
@@ -358,7 +380,7 @@ public function getOutcomeSentList( $documentId ) {
358
380
/**
359
381
* Ritorna i dettagli di una notifica di esito inviata
360
382
* @param int $id
361
- * @return \SHL\SdiClient\Types\ OutcomeSent
383
+ * @return OutcomeSent
362
384
*/
363
385
public function getOutcomeSent ( $ id ) {
364
386
return new Types \OutcomeSent (
@@ -370,7 +392,7 @@ public function getOutcomeSent( $id ) {
370
392
/**
371
393
* Ritorna l'allegato di una notifica di esito inviata
372
394
* @param int $id
373
- * @return \SHL\SdiClient\Types\ File
395
+ * @return File
374
396
*/
375
397
public function getOutcomeSentFile ( $ id ) {
376
398
return new Types \File (
@@ -382,7 +404,7 @@ public function getOutcomeSentFile( $id ) {
382
404
/**
383
405
* Ritorna il file che spiega l'errore di una notifica di esito inviata
384
406
* @param int $id
385
- * @return \SHL\SdiClient\Types\ File
407
+ * @return File
386
408
*/
387
409
public function getOutcomeSentErrorFile ( $ id ) {
388
410
$ file = $ this ->curl ( 'GET ' , '/outcome_sent/error_file/ ' . $ id );
@@ -398,7 +420,7 @@ public function getOutcomeSentErrorFile( $id ) {
398
420
* Invia una nuova notifica di esito
399
421
* @param int $documentId L'id del documento ricevuto per il quale mandare la notifica
400
422
* @param \SHL\SdiClient\Types\OutcomeInfo $outcome
401
- * @return \SHL\SdiClient\Types\ OutcomeSent
423
+ * @return OutcomeSent
402
424
*/
403
425
public function sendOutcome ( $ documentId , Types \OutcomeInfo $ outcome ) {
404
426
return new Types \OutcomeSent (
0 commit comments