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.1.0-alpha.7"
".": "0.1.0-alpha.8"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-70f44e886c51bd700af031ad9b5c8f0042ef15fde038ba83ed08f61cd9d05266.yml
openapi_spec_hash: 9b834ba9e373689a8e2fbd8312b1f2de
config_hash: 8f3ee44d690a305369555016a77ed016
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-1ff30126e780960cb04d5855fb8e9227099f91e1a3293f656cfaad50e1d7eb1c.yml
openapi_spec_hash: 42c1034ce32cbe5410b124e577998de8
config_hash: 4b10254ea5b8e26ce632222b94a918aa
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.1.0-alpha.8 (2025-07-23)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)

### Features

* **api:** manual updates ([7b4fc3a](https://github.com/brand-dot-dev/java-sdk/commit/7b4fc3a69f6df006100550d34340c0451b508cdd))
* **client:** add `{QueryParams,Headers}#put(String, JsonValue)` methods ([e97cbca](https://github.com/brand-dot-dev/java-sdk/commit/e97cbca1c60c8d7ed94838f5553787da727c37dc))
* **client:** allow configuring env via system properties ([6dd2e71](https://github.com/brand-dot-dev/java-sdk/commit/6dd2e71fb4af9920c474b284ba66814f1f74f09b))


### Bug Fixes

* **internal:** set maven publish url ([65c2d32](https://github.com/brand-dot-dev/java-sdk/commit/65c2d329bc9990f1aa73827720cd5e9ea626b5c3))

## 0.1.0-alpha.7 (2025-07-21)

Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.7)
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.7/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7)
[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.8)
[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.8/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.8)

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

Expand All @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/).

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

Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7).
Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.8).

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

Expand All @@ -24,7 +24,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/b
### Gradle

```kotlin
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.7")
implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.8")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.7")
<dependency>
<groupId>com.branddev.api</groupId>
<artifactId>brand-dev-java</artifactId>
<version>0.1.0-alpha.7</version>
<version>0.1.0-alpha.8</version>
</dependency>
```

Expand All @@ -51,7 +51,8 @@ import com.branddev.api.client.okhttp.BrandDevOkHttpClient;
import com.branddev.api.models.brand.BrandRetrieveParams;
import com.branddev.api.models.brand.BrandRetrieveResponse;

// Configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
// Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties
// Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
BrandDevClient client = BrandDevOkHttpClient.fromEnv();

BrandRetrieveParams params = BrandRetrieveParams.builder()
Expand All @@ -62,13 +63,14 @@ BrandRetrieveResponse brand = client.brand().retrieve(params);

## Client configuration

Configure the client using environment variables:
Configure the client using system properties or environment variables:

```java
import com.branddev.api.client.BrandDevClient;
import com.branddev.api.client.okhttp.BrandDevOkHttpClient;

// Configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
// Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties
// Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
BrandDevClient client = BrandDevOkHttpClient.fromEnv();
```

Expand All @@ -90,18 +92,21 @@ import com.branddev.api.client.BrandDevClient;
import com.branddev.api.client.okhttp.BrandDevOkHttpClient;

BrandDevClient client = BrandDevOkHttpClient.builder()
// Configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
// Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties
Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
.fromEnv()
.apiKey("My API Key")
.build();
```

See this table for the available options:

| Setter | Environment variable | Required | Default value |
| --------- | -------------------- | -------- | ---------------------------- |
| `apiKey` | `BRAND_DEV_API_KEY` | true | - |
| `baseUrl` | `BRAND_DEV_BASE_URL` | true | `"https://api.brand.dev/v1"` |
| Setter | System property | Environment variable | Required | Default value |
| --------- | ------------------ | -------------------- | -------- | ---------------------------- |
| `apiKey` | `branddev.apiKey` | `BRAND_DEV_API_KEY` | true | - |
| `baseUrl` | `branddev.baseUrl` | `BRAND_DEV_BASE_URL` | true | `"https://api.brand.dev/v1"` |

System properties take precedence over environment variables.

> [!TIP]
> Don't create more than one client in the same application. Each client has a connection pool and
Expand Down Expand Up @@ -147,7 +152,8 @@ import com.branddev.api.models.brand.BrandRetrieveParams;
import com.branddev.api.models.brand.BrandRetrieveResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
// Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties
// Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
BrandDevClient client = BrandDevOkHttpClient.fromEnv();

BrandRetrieveParams params = BrandRetrieveParams.builder()
Expand All @@ -165,7 +171,8 @@ import com.branddev.api.models.brand.BrandRetrieveParams;
import com.branddev.api.models.brand.BrandRetrieveResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
// Configures using the `branddev.apiKey` and `branddev.baseUrl` system properties
// Or configures using the `BRAND_DEV_API_KEY` and `BRAND_DEV_BASE_URL` environment variables
BrandDevClientAsync client = BrandDevOkHttpClientAsync.fromEnv();

BrandRetrieveParams params = BrandRetrieveParams.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ private constructor(
fun timeout(): Timeout = timeout

fun fromEnv() = apply {
System.getenv("BRAND_DEV_BASE_URL")?.let { baseUrl(it) }
System.getenv("BRAND_DEV_API_KEY")?.let { apiKey(it) }
(System.getProperty("branddev.baseUrl") ?: System.getenv("BRAND_DEV_BASE_URL"))?.let {
baseUrl(it)
}
(System.getProperty("branddev.apiKey") ?: System.getenv("BRAND_DEV_API_KEY"))?.let {
apiKey(it)
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// File generated from our OpenAPI spec by Stainless.

package com.branddev.api.core.http

import com.branddev.api.core.JsonArray
import com.branddev.api.core.JsonBoolean
import com.branddev.api.core.JsonMissing
import com.branddev.api.core.JsonNull
import com.branddev.api.core.JsonNumber
import com.branddev.api.core.JsonObject
import com.branddev.api.core.JsonString
import com.branddev.api.core.JsonValue
import com.branddev.api.core.toImmutable
import java.util.TreeMap

Expand Down Expand Up @@ -28,6 +38,19 @@ private constructor(
TreeMap(String.CASE_INSENSITIVE_ORDER)
private var size: Int = 0

fun put(name: String, value: JsonValue): Builder = apply {
when (value) {
is JsonMissing,
is JsonNull -> {}
is JsonBoolean -> put(name, value.value.toString())
is JsonNumber -> put(name, value.value.toString())
is JsonString -> put(name, value.value)
is JsonArray -> value.values.forEach { put(name, it) }
is JsonObject ->
value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) }
}
}

fun put(name: String, value: String) = apply {
map.getOrPut(name) { mutableListOf() }.add(value)
size++
Expand All @@ -41,15 +64,6 @@ private constructor(
headers.names().forEach { put(it, headers.values(it)) }
}

fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size }

fun removeAll(names: Set<String>) = apply { names.forEach(::remove) }

fun clear() = apply {
map.clear()
size = 0
}

fun replace(name: String, value: String) = apply {
remove(name)
put(name, value)
Expand All @@ -68,6 +82,15 @@ private constructor(
headers.names().forEach { replace(it, headers.values(it)) }
}

fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size }

fun removeAll(names: Set<String>) = apply { names.forEach(::remove) }

fun clear() = apply {
map.clear()
size = 0
}

fun build() =
Headers(
map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

package com.branddev.api.core.http

import com.branddev.api.core.JsonArray
import com.branddev.api.core.JsonBoolean
import com.branddev.api.core.JsonMissing
import com.branddev.api.core.JsonNull
import com.branddev.api.core.JsonNumber
import com.branddev.api.core.JsonObject
import com.branddev.api.core.JsonString
import com.branddev.api.core.JsonValue
import com.branddev.api.core.toImmutable

class QueryParams
Expand All @@ -28,6 +36,39 @@ private constructor(
private val map: MutableMap<String, MutableList<String>> = mutableMapOf()
private var size: Int = 0

fun put(key: String, value: JsonValue): Builder = apply {
when (value) {
is JsonMissing,
is JsonNull -> {}
is JsonBoolean -> put(key, value.value.toString())
is JsonNumber -> put(key, value.value.toString())
is JsonString -> put(key, value.value)
is JsonArray ->
put(
key,
value.values
.asSequence()
.mapNotNull {
when (it) {
is JsonMissing,
is JsonNull -> null
is JsonBoolean -> it.value.toString()
is JsonNumber -> it.value.toString()
is JsonString -> it.value
is JsonArray,
is JsonObject ->
throw IllegalArgumentException(
"Cannot comma separate non-primitives in query params"
)
}
}
.joinToString(","),
)
is JsonObject ->
value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) }
}
}

fun put(key: String, value: String) = apply {
map.getOrPut(key) { mutableListOf() }.add(value)
size++
Expand Down
Loading
Loading