Skip to content

Commit 41528c3

Browse files
committed
update interface of delete FlightOrder method
1 parent 9969629 commit 41528c3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ protected void parse(HTTPClient client) {
6464
parseData(client);
6565
}
6666

67-
// Detects of any exceptions have occurred and throws the appropriate exceptions.
67+
// Detects of any exceptions have occured and throws the appropriate exceptions.
6868
protected void detectError(HTTPClient client) throws ResponseException {
6969
ResponseException exception = null;
70+
if (statusCode == 204) {
71+
return;
72+
}
7073
if (statusCode >= 500) {
7174
exception = new ServerException(this);
7275
} else if (statusCode == 404) {
@@ -97,6 +100,9 @@ private void parseStatusCode() {
97100

98101
// Tries to parse the data
99102
private void parseData(HTTPClient client) {
103+
if (this.statusCode == 204) {
104+
return;
105+
}
100106
this.parsed = false;
101107
this.body = readBody();
102108
this.result = parseJson(client);
@@ -121,11 +127,6 @@ private void parseData(HTTPClient client) {
121127

122128
// Tries to read the body.
123129
private String readBody() {
124-
// Workaround to avoid ParserException when status code is 204
125-
if (statusCode == 204) {
126-
body = "{ \"data\": { } } ";
127-
return body;
128-
}
129130
// Get the connection
130131
HttpURLConnection connection = getRequest().getConnection();
131132

@@ -172,7 +173,7 @@ private boolean isJson() {
172173
private boolean hasJsonHeader() {
173174
String contentType = getRequest().getConnection().getHeaderField(Constants.CONTENT_TYPE);
174175
String[] expectedContentTypes = new String[] {
175-
"application/json", "application/vnd.amadeus+json"
176+
"application/json", "application/vnd.amadeus+json"
176177
};
177178
return Arrays.asList(expectedContentTypes).contains(contentType);
178179
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public com.amadeus.resources.FlightOrder get(Params params) throws ResponseExcep
5353
String path = String.format("/v1/booking/flight-orders/%s", flightOfferId);
5454
Response response = client.get(path, params);
5555
return (com.amadeus.resources.FlightOrder) Resource.fromObject(
56-
response, com.amadeus.resources.FlightOrder.class);
56+
response, com.amadeus.resources.FlightOrder.class);
5757
}
5858

5959
/**
@@ -80,18 +80,17 @@ public com.amadeus.resources.FlightOrder get() throws ResponseException {
8080
* @throws ResponseException when an exception occurs
8181
*/
8282

83-
public com.amadeus.resources.FlightOrder delete(Params params) throws ResponseException {
83+
public Response delete(Params params) throws ResponseException {
8484
String path = String.format("/v1/booking/flight-orders/%s", flightOfferId);
8585
Response response = client.delete(path, params);
86-
return (com.amadeus.resources.FlightOrder) Resource.fromObject(
87-
response, com.amadeus.resources.FlightOrder.class);
86+
return response;
8887
}
89-
88+
9089
/**
9190
* Convenience method for calling <code>delete</code> without any parameters.
9291
* @see com.amadeus.booking.FlightOrder#delete()
9392
*/
94-
public com.amadeus.resources.FlightOrder delete() throws ResponseException {
93+
public Response delete() throws ResponseException {
9594
return delete(null);
9695
}
97-
}
96+
}

0 commit comments

Comments
 (0)