Class: ScrapeBadger::BingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/scrapebadger/api/bing_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ BingApi

Returns a new instance of BingApi.



19
20
21
# File 'lib/scrapebadger/api/bing_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/scrapebadger/api/bing_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#bing_bing_scraper_health_check(opts = {}) ⇒ Object

Bing scraper health check Check health of the Bing scraper service (accepts HEAD for UptimeRobot).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


26
27
28
29
# File 'lib/scrapebadger/api/bing_api.rb', line 26

def bing_bing_scraper_health_check(opts = {})
  data, _status_code, _headers = bing_bing_scraper_health_check_with_http_info(opts)
  data
end

#bing_bing_scraper_health_check_head(opts = {}) ⇒ Object

Bing scraper health check Check health of the Bing scraper service (accepts HEAD for UptimeRobot).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


83
84
85
86
# File 'lib/scrapebadger/api/bing_api.rb', line 83

def bing_bing_scraper_health_check_head(opts = {})
  data, _status_code, _headers = bing_bing_scraper_health_check_head_with_http_info(opts)
  data
end

#bing_bing_scraper_health_check_head_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

Bing scraper health check Check health of the Bing scraper service (accepts HEAD for UptimeRobot).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/scrapebadger/api/bing_api.rb', line 92

def bing_bing_scraper_health_check_head_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_bing_scraper_health_check_head ...'
  end
  # resource path
  local_var_path = '/v1/bing/health'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_bing_scraper_health_check_head",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:HEAD, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_bing_scraper_health_check_head\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_bing_scraper_health_check_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

Bing scraper health check Check health of the Bing scraper service (accepts HEAD for UptimeRobot).

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/scrapebadger/api/bing_api.rb', line 35

def bing_bing_scraper_health_check_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_bing_scraper_health_check ...'
  end
  # resource path
  local_var_path = '/v1/bing/health'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_bing_scraper_health_check",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_bing_scraper_health_check\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_image_search(query, opts = {}) ⇒ Object

Image search Bing Images — thumbnail, full-size and source URL per result.

Parameters:

  • query (String)

    Search keywords, e.g. 'golden retriever'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results to return (default to 35)

  • :safe_search (String)

    off | moderate | strict

Returns:

  • (Object)


144
145
146
147
# File 'lib/scrapebadger/api/bing_api.rb', line 144

def bing_image_search(query, opts = {})
  data, _status_code, _headers = bing_image_search_with_http_info(query, opts)
  data
end

#bing_image_search_with_http_info(query, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Image search Bing Images — thumbnail, full-size and source URL per result.

Parameters:

  • query (String)

    Search keywords, e.g. 'golden retriever'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results to return (default to 35)

  • :safe_search (String)

    off | moderate | strict

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/scrapebadger/api/bing_api.rb', line 157

