com.github.debugthug.TrujetXmlService Maven / Gradle / Ivy
package com.github.debugthug;
import com.github.debugthug.exceptions.CreateBookingException;
import com.github.debugthug.exceptions.FareRulesNotAvailableException;
import com.github.debugthug.exceptions.FlightInfoException;
import com.github.debugthug.exceptions.HoldInventoryException;
import com.github.debugthug.exceptions.IncorrectRequestException;
import com.github.debugthug.exceptions.SearchAvailabilityException;
import com.github.debugthug.transformers.CreateBookingTransformer;
import com.github.debugthug.transformers.FareRulesAndRestrictionsTransformer;
import com.github.debugthug.transformers.FlightInfoTransformer;
import com.github.debugthug.transformers.HoldInventoryTransformer;
import com.github.debugthug.transformers.SearchAvailabilityTransformer;
import com.github.debugthug.xo.Envelope;
public class TrujetXmlService extends BaseTrujetXmlService {
public static Envelope searchAvailability(Envelope envelopeOnlineAvailabilityRQ)
throws SearchAvailabilityException, IncorrectRequestException {
SearchAvailabilityTransformer searchAvailabilityTransformer = new SearchAvailabilityTransformer();
String request = searchAvailabilityTransformer.transformRequest(envelopeOnlineAvailabilityRQ);
// execution of connection and getting response
String postUrl = TrujetDefaultSettings.POST_FLIGHT;
String searchResponse = sendAndReceive(request, postUrl);
Envelope envelopeOnlineAvailabilityRS = searchAvailabilityTransformer.transformResponse(searchResponse);
return envelopeOnlineAvailabilityRS;
}
public static Envelope getFareRules(Envelope envelopeFareRulesRQ)
throws FareRulesNotAvailableException, IncorrectRequestException {
FareRulesAndRestrictionsTransformer fareRulesAndRestrictionsTransformer = new FareRulesAndRestrictionsTransformer();
String request = fareRulesAndRestrictionsTransformer.transformRequest(envelopeFareRulesRQ);
// execution of connection and getting response
String postUrl = TrujetDefaultSettings.POST_RESERVATION;
String fareRulesResponse = sendAndReceive(request, postUrl);
Envelope envelopeFareRulesRS = fareRulesAndRestrictionsTransformer.transformResponse(fareRulesResponse);
return envelopeFareRulesRS;
}
public static Envelope getFlightInformation(Envelope envelopeFlightInfoRQ)
throws FlightInfoException, IncorrectRequestException {
FlightInfoTransformer flightInfoTransformer = new FlightInfoTransformer();
String request = flightInfoTransformer.transformRequest(envelopeFlightInfoRQ);
// execution of connection and getting response
String postUrl = TrujetDefaultSettings.POST_FLIGHT;
String flightInfoResponse = sendAndReceive(request, postUrl);
Envelope envelopeFlightInfoRS = flightInfoTransformer.transformResponse(flightInfoResponse);
return envelopeFlightInfoRS;
}
public static Envelope holdInventory(Envelope envelopeHoldInventoryRQ) throws HoldInventoryException, IncorrectRequestException {
HoldInventoryTransformer holdInventoryTransformer = new HoldInventoryTransformer();
String request = holdInventoryTransformer.transformRequest(envelopeHoldInventoryRQ);
// execution of connection and getting response
String postUrl = TrujetDefaultSettings.POST_FLIGHT;
String holdInventoryResponse = sendAndReceive(request, postUrl);
Envelope envelopeHoldInventoryRS = holdInventoryTransformer.transformResponse(holdInventoryResponse);
return envelopeHoldInventoryRS;
}
public static Envelope createBooking(Envelope envelopeCreateBookingRQ)
throws CreateBookingException, IncorrectRequestException {
CreateBookingTransformer createBookingTransformer = new CreateBookingTransformer();
String request = createBookingTransformer.transformRequest(envelopeCreateBookingRQ);
// execution of connection and getting response::
String postUrl = TrujetDefaultSettings.POST_RESERVATION;
String bookingResponse = sendAndReceive(request, postUrl);
Envelope envelopeCreateBookingRS = createBookingTransformer.transformResponse(bookingResponse);
return envelopeCreateBookingRS;
}
}