package com.jeesharp.business.modules.pay.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 浦发银行请求响应状态码
 *
 * @author wangmeng
 */
@Getter
@AllArgsConstructor
public enum PuFaHttpStatusEnum {

    SUCCESS(200, "通讯成功", "正常调用返回"),
    ERROR_401(401, "无访问权限", "请检查是否订阅该API并通过审核，门户APP内是否正确配IP白名单"),
    ERROR_404(404, "找不到请求路径", "请检查请求URL路径"),
    ERROR_405(405, "非法的请求方式", "请检查是否正确使用 POST/GET/PUT 方法"),
    ERROR_429(429, "请求次数超过限制", "请检查请求频率是否超过限流"),
    ERROR_500(500, "请求参数有误", "请检查 Signature、ClientID、Body 是否上送正确，APP中开发者公钥是否正确上传"),
    ERROR_503(503, "限流错误", "请检查请求频率是否超过限流"),
    ERROR_577(577, "重复请求", "请检查防重放字段");

    private Integer code;
    private String message;
    private String detailMessage;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDetailMessage() {
        return detailMessage;
    }

    public void setDetailMessage(String detailMessage) {
        this.detailMessage = detailMessage;
    }

    public static PuFaHttpStatusEnum getHttpEnum(Integer code) {
        for (PuFaHttpStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

}
