VVM: Update API base, using mobile endpoints.

This commit is contained in:
Andreas Schildbach 2021-09-06 21:01:02 +02:00
parent 8f8439744b
commit 1105bb20a6
2 changed files with 59 additions and 3 deletions

View file

@ -17,17 +17,73 @@
package de.schildbach.pte;
import com.google.common.base.Strings;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsContext;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Date;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Andreas Schildbach
*/
public class VvmProvider extends AbstractEfaProvider {
private static final HttpUrl API_BASE = HttpUrl.parse("http://efa.mobilitaetsverbund.de/web/");
private static final HttpUrl API_BASE = HttpUrl.parse("https://mobile.defas-fgi.de/vvmapp/");
private static final String DEPARTURE_MONITOR_ENDPOINT = "XML_DM_REQUEST";
private static final String TRIP_ENDPOINT = "XML_TRIP_REQUEST2";
public VvmProvider() {
super(NetworkId.VVM, API_BASE);
super(NetworkId.VVM, API_BASE, DEPARTURE_MONITOR_ENDPOINT, TRIP_ENDPOINT, null, null);
setNeedsSpEncId(true);
}
@Override
public NearbyLocationsResult queryNearbyLocations(final Set<LocationType> types, final Location location,
final int maxDistance, final int maxLocations) throws IOException {
if (location.hasCoord())
return mobileCoordRequest(types, location.coord, maxDistance, maxLocations);
if (location.type != LocationType.STATION)
throw new IllegalArgumentException("cannot handle: " + location.type);
throw new IllegalArgumentException("station"); // TODO
}
@Override
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
final int maxDepartures, final boolean equivs) throws IOException {
checkNotNull(Strings.emptyToNull(stationId));
return queryDeparturesMobile(stationId, time, maxDepartures, equivs);
}
@Override
public SuggestLocationsResult suggestLocations(final CharSequence constraint,
final @Nullable Set<LocationType> types, final int maxLocations) throws IOException {
return mobileStopfinderRequest(constraint, types, maxLocations);
}
@Override
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return queryTripsMobile(from, via, to, date, dep, options);
}
@Override
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException {
return queryMoreTripsMobile(contextObj, later);
}
}

View file

@ -57,7 +57,7 @@ public class VvmProviderLiveTest extends AbstractProviderLiveTest {
@Test
public void queryDepartures() throws Exception {
final QueryDeparturesResult result = queryDepartures("3000510", false);
final QueryDeparturesResult result = queryDepartures("3000152", false);
print(result);
}