Package com.vonage.client
Class AbstractMethod<RequestT,ResultT>
java.lang.Object
com.vonage.client.AbstractMethod<RequestT,ResultT>
- Type Parameters:
RequestT- The type of the method-specific request object that will be used to construct an HTTP requestResultT- The type of method-specific response object which will be constructed from the returned HTTP response
- All Implemented Interfaces:
RestEndpoint<RequestT,ResultT>
- Direct Known Subclasses:
DynamicEndpoint
public abstract class AbstractMethod<RequestT,ResultT>
extends Object
implements RestEndpoint<RequestT,ResultT>
Abstract class to assist in implementing a call against a REST endpoint.
Concrete implementations must implement makeRequest(Object) to construct a RequestBuilder from the
provided parameterized request object, and parseResponse(HttpResponse) to construct the parameterized HttpResponse object.
The REST call is executed by calling execute(Object).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecute the REST call represented by this method object.protected abstract Set<Class<? extends AuthMethod>> protected AuthMethodGets the highest priority available authentication method according to its sort key.protected abstract org.apache.http.client.methods.RequestBuildermakeRequest(RequestT request) Construct and return a RequestBuilder instance from the provided request.protected abstract ResultTparseResponse(org.apache.http.HttpResponse response) Construct a ResultT representing the contents of the HTTP response returned from the Vonage Voice API.protected ResultTpostProcessParsedResponse(ResultT response)
-
Field Details
-
httpWrapper
-
-
Constructor Details
-
AbstractMethod
-
-
Method Details
-
getHttpWrapper
-
postProcessParsedResponse
-
execute
Execute the REST call represented by this method object.- Specified by:
executein interfaceRestEndpoint<RequestT,ResultT> - Parameters:
request- A RequestT representing input to the REST call to be made- Returns:
- A ResultT representing the response from the executed REST call
- Throws:
VonageClientException- if there is a problem parsing the HTTP responseVonageResponseParseException
-
getAuthMethod
Gets the highest priority available authentication method according to its sort key.- Returns:
- An AuthMethod created from the accepted auth methods.
- Throws:
VonageUnexpectedException- If no AuthMethod is available.
-
getAcceptableAuthMethods
-
makeRequest
Construct and return a RequestBuilder instance from the provided request.- Parameters:
request- A RequestT representing input to the REST call to be made- Returns:
- A ResultT representing the response from the executed REST call
-
parseResponse
Construct a ResultT representing the contents of the HTTP response returned from the Vonage Voice API.- Parameters:
response- An HttpResponse returned from the Vonage Voice API- Returns:
- A ResultT type representing the result of the REST call
- Throws:
IOException- if a problem occurs parsing the response
-