AbstractAPIClient

abstract class AbstractAPIClient(val baseUrl: String, val getTokenUseCase: IGetTokenUseCase? = null, val renewTokenUseCase: IRenewTokenUseCase? = null, val logoutUseCase: ILogoutUseCase? = null, json: Json? = null, engine: HttpClientEngine? = null, block: HttpClientConfig<*>.() -> Unit = {}) : IAPIClient

Base implementation of IAPIClient using Ktor HTTP client.

Constructors

Link copied to clipboard
constructor(baseUrl: String, getTokenUseCase: IGetTokenUseCase? = null, renewTokenUseCase: IRenewTokenUseCase? = null, logoutUseCase: ILogoutUseCase? = null, json: Json? = null, engine: HttpClientEngine? = null, block: HttpClientConfig<*>.() -> Unit = {})

Properties

Link copied to clipboard
open override val baseUrl: String

Base URL of the API.

Link copied to clipboard
open override val getTokenUseCase: IGetTokenUseCase? = null

Use case to get the current token, if applicable.

Link copied to clipboard
open override val logoutUseCase: ILogoutUseCase? = null

Use case to log out, if applicable.

Link copied to clipboard
open override val renewTokenUseCase: IRenewTokenUseCase? = null

Use case to renew the token, if applicable.

Functions

Link copied to clipboard
open suspend override fun request(method: HttpMethod, path: String, builder: HttpRequestBuilder.() -> Unit): HttpResponse

Makes an HTTP request to the specified path with the given method and request builder. It also applies token management if the relevant use cases are provided.

Link copied to clipboard
open fun shouldIncludeToken(method: HttpMethod, path: String): Boolean

Determines whether to include the authentication token in the request. Can be overridden to customize behavior based on method and path. By default, it returns true for all requests.

Link copied to clipboard
open fun shouldPropagateRequestId(method: HttpMethod, path: String): Boolean

Determines whether to propagate the request ID in the request. Can be overridden to customize behavior based on method and path. By default, it returns true for all requests.