public OneTouchResponse sendApprovalRequest ( ApprovalRequestParams approvalRequestParams ) throws AuthyException { //Integer userId, String message, HashMap<String, Object> options, Integer secondsToExpire) throws OneTouchException { JSONObject params = new JSONObject ( ) ; params . put ( "message" , approvalRequestParams . getMessage ( ) ) ; if ( approvalRequestParams . getSecondsToExpire ( ) != null ) { params . put ( "seconds_to_expire" , approvalRequestParams . getSecondsToExpire ( ) ) ; } if ( approvalRequestParams . getDetails ( ) . size ( ) > 0 ) { params . put ( "details" , mapToJSONObject ( approvalRequestParams . getDetails ( ) ) ) ; } if ( approvalRequestParams . getHidden ( ) . size ( ) > 0 ) { params . put ( "hidden_details" , mapToJSONObject ( approvalRequestParams . getHidden ( ) ) ) ; } if ( ! approvalRequestParams . getLogos ( ) . isEmpty ( ) ) { JSONArray jSONArray = new JSONArray ( ) ; for ( Logo logo : approvalRequestParams . getLogos ( ) ) { logo . addToMap ( jSONArray ) ; } params . put ( "logos" , jSONArray ) ; } final Response response = this . post ( APPROVAL_REQUEST_PRE + approvalRequestParams . getAuthyId ( ) + APPROVAL_REQUEST_POS , new JSONBody ( params ) ) ; OneTouchResponse oneTouchResponse = new OneTouchResponse ( response . getStatus ( ) , response . getBody ( ) ) ; if ( ! oneTouchResponse . isOk ( ) ) { oneTouchResponse . setError ( errorFromJson ( response . getBody ( ) ) ) ; } return oneTouchResponse ; }
Sends the OneTouch s approval request to the Authy servers and returns the OneTouchResponse that comes back .