package com.live.xmutils;

import com.alibaba.fastjson.JSONObject;
import com.live.client.SSLRestfulClient;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


/**
 * Created by zhangying on  2020/11/19
 */

public class GetMsgAuthCodeAndLogin {

    public static SSLRestfulClient sslhttpclient = new SSLRestfulClient();
    public static HashMap<String, String> headers =new HashMap<>();
    public static List params=new ArrayList() {
    };



    @Test
    public static void getMsgAuthCode(){

        String json="{\n" +
                "    \"phone\":15068165765,\n" +
                "    \"serverType\":\"C_LOGIN\"\n" +
                "}";


        sslhttpclient.doPostRequest("https://gateway.xiaomai5.com/horn/anon/horn/msgAuthCode", params,json,headers);

    }
    /**
     * 直播学员端，验证码登录
     */

    @Test
    public void liveCLogin(){
        headers.put("Content-Type", "application/json");

        GetMsgAuthCodeAndLogin.getMsgAuthCode();

        JSONObject jsonObject = new JSONObject();

        jsonObject.put("accountNo","15068165765");
        jsonObject.put("certificate", "0000");
        jsonObject.put("loginType", "PHONE_AUTH_CODE");
        jsonObject.put("appTerm", "IOS");
        jsonObject.put("userType", "C");
        System.out.println("jsonObject= " + jsonObject);
        sslhttpclient.doPostRequest("https://gateway.xiaomai5.com/zeus/anon/account/login", params,jsonObject.toJSONString(),headers);
        JSONObject response = sslhttpclient.getBodyInJSON();
        String xmToken=response.getString("result/xmToken");
        System.out.println("response = " + response);
        System.out.println("xmToken = " + xmToken);
    }

}
