|
| 1 | +package com.easypost.service; |
| 2 | + |
| 3 | +import com.easypost.exception.EasyPostException; |
| 4 | +import com.easypost.http.Requestor; |
| 5 | +import com.easypost.http.Requestor.RequestMethod; |
| 6 | +import com.easypost.model.LumaPromiseResponse; |
| 7 | +import com.easypost.model.LumaInfo; |
| 8 | + |
| 9 | +import java.util.HashMap; |
| 10 | +import java.util.Map; |
| 11 | + |
| 12 | +public class LumaService { |
| 13 | + private final EasyPostClient client; |
| 14 | + |
| 15 | + /** |
| 16 | + * LumaService constructor. |
| 17 | + * |
| 18 | + * @param client The client object. |
| 19 | + */ |
| 20 | + LumaService(EasyPostClient client) { |
| 21 | + this.client = client; |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * Get service recommendations from Luma that meet the criteria of your ruleset. |
| 26 | + * |
| 27 | + * @param params The map of parameters. |
| 28 | + * @return LumaInfo object. |
| 29 | + * @throws EasyPostException When the request fails. |
| 30 | + */ |
| 31 | + public LumaInfo getPromise(final Map<String, Object> params) |
| 32 | + throws EasyPostException { |
| 33 | + Map<String, Object> wrappedParams = new HashMap<>(); |
| 34 | + wrappedParams.put("shipment", params); |
| 35 | + String endpoint = "luma/promise"; |
| 36 | + |
| 37 | + LumaPromiseResponse response = Requestor.request(RequestMethod.POST, endpoint, wrappedParams, |
| 38 | + LumaPromiseResponse.class, client); |
| 39 | + return response.getLumaInfo(); |
| 40 | + } |
| 41 | +} |
0 commit comments