Package blue.starry.penicillin.extensions

Types

Link copied to clipboard
enum AccessLevel : Enum<AccessLevel>

Represents "x-access-level" header.

Link copied to clipboard
data class CreatedAt(val value: String)

Represents "created_at" date format.

Link copied to clipboard
data class Language(val value: String)

Represents parsed "lang" object.

Link copied to clipboard
data class RateLimit(    val limit: Int,     val remaining: Int,     val resetAt: GMTDate)

Represents Twitter API rate limit.

Link copied to clipboard
data class StatusID(val value: Long)

Represents numerical status id.

Link copied to clipboard
data class Via(    val url: String,     val name: String,     val attributes: Map<String, String>)

Functions

Link copied to clipboard
suspend fun RateLimit.awaitRefresh()

Awaits until rate limit is refreshed. (Suspending function)

Link copied to clipboard
fun RateLimit.blockUntilRefresh()

Blocks until rate limit is refreshed. (Classic blocking function)

Link copied to clipboard
fun <R> Endpoint.DelegatedAction(block: suspend () -> R): ApiAction<R>

Creates an ApiAction that is resolved with passed lambda block.

Link copied to clipboard
fun <R : Any> ApiAction<R>.edit(block: ApiRequestBuilder.() -> Unit): ApiAction<R>

Modifies current ApiRequestBuilder with the block.

Link copied to clipboard
suspend fun <R : Any> ApiAction<R>.executeWithTimeout(timeout: Duration): R?

Awaits api execution and returns its result with timeout. This function is suspend-function.

Link copied to clipboard
fun MediaComponent(    file: File,     type: MediaType,     category: MediaCategory = MediaCategory.TweetImage): MediaComponent
fun MediaComponent(    path: Path,     type: MediaType,     category: MediaCategory = MediaCategory.TweetImage): MediaComponent
Link copied to clipboard
inline fun <C : Closeable, R> C.use(block: (C) -> R): R

Closes the receiver after block. Compatibility function.

Properties

Link copied to clipboard
val ApiResponse<*>.accessLevels: Set<AccessLevel>

Set of "x-access-level" header. If this header is absent or unknown, returns empty set.

Link copied to clipboard
val RateLimit.consumed: Int

The count you consumed in last 15 minutes.

Link copied to clipboard
val ActivityEvent.createdAt: CreatedAt

Parsed "created_at" object.

val DirectMessage.createdAt: CreatedAt

Parsed "created_at" object.

val SavedSearch.createdAt: CreatedAt

Parsed "created_at" object.

val Status.createdAt: CreatedAt

Parsed "created_at" object.

val TwitterList.createdAt: CreatedAt

Parsed "created_at" object.

val CommonUser.createdAt: CreatedAt

Parsed "created_at" object.

val Stream.Event.createdAt: CreatedAt

Parsed "created_at" object.

Link copied to clipboard
val RateLimit.duration: Duration

The Duration between now and RateLimit.resetAt.

Link copied to clipboard
val ApiResponse<*>.hasDirectMessagesPermission: Boolean

Checks if this application has "direct messages" permission.

Link copied to clipboard
val ApiResponse<*>.hasReadPermission: Boolean

Checks if this application has "read" permission.

Link copied to clipboard
val ApiResponse<*>.hasWritePermission: Boolean

Checks if this application has "write" permission.

Link copied to clipboard
val Status.idObj: StatusID

Parsed status id object for "id".

Link copied to clipboard
val Status.inReplyToStatusIdObj: StatusID?

Parsed status id object for "in_reply_to_status_id".

Link copied to clipboard
val CreatedAt.instant: Instant

New Instant instance for this "created_at" string.

val StatusID.instant: Instant

New Instant instance with epoch time.

Link copied to clipboard
val RateLimit.isExceeded: Boolean

The flag indicates you may access the same endpoint more at this time. If true, rate limit exceeded.

Link copied to clipboard
val Status.lang: Language

Parsed "lang" object.

val CommonUser.lang: Language?

Parsed "lang" object.

Link copied to clipboard
val Account.Settings.language: Language

Parsed "language" object.

Link copied to clipboard
val Moment.lastPublishTime: CreatedAt

Parsed "lastPublishTime" object.

Link copied to clipboard
val Status.likeCount: Int

Compatibility extension to Status.favoriteCount.

Link copied to clipboard
val Status.liked: Boolean

Compatibility extension to Status.favorited.

Link copied to clipboard
val User.likesCount: Int

Compatibility extension to User.favouritesCount.

Link copied to clipboard
val Language.locale: Locale

New Locale instance for this "lang" value.

Link copied to clipboard
val Status.quotedStatusIdObj: StatusID?

Parsed status id object for "quoted_status_id.

Link copied to clipboard
val ApiResponse<*>.rateLimit: RateLimit?

Twitter API rate limit. If response header does not provide such information, returns null.

val PenicillinException.rateLimit: RateLimit?

Twitter API rate limit. If response header does not provide such information or response is null, returns null.

Link copied to clipboard
val ApiResponse<*>.responseTimeMs: Int?

"x-response-time" value from response header. if the header is absent or invalid, returns null.

Link copied to clipboard
val ApiRequestBuilder.session: Session

Shorthand extension to ApiClient.

val ApiRequest.session: Session

Shorthand extension to ApiClient.

val ApiAction<*>.session: Session

Shorthand extension to ApiClient.

val ApiResponse<*>.session: Session

Shorthand extension to ApiClient.

Link copied to clipboard
val MediaEntity.sourceStatusIdObj: StatusID?

Parsed status id object for "source_status_id".

Link copied to clipboard
val Status.via: Via

Parsed status source.