Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetList for User on SSH Key #43

Open
wants to merge 1 commit into
base: 5.5.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion SSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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;
}
}
}