Skip to content

Commit e826166

Browse files
feat(api): api update
1 parent 2656e0a commit e826166

7 files changed

Lines changed: 177 additions & 73 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-737dbedd830e2c989387e90a9bb5baa3915306ecfef2e46b09d02cb1879f043c.yml
3-
openapi_spec_hash: 7bc21f4c6d5fd39c1a3b22626846ca87
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-73562e26b663cf10185b9e98966accf5f151c6d3cf99b5e060ce5a847045e383.yml
3+
openapi_spec_hash: bf5994966b84f9dda998ad5059ff8318
44
config_hash: 6f10592c7d0c3bafefc1271472283217

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

Lines changed: 107 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.branddev.api.core.JsonField
77
import com.branddev.api.core.JsonMissing
88
import com.branddev.api.core.JsonValue
99
import com.branddev.api.core.Params
10-
import com.branddev.api.core.checkRequired
1110
import com.branddev.api.core.http.Headers
1211
import com.branddev.api.core.http.QueryParams
1312
import com.branddev.api.errors.BrandDevInvalidDataException
@@ -32,12 +31,23 @@ private constructor(
3231
) : Params {
3332

3433
/**
35-
* The domain name to analyze
34+
* A specific URL to use directly as the starting point for extraction without domain
35+
* resolution. Useful when you want to extract products from a specific page rather than
36+
* discovering the site's product pages automatically. Either 'domain' or 'directUrl' must be
37+
* provided, but not both.
3638
*
37-
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type or is
38-
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
39+
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the
40+
* server responded with an unexpected value).
41+
*/
42+
fun directUrl(): Optional<String> = body.directUrl()
43+
44+
/**
45+
* The domain name to analyze. Either 'domain' or 'directUrl' must be provided, but not both.
46+
*
47+
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the
48+
* server responded with an unexpected value).
3949
*/
40-
fun domain(): String = body.domain()
50+
fun domain(): Optional<String> = body.domain()
4151

4252
/**
4353
* Maximum number of products to extract.
@@ -57,6 +67,13 @@ private constructor(
5767
*/
5868
fun timeoutMs(): Optional<Long> = body.timeoutMs()
5969

70+
/**
71+
* Returns the raw JSON value of [directUrl].
72+
*
73+
* Unlike [directUrl], this method doesn't throw if the JSON field has an unexpected type.
74+
*/
75+
fun _directUrl(): JsonField<String> = body._directUrl()
76+
6077
/**
6178
* Returns the raw JSON value of [domain].
6279
*
@@ -90,14 +107,9 @@ private constructor(
90107

91108
companion object {
92109

93-
/**
94-
* Returns a mutable builder for constructing an instance of [BrandAiProductsParams].
95-
*
96-
* The following fields are required:
97-
* ```java
98-
* .domain()
99-
* ```
100-
*/
110+
@JvmStatic fun none(): BrandAiProductsParams = builder().build()
111+
112+
/** Returns a mutable builder for constructing an instance of [BrandAiProductsParams]. */
101113
@JvmStatic fun builder() = Builder()
102114
}
103115

