Skip to content

Commit 6a93cfe

Browse files
authored
Merge branch 'master' into split-test-methods
2 parents 1bc89b5 + 1c3f16d commit 6a93cfe

39 files changed

+127
-284
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ public class Amadeus extends HTTPClient {
6969
*/
7070
public Booking booking;
7171

72-
/**
73-
* <p>
74-
* A namespaced client for the <code>/v2/media</code> endpoints.
75-
* </p>
76-
*/
77-
public Media media;
78-
7972
/**
8073
* <p>
8174
* A namespaced client for the <code>/v1/safety</code> endpoints.
@@ -126,7 +119,6 @@ protected Amadeus(Configuration configuration) {
126119
this.ereputation = new EReputation(this);
127120
this.airport = new Airport(this);
128121
this.booking = new Booking(this);
129-
this.media = new Media(this);
130122
this.safety = new Safety(this);
131123
this.schedule = new Schedule(this);
132124
this.analytics = new Analytics(this);

src/main/java/com/amadeus/DutyOfCare.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* @hide
2020
*/
2121
public class DutyOfCare {
22-
private Amadeus client;
23-
2422
/**
2523
* <p>
2624
* A namespaced client for the
@@ -34,7 +32,6 @@ public class DutyOfCare {
3432
* @hide
3533
*/
3634
public DutyOfCare(Amadeus client) {
37-
this.client = client;
3835
this.diseases = new Diseases(client);
3936
}
4037
}

src/main/java/com/amadeus/EReputation.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.amadeus.ereputation.HotelSentiments;
44

55
public class EReputation {
6-
private Amadeus client;
7-
86
/**
97
* <p>
108
* A namespaced client for the
@@ -14,7 +12,6 @@ public class EReputation {
1412
public HotelSentiments hotelSentiments;
1513

1614
public EReputation(Amadeus client) {
17-
this.client = client;
1815
this.hotelSentiments = new HotelSentiments(client);
1916
}
2017
}

src/main/java/com/amadeus/HTTPClient.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.amadeus.exceptions.NetworkException;
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.resources.Resource;
8+
import com.google.gson.JsonElement;
89
import com.google.gson.JsonObject;
910
import java.io.BufferedWriter;
1011
import java.io.IOException;
@@ -420,23 +421,25 @@ private void write(Request request) throws IOException {
420421
* @hide as ony used internally
421422
*/
422423
protected Response page(String pageName, Response response) throws ResponseException {
423-
try {
424-
String[] parts = response.getResult().get("meta").getAsJsonObject()
425-
.get("links").getAsJsonObject().get(pageName).getAsString()
426-
.split("page%5Boffset%5D=");
427-
428-
String pageNumber = parts[1].split("&")[0];
424+
JsonObject metaLinks = response.getResult().get("meta")
425+
.getAsJsonObject().get("links").getAsJsonObject();
426+
JsonElement pageElement = metaLinks.get(pageName);
429427

430-
Request request = response.getRequest();
431-
Params params = (Params) request.getParams().clone();
432-
params.put("page[offset]", pageNumber);
433-
434-
return request(request.getVerb(), request.getPath(), params, "emptyBody");
435-
} catch (NullPointerException e) {
428+
if (pageElement == null) {
436429
return null;
437430
}
431+
432+
String[] parts = pageElement.getAsString().split("page%5Boffset%5D=");
433+
String pageNumber = parts[1].split("&")[0];
434+
435+
Request request = response.getRequest();
436+
Params params = (Params) request.getParams().clone();
437+
params.put("page[offset]", pageNumber);
438+
439+
return request(request.getVerb(), request.getPath(), params, "emptyBody");
438440
}
439441

442+
440443
/**
441444
* Fetches the response for another page.
442445
* @hide as ony used internally

src/main/java/com/amadeus/Location.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* @hide
2020
*/
2121
public class Location {
22-
private Amadeus client;
23-
2422
/**
2523
* <p>
2624
* A namespaced client for the
@@ -34,7 +32,6 @@ public class Location {
3432
* @hide
3533
*/
3634
public Location(Amadeus client) {
37-
this.client = client;
3835
this.analytics = new Analytics(client);
3936
}
4037
}

src/main/java/com/amadeus/Media.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/main/java/com/amadeus/Params.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.net.URLEncoder;
55
import java.util.HashMap;
66
import java.util.Map;
7+
import java.util.logging.Level;
8+
import java.util.logging.Logger;
79
import lombok.NonNull;
810

911
/**
@@ -64,7 +66,8 @@ protected String toQueryString() {
6466
query.append("=");
6567
query.append(URLEncoder.encode(entry.getValue(), encoding));
6668
} catch (UnsupportedEncodingException e) {
67-
// no need to anything
69+
Logger logger = Logger.getLogger(getClass().getName());
70+
logger.log(Level.WARNING, "Exception while encoding the query string", e);
6871
}
6972
}
7073

src/main/java/com/amadeus/Response.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected Response(Request request) {
6161
protected void parse(HTTPClient client) {
6262
parseStatusCode();
6363
if (this.statusCode != 204) {
64-
parseData(client);
64+
parseData();
6565
}
6666
}
6767

@@ -99,10 +99,10 @@ private void parseStatusCode() {
9999
}
100100

101101
// Tries to parse the data
102-
private void parseData(HTTPClient client) {
102+
private void parseData() {
103103
this.parsed = false;
104104
this.body = readBody();
105-
this.result = parseJson(client);
105+
this.result = parseJson();
106106
this.parsed = this.result != null;
107107
if (parsed && result.has("data")) {
108108
if (result.get("data").isJsonArray()) {
@@ -154,7 +154,7 @@ private String readBody() {
154154
}
155155

156156
// Ties to parse the response body into a JSON Object
157-
private JsonObject parseJson(HTTPClient client) {
157+
private JsonObject parseJson() {
158158
if (isJson()) {
159159
return new JsonParser().parse(getBody()).getAsJsonObject();
160160
}

src/main/java/com/amadeus/booking/FlightOrders.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ public FlightOrder post(FlightPrice flightPrice,
184184
JsonObject typeObject = new JsonObject();
185185
typeObject.addProperty("type", "flight-order");
186186

187-
Gson gson = new GsonBuilder().create();
188-
189187
JsonArray flightOffersArray = buildFlightOffersJSON(flightPrice.getFlightOffers());
190188
typeObject.add("flightOffers", flightOffersArray);
191189

src/main/java/com/amadeus/media/Files.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)