com.sinch.sdk.domains.numbers.api.v1.internal.CallbacksApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sinch-sdk-java Show documentation
Show all versions of sinch-sdk-java Show documentation
SDK providing a Java API for the Sinch REST APIs.
/*
* Numbers | Sinch
*
* OpenAPI document version: 1.0.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit the class manually.
*/
package com.sinch.sdk.domains.numbers.api.v1.internal;
import com.fasterxml.jackson.core.type.TypeReference;
import com.sinch.sdk.core.exceptions.ApiException;
import com.sinch.sdk.core.exceptions.ApiExceptionBuilder;
import com.sinch.sdk.core.http.AuthManager;
import com.sinch.sdk.core.http.HttpClient;
import com.sinch.sdk.core.http.HttpMapper;
import com.sinch.sdk.core.http.HttpMethod;
import com.sinch.sdk.core.http.HttpRequest;
import com.sinch.sdk.core.http.HttpResponse;
import com.sinch.sdk.core.http.HttpStatus;
import com.sinch.sdk.core.http.URLParameter;
import com.sinch.sdk.core.http.URLPathUtils;
import com.sinch.sdk.core.models.ServerConfiguration;
import com.sinch.sdk.domains.numbers.models.v1.callbacks.request.CallbackConfigurationUpdateRequest;
import com.sinch.sdk.domains.numbers.models.v1.callbacks.response.CallbackConfigurationResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
public class CallbacksApi {
private static final Logger LOGGER = Logger.getLogger(CallbacksApi.class.getName());
private HttpClient httpClient;
private ServerConfiguration serverConfiguration;
private Map authManagersByOasSecuritySchemes;
private HttpMapper mapper;
public CallbacksApi(
HttpClient httpClient,
ServerConfiguration serverConfiguration,
Map authManagersByOasSecuritySchemes,
HttpMapper mapper) {
this.httpClient = httpClient;
this.serverConfiguration = serverConfiguration;
this.authManagersByOasSecuritySchemes = authManagersByOasSecuritySchemes;
this.mapper = mapper;
}
/**
* Get callbacks configuration Returns the callbacks configuration for the specified project
*
* @param projectId Found on your [Sinch Customer
* Dashboard](https://dashboard.sinch.com/settings/project-management). (required)
* @return CallbackConfigurationResponse
* @throws ApiException if fails to make API call
*/
public CallbackConfigurationResponse getCallbackConfiguration(String projectId)
throws ApiException {
LOGGER.finest("[getCallbackConfiguration]" + " " + "projectId: " + projectId);
HttpRequest httpRequest = getCallbackConfigurationRequestBuilder(projectId);
HttpResponse response =
httpClient.invokeAPI(
this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest);
if (HttpStatus.isSuccessfulStatus(response.getCode())) {
TypeReference localVarReturnType =
new TypeReference() {};
return mapper.deserialize(response, localVarReturnType);
}
// fallback to default errors handling:
// all error cases definition are not required from specs: will try some "hardcoded" content
// parsing
throw ApiExceptionBuilder.build(
response.getMessage(),
response.getCode(),
mapper.deserialize(response, new TypeReference>() {}));
}
private HttpRequest getCallbackConfigurationRequestBuilder(String projectId) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(
400, "Missing the required parameter 'projectId' when calling getCallbackConfiguration");
}
String localVarPath =
"/v1/projects/{projectId}/callbackConfiguration"
.replaceAll(
"\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString()));
List localVarQueryParams = new ArrayList<>();
Map localVarHeaderParams = new HashMap<>();
final Collection localVarAccepts = Arrays.asList("application/json");
final Collection localVarContentTypes = Arrays.asList();
final Collection localVarAuthNames = Arrays.asList("BasicAuth");
final String serializedBody = null;
return new HttpRequest(
localVarPath,
HttpMethod.GET,
localVarQueryParams,
serializedBody,
localVarHeaderParams,
localVarAccepts,
localVarContentTypes,
localVarAuthNames);
}
/**
* Update callback configuration Updates the callbacks configuration for the specified project
*
* @param projectId Found on your [Sinch Customer
* Dashboard](https://dashboard.sinch.com/settings/project-management). (required)
* @param callbackConfigurationUpdateRequest The callback configuration details to be updated.
* (optional)
* @return CallbackConfigurationResponse
* @throws ApiException if fails to make API call
*/
public CallbackConfigurationResponse updateCallbackConfiguration(
String projectId, CallbackConfigurationUpdateRequest callbackConfigurationUpdateRequest)
throws ApiException {
LOGGER.finest(
"[updateCallbackConfiguration]"
+ " "
+ "projectId: "
+ projectId
+ ", "
+ "callbackConfigurationUpdateRequest: "
+ callbackConfigurationUpdateRequest);
HttpRequest httpRequest =
updateCallbackConfigurationRequestBuilder(projectId, callbackConfigurationUpdateRequest);
HttpResponse response =
httpClient.invokeAPI(
this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest);
if (HttpStatus.isSuccessfulStatus(response.getCode())) {
TypeReference localVarReturnType =
new TypeReference() {};
return mapper.deserialize(response, localVarReturnType);
}
// fallback to default errors handling:
// all error cases definition are not required from specs: will try some "hardcoded" content
// parsing
throw ApiExceptionBuilder.build(
response.getMessage(),
response.getCode(),
mapper.deserialize(response, new TypeReference>() {}));
}
private HttpRequest updateCallbackConfigurationRequestBuilder(
String projectId, CallbackConfigurationUpdateRequest callbackConfigurationUpdateRequest)
throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(
400,
"Missing the required parameter 'projectId' when calling updateCallbackConfiguration");
}
String localVarPath =
"/v1/projects/{projectId}/callbackConfiguration"
.replaceAll(
"\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString()));
List localVarQueryParams = new ArrayList<>();
Map localVarHeaderParams = new HashMap<>();
final Collection localVarAccepts = Arrays.asList("application/json");
final Collection localVarContentTypes = Arrays.asList("application/json");
final Collection localVarAuthNames = Arrays.asList("BasicAuth");
final String serializedBody =
mapper.serialize(localVarContentTypes, callbackConfigurationUpdateRequest);
return new HttpRequest(
localVarPath,
HttpMethod.PATCH,
localVarQueryParams,
serializedBody,
localVarHeaderParams,
localVarAccepts,
localVarContentTypes,
localVarAuthNames);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy