com.plivo.api.models.base.VoiceCreator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plivo-java Show documentation
Show all versions of plivo-java Show documentation
A Java SDK to make voice calls & send SMS using Plivo and to generate Plivo XML
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();
}