import com.github.ljtfreitas.restify.http.contract.CallbackParameter;
import com.github.ljtfreitas.restify.http.client.call.async.EndpointCallSuccessCallback;
import com.github.ljtfreitas.restify.http.client.call.async.EndpointCallFailureCallback;
import com.github.ljtfreitas.restify.http.client.call.async.EndpointCallCallback;
/* callback do tipo java.util.function.BiConsumer:
uma função que recebe o objeto de resposta e a exceção (se houver)
@Path("/customers/{id}") @Get
void getCustomerById(@PathParameter String id, @CallbackParameter BiConsumer<Customer, Throwable> callback);
/* EndpointCallSuccessCallback permite capturar a resposta deserializada como um objeto.
Essa interface possui um único método onSuccess(T response)
@Path("/customers/{id}") @Get
void getCustomerById(@PathParameter String id, @CallbackParameter EndpointCallSuccessCallback<Customer> success);
/* EndpointCallFailureCallback permite capturar a exceção gerada pela requisição HTTP, se ocorrer.
Essa exceção pode ser um problema de I/O ou uma resposta de erro (4xx, 5xx)
Essa interface possui um único método onFailure(Throwable throwable):
@Path("/customers/{id}") @Get
void getCustomerById(@PathParameter String id, @CallbackParameter EndpointCallFailureCallback failure);
/* É possível usar parâmetros dos dois tipos
@Path("/customers/{id}") @Get
void getCustomerById(@PathParameter String id,
@CallbackParameter EndpointCallSuccessCallback<Customer> success,
@CallbackParameter EndpointCallFailureCallback failure);
/* Existe uma terceira interface chamada EndpointCallCallback, que extende EndpointCallSuccessCallback e EndpointCallFailureCallback.
Essa interface também é uma opção caso você precise dos dois callbacks (sucesso e falha)
@Path("/customers/{id}") @Get
void getCustomerById(@PathParameter String id, @CallbackParameter EndpointCallCallback<Customer> callback);