Skip to content

Commit f199738

Browse files
chore(internal): codegen related update
1 parent b2d8fd1 commit f199738

7 files changed

Lines changed: 308 additions & 138 deletions

File tree

lib/brand_dev/models/brand_ai_products_params.rb

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,88 @@ class BrandAIProductsParams < BrandDev::Internal::Type::BaseModel
77
extend BrandDev::Internal::Type::RequestParameters::Converter
88
include BrandDev::Internal::Type::RequestParameters
99

10-
# @!attribute domain
11-
# The domain name to analyze.
10+
# @!attribute body
1211
#
13-
# @return [String]
14-
required :domain, String
12+
# @return [BrandDev::Models::BrandAIProductsParams::Body::ByDomain, BrandDev::Models::BrandAIProductsParams::Body::ByDirectURL]
13+
required :body, union: -> { BrandDev::BrandAIProductsParams::Body }
1514

16-
# @!attribute max_products
17-
# Maximum number of products to extract.
18-
#
19-
# @return [Integer, nil]
20-
optional :max_products, Integer, api_name: :maxProducts
15+
# @!method initialize(body:, request_options: {})
16+
# @param body [BrandDev::Models::BrandAIProductsParams::Body::ByDomain, BrandDev::Models::BrandAIProductsParams::Body::ByDirectURL]
17+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}]
2118

22-
# @!attribute timeout_ms
23-
# Optional timeout in milliseconds for the request. Maximum allowed value is
24-
# 300000ms (5 minutes).
25-
#
26-
# @return [Integer, nil]
27-
optional :timeout_ms, Integer, api_name: :timeoutMS
19+
module Body
20+
extend BrandDev::Internal::Type::Union
2821

29-
# @!attribute direct_url
30-
# A specific URL to use directly as the starting point for extraction without
31-
# domain resolution.
32-
#
33-
# @return [String]
34-
required :direct_url, String, api_name: :directUrl
22+
variant -> { BrandDev::BrandAIProductsParams::Body::ByDomain }
3523

36-
# @!method initialize(domain:, direct_url:, max_products: nil, timeout_ms: nil, request_options: {})
37-
# Some parameter documentations has been truncated, see
38-
# {BrandDev::Models::BrandAIProductsParams} for more details.
39-
#
40-
# @param domain [String] The domain name to analyze.
41-
#
42-
# @param direct_url [String] A specific URL to use directly as the starting point for extraction without doma
43-
#
44-
# @param max_products [Integer] Maximum number of products to extract.
45-
#
46-
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
47-
#
48-
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}]
24+
variant -> { BrandDev::BrandAIProductsParams::Body::ByDirectURL }
25+
26+
class ByDomain < BrandDev::Internal::Type::BaseModel
27+
# @!attribute domain
28+
# The domain name to analyze.
29+
#
30+
# @return [String]
31+
required :domain, String
32+
33+
# @!attribute max_products
34+
# Maximum number of products to extract.
35+
#
36+
# @return [Integer, nil]
37+
optional :max_products, Integer, api_name: :maxProducts
38+
39+
# @!attribute timeout_ms
40+
# Optional timeout in milliseconds for the request. Maximum allowed value is
41+
# 300000ms (5 minutes).
42+
#
43+
# @return [Integer, nil]
44+
optional :timeout_ms, Integer, api_name: :timeoutMS
45+
46+
# @!method initialize(domain:, max_products: nil, timeout_ms: nil)
47+
# Some parameter documentations has been truncated, see
48+
# {BrandDev::Models::BrandAIProductsParams::Body::ByDomain} for more details.
49+
#
50+
# @param domain [String] The domain name to analyze.
51+
#
52+
# @param max_products [Integer] Maximum number of products to extract.
53+
#
54+
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
55+
end
56+
57+
class ByDirectURL < BrandDev::Internal::Type::BaseModel
58+
# @!attribute direct_url
59+
# A specific URL to use directly as the starting point for extraction without
60+
# domain resolution.
61+
#
62+
# @return [String]
63+
required :direct_url, String, api_name: :directUrl
64+
65+
# @!attribute max_products
66+
# Maximum number of products to extract.
67+
#
68+
# @return [Integer, nil]
69+
optional :max_products, Integer, api_name: :maxProducts
70+
71+
# @!attribute timeout_ms
72+
# Optional timeout in milliseconds for the request. Maximum allowed value is
73+
# 300000ms (5 minutes).
74+
#
75+
# @return [Integer, nil]
76+
optional :timeout_ms, Integer, api_name: :timeoutMS
77+
78+
# @!method initialize(direct_url:, max_products: nil, timeout_ms: nil)
79+
# Some parameter documentations has been truncated, see
80+
# {BrandDev::Models::BrandAIProductsParams::Body::ByDirectURL} for more details.
81+
#
82+
# @param direct_url [String] A specific URL to use directly as the starting point for extraction without doma
83+
#
84+
# @param max_products [Integer] Maximum number of products to extract.
85+
#
86+
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
87+
end
88+
89+
# @!method self.variants
90+
# @return [Array(BrandDev::Models::BrandAIProductsParams::Body::ByDomain, BrandDev::Models::BrandAIProductsParams::Body::ByDirectURL)]
91+
end
4992
end
5093
end
5194
end

