context.dev 1.13.0 → 1.15.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/context_dev/models/brand_retrieve_by_email_params.rb +12 -1
  5. data/lib/context_dev/models/brand_retrieve_by_isin_params.rb +12 -1
  6. data/lib/context_dev/models/brand_retrieve_by_name_params.rb +12 -1
  7. data/lib/context_dev/models/brand_retrieve_by_ticker_params.rb +12 -1
  8. data/lib/context_dev/models/brand_retrieve_params.rb +12 -1
  9. data/lib/context_dev/models/brand_retrieve_simplified_params.rb +12 -1
  10. data/lib/context_dev/models/web_web_scrape_images_params.rb +66 -3
  11. data/lib/context_dev/models/web_web_scrape_images_response.rb +91 -18
  12. data/lib/context_dev/resources/brand.rb +24 -12
  13. data/lib/context_dev/resources/web.rb +14 -6
  14. data/lib/context_dev/version.rb +1 -1
  15. data/rbi/context_dev/models/brand_retrieve_by_email_params.rbi +17 -0
  16. data/rbi/context_dev/models/brand_retrieve_by_isin_params.rbi +17 -0
  17. data/rbi/context_dev/models/brand_retrieve_by_name_params.rbi +17 -0
  18. data/rbi/context_dev/models/brand_retrieve_by_ticker_params.rbi +17 -0
  19. data/rbi/context_dev/models/brand_retrieve_params.rbi +17 -0
  20. data/rbi/context_dev/models/brand_retrieve_simplified_params.rbi +17 -0
  21. data/rbi/context_dev/models/web_web_scrape_images_params.rbi +113 -3
  22. data/rbi/context_dev/models/web_web_scrape_images_response.rbi +205 -20
  23. data/rbi/context_dev/resources/brand.rbi +36 -0
  24. data/rbi/context_dev/resources/web.rbi +13 -4
  25. data/sig/context_dev/models/brand_retrieve_by_email_params.rbs +7 -0
  26. data/sig/context_dev/models/brand_retrieve_by_isin_params.rbs +7 -0
  27. data/sig/context_dev/models/brand_retrieve_by_name_params.rbs +7 -0
  28. data/sig/context_dev/models/brand_retrieve_by_ticker_params.rbs +7 -0
  29. data/sig/context_dev/models/brand_retrieve_params.rbs +7 -0
  30. data/sig/context_dev/models/brand_retrieve_simplified_params.rbs +7 -1
  31. data/sig/context_dev/models/web_web_scrape_images_params.rbs +60 -1
  32. data/sig/context_dev/models/web_web_scrape_images_response.rbs +86 -3
  33. data/sig/context_dev/resources/brand.rbs +6 -0
  34. data/sig/context_dev/resources/web.rbs +2 -0
  35. metadata +1 -1
@@ -183,13 +183,21 @@ module ContextDev
183
183
  )
184
184
  end
185
185
 
186
- # Scrapes all images from the given URL. Extracts images from img, svg,
187
- # picture/source, link, and video elements including inline SVGs, base64 data
188
- # URIs, and standard URLs.
186
+ # Some parameter documentations has been truncated, see
187
+ # {ContextDev::Models::WebWebScrapeImagesParams} for more details.
188
+ #
189
+ # Extract image assets from a web page, including standard URLs, inline SVGs, data
190
+ # URIs, responsive image sources, metadata, CSS backgrounds, video posters, and
191
+ # embeds. The base request costs 1 credit; enrichment costs 1 credit per returned
192
+ # image.
193
+ #
194
+ # @overload web_scrape_images(url:, enrichment: nil, max_age_ms: nil, request_options: {})
195
+ #
196
+ # @param url [String] Page URL to inspect. Must include http:// or https://.
189
197
  #
190
- # @overload web_scrape_images(url:, request_options: {})
198
+ # @param enrichment [ContextDev::Models::WebWebScrapeImagesParams::Enrichment] Optional per-image processing, sent as deep-object query params such as enrichme
191
199
  #
192
- # @param url [String] Full URL to scrape images from (must include http:// or https:// protocol)
200
+ # @param max_age_ms [Integer] Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1
193
201
  #
194
202
  # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]
195
203
  #
