Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.0"
".": "0.4.1"
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.4.1 (2024-11-12)

Full Changelog: [v0.4.0...v0.4.1](https://github.com/orbcorp/orb-java/compare/v0.4.0...v0.4.1)

### Bug Fixes

* **internal:** add missing options ([1ed6c28](https://github.com/orbcorp/orb-java/commit/1ed6c28c1dacee3121ae2fad5645ea84b5486737))


### Chores

* rebuild project due to codegen change ([#105](https://github.com/orbcorp/orb-java/issues/105)) ([6c52ea7](https://github.com/orbcorp/orb-java/commit/6c52ea7a17936f5f675d51b1bcc1a3b6d4816c56))
* rebuild project due to codegen change ([#107](https://github.com/orbcorp/orb-java/issues/107)) ([0365098](https://github.com/orbcorp/orb-java/commit/0365098b47e408203b0bc2bc4d723ef2c577fe60))

## 0.4.0 (2024-11-06)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/orbcorp/orb-java/compare/v0.3.0...v0.4.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.4.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.4.1)

<!-- x-release-please-end -->

Expand All @@ -25,7 +25,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.with
<!-- x-release-please-start-version -->

```kotlin
implementation("com.withorb.api:orb-java:0.4.0")
implementation("com.withorb.api:orb-java:0.4.1")
```

#### Maven
Expand All @@ -34,7 +34,7 @@ implementation("com.withorb.api:orb-java:0.4.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group = "com.withorb.api"
version = "0.4.0" // x-release-please-version
version = "0.4.1" // x-release-please-version
}


1 change: 0 additions & 1 deletion orb-java-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
dependencies {
api(project(":orb-java-core"))

implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

testImplementation(kotlin("test"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.withorb.api.client.okhttp

import com.google.common.collect.ListMultimap
import com.google.common.collect.MultimapBuilder
import com.withorb.api.core.RequestOptions
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.HttpClient
import com.withorb.api.core.http.HttpMethod
import com.withorb.api.core.http.HttpRequest
Expand All @@ -16,7 +15,6 @@ import java.time.Duration
import java.util.concurrent.CompletableFuture
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
Expand Down Expand Up @@ -95,7 +93,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
}

val builder = Request.Builder().url(toUrl()).method(method.name, body)
headers.forEach(builder::header)
headers.names().forEach { name ->
headers.values(name).forEach { builder.header(name, it) }
}

return builder.build()
}
Expand All @@ -107,7 +107,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

val builder = baseUrl.newBuilder()
pathSegments.forEach(builder::addPathSegment)
queryParams.forEach(builder::addQueryParameter)
queryParams.keys().forEach { key ->
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
}

return builder.toString()
}
Expand All @@ -133,21 +135,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
return object : HttpResponse {
override fun statusCode(): Int = code

override fun headers(): ListMultimap<String, String> = headers
override fun headers(): Headers = headers

override fun body(): InputStream = body!!.byteStream()

override fun close() = body!!.close()
}
}

private fun Headers.toHeaders(): ListMultimap<String, String> {
val headers =
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
.arrayListValues()
.build<String, String>()
forEach { pair -> headers.put(pair.first, pair.second) }
return headers
private fun okhttp3.Headers.toHeaders(): Headers {
val headersBuilder = Headers.builder()
forEach { (name, value) -> headersBuilder.put(name, value) }
return headersBuilder.build()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.withorb.api.client.OrbClient
import com.withorb.api.client.OrbClientImpl
import com.withorb.api.core.ClientOptions
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.QueryParams
import java.net.Proxy
import java.time.Clock
import java.time.Duration
Expand Down Expand Up @@ -36,6 +38,8 @@ class OrbOkHttpClient private constructor() {

fun clock(clock: Clock) = apply { clientOptions.clock(clock) }

fun headers(headers: Headers) = apply { clientOptions.headers(headers) }

fun headers(headers: Map<String, Iterable<String>>) = apply {
clientOptions.headers(headers)
}
Expand All @@ -46,6 +50,8 @@ class OrbOkHttpClient private constructor() {
clientOptions.putHeaders(name, values)
}

fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }

fun putAllHeaders(headers: Map<String, Iterable<String>>) = apply {
clientOptions.putAllHeaders(headers)
}
Expand All @@ -58,6 +64,8 @@ class OrbOkHttpClient private constructor() {
clientOptions.replaceHeaders(name, values)
}

fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }

fun replaceAllHeaders(headers: Map<String, Iterable<String>>) = apply {
clientOptions.replaceAllHeaders(headers)
}
Expand All @@ -66,6 +74,8 @@ class OrbOkHttpClient private constructor() {

fun removeAllHeaders(names: Set<String>) = apply { clientOptions.removeAllHeaders(names) }

fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }

fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.queryParams(queryParams)
}
Expand All @@ -78,6 +88,10 @@ class OrbOkHttpClient private constructor() {
clientOptions.putQueryParams(key, values)
}

fun putAllQueryParams(queryParams: QueryParams) = apply {
clientOptions.putAllQueryParams(queryParams)
}

fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.putAllQueryParams(queryParams)
}
Expand All @@ -90,6 +104,10 @@ class OrbOkHttpClient private constructor() {
clientOptions.replaceQueryParams(key, values)
}

fun replaceAllQueryParams(queryParams: QueryParams) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}

fun replaceAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.withorb.api.client.OrbClientAsync
import com.withorb.api.client.OrbClientAsyncImpl
import com.withorb.api.core.ClientOptions
import com.withorb.api.core.http.Headers
import com.withorb.api.core.http.QueryParams
import java.net.Proxy
import java.time.Clock
import java.time.Duration
Expand Down Expand Up @@ -36,6 +38,8 @@ class OrbOkHttpClientAsync private constructor() {

fun clock(clock: Clock) = apply { clientOptions.clock(clock) }

fun headers(headers: Headers) = apply { clientOptions.headers(headers) }

fun headers(headers: Map<String, Iterable<String>>) = apply {
clientOptions.headers(headers)
}
Expand All @@ -46,6 +50,8 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.putHeaders(name, values)
}

fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) }

fun putAllHeaders(headers: Map<String, Iterable<String>>) = apply {
clientOptions.putAllHeaders(headers)
}
Expand All @@ -58,6 +64,8 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.replaceHeaders(name, values)
}

fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) }

