Class GravatarProfileRequest
java.lang.Object
com.github.natche.gravatarjavaclient.profile.GravatarProfileRequest
A class for requesting a Profile from the Gravatar Profile API.
Both authenticated and unauthenticated requests are supported by this API.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the provided object equals this.static GravatarProfileRequestConstructs a new GravatarProfileRequest from the provided ID.static GravatarProfileRequestConstructs a new GravatarProfileRequest from the provided email.Returns the SHA256 hash or ID this request will use.Retrieves the profile using the provided email or hash from the Gravatar Profile API using HTTPS as the protocol.inthashCode()Returns a hashcode of this object.Sets the token this request will use when requesting information from the Gravatar API.toString()Returns a string representation of this object.booleanwriteToFile(com.google.gson.Gson serializer, File file) Writes the profile object obtained from this request to the provided file using the provided GSON object as the serializer.booleanwriteToFile(File file) Writes the profile object obtained from this request to the provided file.
-
Method Details
-
from
Constructs a new GravatarProfileRequest from the provided ID.- Parameters:
id- the ID to use in the request- Returns:
- a new GravatarProfileRequest
- Throws:
NullPointerException- if the provided ID is nullIllegalArgumentException- if the provided ID is empty
-
fromEmail
Constructs a new GravatarProfileRequest from the provided email.- Parameters:
email- the email address- Returns:
- a new GravatarProfileRequest
- Throws:
NullPointerException- if the provided email is nullIllegalArgumentException- if the provided email is empty or not a valid email
-
setToken
Sets the token this request will use when requesting information from the Gravatar API. When a valid token is provided, fields requiring authentication will be provided in the response.- Parameters:
token- the token- Returns:
- this request
-
getHashOrId
Returns the SHA256 hash or ID this request will use.- Returns:
- the SHA256 hash or ID this request will use
-
getProfile
Retrieves the profile using the provided email or hash from the Gravatar Profile API using HTTPS as the protocol.- Returns:
- the GravatarProfile obtained from the API
- Throws:
GravatarJavaClientException- if an exception occurs when fetching the profile
-
writeToFile
Writes the profile object obtained from this request to the provided file.- Parameters:
file- the file to write the object to- Returns:
- whether the write operation was successful
- Throws:
NullPointerException- if the provided file is nullIllegalArgumentException- if the provided file is a directory
-
writeToFile
Writes the profile object obtained from this request to the provided file using the provided GSON object as the serializer. The provided file must have a valid name.- Parameters:
serializer- the GSON object to serialize the profilefile- the file to write the object to- Returns:
- whether the write operation was successful
- Throws:
NullPointerException- if the provided file or serializer is nullIllegalArgumentException- if the provided file is a directory, does not exist, or has an invalid name
-
hashCode
public int hashCode()Returns a hashcode of this object. -
equals
Returns whether the provided object equals this. -
toString
Returns a string representation of this object.
-