public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request) { Logger.BeginRequest("DispatchTrip recieved from " + tripthru.name, request, request.tripID); Gateway.DispatchTripResponse response = null; { // TDispatch requires that we supply the string address and postal code in addition to the Lng/Lat coordinates Pair <string, string> pickup_address = MapTools.GetReverseGeoLocAddress(request.pickupLocation); Pair <string, string> dropoff_address = MapTools.GetReverseGeoLocAddress(request.dropoffLocation); TDispatchAPI.CreateBookingRequest createRequest = new TDispatchAPI.CreateBookingRequest { passenger = api.passengerProxyPK, customer_name = request.passengerName, luggage = 1, passengers = 1, payment_method = "cash", pickup_location = new TDispatchAPI.Address { address = pickup_address.First, location = new TDispatchAPI.Location { lat = request.pickupLocation.Lat, lng = request.pickupLocation.Lng }, postcode = pickup_address.Second }, pickup_time = request.pickupTime.ToString("yyyy-MM-dd'T'HH:mm:ssK", DateTimeFormatInfo.InvariantInfo), dropoff_location = new TDispatchAPI.Address { address = dropoff_address.First, location = new TDispatchAPI.Location { lat = request.dropoffLocation.Lat, lng = request.dropoffLocation.Lng }, postcode = dropoff_address.Second }, status = "incoming", pre_paid = false }; TDispatchAPI.CreateBookingResponse createResponse = api.CreateBooking(createRequest); if (createResponse.booking.pk == null) { throw new Exception("Fatal Error: null booking pk"); } activeTrips.Add(request.tripID, createResponse.booking); // TODO: need to clean these up later response = new Gateway.DispatchTripResponse(createResponse.status_code == 200 ? Result.OK : Result.UnknownError); } Logger.EndRequest(response); return(response); }
public override Gateway.DispatchTripResponse DispatchTrip(Gateway.DispatchTripRequest request) { Logger.BeginRequest("DispatchTrip recieved from " + tripthru.name, request, request.tripID); Gateway.DispatchTripResponse response = null; { // TDispatch requires that we supply the string address and postal code in addition to the Lng/Lat coordinates Pair<string, string> pickup_address = MapTools.GetReverseGeoLocAddress(request.pickupLocation); Pair<string, string> dropoff_address = MapTools.GetReverseGeoLocAddress(request.dropoffLocation); TDispatchAPI.CreateBookingRequest createRequest = new TDispatchAPI.CreateBookingRequest { passenger = api.passengerProxyPK, customer_name = request.passengerName, luggage = 1, passengers = 1, payment_method = "cash", pickup_location = new TDispatchAPI.Address { address = pickup_address.First, location = new TDispatchAPI.Location { lat = request.pickupLocation.Lat, lng = request.pickupLocation.Lng }, postcode = pickup_address.Second }, pickup_time = request.pickupTime.ToString("yyyy-MM-dd'T'HH:mm:ssK", DateTimeFormatInfo.InvariantInfo), dropoff_location = new TDispatchAPI.Address { address = dropoff_address.First, location = new TDispatchAPI.Location { lat = request.dropoffLocation.Lat, lng = request.dropoffLocation.Lng }, postcode = dropoff_address.Second }, status = "incoming", pre_paid = false }; TDispatchAPI.CreateBookingResponse createResponse = api.CreateBooking(createRequest); if (createResponse.booking.pk == null) throw new Exception("Fatal Error: null booking pk"); activeTrips.Add(request.tripID, createResponse.booking); // TODO: need to clean these up later response = new Gateway.DispatchTripResponse(createResponse.status_code == 200 ? Result.OK : Result.UnknownError); } Logger.EndRequest(response); return response; }