static void Main(string[] args) { // request object D2DRequest req = new D2DRequest(); // I want to get to my destination at the datetime bellow req.desiredOutboundDate = DateTime.ParseExact("2014-10-15T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); req.outboundDateKind = D2dRequestTripDateKind.arriveAt; // I want to leave my destination at the datetime bellow req.desiredInboundDate = DateTime.ParseExact("2014-10-17T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); req.outboundDateKind = D2dRequestTripDateKind.departureAt; // specifying the origin req.oriLocation = new D2DRequestLocation(); req.oriLocation.lat = "-23.5732853"; req.oriLocation.lng = "-46.64167550000002"; req.oriLocation.type = "street_address"; // specifying the destination req.destLocation = new D2DRequestLocation(); req.destLocation.lat = "52.3661876"; req.destLocation.lng = "4.899111500000004"; req.destLocation.type = "route"; // requesting public transp info as well req.flags = new D2DRequestFlags(); req.flags.includePublicTransp = true; // submitting the request Door2Door d2d = new Door2Door(req); Door2DoorResponse resp = d2d.GetResponse(); Console.WriteLine(JsonConvert.SerializeObject(resp)); }
/// <summary> /// Constructor /// </summary> /// <param name="d2dReq"> /// The request. A <see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/> /// </param> /// <param name="maxWalkingMinutes"> /// Max walking minutes. Controls how much time is acceptable for a walk <see cref="Door2DoorCore.Types.Door2DoorResponse.Segment"/>. If not informed, the default is 10 min. /// </param> /// <param name="flightAntecipation"> /// How many minutes should be considered as antecipation to get to the airport. If not informed, the default is 120 (two hours). /// </param> /// <param name="minutesAfterFlight"> /// How many minutes should be considered after the Arriving time of a flight. If not informed, the default is 30. /// </param> public Door2DoorBase(D2DRequest d2dReq, int maxWalkingMinutes, int flightAntecipation, int minutesAfterFlight) { _maxWalkingMinutes = maxWalkingMinutes; _flightAntecipation = flightAntecipation; _minutesAfterFlight = minutesAfterFlight; VerifyRequest(d2dReq); }
public Door2DoorResponse Getd2d(D2DRequest req) { Door2DoorResponse resp; Door2Door d2d = new Door2Door(req); resp = d2d.GetResponse(); string json = JsonConvert.SerializeObject(resp); return resp; }
/// <summary> /// Constructor of the class. <see cref="Door2DoorCore.Door2Door"/> /// </summary> /// <param name="d2dReq"> /// <para><see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/></para> /// Parameters for the request include coordinates of origin and destination, /// arrival and return dates, external flight options and filters. /// </param> public Door2Door(D2DRequest d2dReq) { if (d2dReq.requestType == D2DRequestType.r2r) { r2r = new Door2DoorRome2Rio(d2dReq); } else { throw new D2DRequestException("Only D2DRequestType.r2r is supported so far."); } }
/// <summary> /// Constructor of the class. <see cref="Door2DoorCore.Door2Door"/> /// </summary> /// <param name="d2dReq"> /// <para><see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/></para> /// Parameters for the request include coordinates of origin and destination, /// arrival and return dates, external flight options and filters. /// </param> /// <param name="maxWalkingMinutes"> /// Max walking minutes. Controls how much time is acceptable for a walk <see cref="Door2DoorCore.Types.Door2DoorResponse.Segment"/>. If not informed, the default is 10 min. /// </param> /// <param name="flightAntecipation"> /// How many minutes should be considered as antecipation to get to the airport. If not informed, the default is 120 (two hours). /// </param> /// <param name="minutesAfterFlight"> /// How many minutes should be considered after the Arriving time of a flight. If not informed, the default is 30. /// </param> public Door2Door(D2DRequest d2dReq, int maxWalkingMinutes, int flightAntecipation, int minutesAfterFlight) { if (d2dReq.requestType == D2DRequestType.r2r) { r2r = new Door2DoorRome2Rio(d2dReq, maxWalkingMinutes, flightAntecipation, minutesAfterFlight); } else { throw new D2DRequestException("Only D2DRequestType.r2r is supported so far."); } }
/// <summary> /// Constructor /// </summary> /// <param name="d2dReq"> /// The request. A <see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/> /// </param> public Door2DoorBase(D2DRequest d2dReq) { VerifyRequest(d2dReq); }
/// <summary> /// Verify if the minimum information was specified in the request /// </summary> /// <param name="d2dReq">The request</param> private void VerifyRequest(D2DRequest d2dReq) { _req = d2dReq; if (!RequestIsOK(_req)) { throw new D2DRequestException("Please check your request."); } }
/// <summary> /// Verifies if all necessary data from the request are correctly informed /// </summary> /// <param name="d2dReq"> /// Route request. <see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/> /// </param> /// <returns> /// Whether the request is ok or not /// </returns> protected bool RequestIsOK(D2DRequest d2dReq) { return d2dReq.flags != null && d2dReq.desiredOutboundDate != DateTime.MinValue && d2dReq.desiredOutboundDate != DateTime.MaxValue && d2dReq.oriLocation != null && d2dReq.destLocation != null; }
/// <summary> /// Constructor /// </summary> /// <param name="d2d"> /// The request. A <see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/> /// </param> /// <param name="maxWalkingMinutes"> /// Max walking minutes. Controls how much time is acceptable for a walk <see cref="Door2DoorCore.Types.Door2DoorResponse.Segment"/>. If not informed, the default is 10 min. /// </param> /// <param name="flightAntecipation"> /// How many minutes should be considered as antecipation to get to the airport. If not informed, the default is 120 (two hours). /// </param> /// <param name="minutesAfterFlight"> /// How many minutes should be considered after the Arriving time of a flight. If not informed, the default is 30. /// </param> public Door2DoorRome2Rio(D2DRequest d2d, int maxWalkingMinutes, int flightAntecipation, int minutesAfterFlight) : base(d2d,maxWalkingMinutes, flightAntecipation, minutesAfterFlight) { }
/// <summary> /// Constructor /// </summary> /// <param name="d2d"> /// The request. A <see cref="Door2DoorCore.Types.Door2DoorRequest.D2DRequest"/> /// </param> public Door2DoorRome2Rio(D2DRequest d2d) : base(d2d) { }
/// <summary> /// Handles the communication between client and Rome2rio api. /// </summary> /// <param name="req"> /// Parameters for the request include coordinates of origin and destination, /// arrival and return dates, external flight options and filters. /// </param> /// <param name="requestFlags"> /// Filters the response segment types. /// </param> internal Rome2RioComm(D2DRequest req, int requestFlags) { _requestFlags = requestFlags; _req = req; _resp = new Door2DoorResponse(); }
/// <summary> /// /// </summary> public void Dispose() { _req = null; _resp = null; }