August 2018
Intermediate to advanced
372 pages
9h 29m
English
In this case, we will consume an endpoint, available in the URI /api/secure/balance, that uses the GET HTTP verb and requires that the token be used as a header in the request:
public interface BankingApi { @GET("/api/secure/balance") Call<BalanceInformation> queryBalance(@Header("x-auth-token") String token);}
As you have probably noticed, this module uses the BalanceInformation and Credentials classes, so we don't need to write them again; we only need to add the banking-domain module as a dependency.
You're probably wondering where you have to specify the IP address and port for the server, and that is done in the Retrofit object, as follows:
Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://IP:PORT" ...Read now
Unlock full access