All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.shoaky.sourcedownloader.sdk.api.BaseRequest.kt Maven / Gradle / Ivy

The newest version!
package xyz.shoaky.sourcedownloader.sdk.api

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.google.common.net.MediaType

abstract class BaseRequest {

    @get:JsonIgnore
    abstract val path: String

    @get:JsonIgnore
    abstract val responseBodyType: TypeReference

    @get:JsonIgnore
    abstract val httpMethod: HttpMethod

    @get:JsonIgnore
    abstract val mediaType: MediaType

    @JsonIgnore
    val queryString = mutableMapOf()

    @JsonIgnore
    protected val httpHeaders = mutableMapOf()

    protected fun addQueryParameter(name: String, value: Any) {
        queryString[name] = value
    }

    fun httpHeaders(): Map {
        return httpHeaders
    }

    fun setHeader(name: String, value: Any) {
        httpHeaders[name] = value.toString()
    }

    companion object {
        val stringTypeReference = jacksonTypeRef()
    }

}

enum class HttpMethod {
    GET, POST, PUT, DELETE
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy