Package com.veeva.vault.sdk.api.http
Interface HttpOperation<T>
- Type Parameters:
T
- type of object a success response is represented as
public interface HttpOperation<T>
A sequence of instructions that can be chained together,
building up a final operation which can be
executed with
execute()
.
Specifying a success-handler via the onSuccess(Consumer)
method is optional.
Specifying an error-handling strategy is also optional, but any error represented
by HttpOperationErrorType
would throw a RollbackException
.
You can specify error-handling via the onError(Consumer)
method.
To ignore errors, use ignoreError()
.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the HTTP operation.When specified, any error specified byHttpOperationErrorType
is ignored during HTTP request execution.onError
(Consumer<HttpOperationError> errorHandler) A function called when an HTTP request execution has failed with one of theHttpOperationErrorType
errors.onSuccess
(Consumer<HttpResponse<T>> successHandler) A function called when HTTP request execution has completed successfully with an HTTP response status code of 200.
-
Method Details
-
onSuccess
A function called when HTTP request execution has completed successfully with an HTTP response status code of 200.- Parameters:
successHandler
- function to call during execution- Returns:
- this HTTP operation
-
onError
A function called when an HTTP request execution has failed with one of theHttpOperationErrorType
errors.If neither this function nor
ignoreError()
is specified, thenRollbackException
is thrown on error.- Parameters:
errorHandler
- function to call during execution- Returns:
- this HTTP operation
-
ignoreError
HttpOperation<T> ignoreError()When specified, any error specified byHttpOperationErrorType
is ignored during HTTP request execution.- Returns:
- this http operation
-
execute
void execute()Executes the HTTP operation.
-