All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ksyun.client.bill.getpostpaydetailbillcsv.v20180601.GetPostpayDetailBillCSVClient Maven / Gradle / Ivy

package client.bill.getpostpaydetailbillcsv.v20180601;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import common.BaseClient;
import common.Credential;
import common.utils.HttpClientUtils;
import common.utils.SignUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
* @Classname GetPostpayDetailBillCSVClient
* @Description 重启实例
*/
@Slf4j
public class GetPostpayDetailBillCSVClient extends BaseClient {
    private final static String service = "bill";
    private final static String version = "2018-06-01";
    private final static String action = "GetPostpayDetailBillCSV";


    /**
     * 证书
     */
    private Credential credential;


    public GetPostpayDetailBillCSVClient(Credential credential) {
        this.credential = credential;
    }


    /**
     * post请求
     *
     * @param path
     * @param requestObj
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doPost(String path, GetPostpayDetailBillCSVRequest requestObj) throws Exception {
        return doPost(path, requestObj, null);
    }

    /**
     * post请求
     *
     * @param path
     * @param requestObj
     * @param head
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doPost(String path, GetPostpayDetailBillCSVRequest requestObj, Map head) throws Exception {
        JSONObject requestParams = getRequestParams(requestObj);
        String response = HttpClientUtils.httpPost(path, requestParams, head);
        log.info("doPost end,path:{},params:{},head:{}", path, requestParams, head);
        return JSON.parseObject(response, GetPostpayDetailBillCSVResponse.class);
    }


    /**
     * get 请求
     *
     * @param path
     * @param requestObj
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doGet(String path, GetPostpayDetailBillCSVRequest requestObj) throws Exception {
        return doGet(path, requestObj, null);
    }

    /**
     * doDelete 请求
     *
     * @param path
     * @param requestObj
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doDelete(String path, GetPostpayDetailBillCSVRequest requestObj) throws Exception {
        return doDelete(path, requestObj, null);
    }

    /**
     * doDelete 请求
     *
     * @param path
     * @param requestObj
     * @param head
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doDelete(String path, GetPostpayDetailBillCSVRequest requestObj, Map head) throws Exception {
        JSONObject requestParams = getRequestParams(requestObj);
        String response = HttpClientUtils.httpDelete(path, requestParams, head);
        log.info("doDelete end,path:{},params:{},head:{}", path, requestParams, head);
        GetPostpayDetailBillCSVResponse GetPostpayDetailBillCSVResponse = JSON.parseObject(response, GetPostpayDetailBillCSVResponse.class);
        return GetPostpayDetailBillCSVResponse;
    }


    /**
     * doPut 请求
     *
     * @param path
     * @param requestObj
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doPut(String path, GetPostpayDetailBillCSVRequest requestObj) throws Exception {
        return doPut(path, requestObj, null);
    }

    /**
     * doPut 请求
     *
     * @param path
     * @param requestObj
     * @param head
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doPut(String path, GetPostpayDetailBillCSVRequest requestObj, Map head) throws Exception {
        JSONObject requestParams = getRequestParams(requestObj);
        String response = HttpClientUtils.httpPut(path, requestParams, head);
        log.info("httpPut end,path:{},params:{},head:{}", path, requestParams, head);
        GetPostpayDetailBillCSVResponse GetPostpayDetailBillCSVResponse = JSON.parseObject(response, GetPostpayDetailBillCSVResponse.class);
        return GetPostpayDetailBillCSVResponse;
    }

    /**
     * get 请求
     *
     * @param path
     * @param requestObj
     * @param head
     * @return
     * @throws Exception
     */
    public GetPostpayDetailBillCSVResponse doGet(String path, GetPostpayDetailBillCSVRequest requestObj, Map head) throws Exception {
        JSONObject requestParams = getRequestParams(requestObj);
        String response = HttpClientUtils.httpGet(path, requestParams, head);
        log.info("doGet end,path:{},params:{},head:{}", path, requestParams, head);
        return JSON.parseObject(response, GetPostpayDetailBillCSVResponse.class);
    }


    /**
     * 构造请求参数
     *
     * @param requestObj
     * @return
     */
    private JSONObject getRequestParams(GetPostpayDetailBillCSVRequest requestObj) throws Exception {
        JSONObject requestParams = new JSONObject();
        //设置证书
        getCommonParams(credential, requestParams);
        //设置接口属性
        requestParams.put("Service", service);
        requestParams.put("Action", action);
        requestParams.put("Version", version);

        //设置请求体请求参数
        setRequestField(requestObj,requestParams);

        //签名
        String signature = SignUtils.signature(requestParams, credential.getSignStr());
        requestParams.put("Signature", signature);
        return requestParams;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy