diff --git a/.github/workflows/release-sdk.yaml b/.github/workflows/release-sdk.yaml index f8e0892..b191393 100644 --- a/.github/workflows/release-sdk.yaml +++ b/.github/workflows/release-sdk.yaml @@ -23,7 +23,6 @@ jobs: release-sdk: uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-release-sdk.yaml@v20241126 - needs: [ run-examples ] secrets: inherit with: branch: ${{ inputs.branch }} diff --git a/code/README.md b/code/README.md index 779b9c3..50c1396 100644 --- a/code/README.md +++ b/code/README.md @@ -5,7 +5,7 @@ com.expediagroup xap-sdk - 1.0.0 + 1.0.0-SNAPSHOT ``` diff --git a/code/pom.xml b/code/pom.xml index da29731..aabc431 100644 --- a/code/pom.xml +++ b/code/pom.xml @@ -4,9 +4,9 @@ 4.0.0 com.expediagroup xap-sdk - 1.0.0 + 1.0.0-SNAPSHOT EG xap-sdk for Java - EG xap-sdk v1.0.0 + EG xap-sdk v1.0.0-SNAPSHOT https://github.com/ExpediaGroup/test-sdk 2022 jar diff --git a/code/src/main/kotlin/com/expediagroup/sdk/xap/models/RateDetails.kt b/code/src/main/kotlin/com/expediagroup/sdk/xap/models/RateDetails.kt index c9c9c5d..efca882 100644 --- a/code/src/main/kotlin/com/expediagroup/sdk/xap/models/RateDetails.kt +++ b/code/src/main/kotlin/com/expediagroup/sdk/xap/models/RateDetails.kt @@ -42,8 +42,8 @@ import javax.validation.constraints.NotNull /** * The rate detail information for a car offer. * @param ratePeriod Rate period. Supported values: Daily,Weekly,Monthly,Trip,Weekend - * @param rateCode Rate plan identifier. * @param prePay Indicates whether this reservation should be paid at the time of booking (true) or at time of rental return (false). + * @param rateCode Rate plan identifier. * @param creditCardRequired Indicates whether credit card is required for booking. * @param discounts List of discount information. * @param mileages A list of charges to be levied based on the mileage driven. @@ -55,16 +55,15 @@ data class RateDetails( @field:NotNull @field:Valid val ratePeriod: kotlin.String, - // Rate plan identifier. - @JsonProperty("RateCode") - @field:NotNull - @field:Valid - val rateCode: kotlin.String, // Indicates whether this reservation should be paid at the time of booking (true) or at time of rental return (false). @JsonProperty("PrePay") @field:NotNull @field:Valid val prePay: kotlin.Boolean, + // Rate plan identifier. + @JsonProperty("RateCode") + @field:Valid + val rateCode: kotlin.String? = null, // Indicates whether credit card is required for booking. @JsonProperty("CreditCardRequired") @field:Valid @@ -89,8 +88,8 @@ data class RateDetails( class Builder( private var ratePeriod: kotlin.String? = null, - private var rateCode: kotlin.String? = null, private var prePay: kotlin.Boolean? = null, + private var rateCode: kotlin.String? = null, private var creditCardRequired: kotlin.Boolean? = null, private var discounts: kotlin.collections.List? = null, private var mileages: kotlin.collections.List? = null, @@ -98,10 +97,10 @@ data class RateDetails( ) { fun ratePeriod(ratePeriod: kotlin.String) = apply { this.ratePeriod = ratePeriod } - fun rateCode(rateCode: kotlin.String) = apply { this.rateCode = rateCode } - fun prePay(prePay: kotlin.Boolean) = apply { this.prePay = prePay } + fun rateCode(rateCode: kotlin.String?) = apply { this.rateCode = rateCode } + fun creditCardRequired(creditCardRequired: kotlin.Boolean?) = apply { this.creditCardRequired = creditCardRequired } fun discounts(discounts: kotlin.collections.List?) = apply { this.discounts = discounts } @@ -114,8 +113,8 @@ data class RateDetails( val instance = RateDetails( ratePeriod = ratePeriod!!, - rateCode = rateCode!!, prePay = prePay!!, + rateCode = rateCode, creditCardRequired = creditCardRequired, discounts = discounts, mileages = mileages, @@ -149,8 +148,8 @@ data class RateDetails( fun toBuilder() = Builder( ratePeriod = ratePeriod!!, - rateCode = rateCode!!, prePay = prePay!!, + rateCode = rateCode, creditCardRequired = creditCardRequired, discounts = discounts, mileages = mileages, diff --git a/code/transformedSpecs.yaml b/code/transformedSpecs.yaml index 520dca3..577a0d7 100644 --- a/code/transformedSpecs.yaml +++ b/code/transformedSpecs.yaml @@ -6353,7 +6353,6 @@ components: RateDetails: required: - PrePay - - RateCode - RatePeriod type: object properties: diff --git a/examples/src/main/java/com/expediagroup/sdk/xap/examples/XapSdkDemoTestRun.java b/examples/src/main/java/com/expediagroup/sdk/xap/examples/XapSdkDemoTestRun.java index 1025cbc..4813bd1 100644 --- a/examples/src/main/java/com/expediagroup/sdk/xap/examples/XapSdkDemoTestRun.java +++ b/examples/src/main/java/com/expediagroup/sdk/xap/examples/XapSdkDemoTestRun.java @@ -54,7 +54,9 @@ public static void main(String[] args) { logger.info( "============================== Running Car Scenarios ============================="); - CarListingsQuickStartScenario carListingsQuickStartScenario = new CarListingsQuickStartScenario(); + CarListingsQuickStartScenario carListingsQuickStartScenario = + new CarListingsQuickStartScenario(); + carListingsQuickStartScenario.run(); CarDetailsQuickStartScenario carDetailsQuickStartScenario = new CarDetailsQuickStartScenario(); diff --git a/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarDetailsQuickStartScenario.java b/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarDetailsQuickStartScenario.java index cf062f2..b16c006 100644 --- a/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarDetailsQuickStartScenario.java +++ b/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarDetailsQuickStartScenario.java @@ -19,218 +19,230 @@ import org.slf4j.LoggerFactory; /** - * This example demonstrates how to retrieve CarDetails information using the Car Details DeepLink obtained from the car listing. + * This example demonstrates how to retrieve CarDetails information using the Car Details DeepLink + * obtained from the car listing. */ public class CarDetailsQuickStartScenario implements XapScenario { - private static final Logger LOGGER = LoggerFactory.getLogger(CarDetailsQuickStartScenario.class); - - /** - * Summary: main function. - */ - public static void main(String[] args) { - new CarListingsQuickStartScenario().run(); - new CarDetailsQuickStartScenario().run(); - System.exit(0); - } - - @Override - public void run() { - LOGGER.info("========== Start QuickStartScenario =========="); - - LOGGER.info("========== Car Listing Start =========="); - - // This example demonstrates how to obtain the Car Details Deep Link from the CarListing. - // For information on using car search, refer to car/shopping/listings/ListingsQuickStartExample. - List linksList = new ArrayList<>(); - linksList.add(GetCarsListingsOperationParams.Links.AD); - linksList.add(GetCarsListingsOperationParams.Links.WS); - linksList.add(GetCarsListingsOperationParams.Links.WD); - GetCarsListingsOperationParams getCarsListingsOperationParams = GetCarsListingsOperationParams.builder() - .partnerTransactionId("EWSCar_Automation") - .dropOffAirport("MCO") - .pickupAirport("MCO") - .pickupTime(LocalDateTime.now().plusDays(5)) - .dropOffTime(LocalDateTime.now().plusDays(8)) - .limit(1) - .links(linksList) - .build(); - - XapClient xapClient = createClient(); - GetCarsListingsOperation getCarsListingsOperation = new GetCarsListingsOperation(getCarsListingsOperationParams); - Response carListingsResponse = xapClient.execute(getCarsListingsOperation); - - LOGGER.info("========== Car Listing Property End =========="); - - // Iterate through the car listings and retrieve the Car Details Deep Link. - LOGGER.info("========== Car Details Start =========="); - Objects.requireNonNull(carListingsResponse.getData().getCars()).forEach(car -> { - if (!car.getLinks().get("ApiDetails").getHref().isEmpty()) { - // Retrieve the Car Details Deep Link from the car listing. - LOGGER.info("Car Details Deep Link: " + car.getLinks().get("ApiDetails").getHref()); - String[] strings = splitUrl(car.getLinks().get("ApiDetails").getHref()); - - // Retrieve the Car Details information using the Car Details Deep Link,which include(offerToken, price, currency) - GetCarDetailsOperationParams getCarDetailsOperationParams = GetCarDetailsOperationParams.builder().partnerTransactionId("EWSCar_Automation") - .offerToken(strings[0]).price(strings[1]).currency(strings[2]).build(); - - // Execute the operation and get the CarDetailsResponse - LOGGER.info("========== Executing GetCarDetailsOperation =========="); - CarDetailsResponse carDetailsResponse = xapClient.execute( - new GetCarDetailsOperation(getCarDetailsOperationParams)).getData(); - LOGGER.info("========== GetCarDetailsOperation Executed =========="); - - if (carDetailsResponse == null || carDetailsResponse.getLinks() == null) { - throw new IllegalStateException("No car found."); - } - - LOGGER.info("========== Car Properties Start =========="); - - // The CarDetailsResponse contains a transaction ID for troubleshooting - LOGGER.info("Transaction ID: {}", carDetailsResponse.getTransactionId()); - - // List Container for warning messages - if (carDetailsResponse.getWarnings() != null) { - LOGGER.info("Warnings: {}", carDetailsResponse.getWarnings()); - } - - // Details of requested car. - // Details refer to the CarDetails Section table below. - if (carDetailsResponse.getValidFormsOfPayment() != null) { - LOGGER.info("Valid Forms Of Payment: {}", carDetailsResponse.getValidFormsOfPayment()); - } - - // A map of links to other Car APIs. - if (carDetailsResponse.getLinks() != null) { - LOGGER.info("Links: {}", carDetailsResponse.getLinks()); - } - - // Specific information for a car. - CarDetails carDetails = carDetailsResponse.getCarDetails(); - VehicleDetails vehicleDetails = carDetails.getVehicleDetails(); - if (vehicleDetails.getMake() != null ) { - //Car manufacturer and model. - LOGGER.info("Make: {}", vehicleDetails.getMake()); - } - - // Car category and type. - LOGGER.info("Car Class: {}", vehicleDetails.getCarClass()); - - // Minimal car door count. - if (vehicleDetails.getMinDoors() != null) { - LOGGER.info("Min Doors: {}", vehicleDetails.getMinDoors()); - } - - // Maximum car door count. - if (vehicleDetails.getMaxDoors() != null) { - LOGGER.info("Max Doors: {}", vehicleDetails.getMaxDoors()); - } - - // Car fuel information. - if (vehicleDetails.getFuelLevel() != null) { - // Fuel level of the car. - LOGGER.info("Fuel Level: {}", vehicleDetails.getFuelLevel()); - } - - // Car category. - LOGGER.info("Car Category: {}", vehicleDetails.getCarCategory()); - - // Car type. - LOGGER.info("Car Type: {}", vehicleDetails.getCarType()); - - // Car transmission and drive. - LOGGER.info("Transmission Drive: {}", vehicleDetails.getTransmissionDrive()); - - // Car fuel type and whether Air Conditioning is included. - LOGGER.info("Fuel AC: {}", vehicleDetails.getFuelAC()); - - // Capacity for car's properties, which include AdultCount, ChildCount, SmallLuggageCount and LargeLuggageCount. - if (vehicleDetails.getCapacity() != null) { - LOGGER.info("Capacity: {}", vehicleDetails.getCapacity()); - } - - // Car rental supplier. - LOGGER.info(" : {}", carDetails.getSupplier()); - - // Pickup information - LOGGER.info("Pickup Details: {}", carDetails.getPickupDetails()); - - // Drop off information, include drop off date time and drop off location information. - LOGGER.info("Drop Off Details: {}", carDetails.getDropOffDetails()); - - // The rate information for a car product. - LOGGER.info("Rate Details: {}", carDetails.getRateDetails()); - - // Base price per rate period. - LOGGER.info("Price: {}", carDetails.getPrice()); - - // List of TaxesAndFees Details. - if (carDetails.getTaxesAndFeesDetails() != null) { - LOGGER.info("Taxes And Fees Details: {}", carDetails.getTaxesAndFeesDetails()); - } - - // List of ExtraFeesDetails - if (carDetails.getExtraFeesDetails() != null) { - LOGGER.info("Extra Fees Details: {}", carDetails.getExtraFeesDetails()); - } - - // ReferencePrice is the totalPrice for the comparable standalone car, when there is a discounted car or need to show strike through pricing. - if (carDetails.getReferencePrice() != null) { - LOGGER.info("Reference Price: {}", carDetails.getReferencePrice()); - } - - // List of additional fees including both mandatory and optional fees such as young driver fee/drop off fee /CollisionDamageWaiver. - if (carDetails.getAdditionalFees() != null) { - LOGGER.info("Additional Fees: {}", carDetails.getAdditionalFees()); - } - - // Description and costs of any optional special equipment that may be rented with the car. - if (carDetails.getSpecialEquipments() != null) { - LOGGER.info("Special Equipments: {}", carDetails.getSpecialEquipments()); - } - - // Limitations that are part of this rental agreement. - if (carDetails.getRentalLimits() != null) { - LOGGER.info("Rental Limits: {}", carDetails.getRentalLimits()); - } - - // Cancellation Policy Container. - LOGGER.info("Cancellation Policy: {}", carDetails.getCancellationPolicy()); - - // Container for no show penalty - if (carDetails.getNoShowPenalty() != null) { - LOGGER.info("No Show Penalty: {}", carDetails.getNoShowPenalty()); - } - - // A list of policies that apply to this car rental. - if (carDetails.getCarPolicies() != null) { - LOGGER.info("Policies: {}", carDetails.getCarPolicies()); - } - - // List of image resources of the car product. - if (carDetails.getImages() != null) { - LOGGER.info("Images: {}", carDetails.getImages()); - } + private static final Logger LOGGER = LoggerFactory.getLogger(CarDetailsQuickStartScenario.class); + + /** + * Summary: main function. + */ + public static void main(String[] args) { + new CarListingsQuickStartScenario().run(); + new CarDetailsQuickStartScenario().run(); + System.exit(0); + } + + /** + * Summary: split URL into components. + */ + public static String[] splitUrl(String url) { + String[] parts = url.split("\\?"); + String base = parts[0]; + String query = parts[1]; + + String offerToken = base.substring(base.lastIndexOf("/") + 1); + String[] queryParams = query.split("&"); + String price = queryParams[0].split("=")[1]; + String currency = queryParams[1].split("=")[1]; + + return new String[] {offerToken, price, currency}; + } + + @Override + public void run() { + LOGGER.info("========== Start QuickStartScenario =========="); + + LOGGER.info("========== Car Listing Start =========="); + + // This example demonstrates how to obtain the Car Details Deep Link from the CarListing. + // For information on using car search, refer to + // car/shopping/listings/ListingsQuickStartExample. + List linksList = new ArrayList<>(); + linksList.add(GetCarsListingsOperationParams.Links.AD); + linksList.add(GetCarsListingsOperationParams.Links.WS); + linksList.add(GetCarsListingsOperationParams.Links.WD); + GetCarsListingsOperationParams getCarsListingsOperationParams = + GetCarsListingsOperationParams.builder() + .partnerTransactionId("EWSCar_Automation") + .dropOffAirport("MCO") + .pickupAirport("MCO") + .pickupTime(LocalDateTime.now().plusDays(5)) + .dropOffTime(LocalDateTime.now().plusDays(8)) + .limit(1) + .links(linksList) + .build(); + + XapClient xapClient = createClient(); + GetCarsListingsOperation getCarsListingsOperation = + new GetCarsListingsOperation(getCarsListingsOperationParams); + Response carListingsResponse = xapClient.execute(getCarsListingsOperation); + + LOGGER.info("========== Car Listing Property End =========="); + + // Iterate through the car listings and retrieve the Car Details Deep Link. + LOGGER.info("========== Car Details Start =========="); + Objects.requireNonNull(carListingsResponse.getData().getCars()).forEach(car -> { + if (!car.getLinks().get("ApiDetails").getHref().isEmpty()) { + // Retrieve the Car Details Deep Link from the car listing. + LOGGER.info("Car Details Deep Link: " + car.getLinks().get("ApiDetails").getHref()); + String[] strings = splitUrl(car.getLinks().get("ApiDetails").getHref()); + + // Retrieve the Car Details information using the Car Details Deep Link, which + // includes (offerToken, price, currency) + GetCarDetailsOperationParams getCarDetailsOperationParams = + GetCarDetailsOperationParams.builder().partnerTransactionId("EWSCar_Automation") + .offerToken(strings[0]).price(strings[1]).currency(strings[2]).build(); + + // Execute the operation and get the CarDetailsResponse + LOGGER.info("========== Executing GetCarDetailsOperation =========="); + CarDetailsResponse carDetailsResponse = xapClient.execute( + new GetCarDetailsOperation(getCarDetailsOperationParams)).getData(); + LOGGER.info("========== GetCarDetailsOperation Executed =========="); + + if (carDetailsResponse == null || carDetailsResponse.getLinks() == null) { + throw new IllegalStateException("No car found."); + } + + LOGGER.info("========== Car Properties Start =========="); + + // The CarDetailsResponse contains a transaction ID for troubleshooting + LOGGER.info("Transaction ID: {}", carDetailsResponse.getTransactionId()); + + // List Container for warning messages + if (carDetailsResponse.getWarnings() != null) { + LOGGER.info("Warnings: {}", carDetailsResponse.getWarnings()); + } + + // Details of requested car. + // Details refer to the CarDetails Section table below. + if (carDetailsResponse.getValidFormsOfPayment() != null) { + LOGGER.info("Valid Forms Of Payment: {}", carDetailsResponse.getValidFormsOfPayment()); + } + + // A map of links to other Car APIs. + if (carDetailsResponse.getLinks() != null) { + LOGGER.info("Links: {}", carDetailsResponse.getLinks()); + } + + // Specific information for a car. + CarDetails carDetails = carDetailsResponse.getCarDetails(); + VehicleDetails vehicleDetails = carDetails.getVehicleDetails(); + if (vehicleDetails.getMake() != null) { + //Car manufacturer and model. + LOGGER.info("Make: {}", vehicleDetails.getMake()); + } + + // Car category and type. + LOGGER.info("Car Class: {}", vehicleDetails.getCarClass()); + + // Minimal car door count. + if (vehicleDetails.getMinDoors() != null) { + LOGGER.info("Min Doors: {}", vehicleDetails.getMinDoors()); + } + + // Maximum car door count. + if (vehicleDetails.getMaxDoors() != null) { + LOGGER.info("Max Doors: {}", vehicleDetails.getMaxDoors()); + } + + // Car fuel information. + if (vehicleDetails.getFuelLevel() != null) { + // Fuel level of the car. + LOGGER.info("Fuel Level: {}", vehicleDetails.getFuelLevel()); + } + + // Car category. + LOGGER.info("Car Category: {}", vehicleDetails.getCarCategory()); + + // Car type. + LOGGER.info("Car Type: {}", vehicleDetails.getCarType()); + + // Car transmission and drive. + LOGGER.info("Transmission Drive: {}", vehicleDetails.getTransmissionDrive()); + + // Car fuel type and whether Air Conditioning is included. + LOGGER.info("Fuel AC: {}", vehicleDetails.getFuelAC()); + + // Capacity for car's properties, which include AdultCount, ChildCount, SmallLuggageCount + // and LargeLuggageCount. + if (vehicleDetails.getCapacity() != null) { + LOGGER.info("Capacity: {}", vehicleDetails.getCapacity()); + } + + // Car rental supplier. + LOGGER.info(" : {}", carDetails.getSupplier()); + + // Pickup information + LOGGER.info("Pickup Details: {}", carDetails.getPickupDetails()); + + // Drop off information, include drop off date time and drop off location information. + LOGGER.info("Drop Off Details: {}", carDetails.getDropOffDetails()); + + // The rate information for a car product. + LOGGER.info("Rate Details: {}", carDetails.getRateDetails()); + + // Base price per rate period. + LOGGER.info("Price: {}", carDetails.getPrice()); + + // List of TaxesAndFees Details. + if (carDetails.getTaxesAndFeesDetails() != null) { + LOGGER.info("Taxes And Fees Details: {}", carDetails.getTaxesAndFeesDetails()); + } + + // List of ExtraFeesDetails + if (carDetails.getExtraFeesDetails() != null) { + LOGGER.info("Extra Fees Details: {}", carDetails.getExtraFeesDetails()); + } + + // ReferencePrice is the totalPrice for the comparable standalone car, when there is + // a discounted car or need to show strike through pricing. + if (carDetails.getReferencePrice() != null) { + LOGGER.info("Reference Price: {}", carDetails.getReferencePrice()); + } + + // List of additional fees including both mandatory and optional fees such as young driver + // fee/drop off fee /CollisionDamageWaiver. + if (carDetails.getAdditionalFees() != null) { + LOGGER.info("Additional Fees: {}", carDetails.getAdditionalFees()); + } + + // Description and costs of any optional special equipment that may be rented with the car. + if (carDetails.getSpecialEquipments() != null) { + LOGGER.info("Special Equipments: {}", carDetails.getSpecialEquipments()); + } + + // Limitations that are part of this rental agreement. + if (carDetails.getRentalLimits() != null) { + LOGGER.info("Rental Limits: {}", carDetails.getRentalLimits()); + } + + // Cancellation Policy Container. + LOGGER.info("Cancellation Policy: {}", carDetails.getCancellationPolicy()); + + // Container for no show penalty + if (carDetails.getNoShowPenalty() != null) { + LOGGER.info("No Show Penalty: {}", carDetails.getNoShowPenalty()); + } + + // A list of policies that apply to this car rental. + if (carDetails.getCarPolicies() != null) { + LOGGER.info("Policies: {}", carDetails.getCarPolicies()); + } + + // List of image resources of the car product. + if (carDetails.getImages() != null) { + LOGGER.info("Images: {}", carDetails.getImages()); + } + + LOGGER.info("========== Property End =========="); + } + + }); - LOGGER.info("========== Property End =========="); - } - - }); - - LOGGER.info("========== End QuickStartExample =========="); - } - - public static String[] splitUrl(String url) { - String[] parts = url.split("\\?"); - String base = parts[0]; - String query = parts[1]; - - String offerToken = base.substring(base.lastIndexOf("/") + 1); - String[] queryParams = query.split("&"); - String price = queryParams[0].split("=")[1]; - String currency = queryParams[1].split("=")[1]; - - return new String[]{offerToken, price, currency}; - } + LOGGER.info("========== End QuickStartExample =========="); + } } diff --git a/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarListingsQuickStartScenario.java b/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarListingsQuickStartScenario.java index df88643..28532ac 100644 --- a/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarListingsQuickStartScenario.java +++ b/examples/src/main/java/com/expediagroup/sdk/xap/examples/scenarios/car/CarListingsQuickStartScenario.java @@ -17,132 +17,140 @@ */ public class CarListingsQuickStartScenario implements XapScenario { - private static final Logger LOGGER = LoggerFactory.getLogger(CarListingsQuickStartScenario.class); - - /** - * Summary: main function. - */ - public static void main(String[] args) { - new CarListingsQuickStartScenario().run(); - System.exit(0); + private static final Logger LOGGER = LoggerFactory.getLogger(CarListingsQuickStartScenario.class); + + /** + * Summary: main function. + */ + public static void main(String[] args) { + new CarListingsQuickStartScenario().run(); + System.exit(0); + } + + @Override + public void run() { + LOGGER.info( + "========================= Running CarListingsQuickStartScenario ========================"); + + LOGGER.info( + "======================== Executing GetCarsListingsOperation ======================="); + // This example will search for properties based on the following criteria: + // 1. The pickup airport is MCO, and the drop-off airport is MCO; + // 2. The pickup time is "2025-01-15T11:00", and the drop-off time is "2025-01-19T11:00"; + // 3. The results should include API details, web search, and web details link; + // 4. Limit the results to 5; + + // Create a list to store the types of links to be returned. + // The added link types include(API details link, Web search link, and Web details link). + List linksList = new ArrayList<>(); + linksList.add(GetCarsListingsOperationParams.Links.AD); + linksList.add(GetCarsListingsOperationParams.Links.WS); + linksList.add(GetCarsListingsOperationParams.Links.WD); + + GetCarsListingsOperationParams getCarsListingsOperationParams = + GetCarsListingsOperationParams.builder().partnerTransactionId("EWSCar_Automation") + //Three letter code for the airport at which the customer would like to pick up the car. + //Supported values: standard 3 letter IATA Airport Code. + //Cannot coexist with other pickup parameters, only one pickup parameter is allowed per + //request. + .pickupAirport("MCO") + //Three letter code for the airport at which the customer would like to drop off the + //car. + //Supported values: standard 3 letter IATA Airport Code. + //Cannot coexist with other drop off parameters, only one drop off parameter is allowed + //per request. + //If no drop off location is specified, it is assumed that the customer will be dropping + //the car off at the same location at which they picked it up. + .dropOffAirport("MCO") + //Requested car pickup date and time. + //Date should be ISO8601 Date format.The supported search window is today to 330 days in + //the future. + //(Note that each rental counter has different hours of operation. If you select a time + //in the middle of the night there may be no inventory available as all locations may be + //closed.) + .pickupTime(LocalDateTime.now().plusDays(5)) + //Requested car drop off date and time. + //Date should be ISO8601 Date format.The supported search window is today to 330 days in + //the future. + //The drop-off datetime should occur at least 2 hours after the pickup datetime. + .dropOffTime(LocalDateTime.now().plusDays(8)) + //The maximum number of search results that will be returned by the query. + .limit(5).links(linksList).build(); + XapClient xapClient = createClient(); + + // Execute the operation and get the CarListingsResponse + CarListingsResponse carListingsResponse = + xapClient.execute(new GetCarsListingsOperation(getCarsListingsOperationParams)).getData(); + LOGGER.info( + "======================== GetCarsListingsOperation Executed ========================"); + + if (carListingsResponse == null || carListingsResponse.getCars() == null + || carListingsResponse.getCars().isEmpty()) { + throw new IllegalStateException("No cars found."); } - @Override - public void run() { - LOGGER.info( - "========================== Running CarListingsQuickStartScenario ========================="); - - LOGGER.info( - "======================== Executing GetCarsListingsOperation ======================="); - // This example will search for properties based on the following criteria: - // 1. The pickup airport is MCO, and the drop-off airport is MCO; - // 2. The pickup time is "2025-01-15T11:00", and the drop-off time is "2025-01-19T11:00"; - // 3. The results should include API details, web search, and web details link; - // 4. Limit the results to 5; - - // Create a list to store the types of links to be returned. - // The added link types include(API details link, Web search link, and Web details link). - List linksList = new ArrayList<>(); - linksList.add(GetCarsListingsOperationParams.Links.AD); - linksList.add(GetCarsListingsOperationParams.Links.WS); - linksList.add(GetCarsListingsOperationParams.Links.WD); - - GetCarsListingsOperationParams getCarsListingsOperationParams = GetCarsListingsOperationParams.builder() - .partnerTransactionId("EWSCar_Automation") - //Three letter code for the airport at which the customer would like to pick up the car. - //Supported values: standard 3 letter IATA Airport Code. - //Cannot coexist with other pickup parameters, only one pickup parameter is allowed per request. - .pickupAirport("MCO") - //Three letter code for the airport at which the customer would like to drop off the car. - //Supported values: standard 3 letter IATA Airport Code. - //Cannot coexist with other drop off parameters, only one drop off parameter is allowed per request. - //If no drop off location is specified, it is assumed that the customer will be dropping the car off at the same location at which they picked it up. - .dropOffAirport("MCO") - //Requested car pickup date and time. - //Date should be ISO8601 Date format.The supported search window is today to 330 days in the future. - //(Note that each rental counter has different hours of operation. If you select a time in the middle of the night there may be no inventory available as all locations may be closed.) - .pickupTime(LocalDateTime.now().plusDays(5)) - //Requested car drop off date and time. - //Date should be ISO8601 Date format.The supported search window is today to 330 days in the future. - //The drop off datetime should occur at least 2 hours after the pickup datetime. - .dropOffTime(LocalDateTime.now().plusDays(8)) - //The maximum number of search results that will be returned by the query. - .limit(5) - .links(linksList) - .build(); - XapClient xapClient = createClient(); - - // Execute the operation and get the CarListingsResponse - CarListingsResponse carListingsResponse = xapClient.execute( - new GetCarsListingsOperation(getCarsListingsOperationParams)).getData(); - LOGGER.info("======================== GetCarsListingsOperation Executed ========================"); - - if (carListingsResponse == null || carListingsResponse.getCars() == null - || carListingsResponse.getCars().isEmpty()) { - throw new IllegalStateException("No cars found."); - } - - // The CarListingsResponse contains a transaction ID for troubleshooting - LOGGER.info("Transaction ID: {}", carListingsResponse.getTransactionId()); - // To get the total number of car found - LOGGER.info("Car Count: {}", carListingsResponse.getCarCount()); + // The CarListingsResponse contains a transaction ID for troubleshooting + LOGGER.info("Transaction ID: {}", carListingsResponse.getTransactionId()); + // To get the total number of car found + LOGGER.info("Car Count: {}", carListingsResponse.getCarCount()); - // To access the properties, iterate through the list of car properties - carListingsResponse.getCars().forEach(car -> { - LOGGER.info("======================== Car Properties Start ========================"); + // To access the properties, iterate through the list of car properties + carListingsResponse.getCars().forEach(car -> { + LOGGER.info("======================== Car Properties Start ========================"); - // Uniquely identifies a Car Offer. - LOGGER.info("Car Id: {}", car.getId()); + // Uniquely identifies a Car Offer. + LOGGER.info("Car Id: {}", car.getId()); - // Specific information for a car. - LOGGER.info("Car VehicleDetails: {}", car.getVehicleDetails()); + // Specific information for a car. + LOGGER.info("Car VehicleDetails: {}", car.getVehicleDetails()); - // The supplier of the car being offered. - LOGGER.info("Car Supplier: {}", car.getSupplier()) ; + // The supplier of the car being offered. + LOGGER.info("Car Supplier: {}", car.getSupplier()); - // Get Pickup information of the car. - LOGGER.info("Pick up Details: {}", car.getPickupDetails()); + // Get Pickup information of the car. + LOGGER.info("Pick up Details: {}", car.getPickupDetails()); - // Get Drop off information of the car. - LOGGER.info("Drop Off Details: {}", car.getDropOffDetails()); + // Get Drop off information of the car. + LOGGER.info("Drop Off Details: {}", car.getDropOffDetails()); - // Get the API details link, web search link, and web details link from the links collection. - if (!car.getLinks().isEmpty()) { - if (car.getLinks().get("ApiDetails") != null) { - LOGGER.info("ApiDetails Link: {}", car.getLinks().get("ApiDetails")); - } - if (car.getLinks().get("WebSearch") != null) { - LOGGER.info("WebSearch Link: {}", car.getLinks().get("WebSearch")); - } - if (car.getLinks().get("WebDetails") != null) { - LOGGER.info("WebDetails Link: {}", car.getLinks().get("WebDetails")); - } - } + // Get the API details link, web search link, and web details link from the links collection. + if (!car.getLinks().isEmpty()) { + if (car.getLinks().get("ApiDetails") != null) { + LOGGER.info("ApiDetails Link: {}", car.getLinks().get("ApiDetails")); + } + if (car.getLinks().get("WebSearch") != null) { + LOGGER.info("WebSearch Link: {}", car.getLinks().get("WebSearch")); + } + if (car.getLinks().get("WebDetails") != null) { + LOGGER.info("WebDetails Link: {}", car.getLinks().get("WebDetails")); + } + } - // The rate detail information for a car offer. - if (car.getRateDetails() != null) { - LOGGER.info("Rate Details: {}", car.getRateDetails()); - } + // The rate detail information for a car offer. + if (car.getRateDetails() != null) { + LOGGER.info("Rate Details: {}", car.getRateDetails()); + } - // Get the detailed pricing information for the rental of the car offer, - LOGGER.info("Car Price: {}", car.getPrice()); + // Get the detailed pricing information for the rental of the car offer, + LOGGER.info("Car Price: {}", car.getPrice()); - // Get a list of additional fees, including both mandatory and optional fees. - if (car.getAdditionalFees() != null) { - LOGGER.info("Additional Fees: {}", car.getAdditionalFees()); - } + // Get a list of additional fees, including both mandatory and optional fees. + if (car.getAdditionalFees() != null) { + LOGGER.info("Additional Fees: {}", car.getAdditionalFees()); + } - // Get the cancellation policy for the car offer, - LOGGER.info("Cancellation Policy: {}", car.getCancellationPolicy()); + // Get the cancellation policy for the car offer, + LOGGER.info("Cancellation Policy: {}", car.getCancellationPolicy()); - // Container for no show penalty element. - if (car.getNoShowPenalty() != null) { - LOGGER.info("No Show Penalty: {}", car.getNoShowPenalty()); - } + // Container for no show penalty element. + if (car.getNoShowPenalty() != null) { + LOGGER.info("No Show Penalty: {}", car.getNoShowPenalty()); + } - LOGGER.info("======================== Property End ========================"); - }); - LOGGER.info("======================== End CarListingsQuickStartScenario ========================"); - } -} \ No newline at end of file + LOGGER.info("======================== Property End ========================"); + }); + LOGGER.info( + "======================== End CarListingsQuickStartScenario ========================"); + } +} diff --git a/specs/xap-car.specs.yaml b/specs/xap-car.specs.yaml index 7a39d3a..777c6dc 100644 --- a/specs/xap-car.specs.yaml +++ b/specs/xap-car.specs.yaml @@ -1066,7 +1066,6 @@ components: RateDetails: required: - PrePay - - RateCode - RatePeriod type: object properties: