69 lines
2.2 KiB
Java
69 lines
2.2 KiB
Java
package com.thebrokenrail.mtudining.api.method;
|
|
|
|
import com.thebrokenrail.mtudining.api.Method;
|
|
import com.thebrokenrail.mtudining.util.Category;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* API call used to list buildings and locations.
|
|
*/
|
|
public class AllLocations implements Method<AllLocations.Response> {
|
|
private final int platform;
|
|
private final String siteId;
|
|
private final boolean withAddress;
|
|
private final boolean withBuildings;
|
|
|
|
// These values slightly change what type of date is returned.
|
|
// for_menus=true includes some locations that for_map=true does not.
|
|
// While for_map=true includes location data, which for_menus=true does not.
|
|
// However, none of the for_menus=true locations actually have any menus.
|
|
private static final boolean FOR_MENUS = false;
|
|
private static final boolean FOR_MAP = true;
|
|
|
|
public AllLocations(int platform, String siteId, boolean withAddress, boolean withBuildings) {
|
|
this.platform = platform;
|
|
this.siteId = siteId;
|
|
this.withAddress = withAddress;
|
|
this.withBuildings = withBuildings;
|
|
}
|
|
|
|
@Override
|
|
public String getPath() {
|
|
return "/locations/all_locations?platform=" + platform + "&site_id=" + siteId + "&for_menus=" + FOR_MENUS + "&for_map=" + FOR_MAP + "&with_address=" + withAddress + "&with_buildings=" + withBuildings;
|
|
}
|
|
|
|
@Override
|
|
public Class<Response> getResponseClass() {
|
|
return Response.class;
|
|
}
|
|
|
|
public static class Response {
|
|
public static class Building {
|
|
public String id;
|
|
public String name;
|
|
public boolean show_menus;
|
|
public List<Location> locations;
|
|
}
|
|
public List<Building> buildings;
|
|
public static class Location implements Category.Named {
|
|
public static class Address {
|
|
public double lat;
|
|
public double lon;
|
|
public String street;
|
|
}
|
|
|
|
public String id;
|
|
public String name;
|
|
public boolean active;
|
|
public Address address;
|
|
|
|
@Override
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
}
|
|
public List<Location> locations;
|
|
}
|
|
}
|