azure_cognitiveservices_autosuggest 0.17.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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest.rb +46 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/autosuggest_client.rb +700 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/action.rb +380 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/answer.rb +131 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/creative_work.rb +371 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/error.rb +109 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/error_code.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/error_response.rb +154 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/identifiable.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/query_context.rb +136 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/response.rb +150 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/response_base.rb +55 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/response_format.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/safe_search.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/scenario_type.rb +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/search_action.rb +407 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/search_kind.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/search_results_answer.rb +146 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/suggestions.rb +166 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/suggestions_suggestion_group.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/models/thing.rb +144 -0
- data/lib/1.0/generated/azure_cognitiveservices_autosuggest/module_definition.rb +9 -0
- data/lib/azure_cognitiveservices_autosuggest.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/autosuggest_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/autosuggest_module_definition.rb +8 -0
- data/lib/profiles/latest/modules/autosuggest_profile_module.rb +133 -0
- data/lib/version.rb +7 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e96cc5588dcdd77d951ac483b84fd391538b3ad2
|
4
|
+
data.tar.gz: 14d3e668b8d0c963f0b95c1a25b55617c876176a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 68c087f893748976655ea3ad254b5f526a763da0610a73990011cc6c5bdb61ad11cdca60630f9f6c8cdb92b67413966a529736f1b0f36d956f23cb1cac07c1c2
|
7
|
+
data.tar.gz: e66d65df321123693685f23721ccf9bd4ccd258538a4d8ffd4e071ea85f7b3d31b125a25e597bdd2a6e33b425ced39d0ee94d7a0fa5b6373f5b94a5665bb9e92
|
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,46 @@
|
|
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_autosuggest/module_definition'
|
20
|
+
require 'ms_rest_azure'
|
21
|
+
|
22
|
+
module Azure::CognitiveServices::Autosuggest::V1_0
|
23
|
+
autoload :AutosuggestClient, '1.0/generated/azure_cognitiveservices_autosuggest/autosuggest_client.rb'
|
24
|
+
|
25
|
+
module Models
|
26
|
+
autoload :Error, '1.0/generated/azure_cognitiveservices_autosuggest/models/error.rb'
|
27
|
+
autoload :QueryContext, '1.0/generated/azure_cognitiveservices_autosuggest/models/query_context.rb'
|
28
|
+
autoload :SuggestionsSuggestionGroup, '1.0/generated/azure_cognitiveservices_autosuggest/models/suggestions_suggestion_group.rb'
|
29
|
+
autoload :ResponseBase, '1.0/generated/azure_cognitiveservices_autosuggest/models/response_base.rb'
|
30
|
+
autoload :Answer, '1.0/generated/azure_cognitiveservices_autosuggest/models/answer.rb'
|
31
|
+
autoload :SearchResultsAnswer, '1.0/generated/azure_cognitiveservices_autosuggest/models/search_results_answer.rb'
|
32
|
+
autoload :Suggestions, '1.0/generated/azure_cognitiveservices_autosuggest/models/suggestions.rb'
|
33
|
+
autoload :Thing, '1.0/generated/azure_cognitiveservices_autosuggest/models/thing.rb'
|
34
|
+
autoload :CreativeWork, '1.0/generated/azure_cognitiveservices_autosuggest/models/creative_work.rb'
|
35
|
+
autoload :Action, '1.0/generated/azure_cognitiveservices_autosuggest/models/action.rb'
|
36
|
+
autoload :SearchAction, '1.0/generated/azure_cognitiveservices_autosuggest/models/search_action.rb'
|
37
|
+
autoload :Identifiable, '1.0/generated/azure_cognitiveservices_autosuggest/models/identifiable.rb'
|
38
|
+
autoload :Response, '1.0/generated/azure_cognitiveservices_autosuggest/models/response.rb'
|
39
|
+
autoload :ErrorResponse, '1.0/generated/azure_cognitiveservices_autosuggest/models/error_response.rb'
|
40
|
+
autoload :ScenarioType, '1.0/generated/azure_cognitiveservices_autosuggest/models/scenario_type.rb'
|
41
|
+
autoload :SearchKind, '1.0/generated/azure_cognitiveservices_autosuggest/models/search_kind.rb'
|
42
|
+
autoload :ErrorCode, '1.0/generated/azure_cognitiveservices_autosuggest/models/error_code.rb'
|
43
|
+
autoload :SafeSearch, '1.0/generated/azure_cognitiveservices_autosuggest/models/safe_search.rb'
|
44
|
+
autoload :ResponseFormat, '1.0/generated/azure_cognitiveservices_autosuggest/models/response_format.rb'
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,700 @@
|
|
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::Autosuggest::V1_0
|
7
|
+
#
|
8
|
+
# A service client - single point of access to the REST API.
|
9
|
+
#
|
10
|
+
class AutosuggestClient < MsRestAzure::AzureServiceClient
|
11
|
+
include MsRestAzure
|
12
|
+
include MsRestAzure::Serialization
|
13
|
+
|
14
|
+
# @return [String] the base URI of the service.
|
15
|
+
attr_reader :base_url
|
16
|
+
|
17
|
+
# @return Credentials needed for the client to connect to Azure.
|
18
|
+
attr_reader :credentials1
|
19
|
+
|
20
|
+
# @return [String] Supported Cognitive Services endpoints (protocol and
|
21
|
+
# hostname, for example: "https://westus.api.cognitive.microsoft.com",
|
22
|
+
# "https://api.cognitive.microsoft.com").
|
23
|
+
attr_accessor :endpoint
|
24
|
+
|
25
|
+
# @return Subscription credentials which uniquely identify client
|
26
|
+
# subscription.
|
27
|
+
attr_accessor :credentials
|
28
|
+
|
29
|
+
# @return [String] The preferred language for the response.
|
30
|
+
attr_accessor :accept_language
|
31
|
+
|
32
|
+
# @return [Integer] The retry timeout in seconds for Long Running
|
33
|
+
# Operations. Default value is 30.
|
34
|
+
attr_accessor :long_running_operation_retry_timeout
|
35
|
+
|
36
|
+
# @return [Boolean] Whether a unique x-ms-client-request-id should be
|
37
|
+
# generated. When set to true a unique x-ms-client-request-id value is
|
38
|
+
# generated and included in each request. Default is true.
|
39
|
+
attr_accessor :generate_client_request_id
|
40
|
+
|
41
|
+
#
|
42
|
+
# Creates initializes a new instance of the AutosuggestClient class.
|
43
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
44
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
45
|
+
#
|
46
|
+
def initialize(credentials = nil, options = nil)
|
47
|
+
super(credentials, options)
|
48
|
+
@base_url = '{Endpoint}/bing/v7.0'
|
49
|
+
|
50
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
|
51
|
+
@credentials = credentials
|
52
|
+
|
53
|
+
@endpoint = 'https://api.cognitive.microsoft.com'
|
54
|
+
@accept_language = 'en-US'
|
55
|
+
@long_running_operation_retry_timeout = 30
|
56
|
+
@generate_client_request_id = true
|
57
|
+
add_telemetry
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Makes a request and returns the body of the response.
|
62
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
63
|
+
# @param path [String] the path, relative to {base_url}.
|
64
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
65
|
+
# @return [Hash{String=>String}] containing the body of the response.
|
66
|
+
# Example:
|
67
|
+
#
|
68
|
+
# request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
|
69
|
+
# path = "/path"
|
70
|
+
# options = {
|
71
|
+
# body: request_content,
|
72
|
+
# query_params: {'api-version' => '2016-02-01'}
|
73
|
+
# }
|
74
|
+
# result = @client.make_request(:put, path, options)
|
75
|
+
#
|
76
|
+
def make_request(method, path, options = {})
|
77
|
+
result = make_request_with_http_info(method, path, options)
|
78
|
+
result.body unless result.nil?
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Makes a request and returns the operation response.
|
83
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
84
|
+
# @param path [String] the path, relative to {base_url}.
|
85
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
86
|
+
# @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
|
87
|
+
#
|
88
|
+
def make_request_with_http_info(method, path, options = {})
|
89
|
+
result = make_request_async(method, path, options).value!
|
90
|
+
result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Makes a request asynchronously.
|
96
|
+
# @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
|
97
|
+
# @param path [String] the path, relative to {base_url}.
|
98
|
+
# @param options [Hash{String=>String}] specifying any request options like :body.
|
99
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
100
|
+
#
|
101
|
+
def make_request_async(method, path, options = {})
|
102
|
+
fail ArgumentError, 'method is nil' if method.nil?
|
103
|
+
fail ArgumentError, 'path is nil' if path.nil?
|
104
|
+
|
105
|
+
request_url = options[:base_url] || @base_url
|
106
|
+
if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
|
107
|
+
@request_headers['Content-Type'] = options[:headers]['Content-Type']
|
108
|
+
end
|
109
|
+
|
110
|
+
request_headers = @request_headers
|
111
|
+
request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
|
112
|
+
options.merge!({headers: request_headers.merge(options[:headers] || {})})
|
113
|
+
options.merge!({credentials: @credentials}) unless @credentials.nil?
|
114
|
+
|
115
|
+
super(request_url, method, path, options)
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# The AutoSuggest API lets you send a search query to Bing and get back a list
|
120
|
+
# of query suggestions. This section provides technical details about the query
|
121
|
+
# parameters and headers that you use to request suggestions and the JSON
|
122
|
+
# response objects that contain them.
|
123
|
+
#
|
124
|
+
# @param query [String] The user's search term.
|
125
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
126
|
+
# languages to use for user interface strings. The list is in decreasing order
|
127
|
+
# of preference. For additional information, including expected format, see
|
128
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
129
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
130
|
+
# both. If you set this header, you must also specify the
|
131
|
+
# [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc)
|
132
|
+
# query parameter. To determine the market to return results for, Bing uses the
|
133
|
+
# first supported language it finds from the list and combines it with the cc
|
134
|
+
# parameter value. If the list does not include a supported language, Bing
|
135
|
+
# finds the closest language and market that supports the request or it uses an
|
136
|
+
# aggregated or default market for the results. To determine the market that
|
137
|
+
# Bing used, see the BingAPIs-Market header. Use this header and the cc query
|
138
|
+
# parameter only if you specify multiple languages. Otherwise, use the
|
139
|
+
# [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt)
|
140
|
+
# and
|
141
|
+
# [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang)
|
142
|
+
# query parameters. A user interface string is a string that's used as a label
|
143
|
+
# in a user interface. There are few user interface strings in the JSON
|
144
|
+
# response objects. Any links to Bing.com properties in the response objects
|
145
|
+
# apply the specified language.
|
146
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
147
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
148
|
+
# no-cache (for example, Pragma: no-cache).
|
149
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
150
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
151
|
+
# optional, you are encouraged to always specify this header. The user-agent
|
152
|
+
# should be the same string that any commonly used browser sends. For
|
153
|
+
# information about user agents, see [RFC
|
154
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
|
155
|
+
# are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
|
156
|
+
# MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
|
157
|
+
# Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
|
158
|
+
# I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
|
159
|
+
# 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
|
160
|
+
# like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
|
161
|
+
# iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
|
162
|
+
# WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
|
163
|
+
# CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
|
164
|
+
# / 7.0 Mobile / 11A465 Safari / 9537.53
|
165
|
+
# @param client_id [String] Bing uses this header to provide users with
|
166
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
167
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
168
|
+
# different flights. If you do not use the same client ID for a user across
|
169
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
170
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
171
|
+
# inconsistent user experience. For example, if the second request has a
|
172
|
+
# different flight assignment than the first, the experience may be unexpected.
|
173
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
174
|
+
# search history, providing a richer experience for the user. Bing also uses
|
175
|
+
# this header to help improve result rankings by analyzing the activity
|
176
|
+
# generated by a client ID. The relevance improvements help with better quality
|
177
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
178
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
179
|
+
# this header required. Persisting the client ID across multiple requests for
|
180
|
+
# the same end user and device combination enables 1) the API consumer to
|
181
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
182
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
183
|
+
# application on the device must have a unique, Bing generated client ID. If
|
184
|
+
# you do not include this header in the request, Bing generates an ID and
|
185
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
186
|
+
# should NOT include this header in a request is the first time the user uses
|
187
|
+
# your app on that device. Use the client ID for each Bing API request that
|
188
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
189
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
190
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
191
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
192
|
+
# time the user uses your app on that device, get the client ID that you
|
193
|
+
# persisted. Bing responses may or may not include this header. If the response
|
194
|
+
# includes this header, capture the client ID and use it for all subsequent
|
195
|
+
# Bing requests for the user on that device. If you include the
|
196
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
197
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
198
|
+
# IP address is used to discover the user's location. Bing uses the location
|
199
|
+
# information to determine safe search behavior. Although optional, you are
|
200
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
201
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
202
|
+
# Obfuscating the address results in the location not being anywhere near the
|
203
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
204
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
205
|
+
# describe the client's geographical location. Bing uses the location
|
206
|
+
# information to determine safe search behavior and to return relevant local
|
207
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
208
|
+
# keys that you use to specify the user's location. lat (required): The
|
209
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
210
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
211
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
212
|
+
# long (required): The longitude of the client's location, in degrees. The
|
213
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
214
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
215
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
216
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
217
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
218
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
219
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
220
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
221
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
222
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
223
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
224
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
225
|
+
# client device is traveling. alt (optional): The altitude of the client
|
226
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
227
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
228
|
+
# the alt key. Although many of the keys are optional, the more information
|
229
|
+
# that you provide, the more accurate the location results are. Although
|
230
|
+
# optional, you are encouraged to always specify the user's geographical
|
231
|
+
# location. Providing the location is especially important if the client's IP
|
232
|
+
# address does not accurately reflect the user's physical location (for
|
233
|
+
# example, if the client uses VPN). For optimal results, you should include
|
234
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
235
|
+
# include this header.
|
236
|
+
# @param country_code [String] A 2-character country code of the country where
|
237
|
+
# the results come from. This API supports only the United States market. If
|
238
|
+
# you specify this query parameter, it must be set to us. If you set this
|
239
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
240
|
+
# first supported language it finds from the languages list, and combine that
|
241
|
+
# language with the country code that you specify to determine the market to
|
242
|
+
# return results for. If the languages list does not include a supported
|
243
|
+
# language, Bing finds the closest language and market that supports the
|
244
|
+
# request, or it may use an aggregated or default market for the results
|
245
|
+
# instead of a specified one. You should use this query parameter and the
|
246
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
247
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
248
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
249
|
+
# both.
|
250
|
+
# @param market [String] The market where the results come from. You are
|
251
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
252
|
+
# market helps Bing route the request and return an appropriate and optimal
|
253
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
254
|
+
# not specify both.
|
255
|
+
# @param safe_search [SafeSearch] Filter suggestions for adult content. The
|
256
|
+
# following are the possible filter values. Off: Return suggestions with adult
|
257
|
+
# text, images, or videos. Moderate: Return suggestion with adult text but not
|
258
|
+
# adult images or videos. Strict: Do not return news articles with adult text,
|
259
|
+
# images, or videos. If the request comes from a market that Bing's adult
|
260
|
+
# policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
|
261
|
+
# value and uses Strict. If you use the site: query operator, there is the
|
262
|
+
# chance that the response may contain adult content regardless of what the
|
263
|
+
# safeSearch query parameter is set to. Use site: only if you are aware of the
|
264
|
+
# content on the site and your scenario supports the possibility of adult
|
265
|
+
# content. Possible values include: 'Off', 'Moderate', 'Strict'
|
266
|
+
# @param set_lang [String] The language to use for user interface strings.
|
267
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
268
|
+
# the language code for English is EN. The default is EN (English). Although
|
269
|
+
# optional, you should always specify the language. Typically, you set setLang
|
270
|
+
# to the same language specified by mkt unless the user wants the user
|
271
|
+
# interface strings displayed in a different language. This parameter and the
|
272
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
273
|
+
# interface string is a string that's used as a label in a user interface.
|
274
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
275
|
+
# links to Bing.com properties in the response objects apply the specified
|
276
|
+
# language.
|
277
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
278
|
+
# response. The following are the possible case-insensitive values: JSON,
|
279
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
280
|
+
# includes JSON-LD objects that contain the search results.
|
281
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
282
|
+
# will be added to the HTTP request.
|
283
|
+
#
|
284
|
+
# @return [Suggestions] operation results.
|
285
|
+
#
|
286
|
+
def auto_suggest(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, market:'en-us', safe_search:nil, set_lang:nil, response_format:nil, custom_headers:nil)
|
287
|
+
response = auto_suggest_async(query, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, market:market, safe_search:safe_search, set_lang:set_lang, response_format:response_format, custom_headers:custom_headers).value!
|
288
|
+
response.body unless response.nil?
|
289
|
+
end
|
290
|
+
|
291
|
+
#
|
292
|
+
# The AutoSuggest API lets you send a search query to Bing and get back a list
|
293
|
+
# of query suggestions. This section provides technical details about the query
|
294
|
+
# parameters and headers that you use to request suggestions and the JSON
|
295
|
+
# response objects that contain them.
|
296
|
+
#
|
297
|
+
# @param query [String] The user's search term.
|
298
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
299
|
+
# languages to use for user interface strings. The list is in decreasing order
|
300
|
+
# of preference. For additional information, including expected format, see
|
301
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
302
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
303
|
+
# both. If you set this header, you must also specify the
|
304
|
+
# [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc)
|
305
|
+
# query parameter. To determine the market to return results for, Bing uses the
|
306
|
+
# first supported language it finds from the list and combines it with the cc
|
307
|
+
# parameter value. If the list does not include a supported language, Bing
|
308
|
+
# finds the closest language and market that supports the request or it uses an
|
309
|
+
# aggregated or default market for the results. To determine the market that
|
310
|
+
# Bing used, see the BingAPIs-Market header. Use this header and the cc query
|
311
|
+
# parameter only if you specify multiple languages. Otherwise, use the
|
312
|
+
# [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt)
|
313
|
+
# and
|
314
|
+
# [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang)
|
315
|
+
# query parameters. A user interface string is a string that's used as a label
|
316
|
+
# in a user interface. There are few user interface strings in the JSON
|
317
|
+
# response objects. Any links to Bing.com properties in the response objects
|
318
|
+
# apply the specified language.
|
319
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
320
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
321
|
+
# no-cache (for example, Pragma: no-cache).
|
322
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
323
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
324
|
+
# optional, you are encouraged to always specify this header. The user-agent
|
325
|
+
# should be the same string that any commonly used browser sends. For
|
326
|
+
# information about user agents, see [RFC
|
327
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
|
328
|
+
# are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
|
329
|
+
# MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
|
330
|
+
# Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
|
331
|
+
# I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
|
332
|
+
# 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
|
333
|
+
# like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
|
334
|
+
# iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
|
335
|
+
# WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
|
336
|
+
# CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
|
337
|
+
# / 7.0 Mobile / 11A465 Safari / 9537.53
|
338
|
+
# @param client_id [String] Bing uses this header to provide users with
|
339
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
340
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
341
|
+
# different flights. If you do not use the same client ID for a user across
|
342
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
343
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
344
|
+
# inconsistent user experience. For example, if the second request has a
|
345
|
+
# different flight assignment than the first, the experience may be unexpected.
|
346
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
347
|
+
# search history, providing a richer experience for the user. Bing also uses
|
348
|
+
# this header to help improve result rankings by analyzing the activity
|
349
|
+
# generated by a client ID. The relevance improvements help with better quality
|
350
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
351
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
352
|
+
# this header required. Persisting the client ID across multiple requests for
|
353
|
+
# the same end user and device combination enables 1) the API consumer to
|
354
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
355
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
356
|
+
# application on the device must have a unique, Bing generated client ID. If
|
357
|
+
# you do not include this header in the request, Bing generates an ID and
|
358
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
359
|
+
# should NOT include this header in a request is the first time the user uses
|
360
|
+
# your app on that device. Use the client ID for each Bing API request that
|
361
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
362
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
363
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
364
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
365
|
+
# time the user uses your app on that device, get the client ID that you
|
366
|
+
# persisted. Bing responses may or may not include this header. If the response
|
367
|
+
# includes this header, capture the client ID and use it for all subsequent
|
368
|
+
# Bing requests for the user on that device. If you include the
|
369
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
370
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
371
|
+
# IP address is used to discover the user's location. Bing uses the location
|
372
|
+
# information to determine safe search behavior. Although optional, you are
|
373
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
374
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
375
|
+
# Obfuscating the address results in the location not being anywhere near the
|
376
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
377
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
378
|
+
# describe the client's geographical location. Bing uses the location
|
379
|
+
# information to determine safe search behavior and to return relevant local
|
380
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
381
|
+
# keys that you use to specify the user's location. lat (required): The
|
382
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
383
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
384
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
385
|
+
# long (required): The longitude of the client's location, in degrees. The
|
386
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
387
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
388
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
389
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
390
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
391
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
392
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
393
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
394
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
395
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
396
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
397
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
398
|
+
# client device is traveling. alt (optional): The altitude of the client
|
399
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
400
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
401
|
+
# the alt key. Although many of the keys are optional, the more information
|
402
|
+
# that you provide, the more accurate the location results are. Although
|
403
|
+
# optional, you are encouraged to always specify the user's geographical
|
404
|
+
# location. Providing the location is especially important if the client's IP
|
405
|
+
# address does not accurately reflect the user's physical location (for
|
406
|
+
# example, if the client uses VPN). For optimal results, you should include
|
407
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
408
|
+
# include this header.
|
409
|
+
# @param country_code [String] A 2-character country code of the country where
|
410
|
+
# the results come from. This API supports only the United States market. If
|
411
|
+
# you specify this query parameter, it must be set to us. If you set this
|
412
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
413
|
+
# first supported language it finds from the languages list, and combine that
|
414
|
+
# language with the country code that you specify to determine the market to
|
415
|
+
# return results for. If the languages list does not include a supported
|
416
|
+
# language, Bing finds the closest language and market that supports the
|
417
|
+
# request, or it may use an aggregated or default market for the results
|
418
|
+
# instead of a specified one. You should use this query parameter and the
|
419
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
420
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
421
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
422
|
+
# both.
|
423
|
+
# @param market [String] The market where the results come from. You are
|
424
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
425
|
+
# market helps Bing route the request and return an appropriate and optimal
|
426
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
427
|
+
# not specify both.
|
428
|
+
# @param safe_search [SafeSearch] Filter suggestions for adult content. The
|
429
|
+
# following are the possible filter values. Off: Return suggestions with adult
|
430
|
+
# text, images, or videos. Moderate: Return suggestion with adult text but not
|
431
|
+
# adult images or videos. Strict: Do not return news articles with adult text,
|
432
|
+
# images, or videos. If the request comes from a market that Bing's adult
|
433
|
+
# policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
|
434
|
+
# value and uses Strict. If you use the site: query operator, there is the
|
435
|
+
# chance that the response may contain adult content regardless of what the
|
436
|
+
# safeSearch query parameter is set to. Use site: only if you are aware of the
|
437
|
+
# content on the site and your scenario supports the possibility of adult
|
438
|
+
# content. Possible values include: 'Off', 'Moderate', 'Strict'
|
439
|
+
# @param set_lang [String] The language to use for user interface strings.
|
440
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
441
|
+
# the language code for English is EN. The default is EN (English). Although
|
442
|
+
# optional, you should always specify the language. Typically, you set setLang
|
443
|
+
# to the same language specified by mkt unless the user wants the user
|
444
|
+
# interface strings displayed in a different language. This parameter and the
|
445
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
446
|
+
# interface string is a string that's used as a label in a user interface.
|
447
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
448
|
+
# links to Bing.com properties in the response objects apply the specified
|
449
|
+
# language.
|
450
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
451
|
+
# response. The following are the possible case-insensitive values: JSON,
|
452
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
453
|
+
# includes JSON-LD objects that contain the search results.
|
454
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
455
|
+
# will be added to the HTTP request.
|
456
|
+
#
|
457
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
458
|
+
#
|
459
|
+
def auto_suggest_with_http_info(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, market:'en-us', safe_search:nil, set_lang:nil, response_format:nil, custom_headers:nil)
|
460
|
+
auto_suggest_async(query, accept_language:accept_language, pragma:pragma, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, market:market, safe_search:safe_search, set_lang:set_lang, response_format:response_format, custom_headers:custom_headers).value!
|
461
|
+
end
|
462
|
+
|
463
|
+
#
|
464
|
+
# The AutoSuggest API lets you send a search query to Bing and get back a list
|
465
|
+
# of query suggestions. This section provides technical details about the query
|
466
|
+
# parameters and headers that you use to request suggestions and the JSON
|
467
|
+
# response objects that contain them.
|
468
|
+
#
|
469
|
+
# @param query [String] The user's search term.
|
470
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
471
|
+
# languages to use for user interface strings. The list is in decreasing order
|
472
|
+
# of preference. For additional information, including expected format, see
|
473
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
474
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
475
|
+
# both. If you set this header, you must also specify the
|
476
|
+
# [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc)
|
477
|
+
# query parameter. To determine the market to return results for, Bing uses the
|
478
|
+
# first supported language it finds from the list and combines it with the cc
|
479
|
+
# parameter value. If the list does not include a supported language, Bing
|
480
|
+
# finds the closest language and market that supports the request or it uses an
|
481
|
+
# aggregated or default market for the results. To determine the market that
|
482
|
+
# Bing used, see the BingAPIs-Market header. Use this header and the cc query
|
483
|
+
# parameter only if you specify multiple languages. Otherwise, use the
|
484
|
+
# [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt)
|
485
|
+
# and
|
486
|
+
# [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang)
|
487
|
+
# query parameters. A user interface string is a string that's used as a label
|
488
|
+
# in a user interface. There are few user interface strings in the JSON
|
489
|
+
# response objects. Any links to Bing.com properties in the response objects
|
490
|
+
# apply the specified language.
|
491
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
492
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
493
|
+
# no-cache (for example, Pragma: no-cache).
|
494
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
495
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
496
|
+
# optional, you are encouraged to always specify this header. The user-agent
|
497
|
+
# should be the same string that any commonly used browser sends. For
|
498
|
+
# information about user agents, see [RFC
|
499
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
|
500
|
+
# are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
|
501
|
+
# MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
|
502
|
+
# Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
|
503
|
+
# I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
|
504
|
+
# 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
|
505
|
+
# like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
|
506
|
+
# iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
|
507
|
+
# WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
|
508
|
+
# CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
|
509
|
+
# / 7.0 Mobile / 11A465 Safari / 9537.53
|
510
|
+
# @param client_id [String] Bing uses this header to provide users with
|
511
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
512
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
513
|
+
# different flights. If you do not use the same client ID for a user across
|
514
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
515
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
516
|
+
# inconsistent user experience. For example, if the second request has a
|
517
|
+
# different flight assignment than the first, the experience may be unexpected.
|
518
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
519
|
+
# search history, providing a richer experience for the user. Bing also uses
|
520
|
+
# this header to help improve result rankings by analyzing the activity
|
521
|
+
# generated by a client ID. The relevance improvements help with better quality
|
522
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
523
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
524
|
+
# this header required. Persisting the client ID across multiple requests for
|
525
|
+
# the same end user and device combination enables 1) the API consumer to
|
526
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
527
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
528
|
+
# application on the device must have a unique, Bing generated client ID. If
|
529
|
+
# you do not include this header in the request, Bing generates an ID and
|
530
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
531
|
+
# should NOT include this header in a request is the first time the user uses
|
532
|
+
# your app on that device. Use the client ID for each Bing API request that
|
533
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
534
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
535
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
536
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
537
|
+
# time the user uses your app on that device, get the client ID that you
|
538
|
+
# persisted. Bing responses may or may not include this header. If the response
|
539
|
+
# includes this header, capture the client ID and use it for all subsequent
|
540
|
+
# Bing requests for the user on that device. If you include the
|
541
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
542
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
543
|
+
# IP address is used to discover the user's location. Bing uses the location
|
544
|
+
# information to determine safe search behavior. Although optional, you are
|
545
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
546
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
547
|
+
# Obfuscating the address results in the location not being anywhere near the
|
548
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
549
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
550
|
+
# describe the client's geographical location. Bing uses the location
|
551
|
+
# information to determine safe search behavior and to return relevant local
|
552
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
553
|
+
# keys that you use to specify the user's location. lat (required): The
|
554
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
555
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
556
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
557
|
+
# long (required): The longitude of the client's location, in degrees. The
|
558
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
559
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
560
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
561
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
562
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
563
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
564
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
565
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
566
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
567
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
568
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
569
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
570
|
+
# client device is traveling. alt (optional): The altitude of the client
|
571
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
572
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
573
|
+
# the alt key. Although many of the keys are optional, the more information
|
574
|
+
# that you provide, the more accurate the location results are. Although
|
575
|
+
# optional, you are encouraged to always specify the user's geographical
|
576
|
+
# location. Providing the location is especially important if the client's IP
|
577
|
+
# address does not accurately reflect the user's physical location (for
|
578
|
+
# example, if the client uses VPN). For optimal results, you should include
|
579
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
580
|
+
# include this header.
|
581
|
+
# @param country_code [String] A 2-character country code of the country where
|
582
|
+
# the results come from. This API supports only the United States market. If
|
583
|
+
# you specify this query parameter, it must be set to us. If you set this
|
584
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
585
|
+
# first supported language it finds from the languages list, and combine that
|
586
|
+
# language with the country code that you specify to determine the market to
|
587
|
+
# return results for. If the languages list does not include a supported
|
588
|
+
# language, Bing finds the closest language and market that supports the
|
589
|
+
# request, or it may use an aggregated or default market for the results
|
590
|
+
# instead of a specified one. You should use this query parameter and the
|
591
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
592
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
593
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
594
|
+
# both.
|
595
|
+
# @param market [String] The market where the results come from. You are
|
596
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
597
|
+
# market helps Bing route the request and return an appropriate and optimal
|
598
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
599
|
+
# not specify both.
|
600
|
+
# @param safe_search [SafeSearch] Filter suggestions for adult content. The
|
601
|
+
# following are the possible filter values. Off: Return suggestions with adult
|
602
|
+
# text, images, or videos. Moderate: Return suggestion with adult text but not
|
603
|
+
# adult images or videos. Strict: Do not return news articles with adult text,
|
604
|
+
# images, or videos. If the request comes from a market that Bing's adult
|
605
|
+
# policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
|
606
|
+
# value and uses Strict. If you use the site: query operator, there is the
|
607
|
+
# chance that the response may contain adult content regardless of what the
|
608
|
+
# safeSearch query parameter is set to. Use site: only if you are aware of the
|
609
|
+
# content on the site and your scenario supports the possibility of adult
|
610
|
+
# content. Possible values include: 'Off', 'Moderate', 'Strict'
|
611
|
+
# @param set_lang [String] The language to use for user interface strings.
|
612
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
613
|
+
# the language code for English is EN. The default is EN (English). Although
|
614
|
+
# optional, you should always specify the language. Typically, you set setLang
|
615
|
+
# to the same language specified by mkt unless the user wants the user
|
616
|
+
# interface strings displayed in a different language. This parameter and the
|
617
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
618
|
+
# interface string is a string that's used as a label in a user interface.
|
619
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
620
|
+
# links to Bing.com properties in the response objects apply the specified
|
621
|
+
# language.
|
622
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
623
|
+
# response. The following are the possible case-insensitive values: JSON,
|
624
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
625
|
+
# includes JSON-LD objects that contain the search results.
|
626
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
627
|
+
# to the HTTP request.
|
628
|
+
#
|
629
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
630
|
+
#
|
631
|
+
def auto_suggest_async(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, market:'en-us', safe_search:nil, set_lang:nil, response_format:nil, custom_headers:nil)
|
632
|
+
fail ArgumentError, 'endpoint is nil' if endpoint.nil?
|
633
|
+
x_bing_apis_sdk = 'true'
|
634
|
+
fail ArgumentError, 'query is nil' if query.nil?
|
635
|
+
|
636
|
+
|
637
|
+
request_headers = {}
|
638
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
639
|
+
|
640
|
+
# Set Headers
|
641
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
642
|
+
request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
|
643
|
+
request_headers['Accept-Language'] = accept_language unless accept_language.nil?
|
644
|
+
request_headers['Pragma'] = pragma unless pragma.nil?
|
645
|
+
request_headers['User-Agent'] = user_agent unless user_agent.nil?
|
646
|
+
request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
|
647
|
+
request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
|
648
|
+
request_headers['X-Search-Location'] = location unless location.nil?
|
649
|
+
path_template = 'Suggestions'
|
650
|
+
|
651
|
+
request_url = @base_url || self.base_url
|
652
|
+
request_url = request_url.gsub('{Endpoint}', endpoint)
|
653
|
+
|
654
|
+
options = {
|
655
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
656
|
+
query_params: {'cc' => country_code,'mkt' => market,'q' => query,'safeSearch' => safe_search,'setLang' => set_lang,'ResponseFormat' => response_format.nil? ? nil : response_format.join(',')},
|
657
|
+
headers: request_headers.merge(custom_headers || {}),
|
658
|
+
base_url: request_url
|
659
|
+
}
|
660
|
+
promise = self.make_request_async(:get, path_template, options)
|
661
|
+
|
662
|
+
promise = promise.then do |result|
|
663
|
+
http_response = result.response
|
664
|
+
status_code = http_response.status
|
665
|
+
response_content = http_response.body
|
666
|
+
unless status_code == 200
|
667
|
+
error_model = JSON.load(response_content)
|
668
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
669
|
+
end
|
670
|
+
|
671
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
672
|
+
# Deserialize Response
|
673
|
+
if status_code == 200
|
674
|
+
begin
|
675
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
676
|
+
result_mapper = Azure::CognitiveServices::Autosuggest::V1_0::Models::Suggestions.mapper()
|
677
|
+
result.body = self.deserialize(result_mapper, parsed_response)
|
678
|
+
rescue Exception => e
|
679
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
result
|
684
|
+
end
|
685
|
+
|
686
|
+
promise.execute
|
687
|
+
end
|
688
|
+
|
689
|
+
|
690
|
+
private
|
691
|
+
#
|
692
|
+
# Adds telemetry information.
|
693
|
+
#
|
694
|
+
def add_telemetry
|
695
|
+
sdk_information = 'azure_cognitiveservices_autosuggest'
|
696
|
+
sdk_information = "#{sdk_information}/0.17.0"
|
697
|
+
add_user_agent_information(sdk_information)
|
698
|
+
end
|
699
|
+
end
|
700
|
+
end
|