|
5 | 5 | import com.route4me.sdk.Manager;
|
6 | 6 | import com.route4me.sdk.RequestMethod;
|
7 | 7 | import com.route4me.sdk.exception.APIException;
|
| 8 | +import java.io.UnsupportedEncodingException; |
8 | 9 | import lombok.AllArgsConstructor;
|
9 | 10 | import lombok.Getter;
|
10 | 11 | import lombok.ToString;
|
|
13 | 14 | import java.util.ArrayList;
|
14 | 15 | import java.util.List;
|
15 | 16 | import java.util.Map;
|
| 17 | +import java.util.logging.Level; |
| 18 | +import java.util.logging.Logger; |
| 19 | +import static org.apache.http.Consts.UTF_8; |
| 20 | +import org.apache.http.NameValuePair; |
| 21 | +import org.apache.http.client.entity.UrlEncodedFormEntity; |
| 22 | +import org.apache.http.message.BasicNameValuePair; |
16 | 23 |
|
17 | 24 | public class RoutingManager extends Manager {
|
18 | 25 | public static final String ROUTE_EP = "/api.v4/route.php";
|
19 | 26 | public static final String ADDRESS_EP = "/api.v4/address.php";
|
20 | 27 | public static final String OPTIMIZATION_EP = "/api.v4/optimization_problem.php";
|
21 | 28 | public static final String DUPLICATE_ROUTE_EP = "/actions/duplicate_route.php";
|
| 29 | + public static final String RENAME_ROUTE_EP = "/actions/route/rename_route.php"; |
22 | 30 |
|
23 | 31 | public RoutingManager(String apiKey) {
|
24 | 32 | super(apiKey);
|
@@ -166,6 +174,20 @@ public DuplicateRouteResponse duplicateRoute(String routeID) throws APIException
|
166 | 174 | return this.makeRequest(RequestMethod.GET, builder, "", DuplicateRouteResponse.class);
|
167 | 175 | }
|
168 | 176 |
|
| 177 | + public RouteRenamedStatus renameRoute(String routeName, String routeID) throws APIException { |
| 178 | + URIBuilder builder = Manager.defaultBuilder(RENAME_ROUTE_EP); |
| 179 | + builder.setParameter("format", "json"); |
| 180 | + |
| 181 | + List<NameValuePair> data = new ArrayList<>(); |
| 182 | + data.add(new BasicNameValuePair("route_name", routeName)); |
| 183 | + data.add(new BasicNameValuePair("route_id", routeID)); |
| 184 | + |
| 185 | + UrlEncodedFormEntity body = null; |
| 186 | + body = new UrlEncodedFormEntity(data, UTF_8); |
| 187 | + |
| 188 | + return this.makeRequest(RequestMethod.POST, builder, body, RouteRenamedStatus.class); |
| 189 | + } |
| 190 | + |
169 | 191 | @Getter
|
170 | 192 | @ToString
|
171 | 193 | public static class DuplicateRouteResponse {
|
|
0 commit comments