OkHttpUtils

class OkHttpUtils(url: String)

Utility class for making HTTP requests using OkHttp library.

Parameters

url

the base URL of the API to be called

Constructors

Link copied to clipboard
constructor(url: String)

Types

Link copied to clipboard

Properties

Link copied to clipboard
val client: OkHttpClient
Link copied to clipboard
Link copied to clipboard
val mediaType: MediaType
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addParameter(jsonObject: JSONObject, key: String, value: Any): JSONObject
Link copied to clipboard
Link copied to clipboard
fun getURL(): String
Link copied to clipboard
fun setHeaders(vararg headers: Any): String
Link copied to clipboard
fun setParameters(vararg params: Any): String

Converts an array of key-value pairs to a JSON string.

Link copied to clipboard
fun setTimeout(timeout: Int)
fun setTimeout(readTimeout: Int? = null, writeTimeout: Int? = null, connectTimeout: Int? = null)
Link copied to clipboard
fun startRequest(method: Methods, formParameters: String? = null, queryParameters: String? = null, headers: String? = null, listener: OkHttpListener)

Starts an HTTP request using OkHttp library.