In my project i'm trying to reserve a hotel from my app. Now I'm a little stuck at the method to check if the hotel is available at a specific date, because the API response is a json object which has different content. It contains the available room types with their discounts for the time you want to stay. So it's possible that there are all rooms available and i'd get as response something like this:
"rates": {
"10": {
"dates": [
{
"date": "2018-05-01",
"amount": 1495.0
}
],
"total": 1495.0,
"discounted_total": null
},
"5": {
"dates": [
{
"date": "2018-05-01",
"amount": 1395.0
}
],
"total": 1395.0,
"discounted_total": null
},
"4": {
"dates": [
{
"date": "2018-05-01",
"amount": 1295.0
}
],
"total": 1295.0,
"discounted_total": null
},
"7": {
"dates": [
{
"date": "2018-05-01",
"amount": 1695.0
}
],
"total": 1695.0,
"discounted_total": null
},
"6": {
"dates": [
{
"date": "2018-05-01",
"amount": 1495.0
}
],
"total": 1495.0,
"discounted_total": null
},
"9": {
"dates": [
{
"date": "2018-05-01",
"amount": 1795.0
}
],
"total": 1795.0,
"discounted_total": null
},
"8": {
"dates": [
{
"date": "2018-05-01",
"amount": 1895.0
}
],
"total": 1895.0,
"discounted_total": null
}
}
4 to 10 are the ids of the available room types. So if there are only the types 6 to 10 available my response for rates would only contain 6 to 10. How am i supposed to serialize the rates object to get all roomtypes that are available?
For now I used
@SerializedName("rates")
private JsonObject rates;
but I'm not sure how i'm supposed to use this now to get all roomtypes. Maybe it's helpful to know that i have a list of available roomtypes as integers in the response too.
I hope someone can help me, thanks in advance.