All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paypal.core.object.AccessToken Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.paypal.core.object;

import com.braintreepayments.http.annotations.Model;
import com.braintreepayments.http.annotations.SerializedName;
import com.paypal.core.Authorization;

import java.util.Date;

@Model
public class AccessToken implements Authorization {

	private final transient Date createDate = new Date();

	@SerializedName("access_token")
	private String accessToken;

	@SerializedName("token_type")
	private String tokenType = "Bearer";

	@SerializedName("expires_in")
    private Integer expiresIn;

	public boolean isExpired() {
    	Date expireDate = new Date(createDate.getTime() + (expiresIn * 1000));
    	return new Date().after(expireDate);
    }

	public String accessToken() {
		return accessToken;
	}

	public String tokenType() {
		return tokenType;
	}

	public Integer expiresIn() {
		return expiresIn;
	}

	public Date createDate() {
		return createDate;
	}

	@Override
	public String authorizationString() {
		return String.format("Bearer %s", accessToken);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy