Skip to content

Commit 0a26841

Browse files
authored
Merge pull request #161 from xianqiliu/add-hotel-list-v1
Add support for hotel list endpoints
2 parents 57a5bd3 + 6a7b546 commit 0a26841

File tree

14 files changed

+17055
-4
lines changed

14 files changed

+17055
-4
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,31 @@ FlightAvailability[] flightAvailabilities
401401
= amadeus.shopping.availability.flightAvailabilities.post(body);
402402

403403
// Travel Restrictions GET
404-
DiseaseAreaReport diseaseAreaReport
404+
DiseaseAreaReport diseaseAreaReport
405405
= amadeus.dutyOfCare.diseases.covid19AreaReport.get(Params.with("countryCode","US"));
406406

407407
// Location Score GET
408-
ScoredLocation[] scoredLocations
408+
ScoredLocation[] scoredLocations
409409
= amadeus.location.analytics.categoryRatedAreas.get(Params
410410
.with("latitude", "41.397158")
411411
.and("longitude", "2.160873"));
412412

413413
// Branded Fares Upsell Post
414414
// body can be a String version of your JSON or a JsonObject
415-
FlightOfferSearch[] upsellFlightOffers
415+
FlightOfferSearch[] upsellFlightOffers
416416
= amadeus.shopping.flightOffers.upselling.post(body);
417+
418+
// Hotel List
419+
// Get list of hotels by hotel id
420+
Hotel[] hotels = amadeus.referenceData.locations.hotels.byHotels.get(Params
421+
.with("hotelIds", "ADPAR001"));
422+
// Get list of hotels by city code
423+
Hotel[] hotels = amadeus.referenceData.locations.hotels.byCity.get(Params
424+
.with("cityCode", "PAR"));
425+
// Get list of hotels by a geocode
426+
Hotel[] hotels = amadeus.referenceData.locations.hotels.byGeocode.get(Params
427+
.with("longitude", 2.160873)
428+
.and("latitude", 41.397158));
417429
```
418430

419431
## Development & Contributing

src/main/java/com/amadeus/referenceData/Locations.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.amadeus.Response;
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.referenceData.locations.Airports;
8+
import com.amadeus.referenceData.locations.Hotels;
89
import com.amadeus.referenceData.locations.PointOfInterest;
910
import com.amadeus.referenceData.locations.PointsOfInterest;
1011
import com.amadeus.resources.Location;
@@ -57,6 +58,14 @@ public class Locations {
5758
*/
5859
public PointOfInterest pointOfInterest;
5960

61+
/**
62+
* <p>
63+
* A namespaced client for the
64+
* <code>/v1/reference-data/locations/hotels</code> endpoints.
65+
* </p>
66+
*/
67+
public Hotels hotels;
68+
6069
/**
6170
* Constructor.
6271
* @hide
@@ -65,6 +74,7 @@ public Locations(Amadeus client) {
6574
this.client = client;
6675
this.airports = new Airports(client);
6776
this.pointsOfInterest = new PointsOfInterest(client);
77+
this.hotels = new Hotels(client);
6878
}
6979

7080
/**
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.amadeus.referenceData.locations;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.referenceData.locations.hotels.ByCity;
5+
import com.amadeus.referenceData.locations.hotels.ByGeocode;
6+
import com.amadeus.referenceData.locations.hotels.ByHotels;
7+
8+
/**
9+
* <p>
10+
* A namespaced client for the
11+
* <code>/v1/reference-data/locations/hotels</code> endpoints.
12+
* </p>
13+
*
14+
* <p>
15+
* Access via the Amadeus client object.
16+
* </p>
17+
*
18+
* <pre>
19+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
20+
* amadeus.referenceData.locations.hotels;</pre>
21+
*/
22+
public class Hotels {
23+
private Amadeus client;
24+
25+
/**
26+
* <p>
27+
* A namespaced client for the
28+
* <code>/v1/reference-data/locations/hotels/by-city</code> endpoints.
29+
* </p>
30+
*/
31+
public ByCity byCity;
32+
33+
/**
34+
* <p>
35+
* A namespaced client for the
36+
* <code>/v1/reference-data/locations/hotels/by-hotels</code> endpoints.
37+
* </p>
38+
*/
39+
public ByHotels byHotels;
40+
41+
/**
42+
* <p>
43+
* A namespaced client for the
44+
* <code>/v1/reference-data/locations/hotels/by-geocode</code> endpoints.
45+
* </p>
46+
*/
47+
public ByGeocode byGeocode;
48+
49+
/**
50+
* Constructor.
51+
* @hide
52+
*/
53+
public Hotels(Amadeus client) {
54+
this.client = client;
55+
this.byCity = new ByCity(client);
56+
this.byHotels = new ByHotels(client);
57+
this.byGeocode = new ByGeocode(client);
58+
}
59+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.amadeus.referenceData.locations.hotels;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.Hotel;
8+
import com.amadeus.resources.Resource;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v1/reference-data/locations/hotels/by-city</code> endpoints.
14+
* </p>
15+
*
16+
* <p>
17+
* Access via the Amadeus client object.
18+
* </p>
19+
*
20+
* <pre>
21+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
22+
* amadeus.referenceData.locations.hotels.byCity;</pre>
23+
*/
24+
public class ByCity {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
* @hide
30+
*/
31+
public ByCity(Amadeus client) {
32+
this.client = client;
33+
}
34+
35+
/**
36+
* <p>
37+
* Returns a list of relevant hotels inside a city.
38+
* </p>
39+
*
40+
* <pre>
41+
* amadeus.referenceData.locations.hotels.byCity.get(Params
42+
* .with("cityCode", "PAR"));</pre>
43+
*
44+
* @param params the parameters to send to the API
45+
* @return an API response object
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public Hotel[] get(Params params) throws ResponseException {
49+
Response response = client.get("/v1/reference-data/locations/hotels/by-city", params);
50+
return (Hotel[]) Resource.fromArray(response, Hotel[].class);
51+
}
52+
53+
/**
54+
* Convenience method for calling <code>get</code> without any parameters.
55+
* @see ByCity#get()
56+
*/
57+
public Hotel[] get() throws ResponseException {
58+
return get(null);
59+
}
60+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.amadeus.referenceData.locations.hotels;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.Hotel;
8+
import com.amadeus.resources.Resource;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v1/reference-data/locations/hotels/by-geocode</code> endpoints.
14+
* </p>
15+
*
16+
* <p>
17+
* Access via the Amadeus client object.
18+
* </p>
19+
*
20+
* <pre>
21+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
22+
* amadeus.referenceData.locations.hotels.byGeocode;</pre>
23+
*/
24+
public class ByGeocode {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
* @hide
30+
*/
31+
public ByGeocode(Amadeus client) {
32+
this.client = client;
33+
}
34+
35+
/**
36+
* <p>
37+
* Returns a list of hotels result of the search using geocode.
38+
* </p>
39+
*
40+
* <pre>
41+
* amadeus.referenceData.locations.hotels.byGeocode.get(Params
42+
* .with("latitude", "41.397158")
43+
* .and("longitude", "2.160873"));</pre>
44+
*
45+
* @param params the parameters to send to the API
46+
* @return an API response object
47+
* @throws ResponseException when an exception occurs
48+
*/
49+
public Hotel[] get(Params params) throws ResponseException {
50+
Response response = client.get("/v1/reference-data/locations/hotels/by-geocode", params);
51+
return (Hotel[]) Resource.fromArray(response, Hotel[].class);
52+
}
53+
54+
/**
55+
* Convenience method for calling <code>get</code> without any parameters.
56+
* @see ByGeocode#get()
57+
*/
58+
public Hotel[] get() throws ResponseException {
59+
return get(null);
60+
}
61+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.amadeus.referenceData.locations.hotels;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.Hotel;
8+
import com.amadeus.resources.Resource;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v1/reference-data/locations/hotels/by-hotels</code> endpoints.
14+
* </p>
15+
*
16+
* <p>
17+
* Access via the Amadeus client object.
18+
* </p>
19+
*
20+
* <pre>
21+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
22+
* amadeus.referenceData.locations.hotels.byHotels;</pre>
23+
*/
24+
public class ByHotels {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
* @hide
30+
*/
31+
public ByHotels(Amadeus client) {
32+
this.client = client;
33+
}
34+
35+
/**
36+
* <p>
37+
* Returns a list of hotels result of the search using unique Id.
38+
* </p>
39+
*
40+
* <pre>
41+
* amadeus.referenceData.locations.hotels.byHotels.get(Params
42+
* .with("hotelIds", "ACPAR733"));</pre>
43+
*
44+
* @param params the parameters to send to the API
45+
* @return an API response object
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public Hotel[] get(Params params) throws ResponseException {
49+
Response response = client.get("/v1/reference-data/locations/hotels/by-hotels", params);
50+
return (Hotel[]) Resource.fromArray(response, Hotel[].class);
51+
}
52+
53+
/**
54+
* Convenience method for calling <code>get</code> without any parameters.
55+
* @see ByHotels#get()
56+
*/
57+
public Hotel[] get() throws ResponseException {
58+
return get(null);
59+
}
60+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.amadeus.resources;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
import lombok.ToString;
6+
7+
/**
8+
* A Hotel object as returned by the Hotel List API.
9+
* @see com.amadeus.referenceData.locations.hotels.ByHotels#get()
10+
* @see com.amadeus.referenceData.locations.hotels.ByCity#get()
11+
* @see com.amadeus.referenceData.locations.hotels.ByGeocode#get()
12+
*/
13+
@ToString
14+
public class Hotel extends Resource {
15+
protected Hotel() {}
16+
17+
private @Getter String subtype;
18+
private @Getter String name;
19+
private @Getter String timeZoneName;
20+
private @Getter String iataCode;
21+
private @Getter Address address;
22+
private @Getter GeoCode geoCode;
23+
private @Getter String googlePlaceId;
24+
private @Getter String openjetAirportId;
25+
private @Getter String uicCode;
26+
private @Getter String hotelId;
27+
private @Getter String chainCode;
28+
private @Getter Distance distance;
29+
@SerializedName("last_update")
30+
private @Getter String lastUpdate;
31+
32+
@ToString
33+
public class Address {
34+
protected Address() {}
35+
36+
private @Getter String category;
37+
private @Getter String[] lines;
38+
private @Getter String postalCode;
39+
private @Getter String countryCode;
40+
private @Getter String cityName;
41+
private @Getter String stateCode;
42+
private @Getter String postalBox;
43+
private @Getter String text;
44+
private @Getter String state;
45+
}
46+
47+
@ToString
48+
public class GeoCode {
49+
protected GeoCode() {}
50+
51+
private @Getter float latitude;
52+
private @Getter float longitude;
53+
}
54+
55+
@ToString
56+
public class Distance {
57+
protected Distance() {}
58+
59+
private @Getter String unit;
60+
private @Getter double value;
61+
private @Getter String displayValue;
62+
private @Getter String isUnlimited;
63+
}
64+
}

0 commit comments

Comments
 (0)