fun replaceAllHeaders(headers: Map<String, Iterable<String>>) = apply {
clientOptions.replaceAllHeaders(headers)
}
Expand All @@ -66,6 +74,8 @@ class OrbOkHttpClientAsync private constructor() {

fun removeAllHeaders(names: Set<String>) = apply { clientOptions.removeAllHeaders(names) }

fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) }

fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.queryParams(queryParams)
}
Expand All @@ -78,6 +88,10 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.putQueryParams(key, values)
}

fun putAllQueryParams(queryParams: QueryParams) = apply {
clientOptions.putAllQueryParams(queryParams)
}

fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.putAllQueryParams(queryParams)
}
Expand All @@ -90,6 +104,10 @@ class OrbOkHttpClientAsync private constructor() {
clientOptions.replaceQueryParams(key, values)
}

fun replaceAllQueryParams(queryParams: QueryParams) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}

fun replaceAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
clientOptions.replaceAllQueryParams(queryParams)
}
Expand Down
1 change: 0 additions & 1 deletion orb-java-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
dependencies {
api("com.fasterxml.jackson.core:jackson-core:2.14.3")
api("com.fasterxml.jackson.core:jackson-databind:2.14.3")
api("com.google.guava:guava:33.0.0-jre")

implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ constructor(
) : OrbClientAsync {

private val clientOptionsWithUserAgent =
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ constructor(
) : OrbClient {

private val clientOptionsWithUserAgent =
if (clientOptions.headers.containsKey("User-Agent")) clientOptions
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
else
clientOptions
.toBuilder()
Expand Down
Loading