Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v8.6.0 (2026-02-03)

- Adds the following functions usable by child and referral customer users:
- `apiKey.create`
- `apiKey.delete`
- `apiKey.enable`
- `apiKey.disable`

## v8.5.1 (2026-01-08)

- Corrects `StatelessRateDeserializer` and `WebhookDeserializer` to treat all camelCase fields like all other models to properly deserialize JSON fields containing underscors
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.5.1</version>
<version>8.6.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.5.1"
implementation "com.easypost:easypost-api-client:8.6.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.5.1
8.6.0
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.5.1</version>
<version>8.6.0</version>
<packaging>jar</packaging>

<name>com.easypost:easypost-api-client</name>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/easypost/model/ApiKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
@Getter
public final class ApiKey extends EasyPostResource {
private String key;
private Boolean active;
}
78 changes: 66 additions & 12 deletions src/main/java/com/easypost/service/ApiKeyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ public class ApiKeyService {
this.client = client;
}

/**
* Get all API keys.
*
* @return ApiKeys object.
* @throws EasyPostException when the request fails.
*/
public ApiKeys all() throws EasyPostException {
String endpoint = "api_keys";

return Requestor.request(RequestMethod.GET, endpoint, null, ApiKeys.class, client);
}

/**
* Get this User's API keys.
*
Expand All @@ -57,4 +45,70 @@ public List<ApiKey> retrieveApiKeysForUser(final String id) throws EasyPostExcep

throw new FilteringError(String.format(Constants.ErrorMessages.NO_OBJECT_FOUND, "API keys"));
}

/**
* Get all API keys.
*
* @return ApiKeys object.
* @throws EasyPostException when the request fails.
*/
public ApiKeys all() throws EasyPostException {
String endpoint = "api_keys";

return Requestor.request(RequestMethod.GET, endpoint, null, ApiKeys.class, client);
}

/**
* Create an API key for a child or referral customer user.
*
* @param mode The mode of the API key (production or test).
* @return ApiKey object.
* @throws EasyPostException when the request fails.
*/
public ApiKey create(final String mode) throws EasyPostException {
String endpoint = "api_keys";

java.util.Map<String, Object> params = new java.util.HashMap<>();
params.put("mode", mode);

return Requestor.request(RequestMethod.POST, endpoint, params, ApiKey.class, client);
}

/**
* Delete an API key for a child or referral customer user.
*
* @param id The ID of the API key to delete.
* @throws EasyPostException when the request fails.
*/
public void delete(final String id) throws EasyPostException {
String endpoint = String.format("api_keys/%s", id);

Requestor.request(RequestMethod.DELETE, endpoint, null, ApiKey.class, client);
}

/**
* Enable a child or referral customer API key.
*
* @param id The ID of the API key to enable.
* @return ApiKey object.
* @throws EasyPostException when the request fails.
*/
public ApiKey enable(final String id) throws EasyPostException {
String endpoint = String.format("api_keys/%s/enable", id);

return Requestor.request(RequestMethod.POST, endpoint, null, ApiKey.class, client);
}

/**
* Disable a child or referral customer API key.
*
* @param id The ID of the API key to disable.
* @return ApiKey object.
* @throws EasyPostException when the request fails.
*/
public ApiKey disable(final String id) throws EasyPostException {
String endpoint = String.format("api_keys/%s/disable", id);

return Requestor.request(RequestMethod.POST, endpoint, null, ApiKey.class, client);
}
}
74 changes: 37 additions & 37 deletions src/test/cassettes/api_key/api_keys.json

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

Loading
Loading