Skip to content

Commit 5b9b2d8

Browse files
authored
Merge pull request #351 from EasyPost/ups_endpoint
fix: endpoint used for UPS create/update
2 parents d1a0020 + eeb4828 commit 5b9b2d8

File tree

9 files changed

+157
-169
lines changed

9 files changed

+157
-169
lines changed

CHANGELOG.md

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

3+
## v8.0.1 (2025-05-27)
4+
5+
- Corrects the endpoint used for creating/updating UPS accounts
6+
37
## v8.0.0 (2025-04-28)
48

59
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-7x-to-80) for more details.

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.0.0</version>
19+
<version>8.0.1</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.0.0"
28+
implementation "com.easypost:easypost-api-client:8.0.1"
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.0.0
1+
8.0.1

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.0.0</version>
9+
<version>8.0.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>com.easypost:easypost-api-client</name>

src/main/java/com/easypost/Constants.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ public abstract static class CarrierAccountTypes {
6565
"FedexAccount", "FedexSmartpostAccount"
6666
);
6767

68-
public static final List<String> UPS_OAUTH_CARRIER_ACCOUNT_TYPES = ImmutableList.of(
69-
"UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount"
70-
);
71-
7268
public static final List<String> CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = ImmutableList.of(
73-
"AmazonShippingAccount"
69+
"AmazonShippingAccount", "UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount"
7470
);
7571
}
7672

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,9 @@ public List<CarrierAccount> all(final Map<String, Object> params) throws EasyPos
8888
* @throws EasyPostException when the request fails.
8989
*/
9090
public CarrierAccount update(String id, final Map<String, Object> params) throws EasyPostException {
91-
CarrierAccount carrierAccount = this.retrieve(id);
92-
String type = (String) carrierAccount.getType();
91+
String endpoint = "carrier_accounts/" + id;
9392
Map<String, Object> wrappedParams = new HashMap<String, Object>();
94-
wrappedParams.put(selectTopLayerKey(type), params);
95-
96-
String endpoint = (Constants.CarrierAccountTypes.UPS_OAUTH_CARRIER_ACCOUNT_TYPES.contains(type)
97-
? "ups_oauth_registrations/"
98-
: "carrier_accounts/") + id;
93+
wrappedParams.put("carrier_account", params);
9994

10095
return Requestor.request(RequestMethod.PUT, endpoint, wrappedParams, CarrierAccount.class,
10196
client);
@@ -123,8 +118,6 @@ public void delete(String id) throws EasyPostException {
123118
private static String selectCarrierAccountCreationEndpoint(final String carrierAccountType) {
124119
if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOW.contains(carrierAccountType)) {
125120
return "carrier_accounts/register";
126-
} else if (Constants.CarrierAccountTypes.UPS_OAUTH_CARRIER_ACCOUNT_TYPES.contains(carrierAccountType)) {
127-
return "ups_oauth_registrations";
128121
} else if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.contains(carrierAccountType)) {
129122
return "carrier_accounts/register_oauth";
130123
} else {
@@ -146,9 +139,7 @@ private static String selectTopLayerKey(final String carrierAccountType) throws
146139
String.format(Constants.ErrorMessages.MISSING_REQUIRED_PARAMETER, "carrier account type"));
147140
}
148141

149-
if (Constants.CarrierAccountTypes.UPS_OAUTH_CARRIER_ACCOUNT_TYPES.contains(carrierAccountType)) {
150-
return "ups_oauth_registrations";
151-
} else if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.contains(carrierAccountType)) {
142+
if (Constants.CarrierAccountTypes.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.contains(carrierAccountType)) {
152143
return "carrier_account_oauth_registrations";
153144
} else {
154145
return "carrier_account";

src/test/cassettes/carrier_account/create_with_ups.json

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

0 commit comments

Comments
 (0)