lib/brand_dev/resources/brand.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,13 @@ def ai_product(params)
6565
)
6666
end
6767

68-
# Some parameter documentations has been truncated, see
69-
# {BrandDev::Models::BrandAIProductsParams} for more details.
70-
#
7168
# Beta feature: Extract product information from a brand's website. Brand.dev will
7269
# analyze the website and return a list of products with details such as name,
7370
# description, image, pricing, features, and more.
7471
#
75-
# @overload ai_products(domain:, direct_url:, max_products: nil, timeout_ms: nil, request_options: {})
76-
#
77-
# @param domain [String] The domain name to analyze.
78-
#
79-
# @param direct_url [String] A specific URL to use directly as the starting point for extraction without doma
80-
#
81-
# @param max_products [Integer] Maximum number of products to extract.
82-
#
83-
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
72+
# @overload ai_products(body:, request_options: {})
8473
#
74+
# @param body [BrandDev::Models::BrandAIProductsParams::Body::ByDomain, BrandDev::Models::BrandAIProductsParams::Body::ByDirectURL]
8575
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}, nil]
8676
#
8777
# @return [BrandDev::Models::BrandAIProductsResponse]
@@ -92,7 +82,7 @@ def ai_products(params)
9282
@client.request(
9383
method: :post,
9484
path: "brand/ai/products",
95-
body: parsed,
85+
body: parsed[:body],
9686
model: BrandDev::Models::BrandAIProductsResponse,
9787
options: options
9888
)

rbi/brand_dev/models/brand_ai_products_params.rbi

Lines changed: 152 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,67 +11,175 @@ module BrandDev
1111
T.any(BrandDev::BrandAIProductsParams, BrandDev::Internal::AnyHash)
1212
end
1313

14-
# The domain name to analyze.
15-
sig { returns(String) }
16-
attr_accessor :domain
17-
18-
# Maximum number of products to extract.
19-
sig { returns(T.nilable(Integer)) }
20-
attr_reader :max_products
21-
22-
sig { params(max_products: Integer).void }
23-
attr_writer :max_products
24-
25-
# Optional timeout in milliseconds for the request. Maximum allowed value is
26-
# 300000ms (5 minutes).
27-
sig { returns(T.nilable(Integer)) }
28-
attr_reader :timeout_ms
29-
30-
sig { params(timeout_ms: Integer).void }
31-
attr_writer :timeout_ms
32-
33-
# A specific URL to use directly as the starting point for extraction without
34-
# domain resolution.
35-
sig { returns(String) }
36-
attr_accessor :direct_url
14+
sig do
15+
returns(
16+
T.any(
17+
BrandDev::BrandAIProductsParams::Body::ByDomain,
18+
BrandDev::BrandAIProductsParams::Body::ByDirectURL
19+
)
20+
)
21+
end
22+
attr_accessor :body
3723

3824
sig do
3925
params(
40-
domain: String,
41-
direct_url: String,
42-
max_products: Integer,
43-
timeout_ms: Integer,
26+
body:
27+
T.any(
28+
BrandDev::BrandAIProductsParams::Body::ByDomain::OrHash,
29+
BrandDev::BrandAIProductsParams::Body::ByDirectURL::OrHash
30+
),
4431
request_options: BrandDev::RequestOptions::OrHash
4532
).returns(T.attached_class)
4633
end
47-
def self.new(
48-
# The domain name to analyze.
49-
domain:,
50-
# A specific URL to use directly as the starting point for extraction without
51-
# domain resolution.
52-
direct_url:,
53-
# Maximum number of products to extract.
54-
max_products: nil,
55-
# Optional timeout in milliseconds for the request. Maximum allowed value is
56-
# 300000ms (5 minutes).
57-
timeout_ms: nil,
58-
request_options: {}
59-
)
34+
def self.new(body:, request_options: {})
6035
end
6136

6237
sig do
6338
override.returns(
6439
{
65-
domain: String,
66-
max_products: Integer,
67-
timeout_ms: Integer,
68-
direct_url: String,
40+
body:
41+
T.any(
42+
BrandDev::BrandAIProductsParams::Body::ByDomain,
43+
BrandDev::BrandAIProductsParams::Body::ByDirectURL
44+
),
6945
request_options: BrandDev::RequestOptions
7046
}
7147
)
7248
end
7349
def to_hash
7450
end
51+
52+
module Body
53+
extend BrandDev::Internal::Type::Union
54+
55+
Variants =
56+
T.type_alias do
57+
T.any(
58+
BrandDev::BrandAIProductsParams::Body::ByDomain,
59+
BrandDev::BrandAIProductsParams::Body::ByDirectURL
60+
)
61+
end
62+
63+
class ByDomain < BrandDev::Internal::Type::BaseModel
64+
OrHash =
65+
T.type_alias do
66+
T.any(
67+
BrandDev::BrandAIProductsParams::Body::ByDomain,
68+
BrandDev::Internal::AnyHash
69+
)
70+
end
71+
72+
# The domain name to analyze.
73+
sig { returns(String) }
74+
attr_accessor :domain
75+
76+
# Maximum number of products to extract.
77+
sig { returns(T.nilable(Integer)) }
78+
attr_reader :max_products
79+
80+
sig { params(max_products: Integer).void }
81+
attr_writer :max_products
82+
83+
# Optional timeout in milliseconds for the request. Maximum allowed value is
84+
# 300000ms (5 minutes).
85+
sig { returns(T.nilable(Integer)) }
86+
attr_reader :timeout_ms
87+
88+
sig { params(timeout_ms: Integer).void }
89+
attr_writer :timeout_ms
90+
91+
sig do
92+
params(
93+
domain: String,
94+
max_products: Integer,
95+
timeout_ms: Integer
96+
).returns(T.attached_class)
97+
end
98+
def self.new(
99+
# The domain name to analyze.
100+
domain:,
101+
# Maximum number of products to extract.
102+
max_products: nil,
103+
# Optional timeout in milliseconds for the request. Maximum allowed value is
104+
# 300000ms (5 minutes).
105+
timeout_ms: nil
106+
)
107+
end
108+
109+
sig do
110+
override.returns(
111+
{ domain: String, max_products: Integer, timeout_ms: Integer }
112+
)
113+
end
114+
def to_hash
115+
end
116+
end
117+
118+
class ByDirectURL < BrandDev::Internal::Type::BaseModel
119+
OrHash =
120+
T.type_alias do
121+
T.any(
122+
BrandDev::BrandAIProductsParams::Body::ByDirectURL,
123+
BrandDev::Internal::AnyHash
124+
)
125+
end
126+
127+
# A specific URL to use directly as the starting point for extraction without
128+
# domain resolution.
129+
sig { returns(String) }
130+
attr_accessor :direct_url
131+
132+
# Maximum number of products to extract.
133+
sig { returns(T.nilable(Integer)) }
134+
attr_reader :max_products
135+
136+
sig { params(max_products: Integer).void }
137+
attr_writer :max_products
138+
139+
# Optional timeout in milliseconds for the request. Maximum allowed value is
140+
# 300000ms (5 minutes).
141+
sig { returns(T.nilable(Integer)) }
142+
attr_reader :timeout_ms
143+
144+
sig { params(timeout_ms: Integer).void }
145+
attr_writer :timeout_ms
146+
147+
sig do
148+
params(
149+
direct_url: String,
150+
max_products: Integer,
151+
timeout_ms: Integer
152+
).returns(T.attached_class)
153+
end
154+
def self.new(
155+
# A specific URL to use directly as the starting point for extraction without
156+
# domain resolution.
157+
direct_url:,
158+
# Maximum number of products to extract.
159+
max_products: nil,
160+
# Optional timeout in milliseconds for the request. Maximum allowed value is
161+
# 300000ms (5 minutes).
162+
timeout_ms: nil
163+
)
164+
end
165+
166+
sig do
167+
override.returns(
168+
{ direct_url: String, max_products: Integer, timeout_ms: Integer }
169+
)
170+
end
171+
def to_hash
172+
end
173+
end
174+
175+
sig do
176+
override.returns(
177+
T::Array[BrandDev::BrandAIProductsParams::Body::Variants]
178+
)
179+
end
180+
def self.variants
181+
end
182+
end
75183
end
76184
end
77185
end

0 commit comments

Comments
 (0)