I saw lots of posts about this and none of them seemed to work because it never specifies how I'm supposed to actually get the data in the enque method.
This is my main fragment:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://apidojo-yahoo-finance-v1.p.rapidapi.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
This is my pojo class:
@SerializedName("longName")
@Expose
private String longName;
@SerializedName("symbol")
@Expose
private String symbol;
@Expose
@SerializedName("regularMarketPrice")
private int regularMarketPrice;
public String getLongName() {
return longName;
}
public String getSymbol() {
return symbol;
}
public int getRegularMarketPrice() {
return regularMarketPrice;
}
This is the interface:
@GET("market/get-quotes?region=US&lang=en&symbols=MSFT")
Call<StockItem> getStocks(
@Header("x-rapidapi-host") String host,
@Header("x-rapidapi-key") String key
);
And finally the Json Response from the webiste:
{1 item
"quoteResponse":{2 items
"result":[1 item
0:{...}97 items
]
"error":NULL
} }
Inside the 0 is just the stocks name symbol and price I want to get
Do I really need to create new java classes as objcets for each json array object I have to go through?