Search in sources :

Example 1 with ResendConfirmationCodeExternalResponse

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.ResendConfirmationCodeExternalResponse in project identity-api-user by wso2.

the class PasswordRecoveryService method buildResendConfirmationResponse.

/**
 * Build Resend confirmation code response according to the notification channel.
 *
 * @param tenantDomain          Tenant domain in the request.
 * @param resendConfirmationDTO ResendConfirmationDTO
 * @return Response
 */
private Response buildResendConfirmationResponse(String tenantDomain, ResendConfirmationDTO resendConfirmationDTO) {
    ArrayList<APICall> apiCallsArrayList = new ArrayList<>();
    // Add confirm API call information.
    apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.CONFIRM_PASSWORD_RECOVERY_API.getType(), Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.CONFIRM_PASSWORD_RECOVERY_API.getApiUrl(), Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null));
    // Add resend confirmation code API call information.
    apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RESEND_CONFIRMATION_API.getType(), Constants.RelationStates.RESEND_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.RESEND_CONFIRMATION_API.getApiUrl(), Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null));
    if (NotificationChannels.EXTERNAL_CHANNEL.getChannelType().equals(resendConfirmationDTO.getNotificationChannel())) {
        ResendConfirmationCodeExternalResponse resendConfirmationCodeExternalResponse = new ResendConfirmationCodeExternalResponse();
        resendConfirmationCodeExternalResponse.setCode(resendConfirmationDTO.getSuccessCode());
        resendConfirmationCodeExternalResponse.setMessage(resendConfirmationDTO.getSuccessMessage());
        resendConfirmationCodeExternalResponse.setNotificationChannel(resendConfirmationDTO.getNotificationChannel());
        resendConfirmationCodeExternalResponse.setResendCode(resendConfirmationDTO.getResendCode());
        resendConfirmationCodeExternalResponse.setConfirmationCode(resendConfirmationDTO.getExternalConfirmationCode());
        resendConfirmationCodeExternalResponse.setLinks(apiCallsArrayList);
        return Response.ok().entity(resendConfirmationCodeExternalResponse).build();
    } else {
        ResendConfirmationCodeInternalResponse resendConfirmationCodeInternalResponse = new ResendConfirmationCodeInternalResponse();
        resendConfirmationCodeInternalResponse.setCode(resendConfirmationDTO.getSuccessCode());
        resendConfirmationCodeInternalResponse.setMessage(resendConfirmationDTO.getSuccessMessage());
        resendConfirmationCodeInternalResponse.setNotificationChannel(resendConfirmationDTO.getNotificationChannel());
        resendConfirmationCodeInternalResponse.setResendCode(resendConfirmationDTO.getResendCode());
        resendConfirmationCodeInternalResponse.setLinks(apiCallsArrayList);
        return Response.accepted().entity(resendConfirmationCodeInternalResponse).build();
    }
}
Also used : APICall(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall) ArrayList(java.util.ArrayList) ResendConfirmationCodeExternalResponse(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.ResendConfirmationCodeExternalResponse) ResendConfirmationCodeInternalResponse(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.ResendConfirmationCodeInternalResponse)

Aggregations

ArrayList (java.util.ArrayList)1 APICall (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall)1 ResendConfirmationCodeExternalResponse (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.ResendConfirmationCodeExternalResponse)1 ResendConfirmationCodeInternalResponse (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.ResendConfirmationCodeInternalResponse)1