Querying data

Let's glue all the pieces we have been creating until now to finally make that HTTP request and receive the stock data.

First of all, create an instance of the Retrofit service:

YahooService yahooService = new RetrofitYahooServiceFactory().create();

Next, define the parameters of the query:

String query = "select * from yahoo.finance.quote where symbol in ('YHOO','AAPL','GOOG','MSFT')";
String env = "store://datatables.org/alltableswithkeys";

Lastly, create the subscription to the service query:

yahooService.yqlQuery(query, env)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(data -> log(
data.getQuery().getResults()
.getQuote().get(0).getSymbol())
);

After this request is executed, a reader will see a nice YHOO message in the logs. Note that you will need to have an additional permission in AndroidManifest.xml to make HTTP requests:

<uses-permission android:name="android.permission.INTERNET" />
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.19.243