Skip to content

Commit fed044d

Browse files
feat(api): api update
1 parent e27c90d commit fed044d

6 files changed

Lines changed: 45 additions & 68 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-863ddc13e032497459a639cf02a16349831dda7e39557cbd5ce33da34d086b02.yml
3-
openapi_spec_hash: f972aac9618fe8df340d96344b3d0578
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-737dbedd830e2c989387e90a9bb5baa3915306ecfef2e46b09d02cb1879f043c.yml
3+
openapi_spec_hash: 7bc21f4c6d5fd39c1a3b22626846ca87
44
config_hash: 6f10592c7d0c3bafefc1271472283217

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ To set a custom timeout, configure the method call using the `timeout` method:
318318
```java
319319
import com.branddev.api.models.brand.BrandRetrieveResponse;
320320

321-
BrandRetrieveResponse brand = client.brand().retrieve(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build());
321+
BrandRetrieveResponse brand = client.brand().retrieve(
322+
params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()
323+
);
322324
```
323325

324326
Or configure the default for all method calls at the client level:
@@ -502,10 +504,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](brand-de
502504

503505
```java
504506
import com.branddev.api.core.JsonMissing;
505-
import com.branddev.api.models.brand.BrandAiProductsParams;
506507
import com.branddev.api.models.brand.BrandRetrieveParams;
507508

508-
BrandRetrieveParams params = BrandAiProductsParams.builder()
509+
BrandRetrieveParams params = BrandRetrieveParams.builder()
509510
.domain(JsonMissing.of())
510511
.build();
511512
```
@@ -583,7 +584,9 @@ Or configure the method call to validate the response using the `responseValidat
583584
```java
584585
import com.branddev.api.models.brand.BrandRetrieveResponse;
585586

586-
BrandRetrieveResponse brand = client.brand().retrieve(RequestOptions.builder().responseValidation(true).build());
587+
BrandRetrieveResponse brand = client.brand().retrieve(
588+
params, RequestOptions.builder().responseValidation(true).build()
589+
);
587590
```
588591

589592
Or configure the default for all method calls at the client level:

brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.branddev.api.models.brand
55
import com.branddev.api.core.Enum
66
import com.branddev.api.core.JsonField
77
import com.branddev.api.core.Params
8+
import com.branddev.api.core.checkRequired
89
import com.branddev.api.core.http.Headers
910
import com.branddev.api.core.http.QueryParams
1011
import com.branddev.api.errors.BrandDevInvalidDataException
@@ -16,7 +17,7 @@ import kotlin.jvm.optionals.getOrNull
1617
/** Retrieve logos, backdrops, colors, industry, description, and more from any domain */
1718
class BrandRetrieveParams
1819
private constructor(
19-
private val domain: String?,
20+
private val domain: String,
2021
private val forceLanguage: ForceLanguage?,
2122
private val maxSpeed: Boolean?,
2223
private val timeoutMs: Long?,
@@ -28,7 +29,7 @@ private constructor(
2829
* Domain name to retrieve brand data for (e.g., 'example.com', 'google.com'). Cannot be used
2930
* with name or ticker parameters.
3031
*/
31-
fun domain(): Optional<String> = Optional.ofNullable(domain)
32+
fun domain(): String = domain
3233

3334
/**
3435
* Optional parameter to force the language of the retrieved brand data. Works with all three
@@ -60,9 +61,14 @@ private constructor(
6061

6162
companion object {
6263

63-
@JvmStatic fun none(): BrandRetrieveParams = builder().build()
64-
65-
/** Returns a mutable builder for constructing an instance of [BrandRetrieveParams]. */
64+
/**
65+
* Returns a mutable builder for constructing an instance of [BrandRetrieveParams].
66+
*
67+
* The following fields are required:
68+
* ```java
69+
* .domain()
70+
* ```
71+
*/
6672
@JvmStatic fun builder() = Builder()
6773
}
6874

@@ -90,10 +96,7 @@ private constructor(
9096
* Domain name to retrieve brand data for (e.g., 'example.com', 'google.com'). Cannot be
9197
* used with name or ticker parameters.
9298
*/
93-
fun domain(domain: String?) = apply { this.domain = domain }
94-
95-
/** Alias for calling [Builder.domain] with `domain.orElse(null)`. */
96-
fun domain(domain: Optional<String>) = domain(domain.getOrNull())
99+
fun domain(domain: String) = apply { this.domain = domain }
97100

98101
/**
99102
* Optional parameter to force the language of the retrieved brand data. Works with all
@@ -243,10 +246,17 @@ private constructor(
243246
* Returns an immutable instance of [BrandRetrieveParams].
244247
*
245248
* Further updates to this [Builder] will not mutate the returned instance.
249+
*
250+
* The following fields are required:
251+
* ```java
252+
* .domain()
253+
* ```
254+
*
255+
* @throws IllegalStateException if any required field is unset.
246256
*/
247257
fun build(): BrandRetrieveParams =
248258
BrandRetrieveParams(
249-
domain,
259+
checkRequired("domain", domain),
250260
forceLanguage,
251261
maxSpeed,
252262
timeoutMs,
@@ -260,7 +270,7 @@ private constructor(
260270
override fun _queryParams(): QueryParams =
261271
QueryParams.builder()
262272
.apply {
263-
domain?.let { put("domain", it) }
273+
put("domain", domain)
264274
forceLanguage?.let { put("force_language", it.toString()) }
265275
maxSpeed?.let { put("maxSpeed", it.toString()) }
266276
timeoutMs?.let { put("timeoutMS", it.toString()) }

brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,15 @@ interface BrandServiceAsync {
5353
fun withOptions(modifier: Consumer<ClientOptions.Builder>): BrandServiceAsync
5454

5555
/** Retrieve logos, backdrops, colors, industry, description, and more from any domain */
56-
fun retrieve(): CompletableFuture<BrandRetrieveResponse> = retrieve(BrandRetrieveParams.none())
56+
fun retrieve(params: BrandRetrieveParams): CompletableFuture<BrandRetrieveResponse> =
57+
retrieve(params, RequestOptions.none())
5758

5859
/** @see retrieve */
5960
fun retrieve(
60-
params: BrandRetrieveParams = BrandRetrieveParams.none(),
61+
params: BrandRetrieveParams,
6162
requestOptions: RequestOptions = RequestOptions.none(),
6263
): CompletableFuture<BrandRetrieveResponse>
6364

64-
/** @see retrieve */
65-
fun retrieve(
66-
params: BrandRetrieveParams = BrandRetrieveParams.none()
67-
): CompletableFuture<BrandRetrieveResponse> = retrieve(params, RequestOptions.none())
68-
69-
/** @see retrieve */
70-
fun retrieve(requestOptions: RequestOptions): CompletableFuture<BrandRetrieveResponse> =
71-
retrieve(BrandRetrieveParams.none(), requestOptions)
72-
7365
/**
7466
* Beta feature: Extract product information from a brand's website. Brand.dev will analyze the
7567
* website and return a list of products with details such as name, description, image, pricing,
@@ -290,26 +282,16 @@ interface BrandServiceAsync {
290282
* Returns a raw HTTP response for `get /brand/retrieve`, but is otherwise the same as
291283
* [BrandServiceAsync.retrieve].
292284
*/
293-
fun retrieve(): CompletableFuture<HttpResponseFor<BrandRetrieveResponse>> =
294-
retrieve(BrandRetrieveParams.none())
295-
296-
/** @see retrieve */
297285
fun retrieve(
298-
params: BrandRetrieveParams = BrandRetrieveParams.none(),
299-
requestOptions: RequestOptions = RequestOptions.none(),
300-
): CompletableFuture<HttpResponseFor<BrandRetrieveResponse>>
301-
302-
/** @see retrieve */
303-
fun retrieve(
304-
params: BrandRetrieveParams = BrandRetrieveParams.none()
286+
params: BrandRetrieveParams
305287
): CompletableFuture<HttpResponseFor<BrandRetrieveResponse>> =
306288
retrieve(params, RequestOptions.none())
307289

308290
/** @see retrieve */
309291
fun retrieve(
310-
requestOptions: RequestOptions
311-
): CompletableFuture<HttpResponseFor<BrandRetrieveResponse>> =
312-
retrieve(BrandRetrieveParams.none(), requestOptions)
292+
params: BrandRetrieveParams,
293+
requestOptions: RequestOptions = RequestOptions.none(),
294+
): CompletableFuture<HttpResponseFor<BrandRetrieveResponse>>
313295

314296
/**
315297
* Returns a raw HTTP response for `post /brand/ai/products`, but is otherwise the same as

brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,15 @@ interface BrandService {
5353
fun withOptions(modifier: Consumer<ClientOptions.Builder>): BrandService
5454

5555
/** Retrieve logos, backdrops, colors, industry, description, and more from any domain */
56-
fun retrieve(): BrandRetrieveResponse = retrieve(BrandRetrieveParams.none())
56+
fun retrieve(params: BrandRetrieveParams): BrandRetrieveResponse =
57+
retrieve(params, RequestOptions.none())
5758

5859
/** @see retrieve */
5960
fun retrieve(
60-
params: BrandRetrieveParams = BrandRetrieveParams.none(),
61+
params: BrandRetrieveParams,
6162
requestOptions: RequestOptions = RequestOptions.none(),
6263
): BrandRetrieveResponse
6364

64-
/** @see retrieve */
65-
fun retrieve(params: BrandRetrieveParams = BrandRetrieveParams.none()): BrandRetrieveResponse =
66-
retrieve(params, RequestOptions.none())
67-
68-
/** @see retrieve */
69-
fun retrieve(requestOptions: RequestOptions): BrandRetrieveResponse =
70-
retrieve(BrandRetrieveParams.none(), requestOptions)
71-
7265
/**
7366
* Beta feature: Extract product information from a brand's website. Brand.dev will analyze the
7467
* website and return a list of products with details such as name, description, image, pricing,
@@ -273,27 +266,16 @@ interface BrandService {
273266
* [BrandService.retrieve].
274267
*/
275268
@MustBeClosed
276-
fun retrieve(): HttpResponseFor<BrandRetrieveResponse> =
277-
retrieve(BrandRetrieveParams.none())
269+
fun retrieve(params: BrandRetrieveParams): HttpResponseFor<BrandRetrieveResponse> =
270+
retrieve(params, RequestOptions.none())
278271

279272
/** @see retrieve */
280273
@MustBeClosed
281274
fun retrieve(
282-
params: BrandRetrieveParams = BrandRetrieveParams.none(),
275+
params: BrandRetrieveParams,
283276
requestOptions: RequestOptions = RequestOptions.none(),
284277
): HttpResponseFor<BrandRetrieveResponse>
285278

286-
/** @see retrieve */
287-
@MustBeClosed
288-
fun retrieve(
289-
params: BrandRetrieveParams = BrandRetrieveParams.none()
290-
): HttpResponseFor<BrandRetrieveResponse> = retrieve(params, RequestOptions.none())
291-
292-
/** @see retrieve */
293-
@MustBeClosed
294-
fun retrieve(requestOptions: RequestOptions): HttpResponseFor<BrandRetrieveResponse> =
295-
retrieve(BrandRetrieveParams.none(), requestOptions)
296-
297279
/**
298280
* Returns a raw HTTP response for `post /brand/ai/products`, but is otherwise the same as
299281
* [BrandService.aiProducts].

brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ internal class BrandRetrieveParamsTest {
4343

4444
@Test
4545
fun queryParamsWithoutOptionalFields() {
46-
val params = BrandRetrieveParams.builder().build()
46+
val params = BrandRetrieveParams.builder().domain("domain").build()
4747

4848
val queryParams = params._queryParams()
4949

50-
assertThat(queryParams).isEqualTo(QueryParams.builder().build())
50+
assertThat(queryParams).isEqualTo(QueryParams.builder().put("domain", "domain").build())
5151
}
5252
}

0 commit comments

Comments
 (0)