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.MchApplicationResp;
import org.springblade.common.upyzt.resp.MchApplicationStoreResp;
import lombok.experimental.Accessors;

import java.util.Map;

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

    /**
     * 二级商户首次进件
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationStoreResp create(Map<String, Object> params) throws UpyztException {
        return create(params, null);
    }

    /**
     * 二级商户首次进件
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationStoreResp create(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, classURL(MchApplication.class), params, MchApplicationStoreResp.class, options);
    }

    /**
     * 修改二级商户信息
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp renew(Map<String, Object> params) throws UpyztException {
        return renew(params, null);
    }

    /**
     * 修改二级商户信息
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp renew(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, classURL(MchApplication.class, "_renew"), params, MchApplicationResp.class, options);
    }

    /**
     * 二级商户进件状态查询（系统订单号）
     *
     * @param id 系统订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp retrieveById(String id) throws UpyztException {
        return retrieveById(id, null);
    }

    /**
     * 二级商户进件状态查询（系统订单号）
     *
     * @param id      系统订单号
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp retrieveById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(MchApplication.class, id), null, MchApplicationResp.class, options);
    }

    /**
     * 二级商户进件状态查询（平台订单号）
     *
     * @param outRequestNo 平台订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp retrieveByOutRequestNo(String outRequestNo) throws UpyztException {
        return retrieveByOutRequestNo(outRequestNo, null);
    }

    /**
     * 二级商户进件状态查询（平台订单号）
     *
     * @param outRequestNo 平台订单号
     * @param options      参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static MchApplicationResp retrieveByOutRequestNo(String outRequestNo, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(MchApplication.class, "_by_out_request_no", outRequestNo), null, MchApplicationResp.class, options);
    }

}
