Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* BandwidthLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
package com.bandwidth.multifactorauth.controllers;
import com.bandwidth.ApiHelper;
import com.bandwidth.AuthManager;
import com.bandwidth.Configuration;
import com.bandwidth.Server;
import com.bandwidth.controllers.BaseController;
import com.bandwidth.exceptions.ApiException;
import com.bandwidth.http.Headers;
import com.bandwidth.http.client.HttpCallback;
import com.bandwidth.http.client.HttpClient;
import com.bandwidth.http.client.HttpContext;
import com.bandwidth.http.request.HttpRequest;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.http.response.HttpResponse;
import com.bandwidth.http.response.HttpStringResponse;
import com.bandwidth.multifactorauth.exceptions.ErrorWithRequestException;
import com.bandwidth.multifactorauth.exceptions.ForbiddenRequestException;
import com.bandwidth.multifactorauth.exceptions.UnauthorizedRequestException;
import com.bandwidth.multifactorauth.models.TwoFactorCodeRequestSchema;
import com.bandwidth.multifactorauth.models.TwoFactorMessagingResponse;
import com.bandwidth.multifactorauth.models.TwoFactorVerifyCodeResponse;
import com.bandwidth.multifactorauth.models.TwoFactorVerifyRequestSchema;
import com.bandwidth.multifactorauth.models.TwoFactorVoiceResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* This class lists all the endpoints of the groups.
*/
public final class MFAController extends BaseController {
/**
* Initializes the controller.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
*/
public MFAController(Configuration config, HttpClient httpClient,
Map authManagers) {
super(config, httpClient, authManagers);
}
/**
* Initializes the controller with HTTPCallback.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
* @param httpCallback Callback to be called before and after the HTTP call.
*/
public MFAController(Configuration config, HttpClient httpClient,
Map authManagers, HttpCallback httpCallback) {
super(config, httpClient, authManagers, httpCallback);
}
/**
* Multi-Factor authentication with Bandwidth Voice services. Allows for a user to send an MFA
* code via a phone call.
* @param accountId Required parameter: Bandwidth Account ID with Voice service enabled
* @param body Required parameter: Example:
* @return Returns the TwoFactorVoiceResponse wrapped in ApiResponse response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public ApiResponse createVoiceTwoFactor(
final String accountId,
final TwoFactorCodeRequestSchema body) throws ApiException, IOException {
HttpRequest request = buildCreateVoiceTwoFactorRequest(accountId, body);
authManagers.get("multiFactorAuth").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleCreateVoiceTwoFactorResponse(context);
}
/**
* Multi-Factor authentication with Bandwidth Voice services. Allows for a user to send an MFA
* code via a phone call.
* @param accountId Required parameter: Bandwidth Account ID with Voice service enabled
* @param body Required parameter: Example:
* @return Returns the TwoFactorVoiceResponse wrapped in ApiResponse response from the API call
*/
public CompletableFuture> createVoiceTwoFactorAsync(
final String accountId,
final TwoFactorCodeRequestSchema body) {
return makeHttpCallAsync(() -> buildCreateVoiceTwoFactorRequest(accountId, body),
req -> authManagers.get("multiFactorAuth").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleCreateVoiceTwoFactorResponse(context));
}
/**
* Builds the HttpRequest object for createVoiceTwoFactor.
*/
private HttpRequest buildCreateVoiceTwoFactorRequest(
final String accountId,
final TwoFactorCodeRequestSchema body) throws JsonProcessingException {
//the base uri for api requests
String baseUri = config.getBaseUri(Server.MULTIFACTORAUTHDEFAULT);
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/accounts/{accountId}/code/voice");
//process template parameters
Map> templateParameters = new HashMap<>();
templateParameters.put("accountId",
new SimpleEntry