static void testHotelAvailability() { HDSRequest rq = new HDSRequest(HDSRequestType.SearchByHotelId); rq.StayDate = new StayDate(); rq.StayDate.CheckIn = "2013-03-17"; rq.StayDate.CheckOut = "2013-03-19"; rq.Session.CurrencyCode = "AUD"; rq.Hotels = new List<Hotel>(); rq.Hotels.Add(new Hotel { Id = 115094 }); rq.Itineraries = new List<Itinerary>(); rq.Itineraries.Add(new Itinerary(1, "1_2")); Console.WriteLine(objectToJson(rq)); Console.WriteLine("\n------------------------------\n"); Console.Write("Press enter key to continue.."); Console.ReadLine(); Console.Write("...\n"); HDSManager manager = new HDSManager(); HotelAvailabilityRS rs = manager.GetHotelAvailability(rq); Console.WriteLine(objectToJson(rs)); Console.ReadLine(); }
/* * general and common value * - checkIn and checkOut * - pageIndex and pageSize * - minStar and maxStar */ private HDSRequest MapGeneral(HDSRequest request, HttpRequest httpRq) { //checkin-out request.StayDate = new StayDate { CheckIn = httpRq["checkIn"], CheckOut = httpRq["checkOut"] }; //page index and page size if (!string.IsNullOrEmpty(httpRq["pageIndex"])) { request.Session.PageIndex = int.Parse(httpRq["pageIndex"]); } if (!string.IsNullOrEmpty(httpRq["pageSize"])) { request.Session.PageSize = int.Parse(httpRq["pageSize"]); } //star rating if (!string.IsNullOrEmpty(httpRq["minStar"])) { request.SearchCriteria.MinStarRating = float.Parse(httpRq["minStar"]); } if (!string.IsNullOrEmpty(httpRq["maxStar"])) { request.SearchCriteria.MaxStarRating = float.Parse(httpRq["maxStar"]); } //room(s) request request.Itineraries = helper.GenerateItineraryList(httpRq); //addition filter for hotel name keyword request.SearchCriteria.HotelNameKeyword = httpRq["hotelNameKeyword"]; //addition filter for amenities if (httpRq["amenities"] != null) { request.SearchCriteria.Amenities = new List<Amenity>(); foreach (string amenityId in httpRq["amenities"].Split(',')){ request.SearchCriteria.Amenities.Add(new Amenity { Code = amenityId }); } } //additon filter for property type if (httpRq["propertyTypes"] != null) { request.SearchCriteria.PropertyTypes = new List<PropertyType>(); foreach (string propertyTypeId in httpRq["propertyTypes"].Split(',')){ request.SearchCriteria.PropertyTypes.Add(new PropertyType { Code = propertyTypeId }); } } //expedia specific if ((httpRq["cacheKey"] != null) && (httpRq["cacheLocation"] != null)) { request.Session.Expedia = new ExpediaSpecific { CacheKey = httpRq["cacheKey"], CacheLocation = httpRq["cacheLocation"] }; } //orbitz specific // ??? return request; }
public HDSRequest MapHotelContent(HDSRequest request, HttpRequest httpRq) { long hotelId = long.Parse(httpRq["hotelID"]); request.Hotels = new List<Hotel>(); request.Hotels.Add(new Hotel { Id = hotelId }); return request; }
//search by location keyword public HDSRequest MapSearchByLocationKeyword(HDSRequest request, HttpRequest httpRq) { request = this.MapGeneral(request, httpRq); request.SearchCriteria.LocationKeyword = httpRq["locationKeyword"]; return request; }
//search by location id public HDSRequest MapSearchByLocationId(HDSRequest request, HttpRequest httpRq) { request = this.MapGeneral(request, httpRq); request.SearchCriteria.Location = new Location { Code = httpRq["locationId"] }; return request; }
//search by list of hotel id public HDSRequest MapSearchByHotelIds(HDSRequest request, HttpRequest httpRq) { request = this.MapGeneral(request, httpRq); request.Hotels = new List<Hotel>(); foreach(string hotelId in httpRq["hotelIds"].Split(',')){ request.Hotels.Add(new Hotel { Id = long.Parse(hotelId) }); } return request; }
public HotelAvailabilityRS GetHotelAvailability(HDSRequest request) { HotelRoomAvailabilityRequest rawRq = new HotelRoomAvailabilityRequest(); rawRq = (HotelRoomAvailabilityRequest)commonHelper.GenerateBaseRequest(rawRq, request); //stay date rawRq.arrivalDate = request.StayDate.GetCheckInUSFormat(); rawRq.departureDate = request.StayDate.GetCheckOutUSFormat(); //hotel rawRq.hotelId = (long)request.Hotels[0].Id; //room and num adults-children rawRq.RoomGroup = commonHelper.GenerateRoomGroup(request.Itineraries); //include details rawRq.includeDetails = true; rawRq.includeDetailsSpecified = true; rawRq.includeRoomImages = true; rawRq.includeRoomImagesSpecified = true; //submit soap request to expedia HotelRoomAvailabilityResponse rawRs; try { serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient(); rawRs = serviceObjShop.getAvailability(rawRq); } catch (Exception e1) { HotelAvailabilityRS error = new HotelAvailabilityRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() }); return error; } //do hotel availability mapping try { return objMapping.MappingHotelAvailability(rawRs); } catch (Exception e2) { HotelAvailabilityRS error = new HotelAvailabilityRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9120, Message = "Hotel Availability mapping exception", DetailDescription = e2.ToString() }); return error; } }
public string GetHotelAvailability(HDSRequest rq) { HDSManager sourceManager = this.GetSourceManager(); HotelAvailabilityRS rs = sourceManager.GetHotelAvailability(rq); if (rs.Hotel != null) //make sure hotel get availability, otherwise will not get content { if (rq.IsContentRequested) { HotelContentRS rsContent = sourceManager.GetHotelInfo(rq); rs.Hotel.HotelInfo = rsContent.Hotels[0].HotelInfo; } } return outputManager.ObjectToJson(rs); }
public HotelContentRS GetHotelInfo(HDSRequest request) { HotelInformationRequest hotelInfoRequest = new HotelInformationRequest(); hotelInfoRequest = (HotelInformationRequest)commonHelper.GenerateBaseRequest(hotelInfoRequest, request); hotelInfoRequest.hotelId = (long)request.Hotels[0].Id; hotelInfoRequest.options = new hotelInfoOption[5]; hotelInfoRequest.options[0] = new hotelInfoOption(); hotelInfoRequest.options[0] = hotelInfoOption.HOTEL_DETAILS; //hotel details hotelInfoRequest.options[1] = new hotelInfoOption(); hotelInfoRequest.options[1] = hotelInfoOption.PROPERTY_AMENITIES; //hotel amenities hotelInfoRequest.options[2] = new hotelInfoOption(); hotelInfoRequest.options[2] = hotelInfoOption.HOTEL_IMAGES; //hotel images hotelInfoRequest.options[3] = new hotelInfoOption(); hotelInfoRequest.options[3] = hotelInfoOption.HOTEL_SUMMARY; //hotel name and address hotelInfoRequest.options[4] = new hotelInfoOption(); hotelInfoRequest.options[4] = hotelInfoOption.ROOM_TYPES; //room info //submit soap request to expedia HotelInformationResponse hotelInfoResponse; try { serviceObjShop = new Expedia.HotelShoppingServiceReference.HotelServicesClient(); hotelInfoResponse = serviceObjShop.getInformation(hotelInfoRequest); } catch (Exception e1) { HotelContentRS error = new HotelContentRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9003, Message = "Error return from provider", DetailDescription = e1.ToString() }); return error; } //do hotel content object mapping try { return objMapping.MappingHotelInfo(hotelInfoResponse); } catch(Exception e2) { HotelContentRS error = new HotelContentRS(); error.Errors = new List<WarningAndError>(); error.Errors.Add(new WarningAndError { Id = 9150, Message = "Hotel Conent mapping exception", DetailDescription = e2.ToString() }); return error; } }
static void testeHotelInfo() { HDSRequest rq = new HDSRequest(HDSRequestType.HotelContent); rq.Hotels = new List<Hotel>(); rq.Hotels.Add(new Hotel { Id = 115094 }); Console.WriteLine(objectToJson(rq)); Console.WriteLine("\n------------------------------\n"); Console.Write("Press enter key to continue.."); Console.ReadLine(); Console.Write("...\n"); HDSManager manager = new HDSManager(); HotelContentRS rs = manager.GetHotelInfo(rq); Console.WriteLine(objectToJson(rs)); Console.ReadLine(); }
/* * these are list of function to generate Expedia object base of given input parameter * * */ //create all the neccessary property for expedia general request parameter public Expedia.HotelShoppingServiceReference.HotelBaseRequest GenerateBaseRequest(HotelBaseRequest hotelRequest, HDSRequest request) { //will need to get apiKey and cid from database base on "request.Session.SiteId" hotelRequest.apiKey = "nt2cqy75cmqumtjm2pscc7py"; hotelRequest.cid = 55505; hotelRequest.customerIpAddress = request.Session.CustomerIpAddress; hotelRequest.customerSessionId = request.Session.SessionId; hotelRequest.customerUserAgent = request.Session.BrowserUserAgent; if (request.Session.Expedia == null) { //only setup locale+currency if there is no cacheKey and no cacheLocation hotelRequest.currencyCode = request.Session.CurrencyCode; hotelRequest.locale = this.MapLocale(request.Session.Locale); hotelRequest.localeSpecified = true; } return hotelRequest; }
public HDSRequest MapSearchByHotelId(HDSRequest request, HttpRequest httpRq) { //checkin-out request.StayDate = new StayDate { CheckIn = httpRq["checkIn"], CheckOut = httpRq["checkOut"] }; //hotel id request.Hotels = new List<Hotel>(); request.Hotels.Add(new Hotel { Id = long.Parse(httpRq["hotelId"]) }); //room(s) request request.Itineraries = helper.GenerateItineraryList(httpRq); //if content is also requested if (!string.IsNullOrEmpty(httpRq["contentRequested"])) { request.IsContentRequested = bool.Parse(httpRq["contentRequested"]); } return request; }
public override SearchResultRS GetSearchResult(HDSRequest request) { return null; }
public override HotelAvailabilityRS GetHotelAvailability(HDSRequest request) { return null; }
public override RateRuleRS GetHotelRateRule(HDSRequest request) { return null; }
//search by location public virtual SearchResultRS GetSearchResult(HDSRequest request) { return null; }
//reservation-booking public virtual ReservationRS MakeHotelReservation(HDSRequest request) { return null; }
//hotel content public virtual HotelContentRS GetHotelInfo(HDSRequest request) { return null; }
//rate rules (only for Orbitz) public virtual RateRuleRS GetHotelRateRule(HDSRequest request) { return null; }
public HotelAvailabilityRS GetHotelAvailability(HDSRequest rq) { SourceSelectionFactory factory = new SourceSelectionFactory(); IHDSHotelShopping shoppingObj = factory.CreateSourceShopping(rq.Session.SourceProvider); return shoppingObj.GetHotelAvailability(rq); }
//search by hotel public virtual HotelAvailabilityRS GetHotelAvailability(HDSRequest request) { return null; }
public HotelContentRS GetHotelInfo(HDSRequest rq) { SourceSelectionFactory factory = new SourceSelectionFactory(); IHDSHotelContent contentObj = factory.CreateSourceContent(rq.Session.SourceProvider); return contentObj.GetHotelInfo(rq); }
public override ReservationRS MakeHotelReservation(HDSRequest request) { return null; }
public string GetHotelInfo(HDSRequest rq) { HDSManager sourceManager = this.GetSourceManager(); HotelContentRS rs = sourceManager.GetHotelInfo(rq); return outputManager.ObjectToJson(rs); }
public SearchResultRS MappingSearchResult(HotelListResponse rawRs, HDSRequest request) { SearchResultRS rs = new SearchResultRS(); //EAN warning and error if (rawRs.EanWsError != null) { if ((rawRs.EanWsError.handling == errorHandling.RECOVERABLE) && (rawRs.EanWsError.category == errorCategory.DATA_VALIDATION)){ //warning about location rs.Warnings = new List<WarningAndError>(); WarningAndError warning = helper.GenerateWarningAndError(9002, rawRs.EanWsError); rs.Warnings.Add(warning); } else{ //error! something has happened rs.Errors = new List<WarningAndError>(); WarningAndError error = helper.GenerateWarningAndError(9001, rawRs.EanWsError); rs.Errors.Add(error); } } //hotels if (rawRs.HotelList != null) { //pagination if (rawRs.moreResultsAvailableSpecified){ rs.IsMoreResultsAvailable = rawRs.moreResultsAvailable; if (rawRs.moreResultsAvailable){ string tempQs = request.RequestQueryString; if (tempQs.Contains("&cacheKey=") && request.Session.Expedia != null) //remove old cacheKey from request query string tempQs = tempQs.Replace("&cacheKey=" + HttpUtility.UrlEncode(request.Session.Expedia.CacheKey), ""); if (tempQs.Contains("&cacheLocation=") && request.Session.Expedia != null) //remove old cacheLocation from request query string tempQs = tempQs.Replace("&cacheLocation=" + HttpUtility.UrlEncode(request.Session.Expedia.CacheLocation), ""); rs.NextPageQueryString = tempQs + "&cacheKey=" + HttpUtility.UrlEncode(rawRs.cacheKey) + "&cacheLocation=" + HttpUtility.UrlEncode(rawRs.cacheLocation); //re-create new expedia session rs.Session.Expedia = new ExpediaSpecific { CacheKey = rawRs.cacheKey, CacheLocation = rawRs.cacheLocation }; } } //popuplate each of every hotels rs.Hotels = new List<HDSInterfaces.Hotel>(); foreach (HotelSummary rawHotel in rawRs.HotelList.HotelSummary) { bool isHotelWithRate = false; HDSInterfaces.Hotel hotel = new HDSInterfaces.Hotel(); /* ****************** for testing ****************** */ //if (hotel.Id == 356393) { string breakkkkkkk = ""; } /* ****************** for testing ****************** */ //address and location hotel.HotelInfo = new HotelInformation(); hotel.HotelInfo.Id = rawHotel.hotelId; hotel.HotelInfo.Name = rawHotel.name; hotel.HotelInfo.Address = helper.GenerateHotelAddress(rawHotel); //star rating if (rawHotel.hotelRatingSpecified) { hotel.HotelInfo.StarRating = rawHotel.hotelRating; } if (rawHotel.tripAdvisorRatingSpecified) { hotel.HotelInfo.TripAdvisorRating = rawHotel.tripAdvisorRating; } //description and image hotel.HotelInfo.HotelDescription = rawHotel.shortDescription; hotel.HotelInfo.Images = new List<HDSInterfaces.HotelImage>(); hotel.HotelInfo.Images.Add(new HDSInterfaces.HotelImage { UrlThumbnail = IMAGE_URL_PREFIX + rawHotel.thumbNailUrl }); //rooms and rates - some expedia hotel won't have rate (but still has all other information) if (rawHotel.RoomRateDetailsList != null) { isHotelWithRate = true; hotel.Rooms = new List<HDSInterfaces.Room>(); foreach (RoomRateDetails rawRoom in rawHotel.RoomRateDetailsList) { /* * room identification code - do it later */ //room info and promotion HDSInterfaces.Room room = new HDSInterfaces.Room(); room.Description = rawRoom.roomDescription; if (rawRoom.currentAllotment > 0) { room.NumberOfRoomAvailable = rawRoom.currentAllotment; } //as per expedia document, 0 doesn't mean unavailable :( //promotion if (!string.IsNullOrEmpty(rawRoom.promoDescription)) { room.Promotions = new List<Promotion>(); room.Promotions.Add(new Promotion { Code = rawRoom.promoId, Description = rawRoom.promoDescription }); } //room rate total and nightly room.Rates = helper.GenerateRoomRate(rawRoom.RateInfo); //value adds if (rawRoom.ValueAdds != null){ room.ValueAdds = new List<RoomValueAdd>(); foreach (valueAdd rawValueAdd in rawRoom.ValueAdds.ValueAdd){ RoomValueAdd valueAdd = new RoomValueAdd { Id = rawValueAdd.id, Description = rawValueAdd.description }; room.ValueAdds.Add(valueAdd); } } hotel.Rooms.Add(room); } } if (isHotelWithRate) //populate hotel only if there is at least 1 rate rs.Hotels.Add(hotel); } } //location suggestion if (rawRs.LocationInfos != null){ rs.Locations = new List<Location>(); foreach (LocationInfo rawLocation in rawRs.LocationInfos.LocationInfo) { if (rawLocation.active){ Location location = new Location { Code = rawLocation.destinationId, Name = rawLocation.code, Address = new Address { State = new State { Name = rawLocation.stateProvinceCode }, City = new City { Name = rawLocation.city }, Country = new Country { Name = rawLocation.countryName, Code = rawLocation.countryCode }, } }; rs.Locations.Add(location); } } } return rs; }
public string GetSearchResult(HDSRequest rq) { HDSManager sourceManager = this.GetSourceManager(); SearchResultRS rs = sourceManager.GetSearchResult(rq); return outputManager.ObjectToJson(rs); }
/* * mapping REST request to HDSRequest object !!!! */ public HDSRequest GetRequest(HttpRequest httpRq) { HDSRequest request; SearchResult mappingSearch; HotelAvailability mappingHotelAvail; HotelContent mappingHotelContent; try { //get type of request (e.g search result, hotel avail) if (string.IsNullOrEmpty(httpRq["cmdType"])){ request = new HDSRequest(HDSRequestType.NoType); request.Error = new WarningAndError { Id = (long)ErrorCode.RequestTypeNotFound, Message = "No Request/Commande type specificed" }; return request; } int cmdType = int.Parse(httpRq["cmdType"]); request = new HDSRequest(MapRequestType(cmdType)); if (request.RequestType == HDSRequestType.NoType) { request.Error = new WarningAndError { Id = (long)ErrorCode.RequestTypeNotMatched, Message = "Request/Command type is not matched" }; return request; } //get select provider source (e.g. expedia, orbitz) string source = httpRq["source"]; if (!string.IsNullOrEmpty(source)) { request.Session.SourceProvider = this.MapProviderSource(source); } //request query string for pagination request.RequestQueryString = httpRq.QueryString.ToString(); //get customer details request.Session.CustomerIpAddress = httpRq["ipAddress"]; request.Session.BrowserUserAgent = httpRq["userAgent"]; request.Session.SessionId = httpRq["sessionId"]; //get client details request.Session.ClientIpAddress = httpRq.UserHostAddress; request.Session.SiteId = httpRq["siteId"]; request.Session.EncryptHash = httpRq["crc"]; //currency and locale request.Session.CurrencyCode = httpRq["currCode"]; request.Session.Locale = httpRq["locale"]; //validate currency only non-hotelcontent request if ((string.IsNullOrEmpty(request.Session.CurrencyCode)) && (request.RequestType != HDSRequestType.HotelContent)) { request.Error = new WarningAndError { Id = (long)ErrorCode.RequestCurrencyCodeMissing, Message = "CurrencyCode is missing" }; return request; } //process request by request type switch (request.RequestType) { //serach result ----------------------------------- case HDSRequestType.SearchByLocationKeyword: mappingSearch = new SearchResult(); request.SearchCriteria = new SearchCriteria(); request = mappingSearch.MapSearchByLocationKeyword(request, httpRq); break; case HDSRequestType.SearchByLocationIds: mappingSearch = new SearchResult(); request.SearchCriteria = new SearchCriteria(); request = mappingSearch.MapSearchByLocationId(request, httpRq); break; case HDSRequestType.SearchByHotelIds: mappingSearch = new SearchResult(); request.SearchCriteria = new SearchCriteria(); request = mappingSearch.MapSearchByHotelIds(request, httpRq); break; //hotel availability ------------------------------ case HDSRequestType.SearchByHotelId: mappingHotelAvail = new HotelAvailability(); request = mappingHotelAvail.MapSearchByHotelId(request, httpRq); break; //hotel content ----------------------------------- case HDSRequestType.HotelContent: mappingHotelContent = new HotelContent(); request = mappingHotelContent.MapHotelContent(request, httpRq); break; //request type unknown ---------------------------- default: request.Error = new WarningAndError { Id = (long)ErrorCode.RequestTypeNotPrepared, Message = "Request/Command type requested is not prepared" }; break; } } catch (Exception e) { request = new HDSRequest(HDSRequestType.NoType); request.Error = new WarningAndError { Id = (long)ErrorCode.RequestTypeError, Message = e.ToString() }; } return request; }
public SearchResultRS GetSearchResult(HDSRequest rq) { SourceSelectionFactory factory = new SourceSelectionFactory(); IHDSHotelShopping shoppingObj = factory.CreateSourceShopping(rq.Session.SourceProvider); return shoppingObj.GetSearchResult(rq); }
static void testSearchResult() { HDSRequest rq = new HDSRequest(HDSRequestType.SearchByLocationKeyword); rq.StayDate = new StayDate(); rq.StayDate.CheckIn = "2013-03-17"; rq.StayDate.CheckOut = "2013-03-19"; rq.Session.CurrencyCode = "AUD"; rq.Session.UserAccess = "Zerodisk"; rq.Session.CustomerIpAddress = "203.1.2.3"; rq.Session.BrowserUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"; rq.SearchCriteria = new SearchCriteria(); rq.SearchCriteria.LocationKeyword = "New York"; //rq.SearchCriteria.Locations = new List<Location>(); //rq.SearchCriteria.Locations.Add(new Location { Code = "B0055425-19CE-4D8F-8769-A2DB23ED2E46" }); rq.SearchCriteria.MinStarRating = 4; rq.SearchCriteria.MaxStarRating = 5; rq.Itineraries = new List<Itinerary>(); rq.Itineraries.Add(new Itinerary(1, "1_2")); rq.Itineraries.Add(new Itinerary(2)); Console.WriteLine(objectToJson(rq)); Console.WriteLine("\n------------------------------\n"); Console.Write("Press enter key to continue.."); Console.ReadLine(); Console.Write("...\n"); HDSManager manager = new HDSManager(); SearchResultRS rs = manager.GetSearchResult(rq); Console.WriteLine(objectToJson(rs)); Console.ReadLine(); }
public ReservationRS MakeHotelReservation(HDSRequest request) { serviceObjBook = new Expedia.HotelBookingServiceReference.HotelServicesClient(); return null; }