From caa6c267e095c3e2e12a74318c1b64fe09f7c8d5 Mon Sep 17 00:00:00 2001 From: Atos William Date: Fri, 3 Nov 2017 17:00:35 +0000 Subject: [PATCH] GetList for User on SSH Key --- SSH.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/SSH.php b/SSH.php index 36c301b4..71beea45 100644 --- a/SSH.php +++ b/SSH.php @@ -108,6 +108,7 @@ public function initFields( $version = null, $className = '' ) { function getResource( $action = ONAPP_GETRESOURCE_DEFAULT ) { switch ( $action ) { + case ONAPP_ACTIVATE_GETLIST_USER : case ONAPP_GETRESOURCE_ADD : /** * ROUTE : @@ -130,7 +131,38 @@ function getResource( $action = ONAPP_GETRESOURCE_DEFAULT ) { $resource = parent::getResource( $action ); break; } - return $resource; } + + + /** + * Sends an API request to get the Objects. After requesting, + * unserializes the received response into the array of Objects + * + * @param int|null $user_id + * + * @return array|bool + */ + function getList( $user_id = null, $url_args = null ) { + //todo rewrite to use parent method + if ( is_null( $user_id ) ) { + return parent::getList( null, $url_args ); + } else { + $this->activateCheck( ONAPP_ACTIVATE_GETLIST ); + $this->logger->add( 'getList: Get Transaction list.' ); + $this->_user_id = $user_id; + $this->setAPIResource( $this->getResource( ONAPP_ACTIVATE_GETLIST_USER ) ); + $response = $this->sendRequest( ONAPP_REQUEST_METHOD_GET ); + $result = $this->castStringToClass( $response ); + if ( ! empty( $response['errors'] ) ) { + //todo test this stuff + //$this->errors = $result->errors; + return false; + } + if ( ! is_array( $result ) && ! is_null( $result ) ) { + $result = array( $result ); + } + return $result; + } + } }