autom 0.1.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.
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Autom
4
+ # Base class for every SDK-defined error.
5
+ class Error < StandardError; end
6
+
7
+ # The client configuration is missing or unusable.
8
+ class ConfigurationError < Error; end
9
+
10
+ # A request value cannot be represented safely on the wire.
11
+ class SerializationError < Error
12
+ attr_reader :param
13
+
14
+ def initialize(message, param = nil)
15
+ super(message)
16
+ @param = param
17
+ end
18
+ end
19
+
20
+ # The request failed before a complete HTTP response was received.
21
+ class TransportError < Error; end
22
+
23
+ # Autom returned a non-success HTTP status.
24
+ class APIError < Error
25
+ attr_reader :status, :error_message, :response_body, :raw_response
26
+
27
+ def initialize(raw_response:, response_body: nil, error_message: nil)
28
+ super(error_message || "Autom API request failed with status #{raw_response.status}.")
29
+ @status = raw_response.status
30
+ @error_message = error_message
31
+ @response_body = response_body
32
+ @raw_response = raw_response
33
+ end
34
+ end
35
+
36
+ # A successful response could not be decoded as the documented representation.
37
+ class ResponseDecodingError < Error
38
+ attr_reader :raw_response
39
+
40
+ def initialize(message, raw_response)
41
+ super(message)
42
+ @raw_response = raw_response
43
+ end
44
+ end
45
+
46
+ # An async job did not reach a terminal status before the deadline.
47
+ class JobTimeoutError < Error
48
+ attr_reader :job_id, :last_response
49
+
50
+ def initialize(job_id, last_response = nil)
51
+ super("Job #{job_id} did not finish before the deadline.")
52
+ @job_id = job_id
53
+ @last_response = last_response
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,429 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated from the Autom OpenAPI document. Do not edit by hand.
4
+
5
+ module Autom
6
+ # One method per documented endpoint. Mixed into {Client}.
7
+ module Operations
8
+ # Bing Search. Query Bing Search via API and retrieve structured organic results (title, link, snippet, position). Credit cost: 1 credit per call.
9
+ #
10
+ # +GET / POST /v1/bing/search+
11
+ #
12
+ # @param query [String] (required) The search query you want to run on Bing.
13
+ # @param page [Numeric] Page number for pagination (1 = first page).
14
+ # @param num [Numeric] Number of results per page (e.g. 10, 20, 50). This value is a suggestion.
15
+ # @param location [String] Search origin location (e.g. city).
16
+ # @param lat [Numeric] GPS latitude for the search origin.
17
+ # @param lon [Numeric] GPS longitude for the search origin.
18
+ # @param mkt [String] Market code where results come from (e.g. en-US). Cannot be used together with cc.
19
+ # @param cc [String] Country code to search from (2-letter ISO 3166-1). Cannot be used together with mkt.
20
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
21
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
22
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
23
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
24
+ # @return [JsonResponse]
25
+ def bing_search(request_options: nil, **params)
26
+ call_operation("bing_search", params, request_options)
27
+ end
28
+
29
+ # Brave Images. Search Brave Images via API and retrieve structured image results with pagination and SafeSearch. Credit cost: 1 credit per call.
30
+ #
31
+ # +GET / POST /v1/brave/images+
32
+ #
33
+ # @param query [String] (required) The search query you want to run on Brave Images.
34
+ # @param page [Numeric] Page number for pagination (50 results per page).
35
+ # @param gl [String] Country code (e.g. fr, us). Mapped to Brave country.
36
+ # @param hl [String] Language code (e.g. fr, en). Mapped to Brave lang.
37
+ # @param safe [String] SafeSearch: active | off | moderate | strict. Google-style active maps to Brave strict.
38
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
39
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
40
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
41
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
42
+ # @return [JsonResponse]
43
+ def brave_images(request_options: nil, **params)
44
+ call_operation("brave_images", params, request_options)
45
+ end
46
+
47
+ # Brave Search. Search Brave Search via API and retrieve structured organic results with pagination. Credit cost: 1 credit per call.
48
+ #
49
+ # +GET / POST /v1/brave/search+
50
+ #
51
+ # @param query [String] (required) The search query you want to run on Brave Search.
52
+ # @param page [Numeric] Page number for pagination.
53
+ # @param gl [String] Country code, for example us, fr, gb, de.
54
+ # @param hl [String] Language code, for example en, fr, de.
55
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
56
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
57
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
58
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
59
+ # @return [JsonResponse]
60
+ def brave_search(request_options: nil, **params)
61
+ call_operation("brave_search", params, request_options)
62
+ end
63
+
64
+ # Brave Videos. Search Brave Videos via API and retrieve structured video results with pagination and SafeSearch. Credit cost: 1 credit per call.
65
+ #
66
+ # +GET / POST /v1/brave/videos+
67
+ #
68
+ # @param query [String] (required) The search query you want to run on Brave Videos.
69
+ # @param page [Numeric] Page number for pagination.
70
+ # @param gl [String] Country code (e.g. fr, us). Mapped to Brave country.
71
+ # @param hl [String] Language code (e.g. fr, en). Mapped to Brave lang.
72
+ # @param safe [String] SafeSearch: active | off | moderate | strict. Google-style active maps to Brave strict.
73
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
74
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
75
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
76
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
77
+ # @return [JsonResponse]
78
+ def brave_videos(request_options: nil, **params)
79
+ call_operation("brave_videos", params, request_options)
80
+ end
81
+
82
+ # DuckDuckGo Search. Query DuckDuckGo via API and retrieve structured organic results with region and language. Credit cost: 1 credit per call.
83
+ #
84
+ # +GET / POST /v1/duckduckgo/search+
85
+ #
86
+ # @param query [String] (required) Search query sent to DuckDuckGo Search.
87
+ # @param page [Numeric] Page number. Page 1 is the first page of results.
88
+ # @param gl [String] Country code, for example us, fr, gb, de, jp.
89
+ # @param hl [String] Language code, for example en, fr, de, ja, zh.
90
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
91
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
92
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
93
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
94
+ # @return [JsonResponse]
95
+ def duckduckgo_search(request_options: nil, **params)
96
+ call_operation("duckduckgo_search", params, request_options)
97
+ end
98
+
99
+ # Google Countries. Search Google countries and retrieve country codes (free Finder endpoint).
100
+ #
101
+ # +GET /v1/finder/google-countries+
102
+ #
103
+ # @param query [String] (required) Filter countries by a search string (case-insensitive). Returns all countries whose code or name matches the specified query.
104
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
105
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
106
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
107
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
108
+ # @return [JsonResponse]
109
+ def finder_google_countries(request_options: nil, **params)
110
+ call_operation("finder_google_countries", params, request_options)
111
+ end
112
+
113
+ # Google Languages. Search Google languages and retrieve language codes (free Finder endpoint).
114
+ #
115
+ # +GET /v1/finder/google-languages+
116
+ #
117
+ # @param query [String] (required) Filter languages by a search string (case-insensitive). Returns all languages whose names contain the specified string.
118
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
119
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
120
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
121
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
122
+ # @return [JsonResponse]
123
+ def finder_google_languages(request_options: nil, **params)
124
+ call_operation("finder_google_languages", params, request_options)
125
+ end
126
+
127
+ # Google Locations. Find supported Google locations and retrieve location IDs and country codes (free endpoint).
128
+ #
129
+ # +GET /v1/finder/google-locations+
130
+ #
131
+ # @param query [String] (required) Search locations supported by Piloterr (cities, countries, etc.) by providing a query string. Returns matching locations ordered by reach.
132
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
133
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
134
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
135
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
136
+ # @return [JsonResponse]
137
+ def finder_google_locations(request_options: nil, **params)
138
+ call_operation("finder_google_locations", params, request_options)
139
+ end
140
+
141
+ # Google Images. Search Google Images via API and retrieve image results (URLs, titles, sources, dimensions). Credit cost: 1 credit per call.
142
+ #
143
+ # +GET / POST /v1/google/images+
144
+ #
145
+ # @param query [String] (required) Query you want to search on Google Images (e.g. "lion", "nike logo", "modern house exterior").
146
+ # @param page [Numeric] Page number for pagination (1 = first page).
147
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
148
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
149
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
150
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
151
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
152
+ # @param async [Boolean] If true, returns a job and lets you fetch results asynchronously.
153
+ # @param safe [String] Adult content filter. active enables Google SafeSearch; off disables it. Omit to use Google default.
154
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
155
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
156
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
157
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
158
+ # @return [JsonResponse]
159
+ def google_images(request_options: nil, **params)
160
+ call_operation("google_images", params, request_options)
161
+ end
162
+
163
+ # Google Jobs. Scrape Google Jobs results via API and retrieve structured job listings with title, company, location, and pagination. Credit cost: 1 credit per call.
164
+ #
165
+ # +GET / POST /v1/google/jobs+
166
+ #
167
+ # @param query [String] (required) The job search query to run on Google Jobs (e.g. developer, barista new york).
168
+ # @param uds [String] Advanced search filters string for Google Jobs (encoded filter chips).
169
+ # @param lrad [Numeric] Search radius in kilometers. Does not strictly limit the radius, but influences result proximity.
170
+ # @param ltype [Numeric] Filter results by work type. Set to 1 to filter for work from home / remote jobs.
171
+ # @param location [String] Human-readable location to originate the search from (e.g. New York, NY, Paris, France). If several locations match, the most popular one is used. Note: location and uule cannot be used together.
172
+ # @param uule [String] Google encoded location parameter. Use for precise geo targeting. Note: uule and location cannot be used together.
173
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
174
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
175
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
176
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
177
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
178
+ # @param next_page_token [String] Token to fetch the next page of results. Returned in the serpapi_pagination.next_page_token field of the previous response.
179
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
180
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
181
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
182
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
183
+ # @return [JsonResponse]
184
+ def google_jobs(request_options: nil, **params)
185
+ call_operation("google_jobs", params, request_options)
186
+ end
187
+
188
+ # Google Maps. Search Google Maps via API and retrieve structured place results (address, website, phone). Credit cost: 1 credit per call.
189
+ #
190
+ # +GET / POST /v1/google/maps+
191
+ #
192
+ # @param query [String] (required) Search query for Google Maps (e.g. business type, brand, or place name).
193
+ # @param page [Numeric] Page number for pagination (1 = first page).
194
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
195
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
196
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
197
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
198
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
199
+ # @param ll [String] Map center / geo hint in Google format (e.g. @43.5131985,1.4600501,60m). Helps focus results around a coordinate and zoom radius.
200
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
201
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
202
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
203
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
204
+ # @return [JsonResponse]
205
+ def google_maps(request_options: nil, **params)
206
+ call_operation("google_maps", params, request_options)
207
+ end
208
+
209
+ # Google News. Search Google News via API and retrieve structured news results with pagination. Credit cost: 1 credit per call.
210
+ #
211
+ # +GET / POST /v1/google/news+
212
+ #
213
+ # @param query [String] (required) Query to search on Google News (keywords, company, topic).
214
+ # @param page [Numeric] Page number for pagination (1 = first page).
215
+ # @param num [Numeric] Maximum number of results per page (e.g. 10).
216
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
217
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
218
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
219
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
220
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
221
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
222
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
223
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
224
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
225
+ # @return [JsonResponse]
226
+ def google_news(request_options: nil, **params)
227
+ call_operation("google_news", params, request_options)
228
+ end
229
+
230
+ # Google Search. Scrape Google Search results via API and retrieve structured SERP data with pagination. Credit cost: 1 credit per call.
231
+ #
232
+ # +GET / POST /v1/google/search+
233
+ #
234
+ # @param query [String] (required) The search query you want to run on Google (supports advanced operators like site:, inurl:, intitle:).
235
+ # @param tbs [String] Advanced search filters string (e.g. time ranges: qdr:h last hour, qdr:d last day, qdr:w last week, qdr:m last month, qdr:y last year).
236
+ # @param safe [String] Adult content filter. active enables Google SafeSearch; off disables it. Omit to use Google default.
237
+ # @param location [String] Human-readable location to originate the search from (e.g. New York, NY, Paris, France). If several locations match, the most popular one is used. Note: location and uule cannot be used together.
238
+ # @param uule [String] Google encoded location parameter. Use for precise geo targeting. Note: uule and location cannot be used together.
239
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
240
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
241
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
242
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
243
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
244
+ # @param page [Numeric] Page number / offset used for pagination.
245
+ # @param num [Numeric] Maximum number of results to return per page (deprecated).
246
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
247
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
248
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
249
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
250
+ # @return [JsonResponse]
251
+ def google_search(request_options: nil, **params)
252
+ call_operation("google_search", params, request_options)
253
+ end
254
+
255
+ # Google AI Mode. Query Google AI Mode via API. JSON with text_blocks, references, and shopping_results. Credit cost: 3 credits per call.
256
+ #
257
+ # +GET / POST /v1/google/search/ai+
258
+ #
259
+ # @param query [String] (required) The question or search query you want Google AI Mode to answer (supports advanced operators like site:, inurl:, intitle:).
260
+ # @param location [String] Human-readable location to originate the search from (e.g. New York, NY, Paris, France). If several locations match, the most popular one is used. Note: location and uule cannot be used together.
261
+ # @param uule [String] Google encoded location parameter. Use for precise geo targeting. Note: uule and location cannot be used together.
262
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
263
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
264
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
265
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
266
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
267
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
268
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
269
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
270
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
271
+ # @return [JsonResponse]
272
+ def google_search_ai(request_options: nil, **params)
273
+ call_operation("google_search_ai", params, request_options)
274
+ end
275
+
276
+ # Google Search Autocomplete. Get Google Search autocomplete suggestions via API for a given query. Credit cost: 1 credit per call.
277
+ #
278
+ # +GET / POST /v1/google/search/autocomplete+
279
+ #
280
+ # @param query [String] (required) The search query for which you want to get autocomplete suggestions.
281
+ # @param cp [Numeric] Cursor position in the search query where you want to get autocomplete suggestions.
282
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
283
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
284
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
285
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
286
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
287
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
288
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
289
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
290
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
291
+ # @return [JsonResponse]
292
+ def google_search_autocomplete(request_options: nil, **params)
293
+ call_operation("google_search_autocomplete", params, request_options)
294
+ end
295
+
296
+ # Google Search Light. Scrape lightweight Google Search results via API: fast, cost-efficient, organic results only. Credit cost: 1 credit per call.
297
+ #
298
+ # +GET / POST /v1/google/search/light+
299
+ #
300
+ # @param query [String] (required) The search query you want to run on Google (supports advanced operators like site:, inurl:, intitle:).
301
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
302
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
303
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
304
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
305
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
306
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
307
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
308
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
309
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
310
+ # @return [JsonResponse]
311
+ def google_search_light(request_options: nil, **params)
312
+ call_operation("google_search_light", params, request_options)
313
+ end
314
+
315
+ # Google Shopping. Scrape Google Shopping results via API and retrieve structured product listings with prices, ratings, and merchant data. Credit cost: 1 credit per call.
316
+ #
317
+ # +GET / POST /v1/google/shopping+
318
+ #
319
+ # @param query [String] (required) Query to search on Google Shopping (product name, brand, category).
320
+ # @param page [Numeric] Page number for pagination (1 = first page).
321
+ # @param location [String] Location to localize results (e.g. New York, United States). Generates a UULE parameter automatically.
322
+ # @param uule [String] Encoded location parameter (UULE). Use location instead if you don't have a pre-encoded value.
323
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
324
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
325
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
326
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
327
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
328
+ # @param safe [String] Adult content filter. active enables Google SafeSearch; off disables it. Omit to use Google default.
329
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
330
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
331
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
332
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
333
+ # @return [JsonResponse]
334
+ def google_shopping(request_options: nil, **params)
335
+ call_operation("google_shopping", params, request_options)
336
+ end
337
+
338
+ # Google Videos. Search Google Videos via API and retrieve structured video results with metadata. Credit cost: 1 credit per call.
339
+ #
340
+ # +GET / POST /v1/google/videos+
341
+ #
342
+ # @param query [String] (required) The search query you want to run on Google Videos.
343
+ # @param location [String] Human-readable location to originate the search from. Note: location and uule cannot be used together.
344
+ # @param uule [String] Google encoded location parameter. Note: uule and location cannot be used together.
345
+ # @param google_domain [String] Google domain to use for the search. Defaults to google.com.
346
+ # @param gl [String] Country to use for the Google search. Two-letter country code (e.g. us for the United States, uk for United Kingdom, or fr for France).
347
+ # @param hl [String] Language to use for the Google search. Two or three-letter language code (e.g. en, es, fr), optionally followed by a region code (e.g. en-gb, es-419).
348
+ # @param cr [String] Limit results to one or more countries. Use country{XX} with | as delimiter (e.g. countryFR|countryDE).
349
+ # @param lr [String] Limit results to one or more languages. Use lang_{xx} with | as delimiter (e.g. lang_fr|lang_de).
350
+ # @param page [Numeric] (required) Page number for pagination (1 = first page).
351
+ # @param num [Numeric] Maximum number of results per page (e.g. 10).
352
+ # @param safe [String] Adult content filter. active enables Google SafeSearch; off disables it. Omit to use Google default.
353
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
354
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
355
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
356
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
357
+ # @return [JsonResponse]
358
+ def google_videos(request_options: nil, **params)
359
+ call_operation("google_videos", params, request_options)
360
+ end
361
+
362
+ # Jobs. Poll the status, progress (0–100) and result of a job started with is_async=true. Polling is free. Poll until status is terminal: CompletedJob, Error, NotFound or BadRequest.
363
+ #
364
+ # +GET /v1/jobs/{id}+
365
+ #
366
+ # @param id [String] (required) The job_id returned by an endpoint called with is_async=true.
367
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
368
+ # @return [JsonResponse]
369
+ def jobs(request_options: nil, **params)
370
+ call_operation("jobs", params, request_options)
371
+ end
372
+
373
+ # Search. One call walks engines in order and returns the first organic results. engines=auto tries Google, then Brave, Bing, DuckDuckGo, Yahoo, and Baidu. Omitted gl is us and omitted hl is en. There is no page parameter: the response is always pag… Credit cost: 1 credit per call.
374
+ #
375
+ # +GET / POST /v1/search+
376
+ #
377
+ # @param query [String] (required) Search query.
378
+ # @param engines [String] Engine order. Default auto tries google, brave, bing, duckduckgo, yahoo, then baidu. A comma-separated list is followed as given. ddg and duck mean duckduckgo. Unknown names are ignored.
379
+ # @param gl [String] Country code. Defaults to us when omitted. For example us, fr, gb, de.
380
+ # @param hl [String] Language code. Defaults to en when omitted. For example en, fr, de.
381
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
382
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
383
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
384
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
385
+ # @return [JsonResponse]
386
+ def search(request_options: nil, **params)
387
+ call_operation("search", params, request_options)
388
+ end
389
+
390
+ # Stats. Infrastructure health for an engine or endpoint over the last hour. Not scoped to your account or tenant. Enabled per account: HTTP 403 means contact support to activate it.
391
+ #
392
+ # +GET /v1/stats+
393
+ #
394
+ # @param engine [String] API family to check, for example google. Provide at least engine or path.
395
+ # @param path [String] Specific endpoint to check, for example /v1/google/search. If you also pass engine, use an endpoint from that API.
396
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
397
+ # @return [JsonResponse]
398
+ def stats(request_options: nil, **params)
399
+ call_operation("stats", params, request_options)
400
+ end
401
+
402
+ # Usage. Retrieve real-time usage statistics and credit balance for your Autom account.
403
+ #
404
+ # +GET /v1/usage+
405
+ #
406
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
407
+ # @return [JsonResponse]
408
+ def usage(request_options: nil, **params)
409
+ call_operation("usage", params, request_options)
410
+ end
411
+
412
+ # Yahoo Search. Query Yahoo via API and retrieve structured organic results with country and language. Credit cost: 1 credit per call.
413
+ #
414
+ # +GET / POST /v1/yahoo/search+
415
+ #
416
+ # @param query [String] (required) Search query sent to Yahoo Search.
417
+ # @param page [Numeric] Page number. Page 1 is the first page of results.
418
+ # @param gl [String] Country code, for example us, fr, gb, de, jp.
419
+ # @param hl [String] Language code, for example en, fr, de, ja, zh.
420
+ # @param fields [String] Comma-separated list of fields to keep in the response, with dot notation for nested fields (e.g. name,location.city). Does not change the credit cost.
421
+ # @param is_async [Boolean] Process the request asynchronously: the response is a job_id to poll on /v1/jobs/{id} (see waitForJob).
422
+ # @param soft_fail [Boolean] Return HTTP 200 even when an error occurs; the error is then in the response body.
423
+ # @param request_options [Hash, nil] +:method+ ("GET"/"POST"), +:timeout+ (seconds), +:headers+
424
+ # @return [JsonResponse]
425
+ def yahoo_search(request_options: nil, **params)
426
+ call_operation("yahoo_search", params, request_options)
427
+ end
428
+ end
429
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Autom
4
+ # Buffered HTTP response: status, lower-cased multi-value headers, content type and body bytes.
5
+ RawResponse = Struct.new(:status, :headers, :content_type, :body, keyword_init: true)
6
+
7
+ # Outcome of one Client#batch item: +value+ when +ok?+, else +error+.
8
+ BatchResult = Struct.new(:index, :value, :error, keyword_init: true) do
9
+ def ok? = error.nil?
10
+ end
11
+
12
+ # A successful JSON response; +data+ is the parsed body (string keys).
13
+ class JsonResponse
14
+ attr_reader :data, :raw_response
15
+
16
+ def initialize(data:, raw_response:)
17
+ @data = data
18
+ @raw_response = raw_response
19
+ end
20
+
21
+ def kind = :json
22
+ def json? = true
23
+ def binary? = false
24
+ end
25
+
26
+ # A successful non-JSON response (image, PDF, HTML…).
27
+ class BinaryResponse
28
+ attr_reader :bytes, :content_type, :raw_response
29
+
30
+ def initialize(bytes:, content_type:, raw_response:)
31
+ @bytes = bytes
32
+ @content_type = content_type
33
+ @raw_response = raw_response
34
+ end
35
+
36
+ def kind = :binary
37
+ def json? = false
38
+ def binary? = true
39
+
40
+ # Writes the body to +path+ and returns the number of bytes written.
41
+ def save(path)
42
+ File.binwrite(path, bytes)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "uri"
5
+
6
+ module Autom
7
+ # Request serialization: path filling, query pairs and JSON bodies.
8
+ module Serialization
9
+ QUERY_STRING_PARAMS = %w[fields is_async soft_fail].freeze
10
+
11
+ module_function
12
+
13
+ # Fills {name} path segments, then returns [path, query_pairs, body].
14
+ # nil values are omitted; false and 0 are sent.
15
+ def serialize(method, path_template, params)
16
+ raise SerializationError, "Request parameters must be a Hash." unless params.nil? || params.is_a?(Hash)
17
+
18
+ remaining = {}
19
+ (params || {}).each { |name, value| remaining[name.to_s] = value unless value.nil? }
20
+ path = path_template.gsub(/\{([^}]+)\}/) do
21
+ name = Regexp.last_match(1)
22
+ raise SerializationError.new("The \"#{name}\" path parameter is required.", name) unless remaining.key?(name)
23
+
24
+ URI.encode_www_form_component(wire_string(name, remaining.delete(name))).gsub("+", "%20")
25
+ end
26
+
27
+ if method == "POST"
28
+ # The API reads the global parameters from the query string, whatever the method.
29
+ globals = QUERY_STRING_PARAMS.filter_map { |name| [name, wire_string(name, remaining.delete(name))] if remaining.key?(name) }
30
+ return [path, globals, remaining]
31
+ end
32
+
33
+ pairs = []
34
+ remaining.each do |name, value|
35
+ if value.is_a?(Array)
36
+ value.each { |item| pairs << [name, wire_string(name, item)] unless item.nil? }
37
+ else
38
+ pairs << [name, wire_string(name, value)]
39
+ end
40
+ end
41
+ [path, pairs, nil]
42
+ end
43
+
44
+ def wire_string(name, value)
45
+ case value
46
+ when String then value
47
+ when true, false, Integer, Symbol then value.to_s
48
+ when Float
49
+ raise SerializationError.new("The \"#{name}\" parameter must be a finite number.", name) unless value.finite?
50
+
51
+ value == value.floor ? value.to_i.to_s : value.to_s
52
+ when Hash, Array then JSON.generate(value)
53
+ else
54
+ raise SerializationError.new("The \"#{name}\" parameter has an unsupported type (#{value.class}).", name)
55
+ end
56
+ end
57
+
58
+ def encode_query(pairs)
59
+ pairs.map { |name, value| "#{escape(name)}=#{escape(value)}" }.join("&")
60
+ end
61
+
62
+ def escape(value)
63
+ URI.encode_www_form_component(value).gsub("+", "%20")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "uri"
5
+
6
+ module Autom
7
+ # Default transport on Net::HTTP. A custom transport is any object with
8
+ # +call(method:, url:, headers:, body:, timeout:)+ returning +[status, headers, body]+,
9
+ # where headers is a Hash of lower-cased names to arrays of values.
10
+ class NetHTTPTransport
11
+ def call(method:, url:, headers:, body:, timeout:)
12
+ uri = URI(url)
13
+ request = (method == "POST" ? Net::HTTP::Post : Net::HTTP::Get).new(uri)
14
+ headers.each { |name, value| request[name] = value }
15
+ request.body = body if body
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ http.use_ssl = uri.scheme == "https"
18
+ if timeout
19
+ http.open_timeout = timeout
20
+ http.read_timeout = timeout
21
+ http.write_timeout = timeout
22
+ end
23
+ response = http.start { |connection| connection.request(request) }
24
+ [response.code.to_i, response.to_hash, response.body || ""]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Autom
4
+ VERSION = "0.1.0"
5
+ end
data/lib/autom.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "autom/version"
4
+ require_relative "autom/errors"
5
+ require_relative "autom/responses"
6
+ require_relative "autom/serialization"
7
+ require_relative "autom/transport"
8
+ require_relative "autom/endpoints"
9
+ require_relative "autom/operations"
10
+ require_relative "autom/client"
11
+
12
+ # Official Ruby SDK for the Autom API (https://www.autom.dev).
13
+ module Autom
14
+ end