EquinoxRequester

abstract class EquinoxRequester(    host: String,     userId: String? = null,     userToken: String? = null,     debugMode: Boolean = false,     connectionTimeout: Long = DEFAULT_REQUEST_TIMEOUT,     connectionErrorMessage: String,     byPassSSLValidation: Boolean = false) : Requester

The EquinoxRequester class is useful to communicate with backend based on the SpringBoot framework with the requests pre-implemented

Author

N7ghtm4r3 - Tecknobit

Since

1.0.6

Parameters

host

The host address where is running the backend

userId

The user identifier

userToken

The user token

debugMode

Whether the requester is still in development and who is developing needs the log of the requester's workflow, if it is enabled all the details of the requests sent and the errors occurred will be printed in the console

connectionTimeout

Time to keep alive request then throw the connection refused error

connectionErrorMessage

The error to send when a connection error occurred

byPassSSLValidation

Whether bypass the SSL certificates validation, this for example when is a self-signed the certificate USE WITH CAUTION

Constructors

Link copied to clipboard
constructor(host: String, userId: String? = null, userToken: String? = null, debugMode: Boolean = false, connectionTimeout: Long = DEFAULT_REQUEST_TIMEOUT, connectionErrorMessage: String, byPassSSLValidation: Boolean = false)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
protected val connectionTimeout: Long
Link copied to clipboard
protected var debugMode: Boolean
Link copied to clipboard
protected var host: String
Link copied to clipboard
private val initHost: () -> Unit
Link copied to clipboard
protected var interceptorAction: () -> Unit?
Link copied to clipboard
protected val ktorClient: HttpClient
Link copied to clipboard
private val loggerMutex: Mutex
Link copied to clipboard
Link copied to clipboard
protected var userId: String?
Link copied to clipboard
protected var userToken: String?

Functions

Link copied to clipboard
protected fun assembleCustomEndpointPath(customEndpoint: String, subEndpoint: String = ""): String

Method used to assemble the endpoint to make the request to the custom controllers

Link copied to clipboard
protected fun assembleUsersEndpointPath(endpoint: String = ""): String

Method used to assemble the endpoint to make the request to the users controller

Link copied to clipboard
fun attachInterceptorOnRequest(interceptor: () -> Unit)
Link copied to clipboard
open suspend fun changeEmail(newEmail: String): JsonObject

Method used to request the to change the email of the user

Link copied to clipboard
open override fun changeHost(host: String)

Method used to change, during the runtime for example when the session changed, the host address to make the requests

Link copied to clipboard
open suspend fun changeLanguage(newLanguage: String): JsonObject

Method used to request the to change the language of the user

Link copied to clipboard
open suspend fun changePassword(newPassword: String): JsonObject

Method used to request the to change the password of the user

Link copied to clipboard
open suspend fun changeProfilePic(profilePicName: String, profilePicBytes: ByteArray): JsonObject

Method used to request the to change the profile pic of the user

Link copied to clipboard
open fun clearSession()
Link copied to clipboard
protected fun connectionErrorMessage(): JsonObject
Link copied to clipboard
protected fun createPaginationQuery(page: Int, pageSize: Int): JsonObject
Link copied to clipboard
open suspend fun deleteAccount(): JsonObject

Method used to request the to delete the account of the user

Link copied to clipboard
protected suspend fun execDelete(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: JsonObject?): JsonObject
Link copied to clipboard
protected suspend fun execGet(endpoint: String, headers: Map<String, Any>, query: JsonObject?): JsonObject
Link copied to clipboard
protected suspend fun execMultipartRequest(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: PartData): JsonObject
protected suspend fun execMultipartRequest(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: List<PartData>): JsonObject
Link copied to clipboard
protected suspend fun execPatch(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: JsonObject): JsonObject
Link copied to clipboard
protected suspend fun execPost(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: JsonObject): JsonObject
Link copied to clipboard
protected suspend fun execPut(endpoint: String, headers: Map<String, Any>, query: JsonObject?, payload: JsonObject): JsonObject
Link copied to clipboard
private suspend fun execRequest(    method: RequestMethod,     endpoint: String,     headers: Map<String, Any>,     query: JsonObject?,     payload: JsonObject?): JsonObject
Link copied to clipboard
suspend fun getDynamicAccountData(): JsonObject

Method used to request the dynamic data of the user

Link copied to clipboard
protected open fun getSignInPayload(email: String, password: String, vararg custom: Any?): JsonObject

Method used to create the payload for the signIn request.

Link copied to clipboard
protected open fun getSignUpPayload(    serverSecret: String,     name: String,     surname: String,     email: String,     password: String,     language: String,     vararg custom: Any?): JsonObject

Method used to create the payload for the signUp request.

Link copied to clipboard
protected fun interceptRequest()
Link copied to clipboard
private fun logError(exception: Exception)
Link copied to clipboard
private fun logHeaders(headers: Map<String, Any>)
Link copied to clipboard
private fun logQuery(query: JsonObject?)
Link copied to clipboard
private suspend fun logRequestInfo(    requestUrl: String,     headers: Map<String, Any>,     query: JsonObject?,     requestPayloadInfo: () -> Unit,     response: JsonObject?)
Link copied to clipboard
private fun HttpRequestBuilder.prepareRequest(headers: Map<String, Any>, contentType: ContentType?, query: JsonObject?, payload: () -> Unit?)
Link copied to clipboard
private fun JsonObject.prettyPrint()
Link copied to clipboard
fun setUserCredentials(userId: String?, userToken: String?)
Link copied to clipboard
open suspend fun signIn(email: String, password: String, vararg custom: Any?): JsonObject

Method used to request the to sign in the Equinox's system

Link copied to clipboard
suspend fun signUp(    serverSecret: String,     name: String,     surname: String,     email: String,     password: String,     language: String,     vararg custom: Any?): JsonObject

Method used to request the to sign up in the Equinox's system