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

com.plivo.api.models.base.VoiceCreator Maven / Gradle / Ivy

Go to download

A Java SDK to make voice calls & send SMS using Plivo and to generate Plivo XML

There is a newer version: 5.44.3
Show newest version
package com.plivo.api.models.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.plivo.api.PlivoClient;
import com.plivo.api.exceptions.PlivoRestException;
import java.io.IOException;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Creates an instance of a resource.
 *
 * @param  The type of the response.
 */
@JsonInclude(Include.NON_NULL)
public abstract class VoiceCreator extends BaseRequest {

  /**
   * Actually create an instance of the resource.
   */
  public CreateResponse create() throws IOException, PlivoRestException {
    validate();
    Response response = obtainCall().execute();

    if(response.code()>=500){
      response = obtainFallback1Call().execute();
      if(response.code()>=500){
        response = obtainFallback2Call().execute();
      }
    }
    handleResponse(response);

    return response.body();
  }

  @Override
  public VoiceCreator client(final PlivoClient plivoClient) {
    this.plivoClient = plivoClient;
    return this;
  }


  protected abstract Call obtainCall();
  protected abstract Call obtainFallback1Call();
  protected abstract Call obtainFallback2Call();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy