Skip to content

Commit

Permalink
URL builder code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jspetrak committed Dec 10, 2017
1 parent f307b04 commit b1d599a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/main/kotlin/ee/smmv/fakturoid/Fakturoid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,12 @@ class Fakturoid(

private fun urlFor(localPath : String) : URI = URL("$API_BASE/$slug/$localPath").toURI()

private fun urlFor(localPath: String, params: Map<String, String>) : URI {
val u = UriComponentsBuilder
.fromHttpUrl("$API_BASE/$slug/$localPath")

with (u) {
private fun urlFor(localPath: String, params: Map<String, String>) : URI =
with (UriComponentsBuilder.fromHttpUrl("$API_BASE/$slug/$localPath")) {
params.forEach { key, value -> queryParam(key, value) }
}

return u.build()
.encode()
.toUri()
}
build().encode().toUri()
}

private fun headers(headers : HttpHeaders = HttpHeaders()) : HttpHeaders {
val cred : String = Base64.getEncoder().encodeToString("$email:$apiKey".toByteArray(StandardCharsets.UTF_8))
Expand Down

0 comments on commit b1d599a

Please sign in to comment.