Skip to content

Commit 59bf43b

Browse files
author
armando
committed
refactor cliente per gestione dell'utente proprietario dei file
1 parent 5d3f6dd commit 59bf43b

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

src/Client.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,17 @@ private function curl(http://github.com/string%20$verb,%20string%20$request,%20/JsonSerializable%20$json%20=%3C/div%3E%3C/code%3E%3C/div%3E%3C/td%3E%3C/tr%3E%3Ctr%20class=%22diff-line-row%22%3E%3Ctd%20data-grid-cell-id=%22diff-40d7473316ef0bb3ba4c4d937b16ae3d1cc47e0d65815034ee2b5be6a74cb11e-114-114-0%22%20data-selected=%22false%22%20role=%22gridcell%22%20style=%22background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">114
114

115115
/**
116116
* Ritorna la lista degli id dei documenti inviati
117+
* @param int $userId
117118
* @return array
118119
*/
119-
public function getDocumentSentList(): array {
120+
public function getDocumentSentList( $userId = null ) {
121+
$route = '/document_sent';
122+
if( !is_null( $userId ) ) {
123+
$route .= '/'.$userId;
124+
}
125+
120126
return json_decode(
121-
$this->curl( 'GET', '/document_sent' )
127+
$this->curl( 'GET', $route )
122128
, true );
123129
}
124130

@@ -185,12 +191,17 @@ public function getDocumentSentNotificationFile( $id ) {
185191

186192
/**
187193
* Ritorna la lista di tutti documenti ricevuti
188-
* @param int $documentId
194+
* @param int $userId
189195
* @return array
190196
*/
191-
public function getDocumentReceivedList() {
197+
public function getDocumentReceivedList( $userId = null ) {
198+
$route = '/document_received';
199+
if( !is_null( $userId ) ) {
200+
$route .= '/'.$userId;
201+
}
202+
192203
return json_decode(
193-
$this->curl( 'GET', '/document_received' )
204+
$this->curl( 'GET', $route )
194205
, true );
195206
}
196207

src/Types/DocumentInfo.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
namespace SHL\SdiClient\Types;
44

55
class DocumentInfo extends GenericType {
6+
7+
/**
8+
* L'id dell'utente
9+
* @var int
10+
*/
11+
public $user_id;
12+
613
/**
714
* L'external id utilizzato per identificare esternemanete all'hub il documento
815
* @var string
@@ -27,9 +34,10 @@ class DocumentInfo extends GenericType {
2734
* @param string $path
2835
* @return \SHL\SdiClient\Types\DocumentInfo
2936
*/
30-
public static function createByFilepath( $path ) {
37+
public static function createByFilepath( $userId, $path ) {
3138
$document = new DocumentInfo();
3239

40+
$document->user_id = $userId;
3341
$document->mimetype = mime_content_type( $path );
3442
$document->file = base64_encode( file_get_contents( $path ) );
3543

src/Types/DocumentReceived.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ class DocumentReceived extends GenericType {
99
*/
1010
public $id;
1111

12+
/**
13+
* @property int
14+
*/
15+
public $user_id;
16+
1217
/**
1318
* @property string
1419
*/

src/Types/DocumentSent.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ class DocumentSent extends GenericType {
77
* @property int
88
*/
99
public $id;
10-
10+
11+
/**
12+
* @var int
13+
*/
14+
public $user_id;
15+
1116
/**
1217
* @property string
1318
*/

0 commit comments

Comments
 (0)