@@ -120,13 +132,34 @@ private constructor(
120132
*
121133
* This is generally only useful if you are already constructing the body separately.
122134
* Otherwise, it's more convenient to use the top-level setters instead:
135+
* - [directUrl]
123136
* - [domain]
124137
* - [maxProducts]
125138
* - [timeoutMs]
126139
*/
127140
fun body(body: Body) = apply { this.body = body.toBuilder() }
128141

129-
/** The domain name to analyze */
142+
/**
143+
* A specific URL to use directly as the starting point for extraction without domain
144+
* resolution. Useful when you want to extract products from a specific page rather than
145+
* discovering the site's product pages automatically. Either 'domain' or 'directUrl' must
146+
* be provided, but not both.
147+
*/
148+
fun directUrl(directUrl: String) = apply { body.directUrl(directUrl) }
149+
150+
/**
151+
* Sets [Builder.directUrl] to an arbitrary JSON value.
152+
*
153+
* You should usually call [Builder.directUrl] with a well-typed [String] value instead.
154+
* This method is primarily for setting the field to an undocumented or not yet supported
155+
* value.
156+
*/
157+
fun directUrl(directUrl: JsonField<String>) = apply { body.directUrl(directUrl) }
158+
159+
/**
160+
* The domain name to analyze. Either 'domain' or 'directUrl' must be provided, but not
161+
* both.
162+
*/
130163
fun domain(domain: String) = apply { body.domain(domain) }
131164

132165
/**
@@ -285,13 +318,6 @@ private constructor(
285318
* Returns an immutable instance of [BrandAiProductsParams].
286319
*
287320
* Further updates to this [Builder] will not mutate the returned instance.
288-
*
289-
* The following fields are required:
290-
* ```java
291-
* .domain()
292-
* ```
293-
*
294-
* @throws IllegalStateException if any required field is unset.
295321
*/
296322
fun build(): BrandAiProductsParams =
297323
BrandAiProductsParams(
@@ -310,6 +336,7 @@ private constructor(
310336
class Body
311337
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
312338
private constructor(
339+
private val directUrl: JsonField<String>,
313340
private val domain: JsonField<String>,
314341
private val maxProducts: JsonField<Long>,
315342
private val timeoutMs: JsonField<Long>,
@@ -318,20 +345,35 @@ private constructor(
318345

319346
@JsonCreator
320347
private constructor(
348+
@JsonProperty("directUrl")
349+
@ExcludeMissing
350+
directUrl: JsonField<String> = JsonMissing.of(),
321351
@JsonProperty("domain") @ExcludeMissing domain: JsonField<String> = JsonMissing.of(),
322352
@JsonProperty("maxProducts")
323353
@ExcludeMissing
324354
maxProducts: JsonField<Long> = JsonMissing.of(),
325355
@JsonProperty("timeoutMS") @ExcludeMissing timeoutMs: JsonField<Long> = JsonMissing.of(),
326-
) : this(domain, maxProducts, timeoutMs, mutableMapOf())
356+
) : this(directUrl, domain, maxProducts, timeoutMs, mutableMapOf())
327357

328358
/**
329-
* The domain name to analyze
359+
* A specific URL to use directly as the starting point for extraction without domain
360+
* resolution. Useful when you want to extract products from a specific page rather than
361+
* discovering the site's product pages automatically. Either 'domain' or 'directUrl' must
362+
* be provided, but not both.
330363
*
331-
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type or is
332-
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
364+
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if
365+
* the server responded with an unexpected value).
333366
*/
334-
fun domain(): String = domain.getRequired("domain")
367+
fun directUrl(): Optional<String> = directUrl.getOptional("directUrl")
368+
369+
/**
370+
* The domain name to analyze. Either 'domain' or 'directUrl' must be provided, but not
371+
* both.
372+
*
373+
* @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if
374+
* the server responded with an unexpected value).
375+
*/
376+
fun domain(): Optional<String> = domain.getOptional("domain")
335377

336378
/**
337379
* Maximum number of products to extract.
@@ -351,6 +393,13 @@ private constructor(
351393
*/
352394
fun timeoutMs(): Optional<Long> = timeoutMs.getOptional("timeoutMS")
353395

396+
/**
397+
* Returns the raw JSON value of [directUrl].
398+
*
399+
* Unlike [directUrl], this method doesn't throw if the JSON field has an unexpected type.
400+
*/
401+
@JsonProperty("directUrl") @ExcludeMissing fun _directUrl(): JsonField<String> = directUrl
402+
354403
/**
355404
* Returns the raw JSON value of [domain].
356405
*
@@ -388,34 +437,49 @@ private constructor(
388437

389438
companion object {
390439

391-
/**
392-
* Returns a mutable builder for constructing an instance of [Body].
393-
*
394-
* The following fields are required:
395-
* ```java
396-
* .domain()
397-
* ```
398-
*/
440+
/** Returns a mutable builder for constructing an instance of [Body]. */
399441
@JvmStatic fun builder() = Builder()
400442
}
401443

402444
/** A builder for [Body]. */
403445
class Builder internal constructor() {
404446

405-
private var domain: JsonField<String>? = null
447+
private var directUrl: JsonField<String> = JsonMissing.of()
448+
private var domain: JsonField<String> = JsonMissing.of()
406449
private var maxProducts: JsonField<Long> = JsonMissing.of()
407450
private var timeoutMs: JsonField<Long> = JsonMissing.of()
408451
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
409452

410453
@JvmSynthetic
411454
internal fun from(body: Body) = apply {
455+
directUrl = body.directUrl
412456
domain = body.domain
413457
maxProducts = body.maxProducts
414458
timeoutMs = body.timeoutMs
415459
additionalProperties = body.additionalProperties.toMutableMap()
416460
}
417461

418-
/** The domain name to analyze */
462+
/**
463+
* A specific URL to use directly as the starting point for extraction without domain
464+
* resolution. Useful when you want to extract products from a specific page rather than
465+
* discovering the site's product pages automatically. Either 'domain' or 'directUrl'
466+
* must be provided, but not both.
467+
*/
468+
fun directUrl(directUrl: String) = directUrl(JsonField.of(directUrl))
469+
470+
/**
471+
* Sets [Builder.directUrl] to an arbitrary JSON value.
472+
*
473+
* You should usually call [Builder.directUrl] with a well-typed [String] value instead.
474+
* This method is primarily for setting the field to an undocumented or not yet
475+
* supported value.
476+
*/
477+
fun directUrl(directUrl: JsonField<String>) = apply { this.directUrl = directUrl }
478+
479+
/**
480+
* The domain name to analyze. Either 'domain' or 'directUrl' must be provided, but not
481+
* both.
482+
*/
419483
fun domain(domain: String) = domain(JsonField.of(domain))
420484

421485
/**
@@ -478,21 +542,9 @@ private constructor(
478542
* Returns an immutable instance of [Body].
479543
*
480544
* Further updates to this [Builder] will not mutate the returned instance.
481-
*
482-
* The following fields are required:
483-
* ```java
484-
* .domain()
485-
* ```
486-
*
487-
* @throws IllegalStateException if any required field is unset.
488545
*/
489546
fun build(): Body =
490-
Body(
491-
checkRequired("domain", domain),
492-
maxProducts,
493-
timeoutMs,
494-
additionalProperties.toMutableMap(),
495-
)
547+
Body(directUrl, domain, maxProducts, timeoutMs, additionalProperties.toMutableMap())
496548
}
497549

498550
private var validated: Boolean = false
@@ -502,6 +554,7 @@ private constructor(
502554
return@apply
503555
}
504556

557+
directUrl()
505558
domain()
506559
maxProducts()
507560
timeoutMs()
@@ -524,7 +577,8 @@ private constructor(
524577
*/
525578
@JvmSynthetic
526579
internal fun validity(): Int =
527-
(if (domain.asKnown().isPresent) 1 else 0) +
580+
(if (directUrl.asKnown().isPresent) 1 else 0) +
581+
(if (domain.asKnown().isPresent) 1 else 0) +
528582
(if (maxProducts.asKnown().isPresent) 1 else 0) +
529583
(if (timeoutMs.asKnown().isPresent) 1 else 0)
530584

@@ -534,20 +588,21 @@ private constructor(
534588
}
535589

536590
return other is Body &&
591+
directUrl == other.directUrl &&
537592
domain == other.domain &&
538593
maxProducts == other.maxProducts &&
539594
timeoutMs == other.timeoutMs &&
540595
additionalProperties == other.additionalProperties
541596
}
542597

543598
private val hashCode: Int by lazy {
544-
Objects.hash(domain, maxProducts, timeoutMs, additionalProperties)
599+
Objects.hash(directUrl, domain, maxProducts, timeoutMs, additionalProperties)
545600
}
546601

547602
override fun hashCode(): Int = hashCode
548603

549604
override fun toString() =
550-
"Body{domain=$domain, maxProducts=$maxProducts, timeoutMs=$timeoutMs, additionalProperties=$additionalProperties}"
605+
"Body{directUrl=$directUrl, domain=$domain, maxProducts=$maxProducts, timeoutMs=$timeoutMs, additionalProperties=$additionalProperties}"
551606
}
552607

553608
override fun equals(other: Any?): Boolean {

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

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,24 @@ interface BrandServiceAsync {
6767
* website and return a list of products with details such as name, description, image, pricing,
6868
* features, and more.
6969
*/
70-
fun aiProducts(params: BrandAiProductsParams): CompletableFuture<BrandAiProductsResponse> =
71-
aiProducts(params, RequestOptions.none())
70+
fun aiProducts(): CompletableFuture<BrandAiProductsResponse> =
71+
aiProducts(BrandAiProductsParams.none())
7272

7373
/** @see aiProducts */
7474
fun aiProducts(
75-
params: BrandAiProductsParams,
75+
params: BrandAiProductsParams = BrandAiProductsParams.none(),
7676
requestOptions: RequestOptions = RequestOptions.none(),
7777
): CompletableFuture<BrandAiProductsResponse>
7878

79+
/** @see aiProducts */
80+
fun aiProducts(
81+
params: BrandAiProductsParams = BrandAiProductsParams.none()
82+
): CompletableFuture<BrandAiProductsResponse> = aiProducts(params, RequestOptions.none())
83+
84+
/** @see aiProducts */
85+
fun aiProducts(requestOptions: RequestOptions): CompletableFuture<BrandAiProductsResponse> =
86+
aiProducts(BrandAiProductsParams.none(), requestOptions)
87+
7988
/**
8089
* Use AI to extract specific data points from a brand's website. The AI will crawl the website
8190
* and extract the requested information based on the provided data points.
@@ -297,16 +306,26 @@ interface BrandServiceAsync {
297306
* Returns a raw HTTP response for `post /brand/ai/products`, but is otherwise the same as
298307
* [BrandServiceAsync.aiProducts].
299308
*/
309+
fun aiProducts(): CompletableFuture<HttpResponseFor<BrandAiProductsResponse>> =
310+
aiProducts(BrandAiProductsParams.none())
311+
312+
/** @see aiProducts */
300313
fun aiProducts(
301-
params: BrandAiProductsParams
314+
params: BrandAiProductsParams = BrandAiProductsParams.none(),
315+
requestOptions: RequestOptions = RequestOptions.none(),
316+
): CompletableFuture<HttpResponseFor<BrandAiProductsResponse>>
317+
318+
/** @see aiProducts */
319+
fun aiProducts(
320+
params: BrandAiProductsParams = BrandAiProductsParams.none()
302321
): CompletableFuture<HttpResponseFor<BrandAiProductsResponse>> =
303322
aiProducts(params, RequestOptions.none())
304323

305324
/** @see aiProducts */
306325
fun aiProducts(
307-
params: BrandAiProductsParams,
308-
requestOptions: RequestOptions = RequestOptions.none(),
309-
): CompletableFuture<HttpResponseFor<BrandAiProductsResponse>>
326+
requestOptions: RequestOptions
327+
): CompletableFuture<HttpResponseFor<BrandAiProductsResponse>> =
328+
aiProducts(BrandAiProductsParams.none(), requestOptions)
310329

311330
/**
312331
* Returns a raw HTTP response for `post /brand/ai/query`, but is otherwise the same as

0 commit comments

Comments
 (0)