package com.izouma.wenlvju;

import cn.hutool.core.convert.Convert;
import com.github.kevinsawicki.http.HttpRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.time.LocalDate;

@RunWith(SpringRunner.class)
@SpringBootTest
public class VoiceTests {
    String appKey    = "7851448260f84d6a83585adfff7301d8";
    String appSecret = "7bd9a092d6ae0f373e9168d85d238efe";

    @Test
    public void testToken() {
        String uri = "https://open.ys7.com/api/lapp/token/get";
        String body = "appKey=" + appKey + "&appSecret=" + appSecret;
        System.out.println(body);
        HttpRequest.post(uri).send(body).receive(System.out);
    }

    @Test
    public void testAdd(){
        String uri = "https://open.ys7.com/api/lapp/device/add";
        String accessToken = "at.bgdp2ewu1btz9gl47vco9rckdexx5p32-8oic3wp6h3-0manyiu-oc0vsrvpy";
        String deviceSerial = "F75663984";
        String validateCode= "PKDYXQ";
        String body = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
        System.out.println(body);
        HttpRequest.post(uri).send(body).receive(System.out);
    }

    @Test
    public void testDel(){
        String uri = "https://open.ys7.com/api/lapp/device/delete";
        String accessToken = "at.bgdp2ewu1btz9gl47vco9rckdexx5p32-8oic3wp6h3-0manyiu-oc0vsrvpy";
        String deviceSerial = "F75663984";
        String body = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial;
        System.out.println(body);
        HttpRequest.post(uri).send(body).receive(System.out);
    }

    @Test
    public void test(){
        LocalDate start = Convert.convert(LocalDate.class, "2021-6-1");
//        System.out.println(LocalDate.now().isBefore(start));
        System.out.println(LocalDate.now().isAfter(start));
    }
}
