Skip to content

feat: adds luma functions #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v8.2.0 (2025-06-18)

- Adds the following functions
- `shipment.createAndBuyLuma`
- `shipment.buyLuma`
- `luma.getPromise`

## v8.1.0 (2025-05-29)

- Adds `reference` to Claims
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your project's POM:
<dependency>
<groupId>com.easypost</groupId>
<artifactId>easypost-api-client</artifactId>
<version>8.1.0</version>
<version>8.2.0</version>
</dependency>
```

Expand All @@ -25,7 +25,7 @@ Add this to your project's POM:
Add this to your project's build file:

```groovy
implementation "com.easypost:easypost-api-client:8.1.0"
implementation "com.easypost:easypost-api-client:8.2.0"
```

**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.1.0
8.2.0
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 1556 files
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.easypost</groupId>
<artifactId>easypost-api-client</artifactId>

<version>8.1.0</version>
<version>8.2.0</version>
<packaging>jar</packaging>

<name>com.easypost:easypost-api-client</name>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/easypost/model/AiResults.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.easypost.model;

import lombok.Getter;

@Getter
public final class AiResults {
private String carrier;
private Boolean meetsRulesetRequirements;
private String predictedDeliverByDate;
private Integer predictedDeliverDays;
private String rateId;
private String rateUsd;
private String service;
}
12 changes: 12 additions & 0 deletions src/main/java/com/easypost/model/LumaInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.easypost.model;

import java.util.List;
import lombok.Getter;

@Getter
public final class LumaInfo {
private List<AiResults> aiResults;
private Integer matchingRuleIdx;
private String rulesetDescription;
private Rate lumaSelectedRate;
}
8 changes: 8 additions & 0 deletions src/main/java/com/easypost/model/LumaPromiseResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.easypost.model;

import lombok.Getter;

@Getter
public class LumaPromiseResponse {
private LumaInfo lumaInfo;
}
2 changes: 2 additions & 0 deletions src/main/java/com/easypost/service/EasyPostClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class EasyPostClient {
public final EndShipperService endShipper;
public final EventService event;
public final InsuranceService insurance;
public final LumaService luma;
public final OrderService order;
public final ParcelService parcel;
public final PaymentMethodService paymentMethod;
Expand Down Expand Up @@ -143,6 +144,7 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTim
this.endShipper = new EndShipperService(this);
this.event = new EventService(this);
this.insurance = new InsuranceService(this);
this.luma = new LumaService(this);
this.order = new OrderService(this);
this.parcel = new ParcelService(this);
this.paymentMethod = new PaymentMethodService(this);
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/easypost/service/LumaService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.easypost.service;

import com.easypost.exception.EasyPostException;
import com.easypost.http.Requestor;
import com.easypost.http.Requestor.RequestMethod;
import com.easypost.model.LumaPromiseResponse;
import com.easypost.model.LumaInfo;

import java.util.HashMap;
import java.util.Map;

public class LumaService {
private final EasyPostClient client;

/**
* LumaService constructor.
*
* @param client The client object.
*/
LumaService(EasyPostClient client) {
this.client = client;
}

/**
* Get service recommendations from Luma that meet the criteria of your ruleset.
*
* @param params The map of parameters.
* @return LumaInfo object.
* @throws EasyPostException When the request fails.
*/
public LumaInfo getPromise(final Map<String, Object> params)
throws EasyPostException {
Map<String, Object> wrappedParams = new HashMap<>();
wrappedParams.put("shipment", params);
String endpoint = "luma/promise";

LumaPromiseResponse response = Requestor.request(RequestMethod.POST, endpoint, wrappedParams,
LumaPromiseResponse.class, client);
return response.getLumaInfo();
}
}
39 changes: 37 additions & 2 deletions src/main/java/com/easypost/service/ShipmentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public Shipment generateForm(final String id, final String formType, final Map<S
*
* @param id The id of the shipment.
* @param plannedShipDate The planned shipment date.
* @return EstimatedDeliveryDate object.
* @return List of EstimatedDeliveryDate objects.
* @throws EasyPostException When the request fails.
*/
public List<EstimatedDeliveryDate> retrieveEstimatedDeliveryDate(final String id, final String plannedShipDate)
Expand All @@ -396,7 +396,7 @@ public List<EstimatedDeliveryDate> retrieveEstimatedDeliveryDate(final String id
*
* @param id The id of the shipment.
* @param desiredDeliveryDate The desired delivery date.
* @return EstimatedDeliveryDate object.
* @return List of RecommendShipDateForShipmentResult objects.
* @throws EasyPostException When the request fails.
*/
public List<RecommendShipDateForShipmentResult> recommendShipDate(final String id, final String desiredDeliveryDate)
Expand All @@ -409,4 +409,39 @@ public List<RecommendShipDateForShipmentResult> recommendShipDate(final String i
RecommendShipDateResponse.class, client);
return response.getRates();
}

/**
* Create and buy a Luma Shipment in one call.
*
* @param params The map of parameters.
* @return Shipment object.
* @throws EasyPostException When the request fails.
*/
public Shipment createAndBuyLuma(final Map<String, Object> params)
throws EasyPostException {
Map<String, Object> wrappedParams = new HashMap<>();
wrappedParams.put("shipment", params);
String endpoint = "shipments/luma";

Shipment response = Requestor.request(RequestMethod.POST, endpoint, wrappedParams,
Shipment.class, client);
return response;
}

/**
* Buy a Shipment with Luma.
*
* @param id The ID of shipment.
* @param params The map of parameters.
* @return Shipment object.
* @throws EasyPostException When the request fails.
*/
public Shipment buyLuma(final String id, final Map<String, Object> params)
throws EasyPostException {
String endpoint = "shipments/" + id + "/luma";

Shipment response = Requestor.request(RequestMethod.POST, endpoint, params,
Shipment.class, client);
return response;
}
}
91 changes: 91 additions & 0 deletions src/test/cassettes/luma/get_promise.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading