cn.ipokerface.aps.response.ResponseCode Maven / Gradle / Ivy
Show all versions of apple-pns-java Show documentation
package cn.ipokerface.aps.response;
/**
* Created by PokerFace
* Create Date 2020-08-23.
* Email: [email protected]
* Version 1.0.0
*
* Description:
*/
public enum ResponseCode {
success(200, "Success"),
bad_request (400, "Bad request"),
auth_error (403, "There was an error with the certificate or with the provider’s authentication token"),
method_invalid(405,"The request used an invalid :method value. Only POST requests are supported"),
device_inactive(410,"The device token is no longer active for the topic"),
payload_large(413,"The notification payload was too large"),
busy(429, "The server received too many requests for the same device token"),
server_error (500, "Internal server error"),
server_shutting_down(503, "The server is shutting down and unavailable")
;
private int code;
private String description;
private ResponseCode(int code, String description) {
this.code = code;
this.description = description;
}
public int getCode() {
return code;
}
public String getDescription() {
return description;
}
public static ResponseCode of(int code) {
ResponseCode[] values = ResponseCode.values();
for(ResponseCode responseCode: values) {
if (responseCode.code == code) {
return responseCode;
}
}
return ResponseCode.success;
}
}