@@ -202,7 +210,7 @@ module ContextDev
202
210
  @client.request(
203
211
  method: :get,
204
212
  path: "web/scrape/images",
205
- query: query,
213
+ query: query.transform_keys(max_age_ms: "maxAgeMs"),
206
214
  model: ContextDev::Models::WebWebScrapeImagesResponse,
207
215
  options: options
208
216
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextDev
4
- VERSION = "1.13.0"
4
+ VERSION = "1.15.0"
5
5
  end
@@ -38,6 +38,16 @@ module ContextDev
38
38
  end
39
39
  attr_writer :force_language
40
40
 
41
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
42
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
43
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
44
+ # year.
45
+ sig { returns(T.nilable(Integer)) }
46
+ attr_reader :max_age_ms
47
+
48
+ sig { params(max_age_ms: Integer).void }
49
+ attr_writer :max_age_ms
50
+
41
51
  # Optional parameter to optimize the API call for maximum speed. When set to true,
42
52
  # the API will skip time-consuming operations for faster response at the cost of
43
53
  # less comprehensive data.
@@ -61,6 +71,7 @@ module ContextDev
61
71
  email: String,
62
72
  force_language:
63
73
  ContextDev::BrandRetrieveByEmailParams::ForceLanguage::OrSymbol,
74
+ max_age_ms: Integer,
64
75
  max_speed: T::Boolean,
65
76
  timeout_ms: Integer,
66
77
  request_options: ContextDev::RequestOptions::OrHash
@@ -73,6 +84,11 @@ module ContextDev
73
84
  email:,
74
85
  # Optional parameter to force the language of the retrieved brand data.
75
86
  force_language: nil,
87
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
88
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
89
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
90
+ # year.
91
+ max_age_ms: nil,
76
92
  # Optional parameter to optimize the API call for maximum speed. When set to true,
77
93
  # the API will skip time-consuming operations for faster response at the cost of
78
94
  # less comprehensive data.
@@ -91,6 +107,7 @@ module ContextDev
91
107
  email: String,
92
108
  force_language:
93
109
  ContextDev::BrandRetrieveByEmailParams::ForceLanguage::OrSymbol,
110
+ max_age_ms: Integer,
94
111
  max_speed: T::Boolean,
95
112
  timeout_ms: Integer,
96
113
  request_options: ContextDev::RequestOptions
@@ -38,6 +38,16 @@ module ContextDev
38
38
  end
39
39
  attr_writer :force_language
40
40
 
41
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
42
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
43
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
44
+ # year.
45
+ sig { returns(T.nilable(Integer)) }
46
+ attr_reader :max_age_ms
47
+
48
+ sig { params(max_age_ms: Integer).void }
49
+ attr_writer :max_age_ms
50
+
41
51
  # Optional parameter to optimize the API call for maximum speed. When set to true,
42
52
  # the API will skip time-consuming operations for faster response at the cost of
43
53
  # less comprehensive data.
@@ -61,6 +71,7 @@ module ContextDev
61
71
  isin: String,
62
72
  force_language:
63
73
  ContextDev::BrandRetrieveByIsinParams::ForceLanguage::OrSymbol,
74
+ max_age_ms: Integer,
64
75
  max_speed: T::Boolean,
65
76
  timeout_ms: Integer,
66
77
  request_options: ContextDev::RequestOptions::OrHash
@@ -73,6 +84,11 @@ module ContextDev
73
84
  isin:,
74
85
  # Optional parameter to force the language of the retrieved brand data.
75
86
  force_language: nil,
87
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
88
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
89
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
90
+ # year.
91
+ max_age_ms: nil,
76
92
  # Optional parameter to optimize the API call for maximum speed. When set to true,
77
93
  # the API will skip time-consuming operations for faster response at the cost of
78
94
  # less comprehensive data.
@@ -91,6 +107,7 @@ module ContextDev
91
107
  isin: String,
92
108
  force_language:
93
109
  ContextDev::BrandRetrieveByIsinParams::ForceLanguage::OrSymbol,
110
+ max_age_ms: Integer,
94
111
  max_speed: T::Boolean,
95
112
  timeout_ms: Integer,
96
113
  request_options: ContextDev::RequestOptions
@@ -53,6 +53,16 @@ module ContextDev
53
53
  end
54
54
  attr_writer :force_language
55
55
 
56
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
57
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
58
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
59
+ # year.
60
+ sig { returns(T.nilable(Integer)) }
61
+ attr_reader :max_age_ms
62
+
63
+ sig { params(max_age_ms: Integer).void }
64
+ attr_writer :max_age_ms
65
+
56
66
  # Optional parameter to optimize the API call for maximum speed. When set to true,
57
67
  # the API will skip time-consuming operations for faster response at the cost of
58
68
  # less comprehensive data.
@@ -78,6 +88,7 @@ module ContextDev
78
88
  ContextDev::BrandRetrieveByNameParams::CountryGl::OrSymbol,
79
89
  force_language:
80
90
  ContextDev::BrandRetrieveByNameParams::ForceLanguage::OrSymbol,
91
+ max_age_ms: Integer,
81
92
  max_speed: T::Boolean,
82
93
  timeout_ms: Integer,
83
94
  request_options: ContextDev::RequestOptions::OrHash
@@ -92,6 +103,11 @@ module ContextDev
92
103
  country_gl: nil,
93
104
  # Optional parameter to force the language of the retrieved brand data.
94
105
  force_language: nil,
106
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
107
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
108
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
109
+ # year.
110
+ max_age_ms: nil,
95
111
  # Optional parameter to optimize the API call for maximum speed. When set to true,
96
112
  # the API will skip time-consuming operations for faster response at the cost of
97
113
  # less comprehensive data.
@@ -112,6 +128,7 @@ module ContextDev
112
128
  ContextDev::BrandRetrieveByNameParams::CountryGl::OrSymbol,
113
129
  force_language:
114
130
  ContextDev::BrandRetrieveByNameParams::ForceLanguage::OrSymbol,
131
+ max_age_ms: Integer,
115
132
  max_speed: T::Boolean,
116
133
  timeout_ms: Integer,
117
134
  request_options: ContextDev::RequestOptions
@@ -37,6 +37,16 @@ module ContextDev
37
37
  end
38
38
  attr_writer :force_language
39
39
 
40
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
41
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
42
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
43
+ # year.
44
+ sig { returns(T.nilable(Integer)) }
45
+ attr_reader :max_age_ms
46
+
47
+ sig { params(max_age_ms: Integer).void }
48
+ attr_writer :max_age_ms
49
+
40
50
  # Optional parameter to optimize the API call for maximum speed. When set to true,
41
51
  # the API will skip time-consuming operations for faster response at the cost of
42
52
  # less comprehensive data.
@@ -78,6 +88,7 @@ module ContextDev
78
88
  ticker: String,
79
89
  force_language:
80
90
  ContextDev::BrandRetrieveByTickerParams::ForceLanguage::OrSymbol,
91
+ max_age_ms: Integer,
81
92
  max_speed: T::Boolean,
82
93
  ticker_exchange:
83
94
  ContextDev::BrandRetrieveByTickerParams::TickerExchange::OrSymbol,
@@ -91,6 +102,11 @@ module ContextDev
91
102
  ticker:,
92
103
  # Optional parameter to force the language of the retrieved brand data.
93
104
  force_language: nil,
105
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
106
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
107
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
108
+ # year.
109
+ max_age_ms: nil,
94
110
  # Optional parameter to optimize the API call for maximum speed. When set to true,
95
111
  # the API will skip time-consuming operations for faster response at the cost of
96
112
  # less comprehensive data.
@@ -111,6 +127,7 @@ module ContextDev
111
127
  ticker: String,
112
128
  force_language:
113
129
  ContextDev::BrandRetrieveByTickerParams::ForceLanguage::OrSymbol,
130
+ max_age_ms: Integer,
114
131
  max_speed: T::Boolean,
115
132
  ticker_exchange:
116
133
  ContextDev::BrandRetrieveByTickerParams::TickerExchange::OrSymbol,
@@ -32,6 +32,16 @@ module ContextDev
32
32
  end
33
33
  attr_writer :force_language
34
34
 
35
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
36
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
37
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
38
+ # year.
39
+ sig { returns(T.nilable(Integer)) }
40
+ attr_reader :max_age_ms
41
+
42
+ sig { params(max_age_ms: Integer).void }
43
+ attr_writer :max_age_ms
44
+
35
45
  # Optional parameter to optimize the API call for maximum speed. When set to true,
36
46
  # the API will skip time-consuming operations for faster response at the cost of
37
47
  # less comprehensive data. Works with all three lookup methods.
@@ -55,6 +65,7 @@ module ContextDev
55
65
  domain: String,
56
66
  force_language:
57
67
  ContextDev::BrandRetrieveParams::ForceLanguage::OrSymbol,
68
+ max_age_ms: Integer,
58
69
  max_speed: T::Boolean,
59
70
  timeout_ms: Integer,
60
71
  request_options: ContextDev::RequestOptions::OrHash
@@ -66,6 +77,11 @@ module ContextDev
66
77
  domain:,
67
78
  # Optional parameter to force the language of the retrieved brand data.
68
79
  force_language: nil,
80
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
81
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
82
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
83
+ # year.
84
+ max_age_ms: nil,
69
85
  # Optional parameter to optimize the API call for maximum speed. When set to true,
70
86
  # the API will skip time-consuming operations for faster response at the cost of
71
87
  # less comprehensive data. Works with all three lookup methods.
@@ -84,6 +100,7 @@ module ContextDev
84
100
  domain: String,
85
101
  force_language:
86
102
  ContextDev::BrandRetrieveParams::ForceLanguage::OrSymbol,
103
+ max_age_ms: Integer,
87
104
  max_speed: T::Boolean,
88
105
  timeout_ms: Integer,
89
106
  request_options: ContextDev::RequestOptions
@@ -18,6 +18,16 @@ module ContextDev
18
18
  sig { returns(String) }
19
19
  attr_accessor :domain
20
20
 
21
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
22
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
23
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
24
+ # year.
25
+ sig { returns(T.nilable(Integer)) }
26
+ attr_reader :max_age_ms
27
+
28
+ sig { params(max_age_ms: Integer).void }
29
+ attr_writer :max_age_ms
30
+
21
31
  # Optional timeout in milliseconds for the request. If the request takes longer
22
32
  # than this value, it will be aborted with a 408 status code. Maximum allowed
23
33
  # value is 300000ms (5 minutes).
@@ -30,6 +40,7 @@ module ContextDev
30
40
  sig do
31
41
  params(
32
42
  domain: String,
43
+ max_age_ms: Integer,
33
44
  timeout_ms: Integer,
34
45
  request_options: ContextDev::RequestOptions::OrHash
35
46
  ).returns(T.attached_class)
@@ -37,6 +48,11 @@ module ContextDev
37
48
  def self.new(
38
49
  # Domain name to retrieve simplified brand data for
39
50
  domain:,
51
+ # Maximum age in milliseconds for cached brand data before the API performs a hard
52
+ # refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms)
53
+ # are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1
54
+ # year.
55
+ max_age_ms: nil,
40
56
  # Optional timeout in milliseconds for the request. If the request takes longer
41
57
  # than this value, it will be aborted with a 408 status code. Maximum allowed
42
58
  # value is 300000ms (5 minutes).
@@ -49,6 +65,7 @@ module ContextDev
49
65
  override.returns(
50
66
  {
51
67
  domain: String,
68
+ max_age_ms: Integer,
52
69
  timeout_ms: Integer,
53
70
  request_options: ContextDev::RequestOptions
54
71
  }
@@ -14,30 +14,140 @@ module ContextDev
14
14
  )
15
15
  end
16
16
 
17
- # Full URL to scrape images from (must include http:// or https:// protocol)
17
+ # Page URL to inspect. Must include http:// or https://.
18
18
  sig { returns(String) }
19
19
  attr_accessor :url
20
20
 
21
+ # Optional per-image processing, sent as deep-object query params such as
22
+ # enrichment[resolution]=true.
23
+ sig do
24
+ returns(T.nilable(ContextDev::WebWebScrapeImagesParams::Enrichment))
25
+ end
26
+ attr_reader :enrichment
27
+
28
+ sig do
29
+ params(
30
+ enrichment: ContextDev::WebWebScrapeImagesParams::Enrichment::OrHash
31
+ ).void
32
+ end
33
+ attr_writer :enrichment
34
+
35
+ # Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1
36
+ # day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
37
+ sig { returns(T.nilable(Integer)) }
38
+ attr_reader :max_age_ms
39
+
40
+ sig { params(max_age_ms: Integer).void }
41
+ attr_writer :max_age_ms
42
+
21
43
  sig do
22
44
  params(
23
45
  url: String,
46
+ enrichment: ContextDev::WebWebScrapeImagesParams::Enrichment::OrHash,
47
+ max_age_ms: Integer,
24
48
  request_options: ContextDev::RequestOptions::OrHash
25
49
  ).returns(T.attached_class)
26
50
  end
27
51
  def self.new(
28
- # Full URL to scrape images from (must include http:// or https:// protocol)
52
+ # Page URL to inspect. Must include http:// or https://.
29
53
  url:,
54
+ # Optional per-image processing, sent as deep-object query params such as
55
+ # enrichment[resolution]=true.
56
+ enrichment: nil,
57
+ # Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1
58
+ # day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
59
+ max_age_ms: nil,
30
60
  request_options: {}
31
61
  )
32
62
  end
33
63
 
34
64
  sig do
35
65
  override.returns(
36
- { url: String, request_options: ContextDev::RequestOptions }
66
+ {
67
+ url: String,
68
+ enrichment: ContextDev::WebWebScrapeImagesParams::Enrichment,
69
+ max_age_ms: Integer,
70
+ request_options: ContextDev::RequestOptions
71
+ }
37
72
  )
38
73
  end
39
74
  def to_hash
40
75
  end
76
+
77
+ class Enrichment < ContextDev::Internal::Type::BaseModel
78
+ OrHash =
79
+ T.type_alias do
80
+ T.any(
81
+ ContextDev::WebWebScrapeImagesParams::Enrichment,
82
+ ContextDev::Internal::AnyHash
83
+ )
84
+ end
85
+
86
+ # Classify each image by visual asset type.
87
+ sig { returns(T.nilable(T::Boolean)) }
88
+ attr_reader :classification
89
+
90
+ sig { params(classification: T::Boolean).void }
91
+ attr_writer :classification
92
+
93
+ # Host materializable images on the Brand.dev CDN and return their URL and MIME
94
+ # type.
95
+ sig { returns(T.nilable(T::Boolean)) }
96
+ attr_reader :hosted_url
97
+
98
+ sig { params(hosted_url: T::Boolean).void }
99
+ attr_writer :hosted_url
100
+
101
+ # Per-image enrichment timeout in milliseconds. Default: 30000. Maximum: 60000.
102
+ sig { returns(T.nilable(Integer)) }
103
+ attr_reader :max_time_per_ms
104
+
105
+ sig { params(max_time_per_ms: Integer).void }
106
+ attr_writer :max_time_per_ms
107
+
108
+ # Measure image width and height when possible.
109
+ sig { returns(T.nilable(T::Boolean)) }
110
+ attr_reader :resolution
111
+
112
+ sig { params(resolution: T::Boolean).void }
113
+ attr_writer :resolution
114
+
115
+ # Optional per-image processing, sent as deep-object query params such as
116
+ # enrichment[resolution]=true.
117
+ sig do
118
+ params(
119
+ classification: T::Boolean,
120
+ hosted_url: T::Boolean,
121
+ max_time_per_ms: Integer,
122
+ resolution: T::Boolean
123
+ ).returns(T.attached_class)
124
+ end
125
+ def self.new(
126
+ # Classify each image by visual asset type.
127
+ classification: nil,
128
+ # Host materializable images on the Brand.dev CDN and return their URL and MIME
129
+ # type.
130
+ hosted_url: nil,
131
+ # Per-image enrichment timeout in milliseconds. Default: 30000. Maximum: 60000.
132
+ max_time_per_ms: nil,
133
+ # Measure image width and height when possible.
134
+ resolution: nil
135
+ )
136
+ end
137
+
138
+ sig do
139
+ override.returns(
140
+ {
141
+ classification: T::Boolean,
142
+ hosted_url: T::Boolean,
143
+ max_time_per_ms: Integer,
144
+ resolution: T::Boolean
145
+ }
146
+ )
147
+ end
148
+ def to_hash
149
+ end
150
+ end
41
151
  end
42
152
  end
43
153
  end