public async Task Batch_GetAvailability_Success() { try { // Arrange var start = DateTime.UtcNow; var end = start.AddDays(1); var serverTypes = new[] { ServerType.AccountApi, ServerType.FileServerWorker }; var deployType = DeployType.DevelopmentStaging; await CreateBatchReservationAsync(start, end, DeployType.DevelopmentStaging, serverTypes); await CreateBatchReservationAsync(start.AddDays(1), end.AddDays(1), DeployType.DevelopmentStaging, serverTypes); var request = new AvailabilityRequest { DeployType = deployType.NumericValue(), ServerTypes = serverTypes.Select((s) => s.NumericValue()).ToList(), Duration = TimeSpan.FromDays(1).ToApiDuration(), Min = start.ToApiDate(), Max = (start + TimeSpan.FromDays(14)).ToApiDate(), }; // Act var httpResponse = await Client.PostAsync($"/api/batch/availability", request.ToRequestBody()); // Assert httpResponse.EnsureSuccessStatusCode(); var availabilities = (await httpResponse.Content.ReadAsStringAsync()).DeserializeJson <List <AvailabilityResponse> >(); Assert.Single(availabilities); } finally { await CleanUpReservationsAsync(); } }
IncludeAvailabilityRestrictions(this IIncludableQueryable <ContractAccommodationRelation, SeasonRange> queryable, AvailabilityRequest availabilityRequest) => queryable.Include(relation => relation.Accommodation) .ThenInclude(accommodation => accommodation.Rooms) .ThenInclude(room => room.AvailabilityRestrictions.Where(availabilityRestrictions => availabilityRequest.CheckInDate <= availabilityRestrictions.ToDate && availabilityRestrictions.FromDate <= availabilityRequest.CheckOutDate));
/// <summary> /// Check if a domain name is available /// </summary> /// <param name="bearerToken">The Azure bearer token</param> /// <param name="subscription">Subscription Id for authorization</param> /// <param name="domainName">Domain name to check for availability. Note that the Azure App Service Domain only supports /// checking and purchase of selected domain TLDs.</param> /// <returns>True if available, False if not, NULL if there was an error.</returns> public static async Task <bool?> IsAvailable(string bearerToken, Guid subscription, string domainName) { if (string.IsNullOrWhiteSpace(bearerToken)) { throw new ArgumentNullException(nameof(bearerToken)); } if (subscription == Guid.Empty) { throw new ArgumentNullException(nameof(subscription)); } // this will cause validation of the domainName and will throw! AvailabilityRequest request = new AvailabilityRequest(domainName); RestApiResponse response = await RestApiClient.POST( bearerToken, $"https://management.azure.com/subscriptions/{subscription:d}/providers/Microsoft.DomainRegistration/checkDomainAvailability", CLIENT_API_VERSION, null, request, new int[] { 200 } ); if ((!response.IsExpectedSuccess) || response.WasException || string.IsNullOrWhiteSpace(response.Body)) { return(null); } AvailabilityResult result = JsonConvert.DeserializeObject <AvailabilityResult>(response.Body); return(result.IsAvailable); }
public Task <AvailabilityDayResponse> NextAvailability(AvailabilityRequest request) { if (request.AppointmentId.Equals(Guid.Parse(BOOKING_WITH_NO_AVAILABILITY))) { throw new BookingNoAvailabilityException("FakeProvider, no available appointments"); } if (request.AppointmentId.Equals(Guid.Parse(BOOKING_UI_TEST))) { return(Task.FromResult(new AvailabilityDayResponse() { Date = new DateTime(2021, 2, 1), AppointmentTimes = new List <AppointmentTime> { new AppointmentTime { StartTime = new TimeSpan(7, 0, 0), EndTime = new TimeSpan(17, 30, 0) } } })); } if (request.AppointmentId.Equals(Guid.Parse(BOOKING_NON_FULL_DAY_APPOINTMENT))) { return(NextAvailability_ForNonFullDayAppointment(request)); } return(NextAvailability_ForFullDayAppointment(request)); }
/// <summary> /// 用于可订检查。客户预订前调用,检查某酒店哪些房型是否可订的,返回房价 /// </summary> /// <returns></returns> public AvailabilityResponse Availability(string HotelCode, string RatePlanCode, string RoomTypeCode, int NumberOfUnits, string CheckIn, string CheckOut, int AdultCount, int ChildCount) { AvailabilityRequest request = new AvailabilityRequest() { UserName = Config.ClientID, Password = Config.LicenseKey, Token = Config.Token, AvailabilityCriteria = new AvailabilityCriteria() { HotelCode = HotelCode, RatePlanCode = RatePlanCode, RoomTypeCode = RoomTypeCode, NumberOfUnits = NumberOfUnits, GuestCount = new GuestCount() { AdultCount = AdultCount, ChildCount = ChildCount }, StayDateRange = new StayDateRange() { CheckIn = CheckIn, CheckOut = CheckOut } } }; return(_Client.Availability(request)); }
public AvailabilityRequest GetAvailabilityRequest(string token) { using (var entities = Database.GetEntities()) { var requestData = entities.AvailabilityDatas.FirstOrDefault(x => x.Token == token); if (requestData == null) { return(null); } var eventData = entities.GameDatas.Single(x => x.Id == requestData.EventId); var eventLocationData = entities.GameLocationDatas.Single(x => x.GameId == requestData.EventId); var abEvent = new Game(eventData) { Location = eventLocationData }; var request = new AvailabilityRequest { Data = requestData, Event = abEvent, TeamName = entities.TeamDatas.Single(x => x.Id == abEvent.HomeTeamId).Name }; return(request); } }
public BookingAvailabilityInfo(string accommodationId, string accommodationName, AccommodationInfo accommodationInfo, RoomContractSet roomContractSet, string zoneName, string localityName, string countryName, string countryCode, string address, GeoPoint coordinates, DateTime checkInDate, DateTime checkOutDate, int numberOfNights, int supplier, List <AppliedMarkup> appliedMarkups, MoneyAmount convertedSupplierPrice, MoneyAmount originalSupplierPrice, string availabilityId, string htId, List <PaymentTypes> availablePaymentTypes, bool isDirectContract, Deadline agentDeadline, Deadline supplierDeadline, CreditCardRequirement?cardRequirement, AvailabilityRequest availabilityRequest) { AccommodationId = accommodationId; AccommodationName = accommodationName; AccommodationInfo = accommodationInfo; RoomContractSet = roomContractSet; ZoneName = zoneName; LocalityName = localityName; CountryName = countryName; CountryCode = countryCode; Address = address; Coordinates = coordinates; CheckInDate = checkInDate; CheckOutDate = checkOutDate; NumberOfNights = numberOfNights; Supplier = supplier; AppliedMarkups = appliedMarkups; ConvertedSupplierPrice = convertedSupplierPrice; OriginalSupplierPrice = originalSupplierPrice; AvailabilityId = availabilityId; HtId = htId; AvailablePaymentTypes = availablePaymentTypes; IsDirectContract = isDirectContract; AgentDeadline = agentDeadline; SupplierDeadline = supplierDeadline; CardRequirement = cardRequirement; AvailabilityRequest = availabilityRequest; }
public void Call_SuccesCall_ReturnisFlights() { var request = new AvailabilityRequest() { DepartureStation = "MEX", ArrivalStation = "CUN", DepartureDateTime = DateTime.Now.AddDays(1).AddHours(-5), Pasengers = new RequestedPassengers { Adult = new RequestedPassanger { Count = 1 } } }; request.BecomeSingleTrip(); var service = new LowFareAvailabilityService() { AvailabilityRequest = request, AvailabilityServices = new List <IAvailabilitySearchable>() { new VolarisAvailability { Request = request }, new InterJetAvailability { Request = request } } }; //Assert.IsNotNull(service.Call().GetAll(), "No se encontraron vuelos"); }
public static bool IsRoomAvailableByAllotment(AvailabilityRequest availabilityRequest, Room room, int roomsNumber = 1) { var roomOccupancies = room.RoomOccupations.OrderBy(ro => ro.FromDate).ToList(); var allocationRequirements = room.AllocationRequirements.OrderBy(ar => ar.SeasonRange.StartDate).ToList(); var currentDate = availabilityRequest.CheckInDate; var currentAllocationRequirement = GetAllocationRequirement(currentDate); do { if (!Include(currentAllocationRequirement !, currentDate)) { currentAllocationRequirement = GetAllocationRequirement(currentDate); if (currentAllocationRequirement?.Allotment == 0) { return(false); } } var availableRoomOccupations = GetRoomOccupations(currentDate); if (!availableRoomOccupations.Any() || availableRoomOccupations.Count + roomsNumber <= currentAllocationRequirement !.Allotment) { currentDate = currentDate.AddDays(1); } else { return(false); } } while (currentDate <= availabilityRequest.CheckOutDate);
public void AvailabilityRequest_Serialize_OnlyRequiredFieldShouldBePresented() { // The required field are Departure and Arrival // other field should not produce any xml tags. var request = new AvailabilityRequest(); request.Query = new AvailabilityQuery(); request.Query.Params = new AvailabilityQueryParamas(); request.Query.Params.Departure = "MOW"; request.Query.Params.Arrival = "RIX"; var rawRequest = SerializationHelper.Serialize(request); var xmlRequest = XDocument.Parse(rawRequest); var availability = xmlRequest. Element("sirena"). Element("query"). Element("availability"); Assert.True(availability.Elements().Count() == 2); var departure = availability.Element("departure"); var arrival = availability.Element("arrival"); Assert.NotNull(departure); Assert.NotNull(arrival); }
public string GetAsync([FromBody] AvailabilityRequest data) { const string url = "https://api.lot.com/flights-dev/v2"; var token = _authenticationService.GetToken(); var client = new RestClient(url); var request = new RestRequest("booking/availability"); request.AddHeader("content-type", "application/json"); request.AddHeader("X-Api-Key", "9YFNNKS31u9gCFKPetPWdAAjEXnED0B3K18AeYgg"); request.AddHeader("Authorization", "Bearer " + token); request.AddJsonBody(new { data.adt, data.cabinClass, data.departureDate, data.destination, data.market, data.origin, data.tripType }); //request.AddParameter("params", new { data.adt, data.cabinClass, data.departureDate, data.destination, data.market, data.origin, data.tripType }); //request.AddParameter ("adt", data.adt); //request.AddParameter ("cabinClass", data.cabinClass); //request.AddParameter ("departureDate", data.departureDate); //request.AddParameter ("destination", data.destination); //request.AddParameter ("market", data.market); //request.AddParameter ("origin", data.origin); //request.AddParameter ("tripType", data.tripType); var response = client.Post <Object>(request); return(response.Content); }
public void Call_AvailabilitySucces_ReturnsFlights() { ISabreService openSessionService = new OpenSessionService(); openSessionService.Call(); var request = new AvailabilityRequest() { DepartureStation = "MEX", ArrivalStation = "CUN", DepartureDateTime = DateTime.Now.AddDays(1).AddHours(-5), Pasengers = new RequestedPassengers { Adult = new RequestedPassanger { Count = 1 } } }; request.BecomeSingleTrip(); //ISabreService<Flights> availabilityService = new VolarisAvialabiltyService() //{ // AvailabilityRequest = request, // ConversationID = openSessionService.ConversationID, // SecurityToken = openSessionService.SecurityToken //}; //Assert.IsTrue(availabilityService.Call().GetAll().Count > 0, "No se pudo obtener los vuelos"); }
/// <summary> /// Sets the availability details of the request. /// </summary> /// <param name="availabilityRequest"> /// The event details for the request, must not be null. /// </param> /// <returns> /// A reference to the <see cref="RealTimeSchedulingRequestBuilder"/>. /// </returns> public RealTimeSchedulingRequestBuilder AvailabilityRequest(AvailabilityRequest availabilityRequest) { Preconditions.NotNull("availability", availabilityRequest); this.availabilityRequestBuilder = Builder.Wrap(availabilityRequest); return(this); }
public async Task GetAvailability_ShouldReturn_ListOfDayResponse() { var request = new AvailabilityRequest(); var result = await _bookingProvider.GetAvailability(request); Assert.IsType <List <AvailabilityDayResponse> >(result); }
public Task <Result <Availability, ProblemDetails> > GetAvailability(AvailabilityRequest request, string languageCode) { return(ExecuteWithLogging(() => { return _connectorClient.Post <AvailabilityRequest, Availability>( new Uri(_baseUrl + "accommodations/availabilities", UriKind.Absolute), request, languageCode); })); }
/// <summary> /// Create a request to transfer a new domain name /// </summary> /// <param name="bearerToken">The Azure bearer token</param> /// <param name="subscription">Subscription Id for authorization</param> /// <param name="domainName">Domain name to transfer. Note that the Azure App Service Domain only supports /// purchase of selected domain TLDs.</param> /// <param name="transferAuthorization">Authorization code received from current Domain Registrar to authorize this transfer request</param> /// <param name="targetResourceGroupName">The Azure Resource Group to place the registered domain in</param> /// <param name="autoRenew">If set, Azure will auto-renew the domain every year</param> /// <param name="registrationContact">Contact information to use for transfer</param> /// <param name="callerIpAddress">IP address of caller for purchase consent agreement</param> /// <param name="agreementKeyNames">Name of the keys of terms and conditions that have been agreed to</param> /// <param name="useCustomDns">If set, will not use Azure DNS for the domain (if Azure DNS is required later, it will need to be /// configured seperately)</param> /// <param name="existingAzureZone">If an existing Azure DNS Zone is to be tied to this domain, the resource Uri to that zone</param> /// <returns>True if the domain registration task was accepted by Azure. False if not, NULL if there were errors</returns> public static async Task <bool?> TransferDomain(string bearerToken, Guid subscription, string domainName, string transferAuthorization, string targetResourceGroupName, bool autoRenew, DomainRegistrationContact registrationContact, string callerIpAddress, string[] agreementKeyNames, bool useCustomDns = false, ResourceUri?existingAzureZone = null) { if (string.IsNullOrWhiteSpace(bearerToken)) { throw new ArgumentNullException(nameof(bearerToken)); } if (string.IsNullOrWhiteSpace(targetResourceGroupName)) { throw new ArgumentNullException(nameof(targetResourceGroupName)); } if (string.IsNullOrWhiteSpace(transferAuthorization)) { throw new ArgumentNullException(nameof(transferAuthorization)); } if (subscription == Guid.Empty) { throw new ArgumentNullException(nameof(subscription)); } if ((agreementKeyNames == null) || (!agreementKeyNames.Any())) { throw new ArgumentNullException(nameof(agreementKeyNames)); } // validate domain name :-) AvailabilityRequest _ = new AvailabilityRequest(domainName); DomainTransferRequest request = new DomainTransferRequest(transferAuthorization, autoRenew, registrationContact, callerIpAddress, agreementKeyNames); if (useCustomDns) { request.Properties.TypeOfDns = DomainRegistrationDnsTypeEnum.DefaultDomainRegistrarDns; } if (existingAzureZone != null) { if ((!existingAzureZone.IsValid) || (!existingAzureZone.Is(ResourceUriCompareLevel.Provider, "Microsoft.Network")) || (!existingAzureZone.Is(ResourceUriCompareLevel.Type, "dnszones"))) { throw new ArgumentException(nameof(existingAzureZone)); } request.Properties.AzureDnsZoneId = existingAzureZone.ToString(); } RestApiResponse response = await RestApiClient.PUT( bearerToken, $"https://management.azure.com/subscriptions/{subscription:d}/resourceGroups/{targetResourceGroupName}/providers/Microsoft.DomainRegistration/domains/{domainName}", CLIENT_API_VERSION, null, request, new int[] { 200, 202 } ); return(response.WasException ? (bool?)null : response.IsExpectedSuccess); }
public IHttpActionResult Availability(AvailabilityRequest request) { List <AttendeeInfo> attendees = new List <AttendeeInfo>(); foreach (var user in request.Users) { attendees.Add(new AttendeeInfo() { SmtpAddress = user, AttendeeType = MeetingAttendeeType.Required }); } // Specify availability options. AvailabilityOptions myOptions = new AvailabilityOptions(); myOptions.MeetingDuration = request.DurationMinutes; myOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy; // Return a set of free/busy times. var service = ExchangeServer.Open(); var startTime = DateTime.Parse(request.Start); var endTime = DateTime.Parse(request.End); GetUserAvailabilityResults freeBusyResults = service.GetUserAvailability(attendees, new TimeWindow(startTime, endTime), AvailabilityData.FreeBusy, myOptions); var response = new AvailabilityResponse { AvailabilityResult = new List <AvailabilityUser>() }; foreach (AttendeeAvailability availability in freeBusyResults.AttendeesAvailability) { var user = new AvailabilityUser(); var avail = new List <TimeBlock>(); foreach (CalendarEvent calendarItem in availability.CalendarEvents) { var block = new TimeBlock { Start = calendarItem.StartTime, End = calendarItem.EndTime, StatusEnum = calendarItem.FreeBusyStatus, Status = calendarItem.FreeBusyStatus.ToString() }; avail.Add(block); } user.Availability = avail; response.AvailabilityResult.Add(user); } return(Ok(response)); }
public async Task NextAvailability_Should_Throw_BookingNoAvailabilityException_OnEmptyGuid() { var request = new AvailabilityRequest { AppointmentId = Guid.Parse("00000000-0000-0000-0000-000000000001") }; var result = await Assert.ThrowsAsync <BookingNoAvailabilityException>(() => _bookingProvider.NextAvailability(request)); Assert.Equal("FakeProvider, no available appointments", result.Message); }
public async Task NextAvailability_ShouldReturnDayResponse_OnSuccessfullyCall() { var request = new AvailabilityRequest(); var result = await _bookigProvider.NextAvailability(request); _mockBookingServiceGateway.Verify(_ => _.NextAvailability(It.IsAny <AvailabilityRequest>()), Times.Once); Assert.IsType <AvailabilityDayResponse>(result); }
public async Task NextAvailability_ShouldReturnDayResponse() { var request = new AvailabilityRequest { AppointmentId = Guid.NewGuid() }; var result = await _bookingProvider.NextAvailability(request); Assert.IsType <AvailabilityDayResponse>(result); }
public static IIncludableQueryable <ContractAccommodationRelation, IEnumerable <SeasonRange> > IncludeCancellationPolicies( this IIncludableQueryable <ContractAccommodationRelation, IEnumerable <RoomAvailabilityRestriction> > queryable, AvailabilityRequest availabilityRequest) => queryable.Include(accommodation => accommodation.Accommodation) .ThenInclude(accommodation => accommodation.Rooms) .ThenInclude(room => room.CancellationPolicies.Where(cancellationPolicy => cancellationPolicy.Season.SeasonRanges.Any(seasonRange => availabilityRequest.CheckInDate <= seasonRange.EndDate && seasonRange.StartDate <= availabilityRequest.CheckOutDate))) .ThenInclude(cancellationPolicy => cancellationPolicy.Season) .ThenInclude(season => season.SeasonRanges.Where(seasonRange => availabilityRequest.CheckInDate <= seasonRange.EndDate && seasonRange.StartDate <= availabilityRequest.CheckOutDate));
public async Task <ActionResult <StartSearchResponse> > StartSearch([FromBody] AvailabilityRequest request, CancellationToken cancellationToken) { var agent = await _agentContextService.GetAgent(); var(isSuccess, _, searchResponse, error) = await _wideSearchService.StartSearch(request, agent, "en"); return(isSuccess ? searchResponse : BadRequest(ProblemDetailsBuilder.Build(error))); }
public void Validate_InvalidDepartureDate_ReturnsNothing() { var request = new AvailabilityRequest(); request.ArrivalStation = "MEX"; request.DepartureStation = "MID"; request.DepartureDateTime = DateTime.Now.AddDays(-4); request.Pasengers.Adult.Count = 1; Assert.Throws <InvalidAvailabilityRequestException>(request.Validate); }
public void TestRoomAvailability() { var request = new AvailabilityRequest { FromDate = DateTime.Now.Date.AddDays(1), ToDate = DateTime.Now.Date.AddDays(1), RequestedRoomCount = 1, City = "Bangalore" }; var response = new WebRepository().GetAvailableRoomList(request); Assert.IsNotNull(response); Assert.IsTrue(response.Rooms.Count > 0); }
private List <RoomTypes> GetRoomTypes(AvailabilityRequest availabilityRequest) { var roomTypes = availabilityRequest.Rooms.Select(room => room.Type).Distinct().ToList(); if (roomTypes.All(rt => rt == RoomTypes.NotSpecified)) { roomTypes = Enum.GetValues(typeof(RoomTypes)).Cast <RoomTypes>().ToList(); } return(roomTypes); }
public IHttpActionResult CheckProductAvailability(AvailabilityRequest request) { Assert.ArgumentNotNullOrEmpty(request.ProductId, nameof(request.ProductId)); Thread.Sleep(500); var random = new Random(); var number = random.Next(10); return(Json(new AvailabilityResponse { Available = number <= 5 })); }
public async Task <IActionResult> Get([FromBody] AvailabilityRequest request) { var(_, isFailure, value, error) = await _availabilityService.GetWideAvailability(request, LanguageCode); if (isFailure) { return(BadRequest(error)); } return(Ok(value)); }
public AvailabilityResponse GetAvailability(List <AvailabilityTransactionDetail> availabilityTransactionDetails) { var availabilityRequest = new AvailabilityRequest { AgentCode = _agentCode, AgentUID = _agentUiId, ApiKey = _apiKey, TransactionDetails = availabilityTransactionDetails.ToArray() }; return(_clientApi.AvailabilityCheck(availabilityRequest)); }
public void Validate_ValidDates_ReturnsNothing() { var request = new AvailabilityRequest(); request.ArrivalStation = "MEX"; request.DepartureStation = "MID"; request.DepartureDateTime = DateTime.Now; request.Pasengers.Adult.Count = 1; request.ReturningDateTime = DateTime.Now.AddDays(2); request.BecomeRoundTrip(); Assert.DoesNotThrow(request.Validate); }
public ActionResult Index() { var init = new AvailabilityRequest { FromDate = DateTime.Now.AddDays(2), ToDate = DateTime.Now.AddDays(5), RequestedRoomCount = 1, City = "Bangalore" }; return(View(init)); }
public GetLowFareAvailabilityResponse getlowfareavailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg, int nightstay) { GetLowFareAvailabilityRequest getlowfareavailrequest = new GetLowFareAvailabilityRequest(); getlowfareavailrequest.Signature = signature; //getlowfareavailrequest.AvailabilityRequest = new AvailabilityRequest();//instantiate a new object AvailabilityRequest availabilityrequest = new AvailabilityRequest(); getlowfareavailrequest.AvailabilityRequest = availabilityrequest;// to instantiate an obj if (sourceorg.Length > 0) { availabilityrequest.SourceOrganization = sourceorg; } availabilityrequest.PaxCount = (short)(numadt + numchd); PaxPriceType[] pricetypes = new PaxPriceType[numadt + numchd]; for (int i = 0; i < pricetypes.Length; i++) { pricetypes[i] = new PaxPriceType(); if (i < numadt) { pricetypes[i].PaxType = "ADT"; } else { pricetypes[i].PaxType = "CHD"; } } availabilityrequest.PaxPriceTypes = pricetypes;//equate it back to the array declared availabilityrequest.AvailabilityType = AvailabilityType.Default; availabilityrequest.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable; availabilityrequest.DepartureStation = dstation; availabilityrequest.ArrivalStation = astation; availabilityrequest.BeginDate = startdate; availabilityrequest.EndDate = endate; availabilityrequest.FlightType = FlightType.All; availabilityrequest.Dow = DOW.Daily; availabilityrequest.MaximumConnectingFlights = 5; availabilityrequest.FareTypes = new string[1]; availabilityrequest.FareTypes[0] = faretype; // pass it back to the method parameter availabilityrequest.FareClassControl = FareClassControl.CompressByProductClass; availabilityrequest.IncludeTaxesAndFees = true; getlowfareavailrequest.AvailabilityRequest = availabilityrequest;// cache availability data back to the getlowfareavailrequest obj GetLowFareAvailabilityResponse getlowfareavailresponse = clientapi.GetLowFareAvailability(getlowfareavailrequest); if (getlowfareavailresponse.GetAvailabilityResponse.Schedule.Length > 0) { Console.WriteLine("{0} journeys returned by availabilty", getlowfareavailresponse.GetAvailabilityResponse.Schedule.Length); } else { Console.WriteLine("No journey found"); getlowfareavailresponse = null; } return getlowfareavailresponse; }
public BookingManager.GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg,int nightstay) { BookingManager.GetAvailabilityRequest gar = new GetAvailabilityRequest();//this is from service contracts gar.Signature = signature;//i need to use the signature property to sign in gar.TripAvailabilityRequest = new TripAvailabilityRequest(); // call the method TripAvailabilityRequest from the GetAvaialbilityRequest class // gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];//this is to define the type of passenger travelling, whether adt or chd. But to check how many of each then i need to use the Pax Count or passenger info for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) // this sets the first item of array to an adult { priceTypes[j].PaxType = "ADT"; } else // this sets the second item to child { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest();//this is from data contracts //AvailabilityRequest []ar = new AvailabilityRequest[2]; //ar[0] = new AvailabilityRequest(); //ar[1] = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; if (faretype.Equals("ST")) { ar.AvailabilityType = AvailabilityType.Standby; } else { ar.AvailabilityType = AvailabilityType.Default; } ar.AvailabilityFilter = AvailabilityFilter.Default; if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; //ar.DepartureStations = new string[1];// for return //ar.DepartureStations[0] = astation; //ar.ArrivalStations = new string[1]; //ar.ArrivalStations[0] = dstation; } ar.FlightType = FlightType.All;//10 ar.Dow = DOW.Daily;//11 ar.MaximumConnectingFlights = 5;//14--since flight type is direct ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable;//13..this will still return me a result set if my currency is set to null although the function demands i pass a value in as the filter is based on flights ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//this i sto tell me the list of SSR avaialble for purchase ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];// must be RE-regular or ST for standby fares ar.FareTypes[0] = faretype; gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar;//get all the parameters from getavailability field and put it back to ar. } DateTime startTiming = DateTime.Now; BookingManager.GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); DateTime endTiming = DateTime.Now; Console.WriteLine("Timing: " + endTiming.Subtract(startTiming).Seconds + "Seconds"); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }
public GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg, int nightstay) { GetAvailabilityRequest gar = new GetAvailabilityRequest(); gar.Signature = signature; gar.TripAvailabilityRequest = new TripAvailabilityRequest(); PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];// this is to define type of passenger travelling, must be adt and chd-also in sell request for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) { priceTypes[j].PaxType = "ADT"; } else { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar; ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; ar.AvailabilityType = AvailabilityType.Default;// if i do not put anything, it is defaulted as Availability Type can be a enum list ar.AvailabilityFilter = AvailabilityFilter.Default;// if i do not put if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; } ar.FlightType = FlightType.All; ar.Dow = DOW.Daily; ar.MaximumConnectingFlights = 5;//if direct, then default the value to 0; ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable; ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//return the SSR available by segment ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];//either RE-regular fare or JP for japan wholesaler ar.FareTypes[0] = faretype;// put this back to the parameter in Get Availability Response } GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }