Skip to content

Commit 76975cb

Browse files
committed
add support for points of interest retrieve
1 parent 0d7d3f6 commit 76975cb

File tree

4 files changed

+79
-2
lines changed

4 files changed

+79
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ PointOfInterest[] pointsOfInterest = amadeus.referenceData.locations.pointsOfInt
322322
.and("south", "41.394582")
323323
.and("east", "2.177181"));
324324

325+
// Returns a single Point of Interest from a given id
326+
PointOfInterest pointOfInterest = amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();
327+
325328
// What's the likelihood flights from this airport will leave on time?
326329
Prediction AirportOnTime = amadeus.airport.predictions.onTime.get(Params
327330
.with("airportCode", "NCE")

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import com.amadeus.Response;
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.referenceData.locations.Airports;
8+
import com.amadeus.referenceData.locations.PointOfInterest;
89
import com.amadeus.referenceData.locations.PointsOfInterest;
910
import com.amadeus.resources.Location;
1011
import com.amadeus.resources.Resource;
11-
import com.google.gson.Gson;
1212

1313
/**
1414
* <p>
@@ -49,6 +49,13 @@ public class Locations {
4949
*/
5050
public PointsOfInterest pointsOfInterest;
5151

52+
/**
53+
* <p>
54+
* A namespaced client for the
55+
* <code>/v2/reference-data/locations/pois</code> endpoints.
56+
* </p>
57+
*/
58+
public PointOfInterest pointOfInterest;
5259

5360
/**
5461
* Constructor.
@@ -86,4 +93,8 @@ public Location[] get(Params params) throws ResponseException {
8693
public Location[] get() throws ResponseException {
8794
return get(null);
8895
}
96+
97+
public PointOfInterest pointOfInterest(String id) {
98+
return new PointOfInterest(client, id);
99+
}
89100
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.amadeus.referenceData.locations;
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.Resource;
8+
9+
/**
10+
* <p>
11+
* A namespaced client for the
12+
* <code>/v1/reference-data/locations/pois</code> endpoints.
13+
* </p>
14+
*
15+
* <p>
16+
* Access via the Amadeus client object.
17+
* </p>
18+
*
19+
* <pre>
20+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
21+
* amadeus.referenceData.locations.pointOfInterest;</pre>
22+
*/
23+
public class PointOfInterest {
24+
private Amadeus client;
25+
private String id;
26+
27+
28+
/**
29+
* Constructor.
30+
* @hide
31+
*/
32+
public PointOfInterest(Amadeus client, String id) {
33+
this.client = client;
34+
this.id = id;
35+
}
36+
37+
/**
38+
* <p>
39+
* Returns a single Point of Interest from a given id.
40+
* </p>
41+
*
42+
* <pre>
43+
* amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();</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 com.amadeus.resources.PointOfInterest get(Params params) throws ResponseException {
50+
String path = String.format("/v1/reference-data/locations/pois/%s", id);
51+
Response response = client.get(path, params);
52+
return (com.amadeus.resources.PointOfInterest) Resource.fromObject(
53+
response, com.amadeus.resources.PointOfInterest.class);
54+
}
55+
56+
/**
57+
* Convenience method for calling <code>get</code> without any parameters.
58+
* @see PointOfInterest#get()
59+
*/
60+
public com.amadeus.resources.PointOfInterest get() throws ResponseException {
61+
return get(null);
62+
}
63+
}

src/main/java/com/amadeus/resources/PointOfInterest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import lombok.ToString;
55

66
/**
7-
* An PointOfInterest object as returned by the Location API.
7+
* A PointOfInterest object as returned by the Location API.
88
* @see com.amadeus.referenceData.locations.PointOfInterest#get()
99
*/
1010
@ToString

0 commit comments

Comments
 (0)