public static string RideTypeToString(LyftConstants.RideType rideType) { if (rideType == LyftConstants.RideType.Lyft) { return("lyft"); } else if (rideType == LyftConstants.RideType.LyftLine) { return("lyft_line"); } else if (rideType == LyftConstants.RideType.LyftPlus) { return("lyft_plus"); } else if (rideType == LyftConstants.RideType.LyftPremier) { return("lyft_premier"); } else if (rideType == LyftConstants.RideType.LyftLux) { return("lyft_lux"); } else if (rideType == LyftConstants.RideType.LyftLuxSuv) { return("lyft_luxsuv"); } else { return("other"); } }
internal static Url SetRideType(this Url url, LyftConstants.RideType rideType) { if (rideType != LyftConstants.RideType.Other) { url.SetQueryParam("ride_type", ShyftConstants.RideTypeToString(rideType)); } return(url); }
private string GetDisplayName(LyftConstants.RideType rideType) { foreach (var availableRideType in availableRideTypes) { if (availableRideType.Type == rideType) { return(availableRideType.DisplayName); } } return(string.Empty); }
public async Task ChangeDriverAvailability(LyftConstants.RideType rideType, double lat, double lng, bool driverAvailability) { Url url = new Url(ShyftConstants.BaseV1SandboxUrl).AppendPathSegments("ridetypes", ShyftConstants.RideTypeToString(rideType)); JObject data = JObject.FromObject(new { lat = lat, lng = lng, driver_availability = driverAvailability }); await PutLyft(url, data); }
private void SelectPreferredType(LyftConstants.RideType preferredRideType) { for (int i = 0; i < rideTypeComboBox.Items.Count; i++) { string text = (string)((ComboBoxItem)rideTypeComboBox.Items[i]).Content; foreach (var availableRideType in availableRideTypes) { if (availableRideType.DisplayName == text && availableRideType.Type == preferredRideType) { rideTypeComboBox.SelectedIndex = i; return; } } } }
private async Task GetEta(BasicGeoposition geoposition, LyftConstants.RideType rideType) { int?etaSeconds = null; int?etaSecondsMax = null; var etas = await AppConstants.ShyftClient.RetrieveDriverEta(geoposition.Latitude, geoposition.Longitude, null, null, rideType); foreach (var eta in etas) { if (eta.RideType == rideType && eta.IsValidEstimate && eta.EtaSeconds != null) { etaSeconds = eta.EtaSeconds; etaSecondsMax = eta.EtaSecondsMax; break; } } if (!etaSeconds.HasValue) { etaTextBlock.Text = "No ETA"; } else { if (etaSeconds.Value < 60) { etaTextBlock.Text = $"{etaSeconds.Value} sec"; } else { etaTextBlock.Text = $"{Math.Round(TimeSpan.FromSeconds(etaSeconds.Value).TotalMinutes)} min"; } if (etaSecondsMax.HasValue) { if (etaSecondsMax.Value < 60) { etaTextBlock.Text += $" - {etaSecondsMax.Value} sec"; } else { etaTextBlock.Text += $" - {Math.Round(TimeSpan.FromSeconds(etaSecondsMax.Value).TotalMinutes)} min"; } } } }
private async Task DisplayDrivers(BasicGeoposition geoposition, LyftConstants.RideType rideType) { var nearbyDrivers = await AppConstants.ShyftClient.RetrieveNearbyDrivers(geoposition.Latitude, geoposition.Longitude); ClearDriversList(); foreach (var nearbyDriver in nearbyDrivers) { if (nearbyDriver.RideType == rideType) { foreach (var driver in nearbyDriver.Drivers) { driverList.Add(CreatePin(driver.Locations.Last())); } break; } } foreach (var driver in driverList) { map.MapElements.Add(driver); } }
public async Task <List <CostEstimate> > RetrieveRideEstimates(double startLat, double startLng, double?endLat, double?endLng, LyftConstants.RideType rideType) { Url url = new Url(ShyftConstants.BaseV1Url).AppendPathSegment("cost") .SetQueryParams(new { start_lat = startLat, start_lng = startLng, end_lat = endLat, end_lng = endLng }) .SetRideType(rideType); return((await GetLyft <CostEstimateResponse>(url)).CostEstimates); }
public async Task <List <Eta> > RetrieveDriverEta(double lat, double lng, double?destinationLat, double?destinationLng, LyftConstants.RideType rideType) { Url url = new Url(ShyftConstants.BaseV1Url).AppendPathSegment("eta") .SetQueryParams(new { lat = lat, lng = lng }) .SetRideType(rideType); return((await GetLyft <EtaEstimateResponse>(url)).EtaEstimates); }
public async Task <List <RideType> > RetrieveRideTypes(double lat, double lng, LyftConstants.RideType rideType) { Url url = new Url(ShyftConstants.BaseV1Url).AppendPathSegment("ridetypes") .SetQueryParams(new { lat = lat, lng = lng }) .SetRideType(rideType); return((await GetLyft <RideTypesResponse>(url)).RideTypes); }
public async Task <RideRequest> RequestRide(double originLat, double originLng, double destinationLat, double destinationLng, LyftConstants.RideType rideType, string originAddress = null, string destinationAddress = null, string costToken = null) { Url url = new Url(ShyftConstants.BaseV1Url).AppendPathSegment("rides"); JObject data = new JObject(); data["origin"] = CreateLocation(originLat, originLng, originAddress); data["destination"] = CreateLocation(destinationLat, destinationLng, destinationAddress); data["ride_type"] = ShyftConstants.RideTypeToString(rideType); if (!string.IsNullOrEmpty(costToken)) { data["cost_token"] = costToken; } return(await PostLyft <RideRequest>(url, data)); }
private async Task GetCostEstimate(BasicGeoposition start, BasicGeoposition end, LyftConstants.RideType rideType) { var costEstimates = await AppConstants.ShyftClient.RetrieveRideEstimates(start.Latitude, start.Longitude, end.Latitude, end.Longitude, rideType); foreach (var costEstimate in costEstimates) { if (costEstimate.RideType == rideType) { currentCostEstimate = costEstimate; costTextBlock.Text = string.Empty; if (!costEstimate.IsValidEstimate) { costTextBlock.Text = "Unknown cost!\n"; } else { costTextBlock.Text = $"${costEstimate.EstimatedCostCentsMin / 100f}"; if (costEstimate.EstimatedCostCentsMin != costEstimate.EstimatedCostCentsMax) { costTextBlock.Text += $" - ${costEstimate.EstimatedCostCentsMax / 100f}"; } } if (costEstimate.PrimetimePercentage != "0%") { costTextBlock.Text += $"\nPrimetime: {costEstimate.PrimetimePercentage}"; } TimeSpan timeEstimate = TimeSpan.FromSeconds(costEstimate.EstimatedDurationSeconds); costTextBlock.Text += $"\n{Math.Round(timeEstimate.TotalMinutes)} min"; costTextBlock.Text += $"\n{costEstimate.EstimatedDistanceMiles} miles"; break; } } }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { LyftConstants.RideType rideType = (LyftConstants.RideType)value; writer.WriteValue(ShyftConstants.RideTypeToString(rideType)); }