AvatarService

class AvatarService(okHttpClient: OkHttpClient? = null)

Service for managing Gravatar avatars.

Parameters

okHttpClient

The OkHttp client to use for making network requests. This client will be extended with Gravatar interceptors to set either API key or OAuth token.

Constructors

Link copied to clipboard
constructor(okHttpClient: OkHttpClient? = null)

Functions

Link copied to clipboard
suspend fun deleteAvatar(avatarId: String, oauthToken: String)

Deletes the avatar with the given ID.

Link copied to clipboard
suspend fun deleteAvatarCatching(avatarId: String, oauthToken: String): GravatarResult<Unit, ErrorType>

Deletes the avatar with the given ID. This method will catch any exception that occurs during the execution and return it as a GravatarResult.Failure.

Link copied to clipboard
suspend fun retrieve(oauthToken: String, hash: Hash): List<Avatar>

Retrieves a list of available avatars for the authenticated user.

Link copied to clipboard
suspend fun retrieveCatching(oauthToken: String, hash: Hash): GravatarResult<List<Avatar>, ErrorType>

Retrieves a list of available avatars for the authenticated user. This method will catch any exception that occurs during the execution and return it as a GravatarResult.Failure.

Link copied to clipboard
suspend fun setAvatar(hash: String, avatarId: String, oauthToken: String)

Sets the avatar for the given email (hash).

Link copied to clipboard
suspend fun setAvatarCatching(hash: String, avatarId: String, oauthToken: String): GravatarResult<Unit, ErrorType>

Sets the avatar for the given email (hash). This method will catch any exception that occurs during the execution and return it as a GravatarResult.Failure.

Link copied to clipboard
suspend fun updateAvatar(avatarId: String, oauthToken: String, avatarRating: Avatar.Rating? = null, altText: String? = null): Avatar

Updates the avatar rating and/or alt text.

Link copied to clipboard
suspend fun updateAvatarCatching(avatarId: String, oauthToken: String, avatarRating: Avatar.Rating? = null, altText: String? = null): GravatarResult<Avatar, ErrorType>

Updates the avatar rating and/or alt text. This method will catch any exception that occurs during the execution and return it as a GravatarResult.Failure.

Link copied to clipboard
suspend fun upload(file: File, oauthToken: String, hash: Hash? = null, selectAvatar: Boolean? = null): Avatar

Uploads an image to be used as Gravatar avatar.

Link copied to clipboard
suspend fun uploadCatching(file: File, oauthToken: String, hash: Hash? = null, selectAvatar: Boolean? = null): GravatarResult<Avatar, ErrorType>

Uploads an image to be used as Gravatar avatar. This method will catch any exception that occurs during the execution and return it as a GravatarResult.Failure.