Skip to content

Commit

Permalink
Merge pull request #24 from amadeus4dev/flight_booking_APIs
Browse files Browse the repository at this point in the history
Updated according to the appropriate project structure
  • Loading branch information
cgitiagofernandes authored Jan 27, 2022
2 parents 726f05e + d85b3c9 commit 475b517
Show file tree
Hide file tree
Showing 23 changed files with 362 additions and 69 deletions.
17 changes: 6 additions & 11 deletions amadeus-integration-test/FlightOffersTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using amadeus;
using amadeus.resources;
using amadeus.travel.flightOffers;
using amadeus.shopping;
using amadeus.shopping.flightOffers;
using Newtonsoft.Json;
using System.Collections.Generic;
using Xunit;
Expand All @@ -14,8 +15,7 @@ public class FlightOffersTest
public void Get_FlightOffers()
{
var amadeus = GetAmadeusBuild();
var flightOffersSearch = new FlightOffersSearch(amadeus);
FlightOffer[] response = flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD").and("destinationLocationCode", "BKK")
FlightOffer[] response = amadeus.shopping.flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD").and("destinationLocationCode", "BKK")
.and("departureDate", System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd")).and("adults", "1"));

Assert.True(response != null);
Expand All @@ -26,10 +26,8 @@ public void Get_FlightOffers()
public void Post_FlightOffers()
{
var amadeus = GetAmadeusBuild();
var flightOffersSearch = new FlightOffersSearch(amadeus);

string body = "{\"originDestinations\":[{\"id\":\"1\",\"originLocationCode\":\"RIO\",\"destinationLocationCode\":\"MAD\",\"departureDateTimeRange\":{\"date\":\"" + System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd") + "\",\"time\":\"10:00:00\"}}],\"travelers\":[{\"id\":\"1\",\"travelerType\":\"ADULT\"}],\"sources\":[\"GDS\"]}";
FlightOffer[] response = flightOffersSearch.postFlightOffers(body);
FlightOffer[] response = amadeus.shopping.flightOffersSearch.postFlightOffers(body);

Assert.True(response != null);
Assert.True(response[0].type == "flight-offer");
Expand All @@ -39,17 +37,14 @@ public void Post_FlightOffers()
public void Post_FlightOffersPricing()
{
var amadeus = GetAmadeusBuild();
var flightOffersPricing = new FlightOffersPricing(amadeus);

var flightOffersSearch = new FlightOffersSearch(amadeus);
FlightOffer[] flightOffersSearches = flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD")
FlightOffer[] flightOffersSearches = amadeus.shopping.flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD")
.and("destinationLocationCode", "BKK")
.and("departureDate", System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd"))
.and("adults", "1")
.and("max", "2"));

string body = "{\"data\":{\"type\":\"flight-offers-pricing\",\"flightOffers\":[" + flightOffersSearches[0].response.data[0] + "]}}";
FlightOfferPricingOutput response = flightOffersPricing.postFlightOffersPricing(new Params(), body);
FlightOfferPricingOutput response = amadeus.shopping.flightOffers.pricing.postFlightOffersPricing(new Params(), body);

Assert.True(response != null);
Assert.True(response.type == "flight-offers-pricing");
Expand Down
21 changes: 8 additions & 13 deletions amadeus-integration-test/FlightOrderManagementTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using amadeus;
using amadeus.resources;
using amadeus.travel.flightOffers;
using amadeus.booking;
using System;
using System.Collections.Generic;
using Xunit;
Expand All @@ -14,35 +14,30 @@ public class FlightOrderManagementTest
public void Get_FlightOrderManagement()
{
var amadeus = GetAmadeusBuild();
var flightOrderManagement = new FlightOrderManagement(amadeus);
FlightOrderCreateQuery response = flightOrderManagement.getFlightOrderManagement(Params.with("flight-orderId", "eJzTd9cPsbR083cDAArgAkc%3D"));
FlightOrderCreateQuery response = amadeus.booking.flightOrder.getFlightOrderManagement(Params.with("flight-orderId", "eJzTd9cPsbR083cDAArgAkc%3D"));
Assert.True(response != null);
Assert.True(response.type == "flight-order");
}*/

[Fact]
/*[Fact]
public void Post_FlightOrderManagement()
{
var amadeus = GetAmadeusBuild();

var flightOrderManagement = new FlightOrderManagement(amadeus);

string body = "{\"data\":{\"type\":\"flight-order\",\"flightOffers\":[{\"type\":\"flight-offer\",\"id\":\"1\",\"source\":\"GDS\",\"instantTicketingRequired\":false,\"nonHomogeneous\":false,\"oneWay\":false,\"lastTicketingDate\":\"2022-01-21\",\"numberOfBookableSeats\":7,\"itineraries\":[{\"duration\":\"PT5H49M\",\"segments\":[{\"departure\":{\"iataCode\":\"JFK\",\"terminal\":\"4\",\"at\":\"2022-02-01T10:31:00\"},\"arrival\":{\"iataCode\":\"LAX\",\"terminal\":\"2\",\"at\":\"2022-02-01T13:20:00\"},\"carrierCode\":\"DL\",\"number\":\"351\",\"aircraft\":{\"code\":\"764\"},\"operating\":{\"carrierCode\":\"DL\"},\"duration\":\"PT5H49M\",\"id\":\"30\",\"numberOfStops\":0,\"blacklistedInEU\":false}]}],\"price\":{\"currency\":\"EUR\",\"total\":\"121.33\",\"base\":\"101.00\",\"fees\":[{\"amount\":\"0.00\",\"type\":\"SUPPLIER\"},{\"amount\":\"0.00\",\"type\":\"TICKETING\"}],\"grandTotal\":\"121.33\"},\"pricingOptions\":{\"fareType\":[\"PUBLISHED\"],\"includedCheckedBagsOnly\":false},\"validatingAirlineCodes\":[\"DL\"],\"travelerPricings\":[{\"travelerId\":\"1\",\"fareOption\":\"STANDARD\",\"travelerType\":\"ADULT\",\"price\":{\"currency\":\"EUR\",\"total\":\"121.33\",\"base\":\"101.00\"},\"fareDetailsBySegment\":[{\"segmentId\":\"30\",\"cabin\":\"ECONOMY\",\"fareBasis\":\"TA7NA0BQ\",\"brandedFare\":\"BASICECON\",\"class\":\"E\",\"includedCheckedBags\":{\"quantity\":0}}]}]}],\"travelers\":[{\"id\":\"1\",\"dateOfBirth\":\"1987-07-22\",\"name\":{\"firstName\":\"amir\",\"lastName\":\"taheri\"},\"gender\":\"MALE\",\"documents\":[{\"documentType\":\"PASSPORT\",\"number\":\"J12345678\",\"expiryDate\":\"2024-02-22\",\"issuanceCountry\":\"TR\",\"nationality\":\"TR\",\"holder\":true}]}],\"contacts\":[{\"companyName\":\"INCREIBLEVIAJES\",\"purpose\":\"STANDARD\",\"phones\":[{\"deviceType\":\"LANDLINE\",\"countryCallingCode\":\"34\",\"number\":\"480080071\"},{\"deviceType\":\"MOBILE\",\"countryCallingCode\":\"33\",\"number\":\"480080072\"}],\"emailAddress\":\"[email protected]\"}]}}";
string body = "{\"data\":{\"type\":\"flight-order\",\"flightOffers\":[{\"type\":\"flight-offer\",\"id\":\"1\",\"source\":\"GDS\",\"instantTicketingRequired\":false,\"nonHomogeneous\":false,\"oneWay\":false,\"lastTicketingDate\":\"2022-01-21\",\"numberOfBookableSeats\":7,\"itineraries\":[{\"duration\":\"PT5H49M\",\"segments\":[{\"departure\":{\"iataCode\":\"JFK\",\"terminal\":\"4\",\"at\":\"2022-02-01T10:31:00\"},\"arrival\":{\"iataCode\":\"LAX\",\"terminal\":\"2\",\"at\":\"2022-02-01T13:20:00\"},\"carrierCode\":\"DL\",\"number\":\"351\",\"aircraft\":{\"code\":\"764\"},\"operating\":{\"carrierCode\":\"DL\"},\"duration\":\"PT5H49M\",\"id\":\"30\",\"numberOfStops\":0,\"blacklistedInEU\":false}]}],\"price\":{\"currency\":\"EUR\",\"total\":\"122.53\",\"base\":\"101.00\",\"fees\":[{\"amount\":\"0.00\",\"type\":\"SUPPLIER\"},{\"amount\":\"0.00\",\"type\":\"TICKETING\"}],\"grandTotal\":\"122.53\"},\"pricingOptions\":{\"fareType\":[\"PUBLISHED\"],\"includedCheckedBagsOnly\":false},\"validatingAirlineCodes\":[\"DL\"],\"travelerPricings\":[{\"travelerId\":\"1\",\"fareOption\":\"STANDARD\",\"travelerType\":\"ADULT\",\"price\":{\"currency\":\"EUR\",\"total\":\"122.53\",\"base\":\"101.00\"},\"fareDetailsBySegment\":[{\"segmentId\":\"30\",\"cabin\":\"ECONOMY\",\"fareBasis\":\"TA7NA0BQ\",\"brandedFare\":\"BASICECON\",\"class\":\"E\",\"includedCheckedBags\":{\"quantity\":0}}]}]}],\"travelers\":[{\"id\":\"1\",\"dateOfBirth\":\"1987-07-22\",\"name\":{\"firstName\":\"amir\",\"lastName\":\"taheri\"},\"gender\":\"MALE\",\"documents\":[{\"documentType\":\"PASSPORT\",\"number\":\"J12345678\",\"expiryDate\":\"2024-02-22\",\"issuanceCountry\":\"TR\",\"nationality\":\"TR\",\"holder\":true}]}],\"contacts\":[{\"companyName\":\"INCREIBLEVIAJES\",\"purpose\":\"STANDARD\",\"phones\":[{\"deviceType\":\"LANDLINE\",\"countryCallingCode\":\"34\",\"number\":\"480080071\"},{\"deviceType\":\"MOBILE\",\"countryCallingCode\":\"33\",\"number\":\"480080072\"}],\"emailAddress\":\"[email protected]\"}]}}";
FlightOrderCreateQuery response = flightOrderManagement.postFlightOrderManagement(body);
FlightOrderCreateQuery response = amadeus.booking.flightOrder.postFlightOrderManagement(body);
Assert.True(response != null);
//Assert.True(restriction[0].type == "flight-order");
//Assert.True(response[0].type == "flight-order");
}
}*/

/*[Fact]
public void Delete_FlightOrderManagement()
{
var amadeus = GetAmadeusBuild();
var flightOrderManagement = new FlightOrderManagement(amadeus);
FlightOrderCreateQuery[] response = flightOrderManagement.deleteFlightOrderManagement(Params.with("flight-orderId", "eJzTd9cPsbR083cDAArgAkc%3D"));
FlightOrderCreateQuery[] response = amadeus.booking.flightOrder.deleteFlightOrderManagement(Params.with("flight-orderId", "eJzTd9cPsbR083cDAArgAkc%3D"));
Assert.True(response != null);
Expand Down
11 changes: 4 additions & 7 deletions amadeus-integration-test/SafePlaceTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using amadeus;
using amadeus.resources;
using amadeus.travel.restrictions;
using amadeus.safety;
using System;
using System.Collections.Generic;
using Xunit;
Expand All @@ -14,8 +14,7 @@ public class SafePlaceTest
public void Get_Safety_Locations()
{
var amadeus = GetAmadeusBuild();
var safePlace = new SafePlace(amadeus);
SafetyRatedLocation[] response = safePlace.getByGeoCode(Params.with("latitude", "41.397158").and("longitude", "2.160873"));
SafetyRatedLocation[] response = amadeus.safety.safetyRatedLocations.getByGeoCode(Params.with("latitude", "41.397158").and("longitude", "2.160873"));

Assert.True(response != null);
Assert.True(response[0].type == "safety-rated-location");
Expand All @@ -25,8 +24,7 @@ public void Get_Safety_Locations()
public void Get_Safety_Locations_by_Square()
{
var amadeus = GetAmadeusBuild();
var safePlace = new SafePlace(amadeus);
SafetyRatedLocation[] response = safePlace.getBySquare(Params.with("north", "41.397158").and("west", "2.160873").and("south", "41.394582").and("east", "2.177181"));
SafetyRatedLocation[] response = amadeus.safety.safetyRatedLocations.getBySquare(Params.with("north", "41.397158").and("west", "2.160873").and("south", "41.394582").and("east", "2.177181"));

Assert.True(response != null);
Assert.True(response[0].type == "safety-rated-location");
Expand All @@ -37,8 +35,7 @@ public void Get_Safety_Locations_by_Square()
public void Get_Safety_Locations_by_Id()
{
var amadeus = GetAmadeusBuild();
var safePlace = new SafePlace(amadeus);
SafetyRatedLocation response = safePlace.getById(Params.with("safety-rated-locationId", "Q930402719"));
SafetyRatedLocation response = amadeus.safety.safetyRatedLocations.getById(Params.with("safety-rated-locationId", "Q930402719"));

Assert.True(response != null);
Assert.True(response.type == "safety-rated-location");
Expand Down
10 changes: 4 additions & 6 deletions amadeus-integration-test/SeatMapDisplayTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using amadeus;
using amadeus.resources;
using amadeus.travel.flightOffers;
using amadeus.shopping;
using System;
using System.Collections.Generic;
using Xunit;
Expand All @@ -14,8 +14,7 @@ public class SeatMapDisplayTest
public void Get_SeatMap()
{
var amadeus = GetAmadeusBuild();
var seatMap = new SeatMapDisplay(amadeus);
SeatMap[] response = seatMap.getSeatMap(Params.with("flightOrderId", "MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy"));
SeatMap[] response = amadeus.shopping.seatmaps.getSeatMap(Params.with("flightOrderId", "MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy"));

Assert.True(response != null);
}
Expand All @@ -24,17 +23,16 @@ public void Get_SeatMap()
public void Post_SeatMap()
{
var amadeus = GetAmadeusBuild();
var seatMap = new SeatMapDisplay(amadeus);

var flightOffersSearch = new FlightOffersSearch(amadeus);
FlightOffer[] flightOffersSearches = flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD")
FlightOffer[] flightOffersSearches = amadeus.shopping.flightOffersSearch.getFlightOffers(Params.with("originLocationCode", "SYD")
.and("destinationLocationCode", "BKK")
.and("departureDate", System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd"))
.and("adults", "1")
.and("max", "2"));
string body = "{\"data\":[" + flightOffersSearches[0].response.data[0] + "]}}";

SeatMap[] response = seatMap.postSeatMap(body);
SeatMap[] response = amadeus.shopping.seatmaps.postSeatMap(body);

Assert.True(response != null);
//Assert.True(response[0].type == "seatmap");
Expand Down
6 changes: 3 additions & 3 deletions amadeus-integration-test/TravelRestrictionsTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using amadeus;
using amadeus.resources;
using amadeus.travel.restrictions;
using amadeus.dutyOfcare;

using Xunit;
using static amadeus_integration_test.TestUtil;

Expand All @@ -12,8 +13,7 @@ public class TravelRestrictionsTest
public void Get_Restrictions()
{
var amadeus = GetAmadeusBuild();
var travelRestrictions = new TravelRestrictions(amadeus);
DiseaseAreaReport response = travelRestrictions.get(Params.with("countryCode", "US"));
DiseaseAreaReport response = amadeus.dutyOfCare.diseases.covid19AreaReport.get(Params.with("countryCode", "US"));

Assert.True(response != null);
Assert.True(response.type == "covid19-area-report");
Expand Down
3 changes: 1 addition & 2 deletions amadeus-integration-test/TravelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class TravelTest
public void Get_Prediction()
{
var amadeus = GetAmadeusBuild();
var tripPurpose = new TripPurpose(amadeus);
Prediction response = tripPurpose.get(Params.with("originLocationCode", "NYC")
Prediction response = amadeus.travel.predictions.tripPurpose.get(Params.with("originLocationCode", "NYC")
.and("destinationLocationCode", "MAD")
.and("departureDate", System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd"))
.and("returnDate", System.DateTime.Now.AddMonths(2).ToString("yyyy-MM-dd"))
Expand Down
18 changes: 18 additions & 0 deletions amadeus/Amadeus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public class Amadeus : HTTPClient
/// </summary>
public Shopping shopping;

/// <summary>
/// A namespaced client for the <code>/v1/booking</code> endpoints.
/// </summary>
public Booking booking;

/// <summary>
/// A namespaced client for the <code>/v1/safety</code> endpoints.
/// </summary>
public Safety safety;

/// <summary>
/// A namespaced client for the <code>/v1/dutyOfCare</code> endpoints.
/// </summary>
public DutyOfCare dutyOfCare;

/// <summary>
/// Initializes a new instance of the Amadeus class.
/// </summary>
Expand All @@ -60,6 +75,9 @@ public Amadeus(Configuration configuration) : base(configuration)
this.referenceData = new ReferenceData(this);
this.travel = new Travel(this);
this.shopping = new Shopping(this);
this.booking = new Booking(this);
this.safety = new Safety(this);
this.dutyOfCare = new DutyOfCare(this);
}

/// <summary>
Expand Down
47 changes: 47 additions & 0 deletions amadeus/Booking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using amadeus.booking;

namespace amadeus
{

/// <summary>
///
/// Booking
///
/// <para>
/// A namespaced client for the
/// <code>/v2/booking</code> endpoints.
/// </para>
///
/// <para>Access via the Amadeus client object.</para>
///
/// <code>
/// Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
/// amadeus.booking;
/// </code>
///
/// </summary>
public class Booking
{
internal Amadeus client;

/// <summary>
/// A namespaced client for the
/// <code>/v1/booking/flight-orders</code> endpoints.
/// </summary>
public FlightOrderManagement flightOrder;

/// <summary>
/// Initializes a new instance of the Booking class.
/// </summary>
/// <param name="client">Client.</param>
public Booking(Amadeus client)
{
this.client = client;
this.flightOrder = new FlightOrderManagement(client);

}

}

}
47 changes: 47 additions & 0 deletions amadeus/DutyOfCare.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using amadeus.dutyOfcare;

namespace amadeus
{

/// <summary>
///
/// DutyOfCare
///
/// <para>
/// A namespaced client for the
/// <code>/v1/duty-of-care</code> endpoints.
/// </para>
///
/// <para>Access via the Amadeus client object.</para>
///
/// <code>
/// Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
/// amadeus.dutyOfCare;
/// </code>
///
/// </summary>
public class DutyOfCare
{
internal Amadeus client;

/// <summary>
/// A namespaced client for the
/// <code>/v1/duty-of-care/diseases</code> endpoints.
/// </summary>
public Diseases diseases;

/// <summary>
/// Initializes a new instance of the DutyOfCare class.
/// </summary>
/// <param name="client">Client.</param>
public DutyOfCare(Amadeus client)
{
this.client = client;
this.diseases = new Diseases(client);

}

}

}
2 changes: 2 additions & 0 deletions amadeus/ReferenceData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using amadeus.referenceData;
using resources.referenceData;

namespace amadeus
Expand Down Expand Up @@ -41,6 +42,7 @@ public class ReferenceData
/// <value>The urls.</value>
public Locations locations { get; set; }


/// <summary>
/// A namespaced client for the
/// <code>/v2/reference-data/airlines</code> endpoints.
Expand Down
47 changes: 47 additions & 0 deletions amadeus/Safety.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using amadeus.safety.safetyRatedLocations;

namespace amadeus
{

/// <summary>
///
/// Safety
///
/// <para>
/// A namespaced client for the
/// <code>/v1/safety</code> endpoints.
/// </para>
///
/// <para>Access via the Amadeus client object.</para>
///
/// <code>
/// Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
/// amadeus.safety;
/// </code>
///
/// </summary>
public class Safety
{
internal Amadeus client;

/// <summary>
/// A namespaced client for the
/// <code>/v1/safety/safety-rated-locations</code> endpoints.
/// </summary>
public SafePlace safetyRatedLocations;

/// <summary>
/// Initializes a new instance of the Safety class.
/// </summary>
/// <param name="client">Client.</param>
public Safety(Amadeus client)
{
this.client = client;
this.safetyRatedLocations = new SafePlace(client);

}

}

}
Loading

0 comments on commit 475b517

Please sign in to comment.