|
1 | 1 | package com.easypost.service; |
2 | 2 |
|
| 3 | +import java.util.Map; |
3 | 4 | import java.util.function.Function; |
4 | 5 |
|
5 | 6 | import com.easypost.Constants; |
| 7 | +import com.easypost.exception.EasyPostException; |
6 | 8 | import com.easypost.exception.General.MissingParameterError; |
7 | 9 | import com.easypost.hooks.RequestHook; |
8 | 10 | import com.easypost.hooks.RequestHookResponses; |
9 | 11 | import com.easypost.hooks.ResponseHook; |
10 | 12 | import com.easypost.hooks.ResponseHookResponses; |
| 13 | +import com.easypost.http.Requestor; |
| 14 | +import com.easypost.http.Requestor.RequestMethod; |
11 | 15 |
|
12 | 16 | import lombok.Getter; |
13 | 17 |
|
@@ -215,4 +219,23 @@ public String getApiVersion() { |
215 | 219 | public String getApiBase() { |
216 | 220 | return apiBase; |
217 | 221 | } |
| 222 | + |
| 223 | + /** |
| 224 | + * Make an API call to the EasyPost API. |
| 225 | + * |
| 226 | + * This public, generic interface is useful for making arbitrary API calls to the EasyPost API that |
| 227 | + * are not yet supported by the client library's services. When possible, the service for your use case |
| 228 | + * should be used instead as it provides a more convenient and higher-level interface depending on the endpoint. |
| 229 | + * |
| 230 | + * @param method The HTTP method to use for the request. |
| 231 | + * @param endpoint The endpoint to call (e.g., "/addresses"). |
| 232 | + * @param params The parameters to send with the request. |
| 233 | + * @return A Map containing the API response. |
| 234 | + * @throws EasyPostException when the request fails. |
| 235 | + */ |
| 236 | + @SuppressWarnings("unchecked") |
| 237 | + public Map<String, Object> makeApiCall(RequestMethod method, String endpoint, Map<String, Object> params) |
| 238 | + throws EasyPostException { |
| 239 | + return Requestor.request(method, endpoint, params, Map.class, this); |
| 240 | + } |
218 | 241 | } |
0 commit comments