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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## Next Release

- Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook
- Fixes error parsing
- Allows for alternative format of `errors` field (previously we deserialized the `errors` field into a list of `Error` objects; however, sometimes the errors are simply a list of strings. This change make the `errors` field a list of `Object` allowing for either the new `FieldError` object or a list of strings. Users will need to check for the type of error returned and handle appropriately)
- Removed the unused `Error` model
- Added an explicit `AddressVerificationFieldError` model
- The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field
- Corrects payload wrapping for updating a webhook
- Bumps dependencies

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/easypost/Constants.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.easypost;

import com.easypost.exception.APIException;
import com.easypost.http.HashMapSerializer;
import com.easypost.model.AddressVerification;
import com.easypost.model.AddressVerificationDeserializer;
import com.easypost.model.Error;
import com.easypost.model.ErrorDeserializer;
import com.easypost.model.SmartrateCollection;
import com.easypost.model.SmartrateCollectionDeserializer;
Expand Down Expand Up @@ -80,7 +80,7 @@ public abstract static class Http {
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.registerTypeAdapter(HashMap.class, new HashMapSerializer())
.registerTypeAdapter(SmartrateCollection.class, new SmartrateCollectionDeserializer())
.registerTypeAdapter(Error.class, new ErrorDeserializer())
.registerTypeAdapter(APIException.class, new ErrorDeserializer())
.registerTypeAdapter(AddressVerification.class, new AddressVerificationDeserializer())
.registerTypeAdapter(StatelessRate[].class, new StatelessRateDeserializer())
.registerTypeAdapter(Webhook[].class, new WebhookDeserializer()).create();
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/BadRequestError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class BadRequestError extends APIException {
/**
* BadRequestError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public BadRequestError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public BadRequestError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/ForbiddenError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class ForbiddenError extends APIException {
/**
* ForbiddenError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public ForbiddenError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public ForbiddenError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class GatewayTimeoutError extends APIException {
/**
* GatewayTimeoutError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public GatewayTimeoutError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public GatewayTimeoutError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class InternalServerError extends APIException {
/**
* InternalServerError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public InternalServerError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public InternalServerError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class InvalidRequestError extends APIException {
/**
* InvalidRequestError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public InvalidRequestError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public InvalidRequestError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class MethodNotAllowedError extends APIException {
/**
* MethodNotAllowedError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public MethodNotAllowedError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public MethodNotAllowedError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/NotFoundError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class NotFoundError extends APIException {
/**
* NotFoundError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public NotFoundError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public NotFoundError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/PaymentError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class PaymentError extends APIException {
/**
* PaymentError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public PaymentError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public PaymentError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/RateLimitError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class RateLimitError extends APIException {
/**
* RateLimitError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public RateLimitError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public RateLimitError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/RedirectError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class RedirectError extends APIException {
/**
* RedirectError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public RedirectError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public RedirectError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class ServiceUnavailableError extends APIException {
/**
* ServiceUnavailablError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public ServiceUnavailableError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public ServiceUnavailableError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/TimeoutError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class TimeoutError extends APIException {
/**
* TimeoutError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public TimeoutError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public TimeoutError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class UnauthorizedError extends APIException {
/**
* UnauthorizedError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public UnauthorizedError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public UnauthorizedError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
11 changes: 5 additions & 6 deletions src/main/java/com/easypost/exception/API/UnknownApiError.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

import java.util.List;

public class UnknownApiError extends APIException {
/**
* UnknownApiError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
* @param statusCode the exception status code
*/
public UnknownApiError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
public UnknownApiError(final String message, final String code, List<Object> errors, final int statusCode) {
super(message, code, errors, statusCode);
}
}
Loading
Loading