package org.springblade.common.upyzt.model;

import org.springblade.common.upyzt.Upyzt;
import org.springblade.common.upyzt.exception.UpyztException;
import org.springblade.common.upyzt.net.APIResource;
import org.springblade.common.upyzt.net.RequestOptions;
import org.springblade.common.upyzt.resp.CombinedGuaranteeDepositResp;
import org.springblade.common.upyzt.resp.GuaranteeDepositResp;
import org.springblade.common.upyzt.resp.GuaranteeDepositResult;
import lombok.experimental.Accessors;

import java.util.Map;

@Accessors(chain = true)
public class CombinedGuaranteeDeposit extends APIResource {

    /**
     * 合并消费担保下单
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp create(Map<String, Object> params) throws UpyztException {
        return create(params, null);
    }

    /**
     * 合并支付担保下单
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp create(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, classURL(CombinedGuaranteeDeposit.class), params, CombinedGuaranteeDepositResp.class, options);
    }

    /**
     * 合并支付担保下单订单查询（系统订单号）
     *
     * @param id 系统订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp retrieveById(String id) throws UpyztException {
        return retrieveById(id, null);
    }

    /**
     * 合并支付担保下单订单查询（系统订单号）
     *
     * @param id      系统订单号
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp retrieveById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(CombinedGuaranteeDeposit.class, id), null, CombinedGuaranteeDepositResp.class, options);
    }

    /**
     * 合并支付担保下单订单查询（平台订单号）
     *
     * @param outOrderNo 平台订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
        return retrieveByOutOrderNo(outOrderNo, null);
    }

    /**
     * 合并支付担保下单订单查询（平台订单号）
     *
     * @param outOrderNo 平台订单号
     * @param options    参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CombinedGuaranteeDepositResp retrieveByOutOrderNo(String outOrderNo, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(CombinedGuaranteeDeposit.class, "_by_out_order_no", outOrderNo), null, CombinedGuaranteeDepositResp.class, options);
    }

    public static GuaranteeDepositResp retrieveByGuaranteeDepositId(String id) throws UpyztException {
        return APIResource.request(RequestMethod.GET, Upyzt.getApiBase() + "/v1/combined_guarantee_deposits/guarantee_deposits/" + id, null, GuaranteeDepositResp.class, null);
    }
}
