All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sinch.sdk.domains.numbers.adapters.CallbackConfigurationService Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.domains.numbers.adapters;

import com.sinch.sdk.core.exceptions.ApiException;
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.domains.numbers.adapters.api.v1.CallbacksApi;
import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationDtoConverter;
import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationUpdateRequestParametersDtoConverter;
import com.sinch.sdk.domains.numbers.models.CallbackConfiguration;
import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto;
import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters;
import com.sinch.sdk.models.Configuration;
import java.util.Map;

public class CallbackConfigurationService
    implements com.sinch.sdk.domains.numbers.CallbackConfigurationService {

  private Configuration configuration;
  private CallbacksApi api;

  public CallbackConfigurationService() {}

  public CallbackConfigurationService(
      Configuration configuration, HttpClient httpClient, Map authManagers) {
    this.configuration = configuration;
    this.api =
        new CallbacksApi(
            httpClient, configuration.getNumbersServer(), authManagers, new HttpMapper());
  }

  private CallbacksApi getApi() {
    return this.api;
  }

  public CallbackConfiguration get() throws ApiException {
    CallbackConfigurationDto response =
        getApi().getCallbackConfiguration(configuration.getProjectId());
    return CallbackConfigurationDtoConverter.convert(response);
  }

  public CallbackConfiguration update(CallbackConfigurationUpdateRequestParameters parameters)
      throws ApiException {

    CallbackConfigurationDto response =
        getApi()
            .updateCallbackConfiguration(
                configuration.getProjectId(),
                CallbackConfigurationUpdateRequestParametersDtoConverter.convert(parameters));
    return CallbackConfigurationDtoConverter.convert(response);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy