package com.usoftchina.qywx.sdk.test;

import com.alibaba.fastjson.JSON;
import com.usoftchina.qywx.sdk.OaSdk;
import com.usoftchina.qywx.sdk.dto.GetCheckinDataReq;
import com.usoftchina.qywx.sdk.dto.GetCheckinDataResp;
import com.usoftchina.qywx.sdk.dto.GetCheckinOptionReq;
import com.usoftchina.qywx.sdk.dto.GetCheckinOptionResp;
import org.junit.Test;
import org.springframework.util.CollectionUtils;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;

/**
 * @author yingp
 */
public class OaSdkTest extends BaseTest {

    private static OaSdk sdk;

    static {
        sdk = new OaSdk(properties);
    }

    @Test
    public void getCheckinOption() {
        List<GetCheckinOptionResp.CheckinOption> options = sdk.getCheckinOption(new GetCheckinOptionReq(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000,
                Arrays.asList("U0308")));
        if (!CollectionUtils.isEmpty(options)) {
            System.out.println(JSON.toJSONString(options));
        }
    }

    @Test
    public void getCheckinData() {
        List<GetCheckinDataResp.CheckinData> dataList = sdk.getCheckinData(new GetCheckinDataReq(
                GetCheckinDataReq.CheckinType.ALL, LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000,
                System.currentTimeMillis() / 1000, Arrays.asList("U0308")));
        if (!CollectionUtils.isEmpty(dataList)) {
            System.out.println(JSON.toJSONString(dataList));
        }
    }
}
