traveltime-dev/traveltime-sdk-java

Time Filter Fast invalid JSON

Closed this issue · 1 comments

Time Filter Fast endpoint returns Invalid request json with the following request:

package org.example;

import com.traveltime.sdk.TravelTimeSDK;
import com.traveltime.sdk.auth.TravelTimeCredentials;
import com.traveltime.sdk.dto.common.Coordinates;
import com.traveltime.sdk.dto.common.Location;
import com.traveltime.sdk.dto.common.Property;
import com.traveltime.sdk.dto.requests.TimeFilterFastRequest;
import com.traveltime.sdk.dto.requests.timefilterfast.ArrivalSearches;
import com.traveltime.sdk.dto.requests.timefilterfast.ManyToOne;
import com.traveltime.sdk.dto.requests.timefilterfast.OneToMany;
import com.traveltime.sdk.dto.requests.timefilterfast.transportation.PublicTransport;
import com.traveltime.sdk.dto.responses.TimeFilterFastResponse;
import com.traveltime.sdk.dto.responses.errors.TravelTimeError;
import io.vavr.control.Either;

import java.util.Arrays;
import java.util.List;

public class TimeFilterFastExampleInvalidJSON {
  public static void main(String[] args) {
    TravelTimeCredentials credentials = new TravelTimeCredentials("xxx", "xxx");
    TravelTimeSDK sdk = new TravelTimeSDK(credentials);

    List < Location > locations = Arrays.asList(
            new Location("London center", new Coordinates(51.508930, -0.131387)),
            new Location("Hyde Park", new Coordinates(51.508824, -0.167093)),
            new Location("ZSL London Zoo", new Coordinates(51.536067, -0.153596))
    );

    ManyToOne manyToOne = new ManyToOne(
            "arrive-at many-to-one search example",
            "London center",
            Arrays.asList("Hyde Park", "ZSL London Zoo"),
            new PublicTransport(),
            1900,
            "weekday_morning",
            Arrays.asList(Property.TRAVEL_TIME, Property.FARES)
    );

    OneToMany oneToMany = new OneToMany(
            "arrive-at one-to-many search example",
            "London Center",
            Arrays.asList("Hyde Park", "ZSL London Zoo"),
            new PublicTransport(),
            1900,
            "weekday_morning",
            Arrays.asList(Property.TRAVEL_TIME, Property.FARES)
    );

    ArrivalSearches arrivalSearches = new ArrivalSearches(
            Arrays.asList(manyToOne),
            Arrays.asList(oneToMany)
    );

    TimeFilterFastRequest request = TimeFilterFastRequest
            .builder()
            .locations(locations)
            .arrivalSearches(arrivalSearches)
            .build();

    Either<TravelTimeError, TimeFilterFastResponse> response = sdk.send(request);

    if(response.isRight()) {
      System.out.println(response.get().getResults().size());
    } else {
      System.out.println(response.getLeft().getMessage());
    }

  }
}

Invalid departure Id. It should be "London center"