package com.friday.custody.utils;

import org.springframework.http.HttpHeaders;

import java.util.HashMap;
import java.util.Map;

public class PullDataFailureUtil {
    public static boolean isFailed(Map<String, Object> remoteData) {
        return remoteData == null || remoteData.containsKey("custodyErrorApi") || remoteData.containsKey("errorMsg");
    }

    public static Map<String, Object> createErrorMap(String trustNo, String custodyErrorApi, String headers, String params, Object errorResp) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("trustNo", trustNo);
        result.put("custodyErrorApi", custodyErrorApi);
        result.put("headers", headers);
        result.put("params", params);
        result.put("errorResp", errorResp);
        return result;
    }

    public static Map<String, Object> createErrorMap(String trustNo, String custodyErrorApi, HttpHeaders headers, String params, Object errorResp) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("trustNo", trustNo);
        result.put("custodyErrorApi", custodyErrorApi);
        result.put("headers", headers);
        result.put("params", params);
        result.put("errorResp", errorResp);
        return result;
    }

    public static Map<String, Object> createErrorMap(String trustNo, String custodyErrorApi, String headers, String params, HashMap errorResp) {
        HashMap<String, Object> result = new HashMap<>();
        result.put("trustNo", trustNo);
        result.put("custodyErrorApi", custodyErrorApi);
        result.put("headers", headers);
        result.put("params", params);
        result.put("errorResp", errorResp);
        return result;
    }

}
