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

com.increase.api.core.RequestOptions.kt Maven / Gradle / Ivy

There is a newer version: 0.142.0
Show newest version
package com.increase.api.core

import java.time.Duration

class RequestOptions
private constructor(
    val responseValidation: Boolean?,
    val timeout: Duration?,
) {
    fun applyDefaults(options: RequestOptions): RequestOptions {
        return RequestOptions(
            responseValidation = this.responseValidation ?: options.responseValidation,
            timeout = this.timeout ?: options.timeout
        )
    }

    companion object {

        private val NONE = builder().build()

        fun none() = NONE

        fun builder() = Builder()
    }

    class Builder {
        private var responseValidation: Boolean? = null
        private var timeout: Duration? = null

        fun responseValidation(responseValidation: Boolean) = apply {
            this.responseValidation = responseValidation
        }

        fun timeout(timeout: Duration) = apply { this.timeout = timeout }

        fun build(): RequestOptions {
            return RequestOptions(responseValidation, timeout)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy