Skip to content

Instantly share code, notes, and snippets.

@caseykulm
Last active July 23, 2017 19:43
Show Gist options
  • Save caseykulm/b399a87e203ee58b5de1d146c485cb7f to your computer and use it in GitHub Desktop.
Save caseykulm/b399a87e203ee58b5de1d146c485cb7f to your computer and use it in GitHub Desktop.
Reverse before
class LibOptions(config1: String, config2: String) {
fun toHttpUrl(): HttpUrl {
httpUrlBuilder = super().newBuilder()
httpUrlBuilder.addQueryParameter("option_1", option1)
httpUrlBuilder.addQueryParameter("option_2", option2)
return httpUrlBuilder.build()
}
}
data class UserRequest(val userName) {
fun toOkRequest(): okhttp3.Request {
val libOptions = LibOptions.getInstance()
val requestBuilder = okhttp3.Request.Builder()
.addQueryParam("config_1", libOptions.getConfig1())
.addQueryParam("config_2", libOptions.getConfig2())
.addQueryParam("user_name", userName)
return requestBuilder.build()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment