azure_cognitiveservices_customsearch 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/custom_instance.rb +653 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/custom_search_client.rb +127 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/answer.rb +90 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/creative_work.rb +150 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/error.rb +116 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/error_code.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/error_response.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/error_sub_code.rb +25 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/identifiable.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/query.rb +87 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/query_context.rb +94 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/response.rb +72 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/response_base.rb +56 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/safe_search.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/search_response.rb +100 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/search_results_answer.rb +126 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/text_format.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/thing.rb +118 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/web_meta_tag.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/web_page.rb +228 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/models/web_web_answer.rb +149 -0
- data/lib/1.0/generated/azure_cognitiveservices_customsearch/module_definition.rb +9 -0
- data/lib/azure_cognitiveservices_customsearch.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/customsearch_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/customsearch_module_definition.rb +8 -0
- data/lib/profiles/latest/modules/customsearch_profile_module.rb +135 -0
- data/lib/version.rb +7 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f755857808aa6834c46b8e3cdb0a9a6c653a1668
|
4
|
+
data.tar.gz: f2a37a4f7aa161b317d9eb3f6a9795439d23cfac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 637dc198f2daa1fb9a4413c52c80cf90e1722a28e4b5d4e8ca675d2ebbe3f262c3029547c73f13303c702eeb2d51c7b5ed0fc4ce29bbbea3ff93f0d78f961dd1
|
7
|
+
data.tar.gz: 4495110d06bec862f1adb4f1ed7dfaf1aa0c7b0597b52e3ac6dcbf6da5c45205c022c26c60d423b9f836da26e3f38c7a6c214352e97759a63e8444b88c720b3e
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Microsoft Corporation
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
require 'uri'
|
7
|
+
require 'cgi'
|
8
|
+
require 'date'
|
9
|
+
require 'json'
|
10
|
+
require 'base64'
|
11
|
+
require 'erb'
|
12
|
+
require 'securerandom'
|
13
|
+
require 'time'
|
14
|
+
require 'timeliness'
|
15
|
+
require 'faraday'
|
16
|
+
require 'faraday-cookie_jar'
|
17
|
+
require 'concurrent'
|
18
|
+
require 'ms_rest'
|
19
|
+
require '1.0/generated/azure_cognitiveservices_customsearch/module_definition'
|
20
|
+
require 'ms_rest_azure'
|
21
|
+
|
22
|
+
module Azure::CognitiveServices::CustomSearch::V1_0
|
23
|
+
autoload :CustomInstance, '1.0/generated/azure_cognitiveservices_customsearch/custom_instance.rb'
|
24
|
+
autoload :CustomSearchClient, '1.0/generated/azure_cognitiveservices_customsearch/custom_search_client.rb'
|
25
|
+
|
26
|
+
module Models
|
27
|
+
autoload :ResponseBase, '1.0/generated/azure_cognitiveservices_customsearch/models/response_base.rb'
|
28
|
+
autoload :QueryContext, '1.0/generated/azure_cognitiveservices_customsearch/models/query_context.rb'
|
29
|
+
autoload :Query, '1.0/generated/azure_cognitiveservices_customsearch/models/query.rb'
|
30
|
+
autoload :Error, '1.0/generated/azure_cognitiveservices_customsearch/models/error.rb'
|
31
|
+
autoload :WebMetaTag, '1.0/generated/azure_cognitiveservices_customsearch/models/web_meta_tag.rb'
|
32
|
+
autoload :WebPage, '1.0/generated/azure_cognitiveservices_customsearch/models/web_page.rb'
|
33
|
+
autoload :WebWebAnswer, '1.0/generated/azure_cognitiveservices_customsearch/models/web_web_answer.rb'
|
34
|
+
autoload :SearchResponse, '1.0/generated/azure_cognitiveservices_customsearch/models/search_response.rb'
|
35
|
+
autoload :SearchResultsAnswer, '1.0/generated/azure_cognitiveservices_customsearch/models/search_results_answer.rb'
|
36
|
+
autoload :Identifiable, '1.0/generated/azure_cognitiveservices_customsearch/models/identifiable.rb'
|
37
|
+
autoload :Response, '1.0/generated/azure_cognitiveservices_customsearch/models/response.rb'
|
38
|
+
autoload :ErrorResponse, '1.0/generated/azure_cognitiveservices_customsearch/models/error_response.rb'
|
39
|
+
autoload :Answer, '1.0/generated/azure_cognitiveservices_customsearch/models/answer.rb'
|
40
|
+
autoload :Thing, '1.0/generated/azure_cognitiveservices_customsearch/models/thing.rb'
|
41
|
+
autoload :CreativeWork, '1.0/generated/azure_cognitiveservices_customsearch/models/creative_work.rb'
|
42
|
+
autoload :ErrorCode, '1.0/generated/azure_cognitiveservices_customsearch/models/error_code.rb'
|
43
|
+
autoload :ErrorSubCode, '1.0/generated/azure_cognitiveservices_customsearch/models/error_sub_code.rb'
|
44
|
+
autoload :SafeSearch, '1.0/generated/azure_cognitiveservices_customsearch/models/safe_search.rb'
|
45
|
+
autoload :TextFormat, '1.0/generated/azure_cognitiveservices_customsearch/models/text_format.rb'
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,653 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::CustomSearch::V1_0
|
7
|
+
#
|
8
|
+
# The Bing Custom Search API lets you send a search query to Bing and get
|
9
|
+
# back search results customized to meet your custom search definition.
|
10
|
+
#
|
11
|
+
class CustomInstance
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the CustomInstance class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [CustomSearchClient] reference to the CustomSearchClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# The Custom Search API lets you send a search query to Bing and get back web
|
27
|
+
# pages found in your custom view of the web.
|
28
|
+
#
|
29
|
+
# @param custom_config [Integer] The identifier for the custom search
|
30
|
+
# configuration
|
31
|
+
# @param query [String] The user's search query term. The term may not be
|
32
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
33
|
+
# results to a specific domain, use the site: operator.
|
34
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
35
|
+
# languages to use for user interface strings. The list is in decreasing order
|
36
|
+
# of preference. For additional information, including expected format, see
|
37
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
38
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
39
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
40
|
+
# Bing will use the first supported language it finds from the list, and
|
41
|
+
# combine that language with the cc parameter value to determine the market to
|
42
|
+
# return results for. If the list does not include a supported language, Bing
|
43
|
+
# will find the closest language and market that supports the request, and may
|
44
|
+
# use an aggregated or default market for the results instead of a specified
|
45
|
+
# one. You should use this header and the cc query parameter only if you
|
46
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
47
|
+
# query parameters. A user interface string is a string that's used as a label
|
48
|
+
# in a user interface. There are very few user interface strings in the JSON
|
49
|
+
# response objects. Any links in the response objects to Bing.com properties
|
50
|
+
# will apply the specified language.
|
51
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
52
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
53
|
+
# optional, you are strongly encouraged to always specify this header. The
|
54
|
+
# user-agent should be the same string that any commonly used browser would
|
55
|
+
# send. For information about user agents, see [RFC
|
56
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
57
|
+
# @param client_id [String] Bing uses this header to provide users with
|
58
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
59
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
60
|
+
# different flights. If you do not use the same client ID for a user across
|
61
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
62
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
63
|
+
# inconsistent user experience. For example, if the second request has a
|
64
|
+
# different flight assignment than the first, the experience may be unexpected.
|
65
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
66
|
+
# search history, providing a richer experience for the user. Bing also uses
|
67
|
+
# this header to help improve result rankings by analyzing the activity
|
68
|
+
# generated by a client ID. The relevance improvements help with better quality
|
69
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
70
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
71
|
+
# this header required. Persisting the client ID across multiple requests for
|
72
|
+
# the same end user and device combination enables 1) the API consumer to
|
73
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
74
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
75
|
+
# application on the device must have a unique, Bing generated client ID. If
|
76
|
+
# you do not include this header in the request, Bing generates an ID and
|
77
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
78
|
+
# should NOT include this header in a request is the first time the user uses
|
79
|
+
# your app on that device. Use the client ID for each Bing API request that
|
80
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
81
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
82
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
83
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
84
|
+
# time the user uses your app on that device, get the client ID that you
|
85
|
+
# persisted. Bing responses may or may not include this header. If the response
|
86
|
+
# includes this header, capture the client ID and use it for all subsequent
|
87
|
+
# Bing requests for the user on that device. If you include the
|
88
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
89
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
90
|
+
# IP address is used to discover the user's location. Bing uses the location
|
91
|
+
# information to determine safe search behavior. Although optional, you are
|
92
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
93
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
94
|
+
# Obfuscating the address results in the location not being anywhere near the
|
95
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
96
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
97
|
+
# describe the client's geographical location. Bing uses the location
|
98
|
+
# information to determine safe search behavior and to return relevant local
|
99
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
100
|
+
# keys that you use to specify the user's location. lat (required): The
|
101
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
102
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
103
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
104
|
+
# long (required): The longitude of the client's location, in degrees. The
|
105
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
106
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
107
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
108
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
109
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
110
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
111
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
112
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
113
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
114
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
115
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
116
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
117
|
+
# client device is traveling. alt (optional): The altitude of the client
|
118
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
119
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
120
|
+
# the alt key. Although many of the keys are optional, the more information
|
121
|
+
# that you provide, the more accurate the location results are. Although
|
122
|
+
# optional, you are encouraged to always specify the user's geographical
|
123
|
+
# location. Providing the location is especially important if the client's IP
|
124
|
+
# address does not accurately reflect the user's physical location (for
|
125
|
+
# example, if the client uses VPN). For optimal results, you should include
|
126
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
127
|
+
# include this header.
|
128
|
+
# @param country_code [String] A 2-character country code of the country where
|
129
|
+
# the results come from. This API supports only the United States market. If
|
130
|
+
# you specify this query parameter, it must be set to us. If you set this
|
131
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
132
|
+
# first supported language it finds from the languages list, and combine that
|
133
|
+
# language with the country code that you specify to determine the market to
|
134
|
+
# return results for. If the languages list does not include a supported
|
135
|
+
# language, Bing finds the closest language and market that supports the
|
136
|
+
# request, or it may use an aggregated or default market for the results
|
137
|
+
# instead of a specified one. You should use this query parameter and the
|
138
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
139
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
140
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
141
|
+
# both.
|
142
|
+
# @param count [Integer] The number of search results to return in the
|
143
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
144
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
145
|
+
# parameter to page results.For example, if your user interface displays 10
|
146
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
147
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
148
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
149
|
+
# overlap in results.
|
150
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
151
|
+
# is the country where the user is making the request from. However, it could
|
152
|
+
# be a different country if the user is not located in a country where Bing
|
153
|
+
# delivers results. The market must be in the form <language code>-<country
|
154
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
155
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
156
|
+
# route the request and return an appropriate and optimal response. If you
|
157
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
158
|
+
# market code based on an internal mapping that is subject to change. This
|
159
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
160
|
+
# both.
|
161
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
162
|
+
# search results to skip before returning results. The default is 0. The offset
|
163
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
164
|
+
# with the count parameter to page results. For example, if your user interface
|
165
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
166
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
167
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
168
|
+
# overlap in results.
|
169
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
170
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
171
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
172
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
173
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
174
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
175
|
+
# use the site: query operator, there is the chance that the response may
|
176
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
177
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
178
|
+
# scenario supports the possibility of adult content. Possible values include:
|
179
|
+
# 'Off', 'Moderate', 'Strict'
|
180
|
+
# @param set_lang [String] The language to use for user interface strings.
|
181
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
182
|
+
# the language code for English is EN. The default is EN (English). Although
|
183
|
+
# optional, you should always specify the language. Typically, you set setLang
|
184
|
+
# to the same language specified by mkt unless the user wants the user
|
185
|
+
# interface strings displayed in a different language. This parameter and the
|
186
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
187
|
+
# interface string is a string that's used as a label in a user interface.
|
188
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
189
|
+
# links to Bing.com properties in the response objects apply the specified
|
190
|
+
# language.
|
191
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
192
|
+
# display strings should contain decoration markers such as hit highlighting
|
193
|
+
# characters. If true, the strings may include markers. The default is false.
|
194
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
195
|
+
# the textFormat query parameter.
|
196
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
197
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
198
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
199
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
200
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
201
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
202
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
203
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
204
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
205
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
206
|
+
# values include: 'Raw', 'Html'
|
207
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
208
|
+
# will be added to the HTTP request.
|
209
|
+
#
|
210
|
+
# @return [SearchResponse] operation results.
|
211
|
+
#
|
212
|
+
def search(custom_config, query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:'en-us', offset:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
213
|
+
response = search_async(custom_config, query, accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, market:market, offset:offset, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
|
214
|
+
response.body unless response.nil?
|
215
|
+
end
|
216
|
+
|
217
|
+
#
|
218
|
+
# The Custom Search API lets you send a search query to Bing and get back web
|
219
|
+
# pages found in your custom view of the web.
|
220
|
+
#
|
221
|
+
# @param custom_config [Integer] The identifier for the custom search
|
222
|
+
# configuration
|
223
|
+
# @param query [String] The user's search query term. The term may not be
|
224
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
225
|
+
# results to a specific domain, use the site: operator.
|
226
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
227
|
+
# languages to use for user interface strings. The list is in decreasing order
|
228
|
+
# of preference. For additional information, including expected format, see
|
229
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
230
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
231
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
232
|
+
# Bing will use the first supported language it finds from the list, and
|
233
|
+
# combine that language with the cc parameter value to determine the market to
|
234
|
+
# return results for. If the list does not include a supported language, Bing
|
235
|
+
# will find the closest language and market that supports the request, and may
|
236
|
+
# use an aggregated or default market for the results instead of a specified
|
237
|
+
# one. You should use this header and the cc query parameter only if you
|
238
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
239
|
+
# query parameters. A user interface string is a string that's used as a label
|
240
|
+
# in a user interface. There are very few user interface strings in the JSON
|
241
|
+
# response objects. Any links in the response objects to Bing.com properties
|
242
|
+
# will apply the specified language.
|
243
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
244
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
245
|
+
# optional, you are strongly encouraged to always specify this header. The
|
246
|
+
# user-agent should be the same string that any commonly used browser would
|
247
|
+
# send. For information about user agents, see [RFC
|
248
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
249
|
+
# @param client_id [String] Bing uses this header to provide users with
|
250
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
251
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
252
|
+
# different flights. If you do not use the same client ID for a user across
|
253
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
254
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
255
|
+
# inconsistent user experience. For example, if the second request has a
|
256
|
+
# different flight assignment than the first, the experience may be unexpected.
|
257
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
258
|
+
# search history, providing a richer experience for the user. Bing also uses
|
259
|
+
# this header to help improve result rankings by analyzing the activity
|
260
|
+
# generated by a client ID. The relevance improvements help with better quality
|
261
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
262
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
263
|
+
# this header required. Persisting the client ID across multiple requests for
|
264
|
+
# the same end user and device combination enables 1) the API consumer to
|
265
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
266
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
267
|
+
# application on the device must have a unique, Bing generated client ID. If
|
268
|
+
# you do not include this header in the request, Bing generates an ID and
|
269
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
270
|
+
# should NOT include this header in a request is the first time the user uses
|
271
|
+
# your app on that device. Use the client ID for each Bing API request that
|
272
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
273
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
274
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
275
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
276
|
+
# time the user uses your app on that device, get the client ID that you
|
277
|
+
# persisted. Bing responses may or may not include this header. If the response
|
278
|
+
# includes this header, capture the client ID and use it for all subsequent
|
279
|
+
# Bing requests for the user on that device. If you include the
|
280
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
281
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
282
|
+
# IP address is used to discover the user's location. Bing uses the location
|
283
|
+
# information to determine safe search behavior. Although optional, you are
|
284
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
285
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
286
|
+
# Obfuscating the address results in the location not being anywhere near the
|
287
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
288
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
289
|
+
# describe the client's geographical location. Bing uses the location
|
290
|
+
# information to determine safe search behavior and to return relevant local
|
291
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
292
|
+
# keys that you use to specify the user's location. lat (required): The
|
293
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
294
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
295
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
296
|
+
# long (required): The longitude of the client's location, in degrees. The
|
297
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
298
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
299
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
300
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
301
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
302
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
303
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
304
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
305
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
306
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
307
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
308
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
309
|
+
# client device is traveling. alt (optional): The altitude of the client
|
310
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
311
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
312
|
+
# the alt key. Although many of the keys are optional, the more information
|
313
|
+
# that you provide, the more accurate the location results are. Although
|
314
|
+
# optional, you are encouraged to always specify the user's geographical
|
315
|
+
# location. Providing the location is especially important if the client's IP
|
316
|
+
# address does not accurately reflect the user's physical location (for
|
317
|
+
# example, if the client uses VPN). For optimal results, you should include
|
318
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
319
|
+
# include this header.
|
320
|
+
# @param country_code [String] A 2-character country code of the country where
|
321
|
+
# the results come from. This API supports only the United States market. If
|
322
|
+
# you specify this query parameter, it must be set to us. If you set this
|
323
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
324
|
+
# first supported language it finds from the languages list, and combine that
|
325
|
+
# language with the country code that you specify to determine the market to
|
326
|
+
# return results for. If the languages list does not include a supported
|
327
|
+
# language, Bing finds the closest language and market that supports the
|
328
|
+
# request, or it may use an aggregated or default market for the results
|
329
|
+
# instead of a specified one. You should use this query parameter and the
|
330
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
331
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
332
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
333
|
+
# both.
|
334
|
+
# @param count [Integer] The number of search results to return in the
|
335
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
336
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
337
|
+
# parameter to page results.For example, if your user interface displays 10
|
338
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
339
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
340
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
341
|
+
# overlap in results.
|
342
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
343
|
+
# is the country where the user is making the request from. However, it could
|
344
|
+
# be a different country if the user is not located in a country where Bing
|
345
|
+
# delivers results. The market must be in the form <language code>-<country
|
346
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
347
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
348
|
+
# route the request and return an appropriate and optimal response. If you
|
349
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
350
|
+
# market code based on an internal mapping that is subject to change. This
|
351
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
352
|
+
# both.
|
353
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
354
|
+
# search results to skip before returning results. The default is 0. The offset
|
355
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
356
|
+
# with the count parameter to page results. For example, if your user interface
|
357
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
358
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
359
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
360
|
+
# overlap in results.
|
361
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
362
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
363
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
364
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
365
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
366
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
367
|
+
# use the site: query operator, there is the chance that the response may
|
368
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
369
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
370
|
+
# scenario supports the possibility of adult content. Possible values include:
|
371
|
+
# 'Off', 'Moderate', 'Strict'
|
372
|
+
# @param set_lang [String] The language to use for user interface strings.
|
373
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
374
|
+
# the language code for English is EN. The default is EN (English). Although
|
375
|
+
# optional, you should always specify the language. Typically, you set setLang
|
376
|
+
# to the same language specified by mkt unless the user wants the user
|
377
|
+
# interface strings displayed in a different language. This parameter and the
|
378
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
379
|
+
# interface string is a string that's used as a label in a user interface.
|
380
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
381
|
+
# links to Bing.com properties in the response objects apply the specified
|
382
|
+
# language.
|
383
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
384
|
+
# display strings should contain decoration markers such as hit highlighting
|
385
|
+
# characters. If true, the strings may include markers. The default is false.
|
386
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
387
|
+
# the textFormat query parameter.
|
388
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
389
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
390
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
391
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
392
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
393
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
394
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
395
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
396
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
397
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
398
|
+
# values include: 'Raw', 'Html'
|
399
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
400
|
+
# will be added to the HTTP request.
|
401
|
+
#
|
402
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
403
|
+
#
|
404
|
+
def search_with_http_info(custom_config, query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:'en-us', offset:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
405
|
+
search_async(custom_config, query, accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, market:market, offset:offset, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
|
406
|
+
end
|
407
|
+
|
408
|
+
#
|
409
|
+
# The Custom Search API lets you send a search query to Bing and get back web
|
410
|
+
# pages found in your custom view of the web.
|
411
|
+
#
|
412
|
+
# @param custom_config [Integer] The identifier for the custom search
|
413
|
+
# configuration
|
414
|
+
# @param query [String] The user's search query term. The term may not be
|
415
|
+
# empty. The term may contain Bing Advanced Operators. For example, to limit
|
416
|
+
# results to a specific domain, use the site: operator.
|
417
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
418
|
+
# languages to use for user interface strings. The list is in decreasing order
|
419
|
+
# of preference. For additional information, including expected format, see
|
420
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
421
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
422
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
423
|
+
# Bing will use the first supported language it finds from the list, and
|
424
|
+
# combine that language with the cc parameter value to determine the market to
|
425
|
+
# return results for. If the list does not include a supported language, Bing
|
426
|
+
# will find the closest language and market that supports the request, and may
|
427
|
+
# use an aggregated or default market for the results instead of a specified
|
428
|
+
# one. You should use this header and the cc query parameter only if you
|
429
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
430
|
+
# query parameters. A user interface string is a string that's used as a label
|
431
|
+
# in a user interface. There are very few user interface strings in the JSON
|
432
|
+
# response objects. Any links in the response objects to Bing.com properties
|
433
|
+
# will apply the specified language.
|
434
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
435
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
436
|
+
# optional, you are strongly encouraged to always specify this header. The
|
437
|
+
# user-agent should be the same string that any commonly used browser would
|
438
|
+
# send. For information about user agents, see [RFC
|
439
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
440
|
+
# @param client_id [String] Bing uses this header to provide users with
|
441
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
442
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
443
|
+
# different flights. If you do not use the same client ID for a user across
|
444
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
445
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
446
|
+
# inconsistent user experience. For example, if the second request has a
|
447
|
+
# different flight assignment than the first, the experience may be unexpected.
|
448
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
449
|
+
# search history, providing a richer experience for the user. Bing also uses
|
450
|
+
# this header to help improve result rankings by analyzing the activity
|
451
|
+
# generated by a client ID. The relevance improvements help with better quality
|
452
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
453
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
454
|
+
# this header required. Persisting the client ID across multiple requests for
|
455
|
+
# the same end user and device combination enables 1) the API consumer to
|
456
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
457
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
458
|
+
# application on the device must have a unique, Bing generated client ID. If
|
459
|
+
# you do not include this header in the request, Bing generates an ID and
|
460
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
461
|
+
# should NOT include this header in a request is the first time the user uses
|
462
|
+
# your app on that device. Use the client ID for each Bing API request that
|
463
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
464
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
465
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
466
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
467
|
+
# time the user uses your app on that device, get the client ID that you
|
468
|
+
# persisted. Bing responses may or may not include this header. If the response
|
469
|
+
# includes this header, capture the client ID and use it for all subsequent
|
470
|
+
# Bing requests for the user on that device. If you include the
|
471
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
472
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
473
|
+
# IP address is used to discover the user's location. Bing uses the location
|
474
|
+
# information to determine safe search behavior. Although optional, you are
|
475
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
476
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
477
|
+
# Obfuscating the address results in the location not being anywhere near the
|
478
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
479
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
480
|
+
# describe the client's geographical location. Bing uses the location
|
481
|
+
# information to determine safe search behavior and to return relevant local
|
482
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
483
|
+
# keys that you use to specify the user's location. lat (required): The
|
484
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
485
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
486
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
487
|
+
# long (required): The longitude of the client's location, in degrees. The
|
488
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
489
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
490
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
491
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
492
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
493
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
494
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
495
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
496
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
497
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
498
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
499
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
500
|
+
# client device is traveling. alt (optional): The altitude of the client
|
501
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
502
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
503
|
+
# the alt key. Although many of the keys are optional, the more information
|
504
|
+
# that you provide, the more accurate the location results are. Although
|
505
|
+
# optional, you are encouraged to always specify the user's geographical
|
506
|
+
# location. Providing the location is especially important if the client's IP
|
507
|
+
# address does not accurately reflect the user's physical location (for
|
508
|
+
# example, if the client uses VPN). For optimal results, you should include
|
509
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
510
|
+
# include this header.
|
511
|
+
# @param country_code [String] A 2-character country code of the country where
|
512
|
+
# the results come from. This API supports only the United States market. If
|
513
|
+
# you specify this query parameter, it must be set to us. If you set this
|
514
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
515
|
+
# first supported language it finds from the languages list, and combine that
|
516
|
+
# language with the country code that you specify to determine the market to
|
517
|
+
# return results for. If the languages list does not include a supported
|
518
|
+
# language, Bing finds the closest language and market that supports the
|
519
|
+
# request, or it may use an aggregated or default market for the results
|
520
|
+
# instead of a specified one. You should use this query parameter and the
|
521
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
522
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
523
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
524
|
+
# both.
|
525
|
+
# @param count [Integer] The number of search results to return in the
|
526
|
+
# response. The default is 10 and the maximum value is 50. The actual number
|
527
|
+
# delivered may be less than requested.Use this parameter along with the offset
|
528
|
+
# parameter to page results.For example, if your user interface displays 10
|
529
|
+
# search results per page, set count to 10 and offset to 0 to get the first
|
530
|
+
# page of results. For each subsequent page, increment offset by 10 (for
|
531
|
+
# example, 0, 10, 20). It is possible for multiple pages to include some
|
532
|
+
# overlap in results.
|
533
|
+
# @param market [String] The market where the results come from. Typically, mkt
|
534
|
+
# is the country where the user is making the request from. However, it could
|
535
|
+
# be a different country if the user is not located in a country where Bing
|
536
|
+
# delivers results. The market must be in the form <language code>-<country
|
537
|
+
# code>. For example, en-US. The string is case insensitive. If known, you are
|
538
|
+
# encouraged to always specify the market. Specifying the market helps Bing
|
539
|
+
# route the request and return an appropriate and optimal response. If you
|
540
|
+
# specify a market that is not listed in Market Codes, Bing uses a best fit
|
541
|
+
# market code based on an internal mapping that is subject to change. This
|
542
|
+
# parameter and the cc query parameter are mutually exclusive—do not specify
|
543
|
+
# both.
|
544
|
+
# @param offset [Integer] The zero-based offset that indicates the number of
|
545
|
+
# search results to skip before returning results. The default is 0. The offset
|
546
|
+
# should be less than (totalEstimatedMatches - count). Use this parameter along
|
547
|
+
# with the count parameter to page results. For example, if your user interface
|
548
|
+
# displays 10 search results per page, set count to 10 and offset to 0 to get
|
549
|
+
# the first page of results. For each subsequent page, increment offset by 10
|
550
|
+
# (for example, 0, 10, 20). it is possible for multiple pages to include some
|
551
|
+
# overlap in results.
|
552
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
553
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
554
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
555
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
556
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
557
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
558
|
+
# use the site: query operator, there is the chance that the response may
|
559
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
560
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
561
|
+
# scenario supports the possibility of adult content. Possible values include:
|
562
|
+
# 'Off', 'Moderate', 'Strict'
|
563
|
+
# @param set_lang [String] The language to use for user interface strings.
|
564
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
565
|
+
# the language code for English is EN. The default is EN (English). Although
|
566
|
+
# optional, you should always specify the language. Typically, you set setLang
|
567
|
+
# to the same language specified by mkt unless the user wants the user
|
568
|
+
# interface strings displayed in a different language. This parameter and the
|
569
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
570
|
+
# interface string is a string that's used as a label in a user interface.
|
571
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
572
|
+
# links to Bing.com properties in the response objects apply the specified
|
573
|
+
# language.
|
574
|
+
# @param text_decorations [Boolean] A Boolean value that determines whether
|
575
|
+
# display strings should contain decoration markers such as hit highlighting
|
576
|
+
# characters. If true, the strings may include markers. The default is false.
|
577
|
+
# To specify whether to use Unicode characters or HTML tags as the markers, see
|
578
|
+
# the textFormat query parameter.
|
579
|
+
# @param text_format [TextFormat] The type of markers to use for text
|
580
|
+
# decorations (see the textDecorations query parameter). Possible values are
|
581
|
+
# Raw—Use Unicode characters to mark content that needs special formatting. The
|
582
|
+
# Unicode characters are in the range E000 through E019. For example, Bing uses
|
583
|
+
# E000 and E001 to mark the beginning and end of query terms for hit
|
584
|
+
# highlighting. HTML—Use HTML tags to mark content that needs special
|
585
|
+
# formatting. For example, use <b> tags to highlight query terms in display
|
586
|
+
# strings. The default is Raw. For display strings that contain escapable HTML
|
587
|
+
# characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
|
588
|
+
# the characters as appropriate (for example, < is escaped to <). Possible
|
589
|
+
# values include: 'Raw', 'Html'
|
590
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
591
|
+
# to the HTTP request.
|
592
|
+
#
|
593
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
594
|
+
#
|
595
|
+
def search_async(custom_config, query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:'en-us', offset:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
|
596
|
+
x_bing_apis_sdk = 'true'
|
597
|
+
fail ArgumentError, 'custom_config is nil' if custom_config.nil?
|
598
|
+
fail ArgumentError, "'custom_config' should satisfy the constraint - 'InclusiveMinimum': '0'" if !custom_config.nil? && custom_config < 0
|
599
|
+
fail ArgumentError, 'query is nil' if query.nil?
|
600
|
+
|
601
|
+
|
602
|
+
request_headers = {}
|
603
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
604
|
+
|
605
|
+
# Set Headers
|
606
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
607
|
+
request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
|
608
|
+
request_headers['Accept-Language'] = accept_language unless accept_language.nil?
|
609
|
+
request_headers['User-Agent'] = user_agent unless user_agent.nil?
|
610
|
+
request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
|
611
|
+
request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
|
612
|
+
request_headers['X-Search-Location'] = location unless location.nil?
|
613
|
+
path_template = 'search'
|
614
|
+
|
615
|
+
request_url = @base_url || @client.base_url
|
616
|
+
|
617
|
+
options = {
|
618
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
619
|
+
query_params: {'customConfig' => custom_config,'cc' => country_code,'count' => count,'mkt' => market,'offset' => offset,'q' => query,'safeSearch' => safe_search,'setLang' => set_lang,'textDecorations' => text_decorations,'textFormat' => text_format},
|
620
|
+
headers: request_headers.merge(custom_headers || {}),
|
621
|
+
base_url: request_url
|
622
|
+
}
|
623
|
+
promise = @client.make_request_async(:get, path_template, options)
|
624
|
+
|
625
|
+
promise = promise.then do |result|
|
626
|
+
http_response = result.response
|
627
|
+
status_code = http_response.status
|
628
|
+
response_content = http_response.body
|
629
|
+
unless status_code == 200
|
630
|
+
error_model = JSON.load(response_content)
|
631
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
632
|
+
end
|
633
|
+
|
634
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
635
|
+
# Deserialize Response
|
636
|
+
if status_code == 200
|
637
|
+
begin
|
638
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
639
|
+
result_mapper = Azure::CognitiveServices::CustomSearch::V1_0::Models::SearchResponse.mapper()
|
640
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
641
|
+
rescue Exception => e
|
642
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
result
|
647
|
+
end
|
648
|
+
|
649
|
+
promise.execute
|
650
|
+
end
|
651
|
+
|
652
|
+
end
|
653
|
+
end
|