def bing_image_search_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_image_search ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling BingApi.bing_image_search"
  end
  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 150
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_image_search, must be smaller than or equal to 150.'
  end

  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_image_search, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/bing/images'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = query
  query_params[:'market'] = opts[:'market'] if !opts[:'market'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'safe_search'] = opts[:'safe_search'] if !opts[:'safe_search'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_image_search",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_image_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_list_supported_markets(opts = {}) ⇒ Object

List supported markets Supported Bing market codes. Free — costs no credits.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


221
222
223
224
# File 'lib/scrapebadger/api/bing_api.rb', line 221

def bing_list_supported_markets(opts = {})
  data, _status_code, _headers = bing_list_supported_markets_with_http_info(opts)
  data
end

#bing_list_supported_markets_with_http_info(opts = {}) ⇒ Array<(Object, Integer, Hash)>

List supported markets Supported Bing market codes. Free — costs no credits.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/scrapebadger/api/bing_api.rb', line 230

def bing_list_supported_markets_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_list_supported_markets ...'
  end
  # resource path
  local_var_path = '/v1/bing/markets'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_list_supported_markets",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_list_supported_markets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_news_search(query, opts = {}) ⇒ Object

News search Bing News — headline, source, published time and snippet per article.

Parameters:

  • query (String)

    Search keywords, e.g. 'interest rates'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :freshness (String)

    day | week | month — restrict to recent articles

Returns:

  • (Object)


281
282
283
284
# File 'lib/scrapebadger/api/bing_api.rb', line 281

def bing_news_search(query, opts = {})
  data, _status_code, _headers = bing_news_search_with_http_info(query, opts)
  data
end

#bing_news_search_with_http_info(query, opts = {}) ⇒ Array<(Object, Integer, Hash)>

News search Bing News — headline, source, published time and snippet per article.

Parameters:

  • query (String)

    Search keywords, e.g. 'interest rates'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :freshness (String)

    day | week | month — restrict to recent articles

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/scrapebadger/api/bing_api.rb', line 293

def bing_news_search_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_news_search ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling BingApi.bing_news_search"
  end
  # resource path
  local_var_path = '/v1/bing/news'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = query
  query_params[:'market'] = opts[:'market'] if !opts[:'market'].nil?
  query_params[:'freshness'] = opts[:'freshness'] if !opts[:'freshness'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_news_search",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_news_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_search_suggestions(query, opts = {}) ⇒ Object

Search suggestions Bing search-box query suggestions.

Parameters:

  • query (String)

    Partial search term, e.g. 'coff'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

Returns:

  • (Object)


350
351
352
353
# File 'lib/scrapebadger/api/bing_api.rb', line 350

def bing_search_suggestions(query, opts = {})
  data, _status_code, _headers = bing_search_suggestions_with_http_info(query, opts)
  data
end

#bing_search_suggestions_with_http_info(query, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Search suggestions Bing search-box query suggestions.

Parameters:

  • query (String)

    Partial search term, e.g. 'coff'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/scrapebadger/api/bing_api.rb', line 361

def bing_search_suggestions_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_search_suggestions ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling BingApi.bing_search_suggestions"
  end
  # resource path
  local_var_path = '/v1/bing/autocomplete'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = query
  query_params[:'market'] = opts[:'market'] if !opts[:'market'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_search_suggestions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_search_suggestions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_video_search(query, opts = {}) ⇒ Object

Video search Bing Videos — title, thumbnail, duration, publisher and source per result.

Parameters:

  • query (String)

    Search keywords, e.g. 'espresso tutorial'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results to return (default to 35)

  • :safe_search (String)

    off | moderate | strict

Returns:

  • (Object)


419
420
421
422
# File 'lib/scrapebadger/api/bing_api.rb', line 419

def bing_video_search(query, opts = {})
  data, _status_code, _headers = bing_video_search_with_http_info(query, opts)
  data
end

#bing_video_search_with_http_info(query, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Video search Bing Videos — title, thumbnail, duration, publisher and source per result.

Parameters:

  • query (String)

    Search keywords, e.g. 'espresso tutorial'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results to return (default to 35)

  • :safe_search (String)

    off | moderate | strict

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/scrapebadger/api/bing_api.rb', line 432

def bing_video_search_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_video_search ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling BingApi.bing_video_search"
  end
  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 150
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_video_search, must be smaller than or equal to 150.'
  end

  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_video_search, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/bing/videos'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = query
  query_params[:'market'] = opts[:'market'] if !opts[:'market'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'safe_search'] = opts[:'safe_search'] if !opts[:'safe_search'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_video_search",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_video_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bing_web_search(query, opts = {}) ⇒ Object

Web search Bing web SERP — organic results, ads, related searches and total count.

Parameters:

  • query (String)

    Search keywords, e.g. 'coffee machine'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results per page (1-50) (default to 10)

  • :offset (Integer)

    Zero-based result offset for pagination (default to 0)

  • :safe_search (String)

    off | moderate | strict (default moderate)

Returns:

  • (Object)


501
502
503
504
# File 'lib/scrapebadger/api/bing_api.rb', line 501

def bing_web_search(query, opts = {})
  data, _status_code, _headers = bing_web_search_with_http_info(query, opts)
  data
end

#bing_web_search_with_http_info(query, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Web search Bing web SERP — organic results, ads, related searches and total count.

Parameters:

  • query (String)

    Search keywords, e.g. 'coffee machine'

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :market (String)

    Bing market code, e.g. 'en-US', 'en-GB', 'de-DE'. See /markets. (default to 'en-US')

  • :count (Integer)

    Results per page (1-50) (default to 10)

  • :offset (Integer)

    Zero-based result offset for pagination (default to 0)

  • :safe_search (String)

    off | moderate | strict (default moderate)

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/scrapebadger/api/bing_api.rb', line 515

def bing_web_search_with_http_info(query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BingApi.bing_web_search ...'
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling BingApi.bing_web_search"
  end
  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 50
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_web_search, must be smaller than or equal to 50.'
  end

  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling BingApi.bing_web_search, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling BingApi.bing_web_search, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/v1/bing/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = query
  query_params[:'market'] = opts[:'market'] if !opts[:'market'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'safe_search'] = opts[:'safe_search'] if !opts[:'safe_search'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"BingApi.bing_web_search",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BingApi#bing_web_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end