/*
 * @Author: Kane
 * @Date: 2023-05-25 21:55:14
 * @LastEditors: Kane
 * @FilePath: /task_schedule/src/test/identify.ts
 * @Description:
 *
 * Copyright (c) ${2022} by Kane, All Rights Reserved.
 */

import { type AxiosResponse } from "axios";
import { service as instance } from "../utils/api/request.js";
import { API_URL } from "../utils/api/config.js";
// import { login, loginCaller, type LoginCallerInfo } from "../utils/account.js";

interface LoginInfo
{
    p13account: string;
    password: string;
}

interface LoginCallerInfo
{
    telsaler_code: string;
}

async function loginCaller( data: LoginCallerInfo ): Promise<AxiosResponse<any, any>>
{
    return await instance.request(
        {
            method: "post",
            url: API_URL.URL_LOGIN_CALLER,
            data,
        });
}

function loginTestCaller(): void
{
    const info: LoginCallerInfo =
   {
       telsaler_code: "61136",
   };

    loginCaller( info )
        .then(( response ) =>
        {
            console.log( response.data );
        })
        .catch(( error ) =>
        {
            console.log( error );
        });
}

async function newCitizen( data: any ): Promise<AxiosResponse<any, any>>
{
    return await instance.request(
        {
            method: "post",
            url: "http://10.39.0.41:8081/NewCitizen/identify.do",
            data,
        }
    );
}

function testNewCitizen(): void
{
    const data = {
        idcard_no: "350402198106130016",
        name: "王炜",
    };

    newCitizen( data )
        .then(( response ) =>
        {
            console.log( response.data );
        })
        .catch(( error ) =>
        {
            console.log( error );
        });
}

export {
    loginTestCaller,
    testNewCitizen,
    type LoginInfo,
    type LoginCallerInfo
};
