package org.springblade.common.upyzt.model;

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.SettleAcctDeleteResp;
import org.springblade.common.upyzt.resp.SettleAcctListResp;
import org.springblade.common.upyzt.resp.SettleAcctResp;
import lombok.experimental.Accessors;

import java.util.Map;

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

    /**
     * 新增绑定账户
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp create(Map<String, Object> params) throws UpyztException {
        return create(params, null);
    }

    /**
     * 新增绑定账户
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp create(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, classURL(SettleAcct.class), params, SettleAcctResp.class, options);
    }

    /**
     * 绑定账户查询（绑定账户编号）
     *
     * @param id 系统订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp retrieveById(String id) throws UpyztException {
        return retrieveById(id, null);
    }

    /**
     * 绑定账户查询（绑定账户编号）
     *
     * @param id      系统订单号
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp retrieveById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(SettleAcct.class, id), null, SettleAcctResp.class, options);
    }

    /**
     * 绑定账户查询（平台订单号）
     *
     * @param outRequestNo 平台订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp retrieveByOutRequestNo(String outRequestNo) throws UpyztException {
        return retrieveByOutRequestNo(outRequestNo, null);
    }

    /**
     * 绑定账户查询（平台订单号）
     *
     * @param outRequestNo 平台订单号
     * @param options      参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp retrieveByOutRequestNo(String outRequestNo, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(SettleAcct.class, "_by_out_request_no", outRequestNo), null, SettleAcctResp.class, options);
    }

    /**
     * 绑定账户查询（用户ID）
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctListResp retrieveByUserId(Map<String, Object> params) throws UpyztException {
        return retrieveByUserId(params, null);
    }

    /**
     * 绑定账户查询（用户ID）
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctListResp retrieveByUserId(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, classURL(SettleAcct.class), params, SettleAcctListResp.class, options);
    }

    /**
     * 删除绑定账户
     *
     * @param id 系统订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctDeleteResp removeById(String id) throws UpyztException {
        return removeById(id, null);
    }

    /**
     * 删除绑定账户
     *
     * @param id      系统订单号
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctDeleteResp removeById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.DELETE, instanceURL(SettleAcct.class, id), null, SettleAcctDeleteResp.class, options);
    }


    /**
     * 验证绑定账户(打款金额验证)
     *
     * @param id     系统订单号
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     * @deprecated 1.3.2后续迭代将删除，可使用validateBySettleAcctId替代
     */
    @Deprecated
    public static SettleAcctResp validate(String id, Map<String, Object> params) throws UpyztException {
        return validateBySettleAcctId(id, params, null);
    }

    /**
     * 验证绑定账户(打款金额验证)
     *
     * @param id     系统订单号
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp validateBySettleAcctId(String id, Map<String, Object> params) throws UpyztException {
        return validateBySettleAcctId(id, params, null);
    }

    /**
     * 打款金额验证（用户银行账号）
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp validateByBankAcctNo(Map<String, Object> params) throws UpyztException {
        return APIResource.request(RequestMethod.PUT, classURL(SettleAcct.class) + "/validate_by_bank_acct_no", params, SettleAcctResp.class, null);
    }

    /**
     * 验证绑定账户(打款金额验证)
     *
     * @param id      系统订单号
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp validateBySettleAcctId(String id, Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.PUT, instanceURL(SettleAcct.class, id) + "/validate", params, SettleAcctResp.class, options);
    }


}
