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

import java.util.Map;

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

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

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

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

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

    /**
     * 个人用户进件-短信验证码
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CusApplicationSmsCodeResp sendSmsCode(Map<String, Object> params) throws UpyztException {
        return sendSmsCode(params, null);
    }

    /**
     * 个人用户进件-短信验证码
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static CusApplicationSmsCodeResp sendSmsCode(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, singleClassURL(CusApplication.class, "_sms_codes"), params, CusApplicationSmsCodeResp.class, options);
    }

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

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

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

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

}
