Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed jwalgemoed/data-classes.kt Secret
Last active Dec 28, 2017

Embed
What would you like to do?
data class Contract private constructor(
val request: Request,
val response: Response
) {
class Builder {
var request = Request.Builder()
var response = Response.Builder()
fun build(): Contract {
return Contract(request.build(), response.build())
}
}
}
class Request private constructor(
val path: String,
val method: HttpMethod,
val body: String?,
val headers: HttpHeaders
) {
class Builder {
var path = ""
var method = HttpMethod.GET
var body: String? = null
var expect = Response.Builder()
var headers = HttpHeaders()
fun build(): Request {
return Request(path, method, body?.trimIndent(), headers)
}
}
}
class Response private constructor(
val status: HttpStatus,
val body: String?
) {
class Builder {
var status = HttpStatus.OK
var body: String? = null
fun build(): Response {
return Response(status, body?.trimIndent())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.