Skip to content

Commit f8a0d1d

Browse files
committed
feat: fedex registration endpoints
1 parent 3850550 commit f8a0d1d

File tree

12 files changed

+482
-4
lines changed

12 files changed

+482
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## v8.5.0 (2025-12-08)
4+
5+
- Adds the following functions:
6+
- `fedex.verifyBillingAddress`
7+
- `fedex.generatePin`
8+
- `fedex.validatePin`
9+
- `fedex.validateInvoice`
10+
- Adds `details` property of a `Rate` object
11+
312
## v8.4.1 (2025-12-01)
413

514
- Adds missing `apiKeys` field to `BaseUser`

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add this to your project's POM:
1616
<dependency>
1717
<groupId>com.easypost</groupId>
1818
<artifactId>easypost-api-client</artifactId>
19-
<version>8.4.1</version>
19+
<version>8.5.0</version>
2020
</dependency>
2121
```
2222

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

2727
```groovy
28-
implementation "com.easypost:easypost-api-client:8.4.1"
28+
implementation "com.easypost:easypost-api-client:8.5.0"
2929
```
3030

3131
**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.4.1
1+
8.5.0

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.easypost</groupId>
77
<artifactId>easypost-api-client</artifactId>
88

9-
<version>8.4.1</version>
9+
<version>8.5.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>com.easypost:easypost-api-client</name>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.easypost.model;
2+
3+
import java.util.Map;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public class FedExAccountValidationResponse {
8+
// If the response contains the following, one must complete pin or invoice validation next
9+
private String emailAddress;
10+
private Map<String, String> options;
11+
private String phoneNumber;
12+
13+
// If the response contains the following, pre-validation has been completed
14+
private String id;
15+
private String object;
16+
private String type;
17+
private Map<String, String> credentials;
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.easypost.model;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public class FedExGeneratePinResponse {
7+
private String message;
8+
}

src/main/java/com/easypost/service/EasyPostClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class EasyPostClient {
3434
public final EmbeddableService embeddable = new EmbeddableService(this);
3535
public final EndShipperService endShipper = new EndShipperService(this);
3636
public final EventService event = new EventService(this);
37+
public final FedExService fedex = new FedExService(this);
3738
public final InsuranceService insurance = new InsuranceService(this);
3839
public final LumaService luma = new LumaService(this);
3940
public final OrderService order = new OrderService(this);
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.easypost.service;
2+
3+
import java.util.Map;
4+
import java.util.HashMap;
5+
6+
import com.easypost.exception.EasyPostException;
7+
import com.easypost.http.Requestor;
8+
import com.easypost.http.Requestor.RequestMethod;
9+
import com.easypost.model.FedExAccountValidationResponse;
10+
import com.easypost.model.FedExGeneratePinResponse;
11+
12+
public class FedExService {
13+
private final EasyPostClient client;
14+
15+
/**
16+
* FedExService constructor.
17+
*
18+
* @param client The client object.
19+
*/
20+
FedExService(EasyPostClient client) {
21+
this.client = client;
22+
}
23+
24+
/**
25+
* Verify a FedEx billing address via the API.
26+
*
27+
* @param fedexAccountNumber FedEx account number.
28+
* @param params Map of parameters.
29+
* @return FedExAccountValidationResponse object
30+
* @throws EasyPostException when the request fails.
31+
*/
32+
public FedExAccountValidationResponse verifyBillingAddress(final String fedexAccountNumber, final Map<String, Object> params) throws EasyPostException {
33+
String endpoint = "fedex_registrations/" + fedexAccountNumber + "/address";
34+
35+
return Requestor.request(RequestMethod.POST, endpoint, params, FedExAccountValidationResponse.class, client);
36+
}
37+
38+
/**
39+
* Generate a pin to verify your FedEx account via the API.
40+
*
41+
* @param fedexAccountNumber FedEx account number.
42+
* @param pinMethod Method of delivery for the pin.
43+
* @return FedExGeneratePinResponse object
44+
* @throws EasyPostException when the request fails.
45+
*/
46+
public FedExGeneratePinResponse generatePin(final String fedexAccountNumber, final String pinMethod) throws EasyPostException {
47+
Map<String, Object> wrappedParams = new HashMap<>();
48+
Map<String, Object> pinMethodMap = new HashMap<>();
49+
pinMethodMap.put("option", pinMethod);
50+
wrappedParams.put("pin_method", pinMethodMap);
51+
String endpoint = "fedex_registrations/" + fedexAccountNumber + "/pin";
52+
53+
return Requestor.request(RequestMethod.POST, endpoint, wrappedParams, FedExGeneratePinResponse.class, client);
54+
}
55+
56+
/**
57+
* Validates a pin for a FedEx account via the API.
58+
*
59+
* @param fedexAccountNumber FedEx account number.
60+
* @param params Map of parameters.
61+
* @return FedExAccountValidationResponse object
62+
* @throws EasyPostException when the request fails.
63+
*/
64+
public FedExAccountValidationResponse validatePin(final String fedexAccountNumber, final Map<String, Object> params) throws EasyPostException {
65+
String endpoint = "fedex_registrations/" + fedexAccountNumber + "/pin/validate";
66+
67+
return Requestor.request(RequestMethod.POST, endpoint, params, FedExAccountValidationResponse.class, client);
68+
}
69+
70+
/**
71+
* Validates details of an invoice for a FedEx account via the API.
72+
*
73+
* @param fedexAccountNumber FedEx account number.
74+
* @param params Map of parameters.
75+
* @return FedExAccountValidationResponse object
76+
* @throws EasyPostException when the request fails.
77+
*/
78+
public FedExAccountValidationResponse validateInvoice(final String fedexAccountNumber, final Map<String, Object> params) throws EasyPostException {
79+
String endpoint = "fedex_registrations/" + fedexAccountNumber + "/invoice";
80+
81+
return Requestor.request(RequestMethod.POST, endpoint, params, FedExAccountValidationResponse.class, client);
82+
}
83+
}

src/test/cassettes/fedex/generate_pin.json

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/cassettes/fedex/validate_pin.json

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)