brand.dev 0.0.1.pre.alpha.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +188 -0
- data/README.md +7 -3
- data/lib/brand_dev/errors.rb +22 -0
- data/lib/brand_dev/internal/transport/base_client.rb +10 -2
- data/lib/brand_dev/internal/type/array_of.rb +6 -1
- data/lib/brand_dev/internal/type/base_model.rb +77 -25
- data/lib/brand_dev/internal/type/boolean.rb +7 -1
- data/lib/brand_dev/internal/type/converter.rb +42 -34
- data/lib/brand_dev/internal/type/enum.rb +16 -5
- data/lib/brand_dev/internal/type/file_input.rb +6 -1
- data/lib/brand_dev/internal/type/hash_of.rb +6 -1
- data/lib/brand_dev/internal/type/union.rb +17 -9
- data/lib/brand_dev/internal/type/unknown.rb +7 -1
- data/lib/brand_dev/internal/util.rb +8 -9
- data/lib/brand_dev/models/brand_ai_query_params.rb +173 -0
- data/lib/brand_dev/models/brand_ai_query_response.rb +80 -0
- data/lib/brand_dev/models/brand_identify_from_transaction_params.rb +14 -1
- data/lib/brand_dev/models/brand_identify_from_transaction_response.rb +1 -29
- data/lib/brand_dev/models/brand_prefetch_params.rb +35 -0
- data/lib/brand_dev/models/brand_prefetch_response.rb +33 -0
- data/lib/brand_dev/models/brand_retrieve_by_ticker_params.rb +14 -1
- data/lib/brand_dev/models/brand_retrieve_by_ticker_response.rb +1 -29
- data/lib/brand_dev/models/brand_retrieve_naics_params.rb +11 -1
- data/lib/brand_dev/models/brand_retrieve_params.rb +24 -1
- data/lib/brand_dev/models/brand_retrieve_response.rb +1 -29
- data/lib/brand_dev/models/brand_retrieve_simplified_params.rb +35 -0
- data/lib/brand_dev/models/brand_retrieve_simplified_response.rb +280 -0
- data/lib/brand_dev/models/brand_screenshot_params.rb +49 -0
- data/lib/brand_dev/models/brand_screenshot_response.rb +64 -0
- data/lib/brand_dev/models/brand_styleguide_params.rb +36 -0
- data/lib/brand_dev/models/brand_styleguide_response.rb +769 -0
- data/lib/brand_dev/models.rb +13 -5
- data/lib/brand_dev/resources/brand.rb +165 -18
- data/lib/brand_dev/version.rb +1 -1
- data/lib/brand_dev.rb +10 -2
- data/rbi/brand_dev/errors.rbi +16 -0
- data/rbi/brand_dev/internal/type/boolean.rbi +2 -0
- data/rbi/brand_dev/internal/type/converter.rbi +15 -15
- data/rbi/brand_dev/internal/type/union.rbi +5 -0
- data/rbi/brand_dev/internal/type/unknown.rbi +2 -0
- data/rbi/brand_dev/internal/util.rbi +2 -0
- data/rbi/brand_dev/models/brand_ai_query_params.rbi +319 -0
- data/rbi/brand_dev/models/brand_ai_query_response.rbi +182 -0
- data/rbi/brand_dev/models/brand_identify_from_transaction_params.rbi +15 -0
- data/rbi/brand_dev/models/brand_identify_from_transaction_response.rbi +0 -69
- data/rbi/brand_dev/models/brand_prefetch_params.rbi +58 -0
- data/rbi/brand_dev/models/brand_prefetch_response.rbi +57 -0
- data/rbi/brand_dev/models/brand_retrieve_by_ticker_params.rbi +19 -1
- data/rbi/brand_dev/models/brand_retrieve_by_ticker_response.rbi +0 -69
- data/rbi/brand_dev/models/brand_retrieve_naics_params.rbi +19 -1
- data/rbi/brand_dev/models/brand_retrieve_params.rbi +30 -0
- data/rbi/brand_dev/models/brand_retrieve_response.rbi +0 -65
- data/rbi/brand_dev/models/brand_retrieve_simplified_params.rbi +61 -0
- data/rbi/brand_dev/models/brand_retrieve_simplified_response.rbi +667 -0
- data/rbi/brand_dev/models/brand_screenshot_params.rbi +105 -0
- data/rbi/brand_dev/models/brand_screenshot_response.rbi +135 -0
- data/rbi/brand_dev/models/brand_styleguide_params.rbi +60 -0
- data/rbi/brand_dev/models/brand_styleguide_response.rbi +1648 -0
- data/rbi/brand_dev/models.rbi +10 -1
- data/rbi/brand_dev/resources/brand.rbi +133 -6
- data/sig/brand_dev/errors.rbs +9 -0
- data/sig/brand_dev/internal/type/converter.rbs +7 -1
- data/sig/brand_dev/models/brand_ai_query_params.rbs +162 -0
- data/sig/brand_dev/models/brand_ai_query_response.rbs +79 -0
- data/sig/brand_dev/models/brand_identify_from_transaction_params.rbs +7 -1
- data/sig/brand_dev/models/brand_identify_from_transaction_response.rbs +0 -25
- data/sig/brand_dev/models/brand_prefetch_params.rbs +30 -0
- data/sig/brand_dev/models/brand_prefetch_response.rbs +28 -0
- data/sig/brand_dev/models/brand_retrieve_by_ticker_params.rbs +8 -1
- data/sig/brand_dev/models/brand_retrieve_by_ticker_response.rbs +0 -25
- data/sig/brand_dev/models/brand_retrieve_naics_params.rbs +8 -1
- data/sig/brand_dev/models/brand_retrieve_params.rbs +15 -1
- data/sig/brand_dev/models/brand_retrieve_response.rbs +0 -25
- data/sig/brand_dev/models/brand_retrieve_simplified_params.rbs +30 -0
- data/sig/brand_dev/models/brand_retrieve_simplified_response.rbs +292 -0
- data/sig/brand_dev/models/brand_screenshot_params.rbs +46 -0
- data/sig/brand_dev/models/brand_screenshot_response.rbs +63 -0
- data/sig/brand_dev/models/brand_styleguide_params.rbs +30 -0
- data/sig/brand_dev/models/brand_styleguide_response.rbs +925 -0
- data/sig/brand_dev/models.rbs +9 -1
- data/sig/brand_dev/resources/brand.rbs +35 -3
- metadata +46 -22
- data/lib/brand_dev/models/brand_search_params.rb +0 -22
- data/lib/brand_dev/models/brand_search_response.rb +0 -35
- data/rbi/brand_dev/models/brand_search_params.rbi +0 -40
- data/rbi/brand_dev/models/brand_search_response.rbi +0 -63
- data/sig/brand_dev/models/brand_search_params.rbs +0 -23
- data/sig/brand_dev/models/brand_search_response.rbs +0 -29
@@ -15,10 +15,14 @@ module BrandDev
|
|
15
15
|
#
|
16
16
|
# @param state [Hash{Symbol=>Object}] .
|
17
17
|
#
|
18
|
-
# @option state [Boolean
|
18
|
+
# @option state [Boolean] :translate_names
|
19
|
+
#
|
20
|
+
# @option state [Boolean] :strictness
|
19
21
|
#
|
20
22
|
# @option state [Hash{Symbol=>Object}] :exactness
|
21
23
|
#
|
24
|
+
# @option state [Class<StandardError>] :error
|
25
|
+
#
|
22
26
|
# @option state [Integer] :branched
|
23
27
|
#
|
24
28
|
# @return [Object]
|
@@ -94,6 +98,21 @@ module BrandDev
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
101
|
+
# @api private
|
102
|
+
#
|
103
|
+
# @param translate_names [Boolean]
|
104
|
+
#
|
105
|
+
# @return [Hash{Symbol=>Object}]
|
106
|
+
def new_coerce_state(translate_names: true)
|
107
|
+
{
|
108
|
+
translate_names: translate_names,
|
109
|
+
strictness: true,
|
110
|
+
exactness: {yes: 0, no: 0, maybe: 0},
|
111
|
+
error: nil,
|
112
|
+
branched: 0
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
97
116
|
# @api private
|
98
117
|
#
|
99
118
|
# Based on `target`, transform `value` into `target`, to the extent possible:
|
@@ -110,14 +129,11 @@ module BrandDev
|
|
110
129
|
#
|
111
130
|
# @param value [Object]
|
112
131
|
#
|
113
|
-
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false
|
114
|
-
#
|
115
|
-
# targets:
|
132
|
+
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy
|
133
|
+
# when we have to decide between multiple possible conversion targets:
|
116
134
|
#
|
117
135
|
# - `true`: the conversion must be exact, with minimum coercion.
|
118
136
|
# - `false`: the conversion can be approximate, with some coercion.
|
119
|
-
# - `:strong`: the conversion must be exact, with no coercion, and raise an error
|
120
|
-
# if not possible.
|
121
137
|
#
|
122
138
|
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
123
139
|
# any given conversion attempt, the exactness will be updated based on how closely
|
@@ -130,21 +146,20 @@ module BrandDev
|
|
130
146
|
#
|
131
147
|
# See implementation below for more details.
|
132
148
|
#
|
133
|
-
# @option state [Boolean
|
149
|
+
# @option state [Boolean] :translate_names
|
150
|
+
#
|
151
|
+
# @option state [Boolean] :strictness
|
134
152
|
#
|
135
153
|
# @option state [Hash{Symbol=>Object}] :exactness
|
136
154
|
#
|
155
|
+
# @option state [Class<StandardError>] :error
|
156
|
+
#
|
137
157
|
# @option state [Integer] :branched
|
138
158
|
#
|
139
159
|
# @return [Object]
|
140
|
-
def coerce(
|
141
|
-
target,
|
142
|
-
value,
|
143
|
-
state: {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0}
|
144
|
-
)
|
145
|
-
# rubocop:disable Lint/SuppressedException
|
160
|
+
def coerce(target, value, state: BrandDev::Internal::Type::Converter.new_coerce_state)
|
146
161
|
# rubocop:disable Metrics/BlockNesting
|
147
|
-
|
162
|
+
exactness = state.fetch(:exactness)
|
148
163
|
|
149
164
|
case target
|
150
165
|
in BrandDev::Internal::Type::Converter
|
@@ -160,29 +175,26 @@ module BrandDev
|
|
160
175
|
exactness[value.nil? ? :yes : :maybe] += 1
|
161
176
|
return nil
|
162
177
|
in -> { _1 <= Integer }
|
163
|
-
|
178
|
+
case value
|
179
|
+
in Integer
|
164
180
|
exactness[:yes] += 1
|
165
181
|
return value
|
166
|
-
elsif strictness == :strong && Integer(value, exception: false) != value
|
167
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
168
|
-
raise value.is_a?(Numeric) ? ArgumentError.new(message) : TypeError.new(message)
|
169
182
|
else
|
170
183
|
Kernel.then do
|
171
184
|
return Integer(value).tap { exactness[:maybe] += 1 }
|
172
|
-
rescue ArgumentError, TypeError
|
185
|
+
rescue ArgumentError, TypeError => e
|
186
|
+
state[:error] = e
|
173
187
|
end
|
174
188
|
end
|
175
189
|
in -> { _1 <= Float }
|
176
190
|
if value.is_a?(Numeric)
|
177
191
|
exactness[:yes] += 1
|
178
192
|
return Float(value)
|
179
|
-
elsif strictness == :strong
|
180
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
181
|
-
raise TypeError.new(message)
|
182
193
|
else
|
183
194
|
Kernel.then do
|
184
195
|
return Float(value).tap { exactness[:maybe] += 1 }
|
185
|
-
rescue ArgumentError, TypeError
|
196
|
+
rescue ArgumentError, TypeError => e
|
197
|
+
state[:error] = e
|
186
198
|
end
|
187
199
|
end
|
188
200
|
in -> { _1 <= String }
|
@@ -194,16 +206,13 @@ module BrandDev
|
|
194
206
|
exactness[:yes] += 1
|
195
207
|
return value.string
|
196
208
|
else
|
197
|
-
|
198
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
199
|
-
raise TypeError.new(message)
|
200
|
-
end
|
209
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{String}")
|
201
210
|
end
|
202
211
|
in -> { _1 <= Date || _1 <= Time }
|
203
212
|
Kernel.then do
|
204
213
|
return target.parse(value).tap { exactness[:yes] += 1 }
|
205
214
|
rescue ArgumentError, TypeError => e
|
206
|
-
|
215
|
+
state[:error] = e
|
207
216
|
end
|
208
217
|
in -> { _1 <= StringIO } if value.is_a?(String)
|
209
218
|
exactness[:yes] += 1
|
@@ -221,10 +230,8 @@ module BrandDev
|
|
221
230
|
return value
|
222
231
|
end
|
223
232
|
else
|
224
|
-
|
225
|
-
|
226
|
-
raise ArgumentError.new(message)
|
227
|
-
end
|
233
|
+
message = "cannot convert non-matching #{value.class} into #{target.inspect}"
|
234
|
+
state[:error] = ArgumentError.new(message)
|
228
235
|
end
|
229
236
|
else
|
230
237
|
end
|
@@ -232,7 +239,6 @@ module BrandDev
|
|
232
239
|
exactness[:no] += 1
|
233
240
|
value
|
234
241
|
# rubocop:enable Metrics/BlockNesting
|
235
|
-
# rubocop:enable Lint/SuppressedException
|
236
242
|
end
|
237
243
|
|
238
244
|
# @api private
|
@@ -277,8 +283,10 @@ module BrandDev
|
|
277
283
|
define_sorbet_constant!(:CoerceState) do
|
278
284
|
T.type_alias do
|
279
285
|
{
|
280
|
-
|
286
|
+
translate_names: T::Boolean,
|
287
|
+
strictness: T::Boolean,
|
281
288
|
exactness: {yes: Integer, no: Integer, maybe: Integer},
|
289
|
+
error: T::Class[StandardError],
|
282
290
|
branched: Integer
|
283
291
|
}
|
284
292
|
end
|
@@ -56,10 +56,14 @@ module BrandDev
|
|
56
56
|
#
|
57
57
|
# @param state [Hash{Symbol=>Object}] .
|
58
58
|
#
|
59
|
-
# @option state [Boolean
|
59
|
+
# @option state [Boolean] :translate_names
|
60
|
+
#
|
61
|
+
# @option state [Boolean] :strictness
|
60
62
|
#
|
61
63
|
# @option state [Hash{Symbol=>Object}] :exactness
|
62
64
|
#
|
65
|
+
# @option state [Class<StandardError>] :error
|
66
|
+
#
|
63
67
|
# @option state [Integer] :branched
|
64
68
|
#
|
65
69
|
# @return [Symbol, Object]
|
@@ -70,8 +74,12 @@ module BrandDev
|
|
70
74
|
if values.include?(val)
|
71
75
|
exactness[:yes] += 1
|
72
76
|
val
|
77
|
+
elsif values.first&.class == val.class
|
78
|
+
exactness[:maybe] += 1
|
79
|
+
value
|
73
80
|
else
|
74
|
-
exactness[
|
81
|
+
exactness[:no] += 1
|
82
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}")
|
75
83
|
value
|
76
84
|
end
|
77
85
|
end
|
@@ -91,11 +99,14 @@ module BrandDev
|
|
91
99
|
#
|
92
100
|
# @return [Object]
|
93
101
|
def to_sorbet_type
|
94
|
-
|
102
|
+
types = values.map { BrandDev::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
103
|
+
case types
|
95
104
|
in []
|
96
105
|
T.noreturn
|
97
|
-
in [
|
98
|
-
|
106
|
+
in [type]
|
107
|
+
type
|
108
|
+
else
|
109
|
+
T.any(*types)
|
99
110
|
end
|
100
111
|
end
|
101
112
|
|
@@ -45,10 +45,14 @@ module BrandDev
|
|
45
45
|
#
|
46
46
|
# @param state [Hash{Symbol=>Object}] .
|
47
47
|
#
|
48
|
-
# @option state [Boolean
|
48
|
+
# @option state [Boolean] :translate_names
|
49
|
+
#
|
50
|
+
# @option state [Boolean] :strictness
|
49
51
|
#
|
50
52
|
# @option state [Hash{Symbol=>Object}] :exactness
|
51
53
|
#
|
54
|
+
# @option state [Class<StandardError>] :error
|
55
|
+
#
|
52
56
|
# @option state [Integer] :branched
|
53
57
|
#
|
54
58
|
# @return [StringIO, Object]
|
@@ -62,6 +66,7 @@ module BrandDev
|
|
62
66
|
exactness[:yes] += 1
|
63
67
|
value
|
64
68
|
else
|
69
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}")
|
65
70
|
exactness[:no] += 1
|
66
71
|
value
|
67
72
|
end
|
@@ -77,10 +77,14 @@ module BrandDev
|
|
77
77
|
#
|
78
78
|
# @param state [Hash{Symbol=>Object}] .
|
79
79
|
#
|
80
|
-
# @option state [Boolean
|
80
|
+
# @option state [Boolean] :translate_names
|
81
|
+
#
|
82
|
+
# @option state [Boolean] :strictness
|
81
83
|
#
|
82
84
|
# @option state [Hash{Symbol=>Object}] :exactness
|
83
85
|
#
|
86
|
+
# @option state [Class<StandardError>] :error
|
87
|
+
#
|
84
88
|
# @option state [Integer] :branched
|
85
89
|
#
|
86
90
|
# @return [Hash{Symbol=>Object}, Object]
|
@@ -89,6 +93,7 @@ module BrandDev
|
|
89
93
|
|
90
94
|
unless value.is_a?(Hash)
|
91
95
|
exactness[:no] += 1
|
96
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}")
|
92
97
|
return value
|
93
98
|
end
|
94
99
|
|
@@ -115,14 +115,23 @@ module BrandDev
|
|
115
115
|
|
116
116
|
# @api private
|
117
117
|
#
|
118
|
+
# Tries to efficiently coerce the given value to one of the known variants.
|
119
|
+
#
|
120
|
+
# If the value cannot match any of the known variants, the coercion is considered
|
121
|
+
# non-viable and returns the original value.
|
122
|
+
#
|
118
123
|
# @param value [Object]
|
119
124
|
#
|
120
125
|
# @param state [Hash{Symbol=>Object}] .
|
121
126
|
#
|
122
|
-
# @option state [Boolean
|
127
|
+
# @option state [Boolean] :translate_names
|
128
|
+
#
|
129
|
+
# @option state [Boolean] :strictness
|
123
130
|
#
|
124
131
|
# @option state [Hash{Symbol=>Object}] :exactness
|
125
132
|
#
|
133
|
+
# @option state [Class<StandardError>] :error
|
134
|
+
#
|
126
135
|
# @option state [Integer] :branched
|
127
136
|
#
|
128
137
|
# @return [Object]
|
@@ -133,7 +142,6 @@ module BrandDev
|
|
133
142
|
|
134
143
|
strictness = state.fetch(:strictness)
|
135
144
|
exactness = state.fetch(:exactness)
|
136
|
-
state[:strictness] = strictness == :strong ? true : strictness
|
137
145
|
|
138
146
|
alternatives = []
|
139
147
|
known_variants.each do |_, variant_fn|
|
@@ -152,13 +160,10 @@ module BrandDev
|
|
152
160
|
end
|
153
161
|
end
|
154
162
|
|
155
|
-
case alternatives.sort_by(&:first)
|
163
|
+
case alternatives.sort_by!(&:first)
|
156
164
|
in []
|
157
165
|
exactness[:no] += 1
|
158
|
-
|
159
|
-
message = "no possible conversion of #{value.class} into a variant of #{target.inspect}"
|
160
|
-
raise ArgumentError.new(message)
|
161
|
-
end
|
166
|
+
state[:error] = ArgumentError.new("no matching variant for #{value.inspect}")
|
162
167
|
value
|
163
168
|
in [[_, exact, coerced], *]
|
164
169
|
exact.each { exactness[_1] += _2 }
|
@@ -195,11 +200,14 @@ module BrandDev
|
|
195
200
|
#
|
196
201
|
# @return [Object]
|
197
202
|
def to_sorbet_type
|
198
|
-
|
203
|
+
types = variants.map { BrandDev::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
204
|
+
case types
|
199
205
|
in []
|
200
206
|
T.noreturn
|
207
|
+
in [type]
|
208
|
+
type
|
201
209
|
else
|
202
|
-
T.any(*
|
210
|
+
T.any(*types)
|
203
211
|
end
|
204
212
|
end
|
205
213
|
|
@@ -33,14 +33,20 @@ module BrandDev
|
|
33
33
|
class << self
|
34
34
|
# @api private
|
35
35
|
#
|
36
|
+
# No coercion needed for Unknown type.
|
37
|
+
#
|
36
38
|
# @param value [Object]
|
37
39
|
#
|
38
40
|
# @param state [Hash{Symbol=>Object}] .
|
39
41
|
#
|
40
|
-
# @option state [Boolean
|
42
|
+
# @option state [Boolean] :translate_names
|
43
|
+
#
|
44
|
+
# @option state [Boolean] :strictness
|
41
45
|
#
|
42
46
|
# @option state [Hash{Symbol=>Object}] :exactness
|
43
47
|
#
|
48
|
+
# @option state [Class<StandardError>] :error
|
49
|
+
#
|
44
50
|
# @option state [Integer] :branched
|
45
51
|
#
|
46
52
|
# @return [Object]
|
@@ -497,7 +497,7 @@ module BrandDev
|
|
497
497
|
# @param closing [Array<Proc>]
|
498
498
|
# @param content_type [String, nil]
|
499
499
|
private def write_multipart_content(y, val:, closing:, content_type: nil)
|
500
|
-
|
500
|
+
content_line = "Content-Type: %s\r\n\r\n"
|
501
501
|
|
502
502
|
case val
|
503
503
|
in BrandDev::FilePart
|
@@ -508,24 +508,21 @@ module BrandDev
|
|
508
508
|
content_type: val.content_type
|
509
509
|
)
|
510
510
|
in Pathname
|
511
|
-
y <<
|
511
|
+
y << format(content_line, content_type || "application/octet-stream")
|
512
512
|
io = val.open(binmode: true)
|
513
513
|
closing << io.method(:close)
|
514
514
|
IO.copy_stream(io, y)
|
515
515
|
in IO
|
516
|
-
y <<
|
516
|
+
y << format(content_line, content_type || "application/octet-stream")
|
517
517
|
IO.copy_stream(val, y)
|
518
518
|
in StringIO
|
519
|
-
y <<
|
519
|
+
y << format(content_line, content_type || "application/octet-stream")
|
520
520
|
y << val.string
|
521
|
-
in String
|
522
|
-
y << "Content-Type: #{content_type}\r\n\r\n"
|
523
|
-
y << val.to_s
|
524
521
|
in -> { primitive?(_1) }
|
525
|
-
y << "
|
522
|
+
y << format(content_line, content_type || "text/plain")
|
526
523
|
y << val.to_s
|
527
524
|
else
|
528
|
-
y << "
|
525
|
+
y << format(content_line, content_type || "application/json")
|
529
526
|
y << JSON.generate(val)
|
530
527
|
end
|
531
528
|
y << "\r\n"
|
@@ -563,6 +560,8 @@ module BrandDev
|
|
563
560
|
|
564
561
|
# @api private
|
565
562
|
#
|
563
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
|
564
|
+
#
|
566
565
|
# @param body [Object]
|
567
566
|
#
|
568
567
|
# @return [Array(String, Enumerable<String>)]
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Models
|
5
|
+
# @see BrandDev::Resources::Brand#ai_query
|
6
|
+
class BrandAIQueryParams < BrandDev::Internal::Type::BaseModel
|
7
|
+
extend BrandDev::Internal::Type::RequestParameters::Converter
|
8
|
+
include BrandDev::Internal::Type::RequestParameters
|
9
|
+
|
10
|
+
# @!attribute data_to_extract
|
11
|
+
# Array of data points to extract from the website
|
12
|
+
#
|
13
|
+
# @return [Array<BrandDev::Models::BrandAIQueryParams::DataToExtract>]
|
14
|
+
required :data_to_extract,
|
15
|
+
-> { BrandDev::Internal::Type::ArrayOf[BrandDev::BrandAIQueryParams::DataToExtract] }
|
16
|
+
|
17
|
+
# @!attribute domain
|
18
|
+
# The domain name to analyze
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
required :domain, String
|
22
|
+
|
23
|
+
# @!attribute specific_pages
|
24
|
+
# Optional object specifying which pages to analyze
|
25
|
+
#
|
26
|
+
# @return [BrandDev::Models::BrandAIQueryParams::SpecificPages, nil]
|
27
|
+
optional :specific_pages, -> { BrandDev::BrandAIQueryParams::SpecificPages }
|
28
|
+
|
29
|
+
# @!attribute timeout_ms
|
30
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
31
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
32
|
+
# value is 300000ms (5 minutes).
|
33
|
+
#
|
34
|
+
# @return [Integer, nil]
|
35
|
+
optional :timeout_ms, Integer, api_name: :timeoutMS
|
36
|
+
|
37
|
+
# @!method initialize(data_to_extract:, domain:, specific_pages: nil, timeout_ms: nil, request_options: {})
|
38
|
+
# Some parameter documentations has been truncated, see
|
39
|
+
# {BrandDev::Models::BrandAIQueryParams} for more details.
|
40
|
+
#
|
41
|
+
# @param data_to_extract [Array<BrandDev::Models::BrandAIQueryParams::DataToExtract>] Array of data points to extract from the website
|
42
|
+
#
|
43
|
+
# @param domain [String] The domain name to analyze
|
44
|
+
#
|
45
|
+
# @param specific_pages [BrandDev::Models::BrandAIQueryParams::SpecificPages] Optional object specifying which pages to analyze
|
46
|
+
#
|
47
|
+
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th
|
48
|
+
#
|
49
|
+
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}]
|
50
|
+
|
51
|
+
class DataToExtract < BrandDev::Internal::Type::BaseModel
|
52
|
+
# @!attribute datapoint_description
|
53
|
+
# Description of what to extract
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
required :datapoint_description, String
|
57
|
+
|
58
|
+
# @!attribute datapoint_example
|
59
|
+
# Example of the expected value
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
required :datapoint_example, String
|
63
|
+
|
64
|
+
# @!attribute datapoint_name
|
65
|
+
# Name of the data point to extract
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
required :datapoint_name, String
|
69
|
+
|
70
|
+
# @!attribute datapoint_type
|
71
|
+
# Type of the data point
|
72
|
+
#
|
73
|
+
# @return [Symbol, BrandDev::Models::BrandAIQueryParams::DataToExtract::DatapointType]
|
74
|
+
required :datapoint_type, enum: -> { BrandDev::BrandAIQueryParams::DataToExtract::DatapointType }
|
75
|
+
|
76
|
+
# @!method initialize(datapoint_description:, datapoint_example:, datapoint_name:, datapoint_type:)
|
77
|
+
# @param datapoint_description [String] Description of what to extract
|
78
|
+
#
|
79
|
+
# @param datapoint_example [String] Example of the expected value
|
80
|
+
#
|
81
|
+
# @param datapoint_name [String] Name of the data point to extract
|
82
|
+
#
|
83
|
+
# @param datapoint_type [Symbol, BrandDev::Models::BrandAIQueryParams::DataToExtract::DatapointType] Type of the data point
|
84
|
+
|
85
|
+
# Type of the data point
|
86
|
+
#
|
87
|
+
# @see BrandDev::Models::BrandAIQueryParams::DataToExtract#datapoint_type
|
88
|
+
module DatapointType
|
89
|
+
extend BrandDev::Internal::Type::Enum
|
90
|
+
|
91
|
+
TEXT = :text
|
92
|
+
NUMBER = :number
|
93
|
+
DATE = :date
|
94
|
+
BOOLEAN = :boolean
|
95
|
+
LIST = :list
|
96
|
+
URL = :url
|
97
|
+
|
98
|
+
# @!method self.values
|
99
|
+
# @return [Array<Symbol>]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class SpecificPages < BrandDev::Internal::Type::BaseModel
|
104
|
+
# @!attribute about_us
|
105
|
+
# Whether to analyze the about us page
|
106
|
+
#
|
107
|
+
# @return [Boolean, nil]
|
108
|
+
optional :about_us, BrandDev::Internal::Type::Boolean
|
109
|
+
|
110
|
+
# @!attribute blog
|
111
|
+
# Whether to analyze the blog
|
112
|
+
#
|
113
|
+
# @return [Boolean, nil]
|
114
|
+
optional :blog, BrandDev::Internal::Type::Boolean
|
115
|
+
|
116
|
+
# @!attribute careers
|
117
|
+
# Whether to analyze the careers page
|
118
|
+
#
|
119
|
+
# @return [Boolean, nil]
|
120
|
+
optional :careers, BrandDev::Internal::Type::Boolean
|
121
|
+
|
122
|
+
# @!attribute contact_us
|
123
|
+
# Whether to analyze the contact us page
|
124
|
+
#
|
125
|
+
# @return [Boolean, nil]
|
126
|
+
optional :contact_us, BrandDev::Internal::Type::Boolean
|
127
|
+
|
128
|
+
# @!attribute faq
|
129
|
+
# Whether to analyze the FAQ page
|
130
|
+
#
|
131
|
+
# @return [Boolean, nil]
|
132
|
+
optional :faq, BrandDev::Internal::Type::Boolean
|
133
|
+
|
134
|
+
# @!attribute home_page
|
135
|
+
# Whether to analyze the home page
|
136
|
+
#
|
137
|
+
# @return [Boolean, nil]
|
138
|
+
optional :home_page, BrandDev::Internal::Type::Boolean
|
139
|
+
|
140
|
+
# @!attribute privacy_policy
|
141
|
+
# Whether to analyze the privacy policy page
|
142
|
+
#
|
143
|
+
# @return [Boolean, nil]
|
144
|
+
optional :privacy_policy, BrandDev::Internal::Type::Boolean
|
145
|
+
|
146
|
+
# @!attribute terms_and_conditions
|
147
|
+
# Whether to analyze the terms and conditions page
|
148
|
+
#
|
149
|
+
# @return [Boolean, nil]
|
150
|
+
optional :terms_and_conditions, BrandDev::Internal::Type::Boolean
|
151
|
+
|
152
|
+
# @!method initialize(about_us: nil, blog: nil, careers: nil, contact_us: nil, faq: nil, home_page: nil, privacy_policy: nil, terms_and_conditions: nil)
|
153
|
+
# Optional object specifying which pages to analyze
|
154
|
+
#
|
155
|
+
# @param about_us [Boolean] Whether to analyze the about us page
|
156
|
+
#
|
157
|
+
# @param blog [Boolean] Whether to analyze the blog
|
158
|
+
#
|
159
|
+
# @param careers [Boolean] Whether to analyze the careers page
|
160
|
+
#
|
161
|
+
# @param contact_us [Boolean] Whether to analyze the contact us page
|
162
|
+
#
|
163
|
+
# @param faq [Boolean] Whether to analyze the FAQ page
|
164
|
+
#
|
165
|
+
# @param home_page [Boolean] Whether to analyze the home page
|
166
|
+
#
|
167
|
+
# @param privacy_policy [Boolean] Whether to analyze the privacy policy page
|
168
|
+
#
|
169
|
+
# @param terms_and_conditions [Boolean] Whether to analyze the terms and conditions page
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrandDev
|
4
|
+
module Models
|
5
|
+
# @see BrandDev::Resources::Brand#ai_query
|
6
|
+
class BrandAIQueryResponse < BrandDev::Internal::Type::BaseModel
|
7
|
+
# @!attribute data_extracted
|
8
|
+
# Array of extracted data points
|
9
|
+
#
|
10
|
+
# @return [Array<BrandDev::Models::BrandAIQueryResponse::DataExtracted>, nil]
|
11
|
+
optional :data_extracted,
|
12
|
+
-> { BrandDev::Internal::Type::ArrayOf[BrandDev::Models::BrandAIQueryResponse::DataExtracted] }
|
13
|
+
|
14
|
+
# @!attribute domain
|
15
|
+
# The domain that was analyzed
|
16
|
+
#
|
17
|
+
# @return [String, nil]
|
18
|
+
optional :domain, String
|
19
|
+
|
20
|
+
# @!attribute urls_analyzed
|
21
|
+
# List of URLs that were analyzed
|
22
|
+
#
|
23
|
+
# @return [Array<String>, nil]
|
24
|
+
optional :urls_analyzed, BrandDev::Internal::Type::ArrayOf[String]
|
25
|
+
|
26
|
+
# @!method initialize(data_extracted: nil, domain: nil, urls_analyzed: nil)
|
27
|
+
# @param data_extracted [Array<BrandDev::Models::BrandAIQueryResponse::DataExtracted>] Array of extracted data points
|
28
|
+
#
|
29
|
+
# @param domain [String] The domain that was analyzed
|
30
|
+
#
|
31
|
+
# @param urls_analyzed [Array<String>] List of URLs that were analyzed
|
32
|
+
|
33
|
+
class DataExtracted < BrandDev::Internal::Type::BaseModel
|
34
|
+
# @!attribute datapoint_name
|
35
|
+
# Name of the extracted data point
|
36
|
+
#
|
37
|
+
# @return [String, nil]
|
38
|
+
optional :datapoint_name, String
|
39
|
+
|
40
|
+
# @!attribute datapoint_value
|
41
|
+
# Value of the extracted data point
|
42
|
+
#
|
43
|
+
# @return [String, Float, Boolean, Array<String>, Array<Float>, nil]
|
44
|
+
optional :datapoint_value,
|
45
|
+
union: -> { BrandDev::Models::BrandAIQueryResponse::DataExtracted::DatapointValue }
|
46
|
+
|
47
|
+
# @!method initialize(datapoint_name: nil, datapoint_value: nil)
|
48
|
+
# @param datapoint_name [String] Name of the extracted data point
|
49
|
+
#
|
50
|
+
# @param datapoint_value [String, Float, Boolean, Array<String>, Array<Float>] Value of the extracted data point
|
51
|
+
|
52
|
+
# Value of the extracted data point
|
53
|
+
#
|
54
|
+
# @see BrandDev::Models::BrandAIQueryResponse::DataExtracted#datapoint_value
|
55
|
+
module DatapointValue
|
56
|
+
extend BrandDev::Internal::Type::Union
|
57
|
+
|
58
|
+
variant String
|
59
|
+
|
60
|
+
variant Float
|
61
|
+
|
62
|
+
variant BrandDev::Internal::Type::Boolean
|
63
|
+
|
64
|
+
variant -> { BrandDev::Models::BrandAIQueryResponse::DataExtracted::DatapointValue::StringArray }
|
65
|
+
|
66
|
+
variant -> { BrandDev::Models::BrandAIQueryResponse::DataExtracted::DatapointValue::FloatArray }
|
67
|
+
|
68
|
+
# @!method self.variants
|
69
|
+
# @return [Array(String, Float, Boolean, Array<String>, Array<Float>)]
|
70
|
+
|
71
|
+
# @type [BrandDev::Internal::Type::Converter]
|
72
|
+
StringArray = BrandDev::Internal::Type::ArrayOf[String]
|
73
|
+
|
74
|
+
# @type [BrandDev::Internal::Type::Converter]
|
75
|
+
FloatArray = BrandDev::Internal::Type::ArrayOf[Float]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -13,9 +13,22 @@ module BrandDev
|
|
13
13
|
# @return [String]
|
14
14
|
required :transaction_info, String
|
15
15
|
|
16
|
-
# @!
|
16
|
+
# @!attribute timeout_ms
|
17
|
+
# Optional timeout in milliseconds for the request. If the request takes longer
|
18
|
+
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
19
|
+
# value is 300000ms (5 minutes).
|
20
|
+
#
|
21
|
+
# @return [Integer, nil]
|
22
|
+
optional :timeout_ms, Integer
|
23
|
+
|
24
|
+
# @!method initialize(transaction_info:, timeout_ms: nil, request_options: {})
|
25
|
+
# Some parameter documentations has been truncated, see
|
26
|
+
# {BrandDev::Models::BrandIdentifyFromTransactionParams} for more details.
|
27
|
+
#
|
17
28
|
# @param transaction_info [String] Transaction information to identify the brand
|
18
29
|
#
|
30
|
+
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th
|
31
|
+
#
|
19
32
|
# @param request_options [BrandDev::RequestOptions, Hash{Symbol=>Object}]
|
20
33
|
end
|
21
34
|
end
|