package com.njzscloud.common.http.support;

import cn.hutool.core.map.MapUtil;

import java.util.List;
import java.util.Map;

public record ResponseInfo(boolean success, int code, String message, Map<String, List<String>> header, byte[] body, Exception e) {

    public static ResponseInfo create(int code, String message, Map<String, List<String>> header, byte[] body) {
        return new ResponseInfo(code >= 200 && code <= 299, code, message, header, body, null);
    }

    public static ResponseInfo create(Exception e) {
        return new ResponseInfo(false, 0, e.getMessage(), MapUtil.empty(), new byte[0], e);
    }
}
