package com.iflytek.aicloud.http;

import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RequestMetaData {
    private static final String hostUrl = "https://cn-huadong-1.xf-yun.com/v1/ocr";
    private static final Map<String, String> mediaTypePathMap = new HashMap<>();
    private static final List<String> responsePathList = new ArrayList<>();

    static {
        mediaTypePathMap.put("$.payload.image.image", "input/image/阳光总在风雨后.jpg");
        responsePathList.add("$.payload.ocr_output_text");
    }

    public static Map<String, String> getRequestPathMap() {
        return mediaTypePathMap;
    }

    public static String getHostUrl() {
        return hostUrl;
    }

    public static List<String> getResponsePathList() {
        return responsePathList;
    }

    /**
    * 获取JsonObject形式的请求协议
    *
    */
    public static JSONObject getJsonObjectRequestData() {
        JSONObject jsonObjectRequestData = new JSONObject();
        JSONObject header = new JSONObject();
        jsonObjectRequestData.put("header", header);
        header.put("uid", "39769795890");
        header.put("net_isp", "CMCC");
        header.put("net_type", "wifi");
        header.put("res_id", "");
        header.put("imei", "8664020318693660");
        header.put("imsi", "4600264952729100");
        header.put("app_id", "123456");
        header.put("request_id", null);
        header.put("did", "SR082321940000200");
        header.put("mac", "6c:92:bf:65:c6:14");
        header.put("status", 3);
        JSONObject payload = new JSONObject();
        jsonObjectRequestData.put("payload", payload);
        JSONObject image = new JSONObject();
        payload.put("image", image);
        image.put("image", "");
        image.put("encoding", "jpg");
        image.put("status", 3);
        JSONObject parameter = new JSONObject();
        jsonObjectRequestData.put("parameter", parameter);
        JSONObject ocr = new JSONObject();
        parameter.put("ocr", ocr);
        ocr.put("language", "af");
        JSONObject ocr_output_text = new JSONObject();
        ocr.put("ocr_output_text", ocr_output_text);
        ocr_output_text.put("format", "json");
        ocr_output_text.put("encoding", "utf8");
        ocr_output_text.put("compress", "raw");
        return jsonObjectRequestData;
    }

    /**
    * 获取Json字符串形式的请求协议
    *
    */
    public static String getJsonStringRequestData() {
        String jsonStringRequestData = "{\n" +
                "    \"header\": {\n" +
                "        \"uid\": \"39769795890\",\n" +
                "        \"net_isp\": \"CMCC\",\n" +
                "        \"net_type\": \"wifi\",\n" +
                "        \"res_id\": \"\",\n" +
                "        \"imei\": \"8664020318693660\",\n" +
                "        \"imsi\": \"4600264952729100\",\n" +
                "        \"app_id\": \"123456\",\n" +
                "        \"did\": \"SR082321940000200\",\n" +
                "        \"mac\": \"6c:92:bf:65:c6:14\",\n" +
                "        \"status\": 3\n" +
                "    },\n" +
                "    \"payload\": {\n" +
                "        \"image\": {\n" +
                "            \"image\": \"\",\n" +
                "            \"encoding\": \"jpg\",\n" +
                "            \"status\": 3\n" +
                "        }\n" +
                "    },\n" +
                "    \"parameter\": {\n" +
                "        \"ocr\": {\n" +
                "            \"language\": \"af\",\n" +
                "            \"ocr_output_text\": {\n" +
                "                \"format\": \"json\",\n" +
                "                \"encoding\": \"utf8\",\n" +
                "                \"compress\": \"raw\"\n" +
                "            }\n" +
                "        }\n" +
                "    }\n" +
                "}";
        return jsonStringRequestData;
    }
}