RequestBuilder

class RequestBuilder(parent: IRequestParent) : IResourceBuilder<Request>

Request resource builder

Samples

import com.yamilovs.insomnia.exporter.model.*
import com.yamilovs.insomnia.exporter.model.Collection
import com.yamilovs.insomnia.exporter.model.request.FollowRedirect
import com.yamilovs.insomnia.exporter.model.request.Method
import com.yamilovs.insomnia.exporter.model.request.authentication.EmptyAuthentication
import com.yamilovs.insomnia.exporter.model.request.body.EmptyBody
import com.yamilovs.insomnia.exporter.model.request.header.Header
import com.yamilovs.insomnia.exporter.model.request.parameter.Parameter
import java.net.URL
fun main() { 
   //sampleStart 
   val workspace = Workspace()

Request.build(workspace) {

    // setting up `name` property
    // next function call will rewrite previous value
    // mandatory method for Request resource
    name("My group name")
    name { "My group name" }

    // setting up `url` property
    // next function call will rewrite previous value
    // mandatory method for Request resource
    url("https://yamilovs.com")
    url { "https://yamilovs.com" }
    +URL("https://yamilovs.com")

    // setting up `description` property
    // next function call will rewrite previous value
    description("About request")
    description { "About request" }

    // setting up `method` property
    // next function call will rewrite previous value
    method(Method.POST)
    method { Method.POST }
    +Method.POST

    // setting up `body` property
    // next function call will rewrite previous value
    body(EmptyBody)
    body { EmptyBody }
    +EmptyBody

    // setting up `parameters` collection
    val emptyParameter = Parameter("first", "value")
    parameter(emptyParameter) // added first parameter
    parameter { emptyParameter.copy(name = "second") } // added second parameter
    +emptyParameter.copy(name = "third") // added third parameter
    parameters(listOf(emptyParameter)) // added all parameters from list
    parameters { listOf(emptyParameter) } // added all parameters from list

    // setting up `headers` collection
    val emptyHeader = Header("first", "value")
    header(emptyHeader) // added first header
    header { emptyHeader.copy(name = "second") } // added second header
    +emptyHeader.copy(name = "third") // added third header
    headers(listOf(emptyHeader)) // added all headers from list
    headers { listOf(emptyHeader) } // added all headers from list

    // setting up `authentication` property
    // next function call will rewrite previous value
    authentication(EmptyAuthentication)
    authentication { EmptyAuthentication }
    +EmptyAuthentication

    // setting request resource position
    // next function call will rewrite previous value
    metaSortKey(10)
    metaSortKey { 10 }

    // setting up `isPrivate` property
    // next function call will rewrite previous value
    private(true)
    private { true }

    // setting up `settingStoreCookies` property
    // next function call will rewrite previous value
    storeCookies(true)
    storeCookies { true }

    // setting up `settingSendCookies` property
    // next function call will rewrite previous value
    sendCookies(true)
    sendCookies { true }

    // setting up `settingDisableRenderRequestBody` property
    // next function call will rewrite previous value
    disableRenderRequestBody(true)
    disableRenderRequestBody { true }

    // setting up `settingEncodeUrl` property
    // next function call will rewrite previous value
    encodeUrl(true)
    encodeUrl { true }

    // setting up `settingRebuildPath` property
    // next function call will rewrite previous value
    rebuildPath(true)
    rebuildPath { true }

    // setting up `settingFollowRedirects` property
    // next function call will rewrite previous value
    followRedirects(FollowRedirect.ON)
    followRedirects { FollowRedirect.ON }
    +FollowRedirect.ON
} 
   //sampleEnd
}

Constructors

Link copied to clipboard
fun RequestBuilder(parent: IRequestParent)

Functions

Link copied to clipboard
fun authentication(authentication: IAuthentication): RequestBuilder
fun authentication(init: () -> IAuthentication): RequestBuilder
Link copied to clipboard
fun body(body: IBody): RequestBuilder
fun body(init: () -> IBody): RequestBuilder
Link copied to clipboard
open override fun build(): Request
Link copied to clipboard
fun description(init: () -> String): RequestBuilder
fun description(description: String): RequestBuilder
Link copied to clipboard
fun disableRenderRequestBody(disableRenderRequestBody: Boolean): RequestBuilder
fun disableRenderRequestBody(init: () -> Boolean): RequestBuilder
Link copied to clipboard
fun encodeUrl(encodeUrl: Boolean): RequestBuilder
fun encodeUrl(init: () -> Boolean): RequestBuilder
Link copied to clipboard
fun followRedirects(followRedirects: FollowRedirect): RequestBuilder
fun followRedirects(init: () -> FollowRedirect): RequestBuilder
Link copied to clipboard
fun header(header: IHeader): RequestBuilder
fun header(init: () -> IHeader): RequestBuilder
Link copied to clipboard
fun headers(init: () -> List<IHeader>): RequestBuilder
fun headers(headers: List<IHeader>): RequestBuilder
Link copied to clipboard
fun metaSortKey(init: () -> Long): RequestBuilder
fun metaSortKey(metaSortKey: Long): RequestBuilder
Link copied to clipboard
fun method(method: Method): RequestBuilder
fun method(init: () -> Method): RequestBuilder
Link copied to clipboard
fun name(init: () -> String): RequestBuilder
fun name(name: String): RequestBuilder
Link copied to clipboard
fun parameter(parameter: IParameter): RequestBuilder
fun parameter(init: () -> IParameter): RequestBuilder
Link copied to clipboard
fun parameters(init: () -> List<IParameter>): RequestBuilder
fun parameters(parameters: List<IParameter>): RequestBuilder
Link copied to clipboard
fun private(isPrivate: Boolean): RequestBuilder
fun private(init: () -> Boolean): RequestBuilder
Link copied to clipboard
fun rebuildPath(rebuildPath: Boolean): RequestBuilder
fun rebuildPath(init: () -> Boolean): RequestBuilder
Link copied to clipboard
fun sendCookies(sendCookies: Boolean): RequestBuilder
fun sendCookies(init: () -> Boolean): RequestBuilder
Link copied to clipboard
fun storeCookies(storeCookies: Boolean): RequestBuilder
fun storeCookies(init: () -> Boolean): RequestBuilder
Link copied to clipboard
operator fun FollowRedirect.unaryPlus(): RequestBuilder
operator fun Method.unaryPlus(): RequestBuilder
operator fun IAuthentication.unaryPlus(): RequestBuilder
operator fun IBody.unaryPlus(): RequestBuilder
operator fun IHeader.unaryPlus(): RequestBuilder
operator fun IParameter.unaryPlus(): RequestBuilder
operator fun URL.unaryPlus(): RequestBuilder
Link copied to clipboard
fun url(init: () -> String): RequestBuilder
fun url(url: String): RequestBuilder