Skip to content

Commit a7c8955

Browse files
authored
Merge pull request #17 from amadeus4dev/doc_update_26oct2018
Update authentication documentation and examples
2 parents fea9573 + 77c40c2 commit a7c8955

File tree

3 files changed

+74
-76
lines changed

3 files changed

+74
-76
lines changed

README.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import com.amadeus.resources.Location;
5959
public class AmadeusExample {
6060
public static void main(String[] args) throws ResponseException {
6161
Amadeus amadeus = Amadeus
62-
.builder("[client_id]", "[client_secret]")
62+
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
6363
.build();
6464

6565
Location[] locations = amadeus.referenceData.locations.get(Params
@@ -78,7 +78,7 @@ The client can be initialized directly.
7878
```java
7979
//Initialize using parameters
8080
Amadeus amadeus = Amadeus
81-
.builder("[client_id]", "[client_secret]")
81+
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
8282
.build();
8383
```
8484

@@ -123,10 +123,10 @@ in-depth information about every SDK method, its arguments and return types.
123123

124124
This library conveniently maps every API path to a similar path.
125125

126-
For example, `GET /v2/reference-data/urls/checkin-links?airline=1X` would be:
126+
For example, `GET /v2/reference-data/urls/checkin-links?airline=BA` would be:
127127

128128
```java
129-
amadeus.referenceData.urls.checkinLinks.get(Params.with("airline", "1X"));
129+
amadeus.referenceData.urls.checkinLinks.get(Params.with("airline", "BA"));
130130
```
131131

132132
Similarly, to select a resource by ID, you can pass in the ID to the **singular** path.
@@ -142,7 +142,7 @@ Keep in mind, this returns a raw `Resource`
142142

143143
```java
144144
Resource resource = amadeus.get('/v2/reference-data/urls/checkin-links',
145-
Params.with("airline", "1X"));
145+
Params.with("airline", "BA"));
146146

147147
resource.getResult();
148148
```
@@ -181,13 +181,18 @@ If a page is not available, the method will return `null`.
181181

182182
The SDK makes it easy to add your own logger.
183183

184-
```java
185-
require 'logger'
184+
```java TO FIX
185+
import java.util.logging.Logger;
186+
187+
// Assumes the current class is called MyLogger
188+
private final static Logger LOGGER = Logger.getLogger(MyLogger.class.getName());
186189

187-
amadeus = Amadeus::Client.new(
188-
client_id: '...',
189-
client_secret: '...',
190-
logger: Logger.new(STDOUT)
190+
...
191+
192+
Amadeus amadeus = Amadeus
193+
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_KEY")
194+
.setLogger(LOGGER)
195+
.build();
191196
)
192197
```
193198

@@ -198,29 +203,27 @@ variable.
198203

199204
```java
200205
Amadeus amadeus = Amadeus
201-
.builder("[client_id]", "[client_secret]")
206+
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
202207
.setLogLevel("debug") // or warn
203208
.build();
204209
```
205210

206211
## List of supported endpoints
207-
208212
```java
209-
// Flight Cheapest Date Search
210-
FlightDate[] flightDates = amadeus.shopping.flightDates.get(Params
211-
.with("origin", "LON")
212-
.and("destination", "FRA")
213-
.and("duration", 3));
214-
215213
// Flight Inspiration Search
216214
FlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params
217-
.with("origin", "LON"));
215+
.with("origin", "MAD"));
216+
217+
// Flight Cheapest Date Search
218+
FlightDate[] flightDates = amadeus.shopping.flightDates.get(Params
219+
.with("origin", "NYC")
220+
.and("destination", "MAD");
218221

219222
// Flight Low-fare Search
220223
FlightOffer[] flightOffers = amadeus.shopping.flightOffers.get(Params
221-
.with("origin", "MAD")
222-
.and("destination", "OPO")
223-
.and("departureDate", "2018-11-01"));
224+
.with("origin", "NYC")
225+
.and("destination", "MAD")
226+
.and("departureDate", "2019-08-01"));
224227

225228
// Flight Check-in Links
226229
CheckinLink[] checkinLinks = amadeus.referenceData.urls.checkinLinks.get(Params
@@ -231,11 +234,10 @@ Airline[] airlines = amadeus.referenceData.airlines.get(Params
231234
.with("IATACode", "BA"));
232235

233236
// Airport & City Search (autocomplete)
234-
// Find all the cities and airports starting by the keyword 'Lon'
237+
// Find all the cities and airports starting by the keyword 'LON'
235238
Location[] locations = amadeus.referenceData.locations.get(Params
236-
.with("keyword", "lon")
239+
.with("keyword", "LON")
237240
.and("subType", Locations.ANY));
238-
239241
// Get a specific city or airport based on its id
240242
Location location = amadeus.referenceData
241243
.location("ALHR").get();
@@ -247,36 +249,34 @@ Location[] locations = amadeus.referenceData.locations.airports.get(Params
247249

248250
// Flight Most Searched Destinations
249251
FareSearch[] fareSearches = amadeus.travel.analytics.fareSearches.get(Params
250-
.with("origin", "SFO")
251-
.and("sourceCountry", "US")
252-
.and("period", "2017-08"));
253-
254-
// Flight Most Traveled Destinations
255-
AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.traveled.get(Params
256-
.with("origin", "NCE")
252+
.with("origin", "MAD")
253+
.and("sourceCountry", "SP")
257254
.and("period", "2017-08"));
258255

259256
// Flight Most Booked Destinations
260257
AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.booked.get(Params
261-
.with("origin", "NCE")
258+
.with("origin", "MAD")
262259
.and("period", "2017-08"));
263260

261+
// Flight Most Traveled Destinations
262+
AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.traveled.get(Params
263+
.with("origin", "MAD")
264+
.and("period", "2017-01"));
265+
264266
// Flight Busiest Traveling Period
265267
Period[] busiestPeriods = amadeus.travel.analytics.airTraffic.busiestPeriod.get(Params
266268
.with("cityCode", "MAD")
267269
.and("period", "2017")
268270
.and("direction", BusiestPeriod.ARRIVING));
269271

270272
// Hotel Search API
271-
// Get list of hotels by cityCode
273+
// Get list of hotels by city code
272274
HotelOffer[] offers = amadeus.shopping.hotelOffers.get(Params
273-
.with("cityCode", "PAR"));
274-
275+
.with("cityCode", "MAD"));
275276
// Get list of offers for a specific hotel
276277
HotelOffer offer = amadeus.shopping
277278
.hotel("SMPARCOL")
278279
.hotelOffers.get();
279-
280280
// Confirm the availability of a specific offer for a specific hotel
281281
Offer offer = amadeus.shopping
282282
.hotel("SMPARCOL")

src/main/java/com/amadeus/Amadeus.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
import lombok.NonNull;
55

66
/**
7-
* <p>The Amadeus API client. To initialize, use the builder as follows:</p>
7+
* <p>
8+
* The Amadeus API client. To initialize, use the builder as follows:
9+
* </p>
810
*
911
* <pre>
10-
* Amadeus amadeus = Amadeus.builder("CLIENT_ID", "CLIENT_SECRET").build();
12+
* Amadeus amadeus =
13+
* Amadeus.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET").build();
1114
* </pre>
1215
*
13-
* <p>Or pass in environment variables directly:</p>
16+
* <p>
17+
* Or pass in environment variables directly:
18+
* </p>
1419
*
1520
* <pre>
16-
* Amadeus.builder(System.getenv()).build();
21+
* Amadeus.builder(System.getenv()).build();
1722
* </pre>
1823
*/
1924
public class Amadeus extends HTTPClient {
@@ -24,24 +29,21 @@ public class Amadeus extends HTTPClient {
2429

2530
/**
2631
* <p>
27-
* A namespaced client for the
28-
* <code>/v2/reference-data</code> endpoints.
32+
* A namespaced client for the <code>/v2/reference-data</code> endpoints.
2933
* </p>
3034
*/
3135
public ReferenceData referenceData;
3236

3337
/**
3438
* <p>
35-
* A namespaced client for the
36-
* <code>/v1/travel</code> endpoints.
39+
* A namespaced client for the <code>/v1/travel</code> endpoints.
3740
* </p>
3841
*/
3942
public Travel travel;
4043

4144
/**
4245
* <p>
43-
* A namespaced client for the
44-
* <code>/v1/shopping</code> endpoints.
46+
* A namespaced client for the <code>/v1/shopping</code> endpoints.
4547
* </p>
4648
*/
4749
public Shopping shopping;
@@ -54,14 +56,13 @@ protected Amadeus(Configuration configuration) {
5456
}
5557

5658
/**
57-
* Creates a builder object that can be used to build
58-
* an Amadeus com.amadeus.client.
59+
* Creates a builder object that can be used to build an Amadeus com.amadeus.client.
5960
*
6061
* <pre>
6162
* Amadeus amadeus = Amadeus.builder("CLIENT_ID", "CLIENT_SECRET").build();
6263
* </pre>
6364
*
64-
* @param clientId Your API com.amadeus.client credential ID
65+
* @param clientId Your API com.amadeus.client credential ID
6566
* @param clientSecret Your API com.amadeus.client credential secret
6667
* @return a Configuration object
6768
*/
@@ -70,8 +71,8 @@ public static Configuration builder(@NonNull String clientId, @NonNull String cl
7071
}
7172

7273
/**
73-
* Creates a builder object initialized with the environment variables that can be used to
74-
* build an Amadeus API com.amadeus.client.
74+
* Creates a builder object initialized with the environment variables that can be used to build
75+
* an Amadeus API com.amadeus.client.
7576
*
7677
* <pre>
7778
* Amadeus amadeus = Amadeus.builder(System.getenv()).build();

src/main/java/com/amadeus/Configuration.java

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,29 @@
77
import lombok.ToString;
88
import lombok.experimental.Accessors;
99

10-
1110
/**
12-
* <p>The configuration for the Amadeus API client. To initialize, use the builder as follows:</p>
11+
* <p>
12+
* The configuration for the Amadeus API client. To initialize, use the builder as follows:
13+
* </p>
1314
*
1415
* <pre>
15-
* Amadeus amadeus = Amadeus.builder("CLIENT_ID", "CLIENT_SECRET").build();
16+
* Amadeus amadeus =
17+
* Amadeus.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET").build();
1618
* </pre>
1719
*
18-
* <p>Or pass in environment variables directly:</p>
20+
* <p>
21+
* Or pass in environment variables directly:
22+
* </p>
1923
*
2024
* <pre>
21-
* Amadeus.builder(System.getenv()).build();
25+
* Amadeus.builder(System.getenv()).build();
2226
* </pre>
2327
*/
2428
@Accessors(chain = true)
2529
@ToString
2630
public class Configuration {
27-
private static final Params HOSTS = Params
28-
.with("production", "api.amadeus.com")
29-
.and("test", "test.api.amadeus.com");
31+
private static final Params HOSTS =
32+
Params.with("production", "api.amadeus.com").and("test", "test.api.amadeus.com");
3033

3134
/**
3235
* The client ID used to authenticate the API calls.
@@ -48,24 +51,22 @@ public class Configuration {
4851
*/
4952
private @Getter @Setter Logger logger = Logger.getLogger("Amadeus");
5053
/**
51-
* The log level. Can be 'silent', 'warn', or 'debug'.
52-
* Defaults to 'silent'.
54+
* The log level. Can be 'silent', 'warn', or 'debug'. Defaults to 'silent'.
5355
*
5456
* @param logLevel The log level for the logger
5557
* @return The log level for the logger
5658
*/
5759
private @Getter @Setter String logLevel = "silent";
5860
/**
59-
* The the name of the server API calls are made to, 'production' or 'test'.
60-
* Defaults to 'test'
61+
* The the name of the server API calls are made to, 'production' or 'test'. Defaults to 'test'
6162
*
6263
* @param hostname The name of the server API calls are made to
6364
* @return The name of the server API calls are made to
6465
*/
6566
private @Getter String hostname = "test";
6667
/**
67-
* The optional custom host domain to use for API calls.
68-
* Defaults to internal value for 'hostname'.
68+
* The optional custom host domain to use for API calls. Defaults to internal value for
69+
* 'hostname'.
6970
*
7071
* @param host The optional custom host domain to use for API calls.
7172
* @return The optional custom host domain to use for API calls.
@@ -79,24 +80,21 @@ public class Configuration {
7980
*/
8081
private @Getter boolean ssl = true;
8182
/**
82-
* The port to use. Defaults to 443 for an SSL connection, and 80 for
83-
* a non SSL connection.
83+
* The port to use. Defaults to 443 for an SSL connection, and 80 for a non SSL connection.
8484
*
8585
* @param port The port to use for the connection
8686
* @return The port to use for the connection
8787
*/
8888
private @Getter @Setter int port = 443;
8989
/**
90-
* An optional custom App ID to be passed in the User Agent to the
91-
* server (Defaults to null).
90+
* An optional custom App ID to be passed in the User Agent to the server (Defaults to null).
9291
*
9392
* @param customAppId An optional custom App ID
9493
* @return The optional custom App ID
9594
*/
9695
private @Getter @Setter String customAppId;
9796
/**
98-
* An optional custom App version to be passed in the User Agent to the
99-
* server (Defaults to null).
97+
* An optional custom App version to be passed in the User Agent to the server (Defaults to null).
10098
*
10199
* @param customAppVersion An optional custom App version
102100
* @return The optional custom App version
@@ -119,16 +117,15 @@ public Amadeus build() throws NullPointerException {
119117
}
120118

121119
/**
122-
* The the name of the server API calls are made to, 'production' or 'test'.
123-
* Defaults to 'test'.
120+
* The the name of the server API calls are made to, 'production' or 'test'. Defaults to 'test'.
124121
*
125122
* @param hostname The name of the server API calls are made to
126123
* @return The name of the server API calls are made to
127124
*/
128125
public Configuration setHostname(String hostname) {
129126
if (!HOSTS.containsKey(hostname)) {
130127
throw new IllegalArgumentException(
131-
String.format("Hostname %s not found in %s", hostname, HOSTS.keySet().toString()));
128+
String.format("Hostname %s not found in %s", hostname, HOSTS.keySet().toString()));
132129
}
133130
this.hostname = hostname;
134131
this.host = HOSTS.get(hostname);

0 commit comments

Comments
 (0)