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

com.sinch.sdk.domains.numbers.adapters.AvailableRegionService 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.domains.numbers.adapters.converters.AvailableRegionsDtoConverter;
import com.sinch.sdk.domains.numbers.models.Region;
import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters;
import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse;
import com.sinch.sdk.domains.numbers.models.v1.NumberType;
import com.sinch.sdk.domains.numbers.models.v1.regions.available.request.AvailableRegionListRequest;
import java.util.Collection;
import java.util.stream.Collectors;

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

  private final com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService v1;

  public AvailableRegionService(com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService v1) {
    this.v1 = v1;
  }

  public AvailableRegionListResponse list(AvailableRegionListAllRequestParameters parameters)
      throws ApiException {

    AvailableRegionListRequest dto = null;
    if (null != parameters && parameters.getTypes().isPresent()) {
      dto =
          AvailableRegionListRequest.builder()
              .setTypes(
                  parameters.getTypes().get().stream()
                      .map(f -> NumberType.from(f.value()))
                      .collect(Collectors.toList()))
              .build();
    }

    com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegionListResponse
        response = v1.list(dto);
    Collection entities = AvailableRegionsDtoConverter.convert(response);

    return new AvailableRegionListResponse(entities);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy