package cn.iselab.mooctest.user.data;

/**
 * @Author ROKG
 * @Description
 * @Date: Created in 下午4:38 2018/4/2
 * @Modified By:
 */
public class Token {

    // 接口访问凭证
    private String accessToken;
    // 凭证有效期，单位：秒
    private int expiresIn;
    private Long createTime;

    private String refresh_token;

    private String openId;

    public Token() {
        createTime = System.currentTimeMillis();
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public int getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }

    public boolean isValid() {
        if ((System.currentTimeMillis() - createTime) < (expiresIn - 100) * 1000) {
            return true;
        }
        return false;
    }

    public String getRefresh_token() {
        return refresh_token;
    }

    public void setRefresh_token(String refresh_token) {
        this.refresh_token = refresh_token;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }
}
