예제 #1
0
 private BrestBTRequest CreateApiRequest(UserBookingOptions bookingOptions)
 {
     return(new BrestBTRequest
     {
         BookingTime = bookingOptions.UserBookingTime
     });
 }
예제 #2
0
        public async Task <BrestBTResponse> GetTicketBooking(UserBookingOptions bookingOptions, IBrestGatewayConfiguration brestGatewayConfiguration)
        {
            var request         = CreateApiRequest(bookingOptions);
            var restSharpClient = _clientFactory.Create(brestGatewayConfiguration.ApiEndpoint);

            var response = await restSharpClient.GetResponse <BrestBTRequest>(request);

            if (!IsResponseSuccessful(response))
            {
                throw new BrestBTApiException(brestGatewayConfiguration.Username, response.ErrorStatus.Error);
            }

            return(response);
        }
예제 #3
0
        public override async Task <TicketBooking> BookTicket(UserBookingOptions userBookingOptions)
        {
            var userConfiguration =
                _configurationProvider.GetApiConfiguration <IBrestGatewayConfiguration>(userBookingOptions.UserId);

            var ticketBooking = await _brestBTClient.GetTicketBooking(userBookingOptions, userConfiguration);

            return(new TicketBooking
            {
                TicketNumber = ticketBooking.TicketNumber,
                Seat = ticketBooking.SeatNumber,
                BusNumber = ticketBooking.BusNumber
            });
        }