-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Flight Delay Prediction #48
Changes from 5 commits
247818c
b81fea4
5fc9298
b57f0e3
ad1c20b
e00b26f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.amadeus.resources; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* A Delay object as returned by the FlightDelay API. | ||
* @see com.amadeus.travel.predictions.FlightDelay#get() | ||
*/ | ||
@ToString | ||
public class Delay extends Resource { | ||
protected Delay() {} | ||
|
||
private @Getter String id; | ||
private @Getter String probability; | ||
private @Getter String result; | ||
private @Getter String subType; | ||
private @Getter String type; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.amadeus.travel.predictions; | ||
|
||
import com.amadeus.Amadeus; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/travel/predictions</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.travel.analytics;</pre> | ||
* | ||
* @hide | ||
*/ | ||
public class Predictions { | ||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/travel/predictions/flight-delay</code> endpoints. | ||
* </p> | ||
*/ | ||
public FlightDelay flightDelay; | ||
|
||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public Predictions(Amadeus client) { | ||
this.flightDelay = new FlightDelay(client); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.amadeus.travel.predictions; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.Response; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Delay; | ||
import com.amadeus.resources.Resource; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/travel/predictions/flight-delay</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.travel.predictions.flightDelay;</pre> | ||
*/ | ||
public class FlightDelay { | ||
private Amadeus client; | ||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public FlightDelay(Amadeus client) { | ||
this.client = client; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Predicts delay of a given flight. | ||
* </p> | ||
* | ||
* <pre> | ||
* Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params | ||
* .with("originLocationCode", "NCE") | ||
* .and("destinationLocationCode", "IST") | ||
* .and("departureDate", "2020-08-01") | ||
* .and("departureTime", "18:20:00")) | ||
* .and("arrivalDate", "2020-08-01") | ||
* .and("arrivalTime", "22:15:00") | ||
* .and("aircraftCode", "321")) | ||
* .and("carrierCode", "TK") | ||
* .and("flightNumber", "1816") | ||
* .and("duration", "PT31H10M")); | ||
* </pre> | ||
* @param params the parameters to send to the API | ||
* @return an API response object | ||
* @throws ResponseException when an exception occurs | ||
*/ | ||
public Delay[] get(Params params) throws ResponseException { | ||
Response response = client.get("/v1/travel/predictions/flight-delay", params); | ||
return (Delay[]) Resource.fromArray(response, Delay[].class); | ||
} | ||
|
||
/** | ||
* Convenience method for calling <code>get</code> without any parameters. | ||
* @see FlightDelay#get() | ||
*/ | ||
public Delay[] get() throws ResponseException { | ||
return get(null); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import com.amadeus.referenceData.locations.Airports; | ||
import com.amadeus.referenceData.locations.PointsOfInterest; | ||
import com.amadeus.referenceData.urls.CheckinLinks; | ||
import com.amadeus.resources.Delay; | ||
import com.amadeus.shopping.FlightDates; | ||
import com.amadeus.shopping.FlightDestinations; | ||
import com.amadeus.shopping.FlightOffers; | ||
|
@@ -21,6 +22,7 @@ | |
import com.amadeus.travel.analytics.airTraffic.Searched; | ||
import com.amadeus.travel.analytics.airTraffic.SearchedByDestination; | ||
import com.amadeus.travel.analytics.airTraffic.Traveled; | ||
import com.amadeus.travel.predictions.FlightDelay; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
import junit.framework.TestCase; | ||
|
@@ -50,6 +52,7 @@ public void testAllNamespacesExist() { | |
TestCase.assertNotNull(client.travel.analytics.airTraffic.booked); | ||
TestCase.assertNotNull(client.travel.analytics.airTraffic.searched); | ||
TestCase.assertNotNull(client.travel.analytics.airTraffic.searchedByDestination); | ||
TestCase.assertNotNull(client.travel.predictions.flightDelay); | ||
TestCase.assertNotNull(client.shopping.flightDates); | ||
TestCase.assertNotNull(client.shopping.flightDestinations); | ||
TestCase.assertNotNull(client.shopping.flightOffers); | ||
|
@@ -277,6 +280,15 @@ public void testGetMethods() throws ResponseException { | |
.thenReturn(multiResponse); | ||
HotelSentiments hotelSentiments = new HotelSentiments(client); | ||
TestCase.assertNotNull(hotelSentiments.get(params)); | ||
|
||
// Test flight delay predictions | ||
Mockito.when(client.get("/v1/travel/predictions/flight-delay", null)) | ||
.thenReturn(multiResponse); | ||
Mockito.when(client.get("/v1/travel/predictions/flight-delay", params)) | ||
.thenReturn(multiResponse); | ||
FlightDelay flightDelay = new FlightDelay(client); | ||
TestCase.assertNotNull(flightDelay.get()); | ||
TestCase.assertNotNull(flightDelay.get(params)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the other unit test we check that the response's length is 2... I dont really remember why and if it is very useful... TestCase.assertEquals(flightOffersPrediction.post().length, 2); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first I had this check, but I removed it because I didn't know if it was relevant to this test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be honest, I am not sure either... |
||
} | ||
|
||
@Test | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travel.predictions