azure_cognitiveservices_localsearch 0.17.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_localsearch.rb +54 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/local.rb +601 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/local_search_client.rb +128 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/action.rb +424 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/answer.rb +131 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/creative_work.rb +392 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/entities_entity_presentation_info.rb +127 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/entity_scenario.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/entity_type.rb +18 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/error.rb +126 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/error_code.rb +20 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/error_response.rb +154 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/error_sub_code.rb +25 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/geo_coordinates.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/identifiable.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/intangible.rb +162 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/place.rb +217 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/places.rb +182 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/postal_address.rb +338 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/query_context.rb +150 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/response.rb +150 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/response_base.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/response_format.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/safe_search.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/search_action.rb +464 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/search_response.rb +190 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/search_results_answer.rb +172 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/structured_value.rb +162 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/models/thing.rb +174 -0
- data/lib/1.0/generated/azure_cognitiveservices_localsearch/module_definition.rb +9 -0
- data/lib/azure_cognitiveservices_localsearch.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/localsearch_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/localsearch_module_definition.rb +8 -0
- data/lib/profiles/latest/modules/localsearch_profile_module.rb +163 -0
- data/lib/version.rb +7 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7415e0be94789e72f600a4eaf1ccc76cc185e336
|
4
|
+
data.tar.gz: 7529bc1fcb96e3ac6d71239b1edc2357e5b4db53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 551bbc2c725491d646d0842a50a36a79cf5bbf1b0a0baa15d9bf0d25446ae242d5b3c13337f69f1e13f271643e2493ff69bbe9411c8c28582ab7817835d9ca9f
|
7
|
+
data.tar.gz: 284005b254caa6c30d7a3129b15bf7dbbfa4ba882e3cf4609427f84038ef9190969dfca1d4235bc145611c275f04b6f1c1757de8b533b1b0ea8fdac587574fa1
|
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,54 @@
|
|
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_localsearch/module_definition'
|
20
|
+
require 'ms_rest_azure'
|
21
|
+
|
22
|
+
module Azure::CognitiveServices::LocalSearch::V1_0
|
23
|
+
autoload :Local, '1.0/generated/azure_cognitiveservices_localsearch/local.rb'
|
24
|
+
autoload :LocalSearchClient, '1.0/generated/azure_cognitiveservices_localsearch/local_search_client.rb'
|
25
|
+
|
26
|
+
module Models
|
27
|
+
autoload :ResponseBase, '1.0/generated/azure_cognitiveservices_localsearch/models/response_base.rb'
|
28
|
+
autoload :GeoCoordinates, '1.0/generated/azure_cognitiveservices_localsearch/models/geo_coordinates.rb'
|
29
|
+
autoload :EntitiesEntityPresentationInfo, '1.0/generated/azure_cognitiveservices_localsearch/models/entities_entity_presentation_info.rb'
|
30
|
+
autoload :QueryContext, '1.0/generated/azure_cognitiveservices_localsearch/models/query_context.rb'
|
31
|
+
autoload :Error, '1.0/generated/azure_cognitiveservices_localsearch/models/error.rb'
|
32
|
+
autoload :SearchResultsAnswer, '1.0/generated/azure_cognitiveservices_localsearch/models/search_results_answer.rb'
|
33
|
+
autoload :Places, '1.0/generated/azure_cognitiveservices_localsearch/models/places.rb'
|
34
|
+
autoload :PostalAddress, '1.0/generated/azure_cognitiveservices_localsearch/models/postal_address.rb'
|
35
|
+
autoload :Place, '1.0/generated/azure_cognitiveservices_localsearch/models/place.rb'
|
36
|
+
autoload :Action, '1.0/generated/azure_cognitiveservices_localsearch/models/action.rb'
|
37
|
+
autoload :Identifiable, '1.0/generated/azure_cognitiveservices_localsearch/models/identifiable.rb'
|
38
|
+
autoload :Response, '1.0/generated/azure_cognitiveservices_localsearch/models/response.rb'
|
39
|
+
autoload :Thing, '1.0/generated/azure_cognitiveservices_localsearch/models/thing.rb'
|
40
|
+
autoload :SearchResponse, '1.0/generated/azure_cognitiveservices_localsearch/models/search_response.rb'
|
41
|
+
autoload :Answer, '1.0/generated/azure_cognitiveservices_localsearch/models/answer.rb'
|
42
|
+
autoload :ErrorResponse, '1.0/generated/azure_cognitiveservices_localsearch/models/error_response.rb'
|
43
|
+
autoload :CreativeWork, '1.0/generated/azure_cognitiveservices_localsearch/models/creative_work.rb'
|
44
|
+
autoload :Intangible, '1.0/generated/azure_cognitiveservices_localsearch/models/intangible.rb'
|
45
|
+
autoload :SearchAction, '1.0/generated/azure_cognitiveservices_localsearch/models/search_action.rb'
|
46
|
+
autoload :StructuredValue, '1.0/generated/azure_cognitiveservices_localsearch/models/structured_value.rb'
|
47
|
+
autoload :EntityScenario, '1.0/generated/azure_cognitiveservices_localsearch/models/entity_scenario.rb'
|
48
|
+
autoload :EntityType, '1.0/generated/azure_cognitiveservices_localsearch/models/entity_type.rb'
|
49
|
+
autoload :ErrorCode, '1.0/generated/azure_cognitiveservices_localsearch/models/error_code.rb'
|
50
|
+
autoload :ErrorSubCode, '1.0/generated/azure_cognitiveservices_localsearch/models/error_sub_code.rb'
|
51
|
+
autoload :ResponseFormat, '1.0/generated/azure_cognitiveservices_localsearch/models/response_format.rb'
|
52
|
+
autoload :SafeSearch, '1.0/generated/azure_cognitiveservices_localsearch/models/safe_search.rb'
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,601 @@
|
|
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::LocalSearch::V1_0
|
7
|
+
#
|
8
|
+
# The Local Search client lets you send a search query to Bing and get back
|
9
|
+
# search results that include local businesses such as restaurants, hotels,
|
10
|
+
# retail stores, or other local businesses. The query can specify the name of
|
11
|
+
# the local business or it can ask for a list (for example, restaurants near
|
12
|
+
# me).
|
13
|
+
#
|
14
|
+
class Local
|
15
|
+
include MsRestAzure
|
16
|
+
|
17
|
+
#
|
18
|
+
# Creates and initializes a new instance of the Local class.
|
19
|
+
# @param client service class for accessing basic functionality.
|
20
|
+
#
|
21
|
+
def initialize(client)
|
22
|
+
@client = client
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [LocalSearchClient] reference to the LocalSearchClient
|
26
|
+
attr_reader :client
|
27
|
+
|
28
|
+
#
|
29
|
+
# The Local Search API lets you send a search query to Bing and get back search
|
30
|
+
# results that include local businesses such as restaurants, hotels, retail
|
31
|
+
# stores, or other local businesses. The query can specify the name of the
|
32
|
+
# local business or it can ask for a list (for example, restaurants near me).
|
33
|
+
#
|
34
|
+
# @param query [String] The user's search term.
|
35
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
36
|
+
# languages to use for user interface strings. The list is in decreasing order
|
37
|
+
# of preference. For additional information, including expected format, see
|
38
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
39
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
40
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
41
|
+
# Bing will use the first supported language it finds from the list, and
|
42
|
+
# combine that language with the cc parameter value to determine the market to
|
43
|
+
# return results for. If the list does not include a supported language, Bing
|
44
|
+
# will find the closest language and market that supports the request, and may
|
45
|
+
# use an aggregated or default market for the results instead of a specified
|
46
|
+
# one. You should use this header and the cc query parameter only if you
|
47
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
48
|
+
# query parameters. A user interface string is a string that's used as a label
|
49
|
+
# in a user interface. There are very few user interface strings in the JSON
|
50
|
+
# response objects. Any links in the response objects to Bing.com properties
|
51
|
+
# will apply the specified language.
|
52
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
53
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
54
|
+
# no-cache (for example, Pragma: no-cache).
|
55
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
56
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
57
|
+
# optional, you are strongly encouraged to always specify this header. The
|
58
|
+
# user-agent should be the same string that any commonly used browser would
|
59
|
+
# send. For information about user agents, see [RFC
|
60
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
61
|
+
# @param client_id [String] Bing uses this header to provide users with
|
62
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
63
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
64
|
+
# different flights. If you do not use the same client ID for a user across
|
65
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
66
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
67
|
+
# inconsistent user experience. For example, if the second request has a
|
68
|
+
# different flight assignment than the first, the experience may be unexpected.
|
69
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
70
|
+
# search history, providing a richer experience for the user. Bing also uses
|
71
|
+
# this header to help improve result rankings by analyzing the activity
|
72
|
+
# generated by a client ID. The relevance improvements help with better quality
|
73
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
74
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
75
|
+
# this header required. Persisting the client ID across multiple requests for
|
76
|
+
# the same end user and device combination enables 1) the API consumer to
|
77
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
78
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
79
|
+
# application on the device must have a unique, Bing generated client ID. If
|
80
|
+
# you do not include this header in the request, Bing generates an ID and
|
81
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
82
|
+
# should NOT include this header in a request is the first time the user uses
|
83
|
+
# your app on that device. Use the client ID for each Bing API request that
|
84
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
85
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
86
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
87
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
88
|
+
# time the user uses your app on that device, get the client ID that you
|
89
|
+
# persisted. Bing responses may or may not include this header. If the response
|
90
|
+
# includes this header, capture the client ID and use it for all subsequent
|
91
|
+
# Bing requests for the user on that device. If you include the
|
92
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
93
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
94
|
+
# IP address is used to discover the user's location. Bing uses the location
|
95
|
+
# information to determine safe search behavior. Although optional, you are
|
96
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
97
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
98
|
+
# Obfuscating the address results in the location not being anywhere near the
|
99
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
100
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
101
|
+
# describe the client's geographical location. Bing uses the location
|
102
|
+
# information to determine safe search behavior and to return relevant local
|
103
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
104
|
+
# keys that you use to specify the user's location. lat (required): The
|
105
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
106
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
107
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
108
|
+
# long (required): The longitude of the client's location, in degrees. The
|
109
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
110
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
111
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
112
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
113
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
114
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
115
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
116
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
117
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
118
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
119
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
120
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
121
|
+
# client device is traveling. alt (optional): The altitude of the client
|
122
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
123
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
124
|
+
# the alt key. Although many of the keys are optional, the more information
|
125
|
+
# that you provide, the more accurate the location results are. Although
|
126
|
+
# optional, you are encouraged to always specify the user's geographical
|
127
|
+
# location. Providing the location is especially important if the client's IP
|
128
|
+
# address does not accurately reflect the user's physical location (for
|
129
|
+
# example, if the client uses VPN). For optimal results, you should include
|
130
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
131
|
+
# include this header.
|
132
|
+
# @param country_code [String] A 2-character country code of the country where
|
133
|
+
# the results come from. This API supports only the United States market. If
|
134
|
+
# you specify this query parameter, it must be set to us. If you set this
|
135
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
136
|
+
# first supported language it finds from the languages list, and combine that
|
137
|
+
# language with the country code that you specify to determine the market to
|
138
|
+
# return results for. If the languages list does not include a supported
|
139
|
+
# language, Bing finds the closest language and market that supports the
|
140
|
+
# request, or it may use an aggregated or default market for the results
|
141
|
+
# instead of a specified one. You should use this query parameter and the
|
142
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
143
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
144
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
145
|
+
# both.
|
146
|
+
# @param market [String] The market where the results come from. You are
|
147
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
148
|
+
# market helps Bing route the request and return an appropriate and optimal
|
149
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
150
|
+
# not specify both.
|
151
|
+
# @param local_categories [String] comma-delimited list of business categories
|
152
|
+
# to search for. Supported categories can be high-level such as EatDrink, Shop,
|
153
|
+
# SeeDo.
|
154
|
+
# @param local_circular_view [String] Preferred location to search around,
|
155
|
+
# expressed as Latitude, longitude and radius in meters. For example
|
156
|
+
# 47.61503,-122.1719,5000. Note that circular view should only be used to
|
157
|
+
# indicate a search around a point on the map, not as an approximation for a
|
158
|
+
# view port of a map rectangle.
|
159
|
+
# @param local_map_view [String] Preferred bounding box for results, specified
|
160
|
+
# in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. For example
|
161
|
+
# 47.64,-122.13,47.63,-122.12. These values are lat, long pairs for the
|
162
|
+
# Northwest corner and the Southeast corner of a rectangle.
|
163
|
+
# @param count [String] Preferred number of results to return. If not
|
164
|
+
# specified, then Bing returns 1-20 of the most relevant results.
|
165
|
+
# @param first [String] First result to return. zero-based. default is 0.
|
166
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
167
|
+
# response. The following are the possible case-insensitive values: JSON,
|
168
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
169
|
+
# includes JSON-LD objects that contain the search results.
|
170
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
171
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
172
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
173
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
174
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
175
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
176
|
+
# use the site: query operator, there is the chance that the response may
|
177
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
178
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
179
|
+
# scenario supports the possibility of adult content. Possible values include:
|
180
|
+
# 'Off', 'Moderate', 'Strict'
|
181
|
+
# @param set_lang [String] The language to use for user interface strings.
|
182
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
183
|
+
# the language code for English is EN. The default is EN (English). Although
|
184
|
+
# optional, you should always specify the language. Typically, you set setLang
|
185
|
+
# to the same language specified by mkt unless the user wants the user
|
186
|
+
# interface strings displayed in a different language. This parameter and the
|
187
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
188
|
+
# interface string is a string that's used as a label in a user interface.
|
189
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
190
|
+
# links to Bing.com properties in the response objects apply the specified
|
191
|
+
# language.
|
192
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
193
|
+
# will be added to the HTTP request.
|
194
|
+
#
|
195
|
+
# @return [SearchResponse] operation results.
|
196
|
+
#
|
197
|
+
def search(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, market:'en-us', local_categories:nil, local_circular_view:nil, local_map_view:nil, count:nil, first:nil, response_format:nil, safe_search:nil, set_lang:nil, custom_headers:nil)
|
198
|
+
response = search_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, local_categories:local_categories, local_circular_view:local_circular_view, local_map_view:local_map_view, count:count, first:first, response_format:response_format, safe_search:safe_search, set_lang:set_lang, custom_headers:custom_headers).value!
|
199
|
+
response.body unless response.nil?
|
200
|
+
end
|
201
|
+
|
202
|
+
#
|
203
|
+
# The Local Search API lets you send a search query to Bing and get back search
|
204
|
+
# results that include local businesses such as restaurants, hotels, retail
|
205
|
+
# stores, or other local businesses. The query can specify the name of the
|
206
|
+
# local business or it can ask for a list (for example, restaurants near me).
|
207
|
+
#
|
208
|
+
# @param query [String] The user's search term.
|
209
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
210
|
+
# languages to use for user interface strings. The list is in decreasing order
|
211
|
+
# of preference. For additional information, including expected format, see
|
212
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
213
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
214
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
215
|
+
# Bing will use the first supported language it finds from the list, and
|
216
|
+
# combine that language with the cc parameter value to determine the market to
|
217
|
+
# return results for. If the list does not include a supported language, Bing
|
218
|
+
# will find the closest language and market that supports the request, and may
|
219
|
+
# use an aggregated or default market for the results instead of a specified
|
220
|
+
# one. You should use this header and the cc query parameter only if you
|
221
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
222
|
+
# query parameters. A user interface string is a string that's used as a label
|
223
|
+
# in a user interface. There are very few user interface strings in the JSON
|
224
|
+
# response objects. Any links in the response objects to Bing.com properties
|
225
|
+
# will apply the specified language.
|
226
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
227
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
228
|
+
# no-cache (for example, Pragma: no-cache).
|
229
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
230
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
231
|
+
# optional, you are strongly encouraged to always specify this header. The
|
232
|
+
# user-agent should be the same string that any commonly used browser would
|
233
|
+
# send. For information about user agents, see [RFC
|
234
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
235
|
+
# @param client_id [String] Bing uses this header to provide users with
|
236
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
237
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
238
|
+
# different flights. If you do not use the same client ID for a user across
|
239
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
240
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
241
|
+
# inconsistent user experience. For example, if the second request has a
|
242
|
+
# different flight assignment than the first, the experience may be unexpected.
|
243
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
244
|
+
# search history, providing a richer experience for the user. Bing also uses
|
245
|
+
# this header to help improve result rankings by analyzing the activity
|
246
|
+
# generated by a client ID. The relevance improvements help with better quality
|
247
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
248
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
249
|
+
# this header required. Persisting the client ID across multiple requests for
|
250
|
+
# the same end user and device combination enables 1) the API consumer to
|
251
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
252
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
253
|
+
# application on the device must have a unique, Bing generated client ID. If
|
254
|
+
# you do not include this header in the request, Bing generates an ID and
|
255
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
256
|
+
# should NOT include this header in a request is the first time the user uses
|
257
|
+
# your app on that device. Use the client ID for each Bing API request that
|
258
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
259
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
260
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
261
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
262
|
+
# time the user uses your app on that device, get the client ID that you
|
263
|
+
# persisted. Bing responses may or may not include this header. If the response
|
264
|
+
# includes this header, capture the client ID and use it for all subsequent
|
265
|
+
# Bing requests for the user on that device. If you include the
|
266
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
267
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
268
|
+
# IP address is used to discover the user's location. Bing uses the location
|
269
|
+
# information to determine safe search behavior. Although optional, you are
|
270
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
271
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
272
|
+
# Obfuscating the address results in the location not being anywhere near the
|
273
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
274
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
275
|
+
# describe the client's geographical location. Bing uses the location
|
276
|
+
# information to determine safe search behavior and to return relevant local
|
277
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
278
|
+
# keys that you use to specify the user's location. lat (required): The
|
279
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
280
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
281
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
282
|
+
# long (required): The longitude of the client's location, in degrees. The
|
283
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
284
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
285
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
286
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
287
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
288
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
289
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
290
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
291
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
292
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
293
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
294
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
295
|
+
# client device is traveling. alt (optional): The altitude of the client
|
296
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
297
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
298
|
+
# the alt key. Although many of the keys are optional, the more information
|
299
|
+
# that you provide, the more accurate the location results are. Although
|
300
|
+
# optional, you are encouraged to always specify the user's geographical
|
301
|
+
# location. Providing the location is especially important if the client's IP
|
302
|
+
# address does not accurately reflect the user's physical location (for
|
303
|
+
# example, if the client uses VPN). For optimal results, you should include
|
304
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
305
|
+
# include this header.
|
306
|
+
# @param country_code [String] A 2-character country code of the country where
|
307
|
+
# the results come from. This API supports only the United States market. If
|
308
|
+
# you specify this query parameter, it must be set to us. If you set this
|
309
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
310
|
+
# first supported language it finds from the languages list, and combine that
|
311
|
+
# language with the country code that you specify to determine the market to
|
312
|
+
# return results for. If the languages list does not include a supported
|
313
|
+
# language, Bing finds the closest language and market that supports the
|
314
|
+
# request, or it may use an aggregated or default market for the results
|
315
|
+
# instead of a specified one. You should use this query parameter and the
|
316
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
317
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
318
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
319
|
+
# both.
|
320
|
+
# @param market [String] The market where the results come from. You are
|
321
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
322
|
+
# market helps Bing route the request and return an appropriate and optimal
|
323
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
324
|
+
# not specify both.
|
325
|
+
# @param local_categories [String] comma-delimited list of business categories
|
326
|
+
# to search for. Supported categories can be high-level such as EatDrink, Shop,
|
327
|
+
# SeeDo.
|
328
|
+
# @param local_circular_view [String] Preferred location to search around,
|
329
|
+
# expressed as Latitude, longitude and radius in meters. For example
|
330
|
+
# 47.61503,-122.1719,5000. Note that circular view should only be used to
|
331
|
+
# indicate a search around a point on the map, not as an approximation for a
|
332
|
+
# view port of a map rectangle.
|
333
|
+
# @param local_map_view [String] Preferred bounding box for results, specified
|
334
|
+
# in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. For example
|
335
|
+
# 47.64,-122.13,47.63,-122.12. These values are lat, long pairs for the
|
336
|
+
# Northwest corner and the Southeast corner of a rectangle.
|
337
|
+
# @param count [String] Preferred number of results to return. If not
|
338
|
+
# specified, then Bing returns 1-20 of the most relevant results.
|
339
|
+
# @param first [String] First result to return. zero-based. default is 0.
|
340
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
341
|
+
# response. The following are the possible case-insensitive values: JSON,
|
342
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
343
|
+
# includes JSON-LD objects that contain the search results.
|
344
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
345
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
346
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
347
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
348
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
349
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
350
|
+
# use the site: query operator, there is the chance that the response may
|
351
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
352
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
353
|
+
# scenario supports the possibility of adult content. Possible values include:
|
354
|
+
# 'Off', 'Moderate', 'Strict'
|
355
|
+
# @param set_lang [String] The language to use for user interface strings.
|
356
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
357
|
+
# the language code for English is EN. The default is EN (English). Although
|
358
|
+
# optional, you should always specify the language. Typically, you set setLang
|
359
|
+
# to the same language specified by mkt unless the user wants the user
|
360
|
+
# interface strings displayed in a different language. This parameter and the
|
361
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
362
|
+
# interface string is a string that's used as a label in a user interface.
|
363
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
364
|
+
# links to Bing.com properties in the response objects apply the specified
|
365
|
+
# language.
|
366
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
367
|
+
# will be added to the HTTP request.
|
368
|
+
#
|
369
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
370
|
+
#
|
371
|
+
def search_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', local_categories:nil, local_circular_view:nil, local_map_view:nil, count:nil, first:nil, response_format:nil, safe_search:nil, set_lang:nil, custom_headers:nil)
|
372
|
+
search_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, local_categories:local_categories, local_circular_view:local_circular_view, local_map_view:local_map_view, count:count, first:first, response_format:response_format, safe_search:safe_search, set_lang:set_lang, custom_headers:custom_headers).value!
|
373
|
+
end
|
374
|
+
|
375
|
+
#
|
376
|
+
# The Local Search API lets you send a search query to Bing and get back search
|
377
|
+
# results that include local businesses such as restaurants, hotels, retail
|
378
|
+
# stores, or other local businesses. The query can specify the name of the
|
379
|
+
# local business or it can ask for a list (for example, restaurants near me).
|
380
|
+
#
|
381
|
+
# @param query [String] The user's search term.
|
382
|
+
# @param accept_language [String] A comma-delimited list of one or more
|
383
|
+
# languages to use for user interface strings. The list is in decreasing order
|
384
|
+
# of preference. For additional information, including expected format, see
|
385
|
+
# [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
|
386
|
+
# header and the setLang query parameter are mutually exclusive; do not specify
|
387
|
+
# both. If you set this header, you must also specify the cc query parameter.
|
388
|
+
# Bing will use the first supported language it finds from the list, and
|
389
|
+
# combine that language with the cc parameter value to determine the market to
|
390
|
+
# return results for. If the list does not include a supported language, Bing
|
391
|
+
# will find the closest language and market that supports the request, and may
|
392
|
+
# use an aggregated or default market for the results instead of a specified
|
393
|
+
# one. You should use this header and the cc query parameter only if you
|
394
|
+
# specify multiple languages; otherwise, you should use the mkt and setLang
|
395
|
+
# query parameters. A user interface string is a string that's used as a label
|
396
|
+
# in a user interface. There are very few user interface strings in the JSON
|
397
|
+
# response objects. Any links in the response objects to Bing.com properties
|
398
|
+
# will apply the specified language.
|
399
|
+
# @param pragma [String] By default, Bing returns cached content, if available.
|
400
|
+
# To prevent Bing from returning cached content, set the Pragma header to
|
401
|
+
# no-cache (for example, Pragma: no-cache).
|
402
|
+
# @param user_agent [String] The user agent originating the request. Bing uses
|
403
|
+
# the user agent to provide mobile users with an optimized experience. Although
|
404
|
+
# optional, you are strongly encouraged to always specify this header. The
|
405
|
+
# user-agent should be the same string that any commonly used browser would
|
406
|
+
# send. For information about user agents, see [RFC
|
407
|
+
# 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
|
408
|
+
# @param client_id [String] Bing uses this header to provide users with
|
409
|
+
# consistent behavior across Bing API calls. Bing often flights new features
|
410
|
+
# and improvements, and it uses the client ID as a key for assigning traffic on
|
411
|
+
# different flights. If you do not use the same client ID for a user across
|
412
|
+
# multiple requests, then Bing may assign the user to multiple conflicting
|
413
|
+
# flights. Being assigned to multiple conflicting flights can lead to an
|
414
|
+
# inconsistent user experience. For example, if the second request has a
|
415
|
+
# different flight assignment than the first, the experience may be unexpected.
|
416
|
+
# Also, Bing can use the client ID to tailor web results to that client ID’s
|
417
|
+
# search history, providing a richer experience for the user. Bing also uses
|
418
|
+
# this header to help improve result rankings by analyzing the activity
|
419
|
+
# generated by a client ID. The relevance improvements help with better quality
|
420
|
+
# of results delivered by Bing APIs and in turn enables higher click-through
|
421
|
+
# rates for the API consumer. IMPORTANT: Although optional, you should consider
|
422
|
+
# this header required. Persisting the client ID across multiple requests for
|
423
|
+
# the same end user and device combination enables 1) the API consumer to
|
424
|
+
# receive a consistent user experience, and 2) higher click-through rates via
|
425
|
+
# better quality of results from the Bing APIs. Each user that uses your
|
426
|
+
# application on the device must have a unique, Bing generated client ID. If
|
427
|
+
# you do not include this header in the request, Bing generates an ID and
|
428
|
+
# returns it in the X-MSEdge-ClientID response header. The only time that you
|
429
|
+
# should NOT include this header in a request is the first time the user uses
|
430
|
+
# your app on that device. Use the client ID for each Bing API request that
|
431
|
+
# your app makes for this user on the device. Persist the client ID. To persist
|
432
|
+
# the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
|
433
|
+
# used across all sessions. Do not use a session cookie. For other apps such as
|
434
|
+
# mobile apps, use the device's persistent storage to persist the ID. The next
|
435
|
+
# time the user uses your app on that device, get the client ID that you
|
436
|
+
# persisted. Bing responses may or may not include this header. If the response
|
437
|
+
# includes this header, capture the client ID and use it for all subsequent
|
438
|
+
# Bing requests for the user on that device. If you include the
|
439
|
+
# X-MSEdge-ClientID, you must not include cookies in the request.
|
440
|
+
# @param client_ip [String] The IPv4 or IPv6 address of the client device. The
|
441
|
+
# IP address is used to discover the user's location. Bing uses the location
|
442
|
+
# information to determine safe search behavior. Although optional, you are
|
443
|
+
# encouraged to always specify this header and the X-Search-Location header. Do
|
444
|
+
# not obfuscate the address (for example, by changing the last octet to 0).
|
445
|
+
# Obfuscating the address results in the location not being anywhere near the
|
446
|
+
# device's actual location, which may result in Bing serving erroneous results.
|
447
|
+
# @param location [String] A semicolon-delimited list of key/value pairs that
|
448
|
+
# describe the client's geographical location. Bing uses the location
|
449
|
+
# information to determine safe search behavior and to return relevant local
|
450
|
+
# content. Specify the key/value pair as <key>:<value>. The following are the
|
451
|
+
# keys that you use to specify the user's location. lat (required): The
|
452
|
+
# latitude of the client's location, in degrees. The latitude must be greater
|
453
|
+
# than or equal to -90.0 and less than or equal to +90.0. Negative values
|
454
|
+
# indicate southern latitudes and positive values indicate northern latitudes.
|
455
|
+
# long (required): The longitude of the client's location, in degrees. The
|
456
|
+
# longitude must be greater than or equal to -180.0 and less than or equal to
|
457
|
+
# +180.0. Negative values indicate western longitudes and positive values
|
458
|
+
# indicate eastern longitudes. re (required): The radius, in meters, which
|
459
|
+
# specifies the horizontal accuracy of the coordinates. Pass the value returned
|
460
|
+
# by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
|
461
|
+
# 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
|
462
|
+
# (optional): The UTC UNIX timestamp of when the client was at the location.
|
463
|
+
# (The UNIX timestamp is the number of seconds since January 1, 1970.) head
|
464
|
+
# (optional): The client's relative heading or direction of travel. Specify the
|
465
|
+
# direction of travel as degrees from 0 through 360, counting clockwise
|
466
|
+
# relative to true north. Specify this key only if the sp key is nonzero. sp
|
467
|
+
# (optional): The horizontal velocity (speed), in meters per second, that the
|
468
|
+
# client device is traveling. alt (optional): The altitude of the client
|
469
|
+
# device, in meters. are (optional): The radius, in meters, that specifies the
|
470
|
+
# vertical accuracy of the coordinates. Specify this key only if you specify
|
471
|
+
# the alt key. Although many of the keys are optional, the more information
|
472
|
+
# that you provide, the more accurate the location results are. Although
|
473
|
+
# optional, you are encouraged to always specify the user's geographical
|
474
|
+
# location. Providing the location is especially important if the client's IP
|
475
|
+
# address does not accurately reflect the user's physical location (for
|
476
|
+
# example, if the client uses VPN). For optimal results, you should include
|
477
|
+
# this header and the X-MSEdge-ClientIP header, but at a minimum, you should
|
478
|
+
# include this header.
|
479
|
+
# @param country_code [String] A 2-character country code of the country where
|
480
|
+
# the results come from. This API supports only the United States market. If
|
481
|
+
# you specify this query parameter, it must be set to us. If you set this
|
482
|
+
# parameter, you must also specify the Accept-Language header. Bing uses the
|
483
|
+
# first supported language it finds from the languages list, and combine that
|
484
|
+
# language with the country code that you specify to determine the market to
|
485
|
+
# return results for. If the languages list does not include a supported
|
486
|
+
# language, Bing finds the closest language and market that supports the
|
487
|
+
# request, or it may use an aggregated or default market for the results
|
488
|
+
# instead of a specified one. You should use this query parameter and the
|
489
|
+
# Accept-Language query parameter only if you specify multiple languages;
|
490
|
+
# otherwise, you should use the mkt and setLang query parameters. This
|
491
|
+
# parameter and the mkt query parameter are mutually exclusive—do not specify
|
492
|
+
# both.
|
493
|
+
# @param market [String] The market where the results come from. You are
|
494
|
+
# strongly encouraged to always specify the market, if known. Specifying the
|
495
|
+
# market helps Bing route the request and return an appropriate and optimal
|
496
|
+
# response. This parameter and the cc query parameter are mutually exclusive—do
|
497
|
+
# not specify both.
|
498
|
+
# @param local_categories [String] comma-delimited list of business categories
|
499
|
+
# to search for. Supported categories can be high-level such as EatDrink, Shop,
|
500
|
+
# SeeDo.
|
501
|
+
# @param local_circular_view [String] Preferred location to search around,
|
502
|
+
# expressed as Latitude, longitude and radius in meters. For example
|
503
|
+
# 47.61503,-122.1719,5000. Note that circular view should only be used to
|
504
|
+
# indicate a search around a point on the map, not as an approximation for a
|
505
|
+
# view port of a map rectangle.
|
506
|
+
# @param local_map_view [String] Preferred bounding box for results, specified
|
507
|
+
# in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. For example
|
508
|
+
# 47.64,-122.13,47.63,-122.12. These values are lat, long pairs for the
|
509
|
+
# Northwest corner and the Southeast corner of a rectangle.
|
510
|
+
# @param count [String] Preferred number of results to return. If not
|
511
|
+
# specified, then Bing returns 1-20 of the most relevant results.
|
512
|
+
# @param first [String] First result to return. zero-based. default is 0.
|
513
|
+
# @param response_format [Array<ResponseFormat>] The media type to use for the
|
514
|
+
# response. The following are the possible case-insensitive values: JSON,
|
515
|
+
# JSONLD. The default is JSON. If you specify JSONLD, the response body
|
516
|
+
# includes JSON-LD objects that contain the search results.
|
517
|
+
# @param safe_search [SafeSearch] A filter used to filter adult content. Off:
|
518
|
+
# Return webpages with adult text, images, or videos. Moderate: Return webpages
|
519
|
+
# with adult text, but not adult images or videos. Strict: Do not return
|
520
|
+
# webpages with adult text, images, or videos. The default is Moderate. If the
|
521
|
+
# request comes from a market that Bing's adult policy requires that safeSearch
|
522
|
+
# is set to Strict, Bing ignores the safeSearch value and uses Strict. If you
|
523
|
+
# use the site: query operator, there is the chance that the response may
|
524
|
+
# contain adult content regardless of what the safeSearch query parameter is
|
525
|
+
# set to. Use site: only if you are aware of the content on the site and your
|
526
|
+
# scenario supports the possibility of adult content. Possible values include:
|
527
|
+
# 'Off', 'Moderate', 'Strict'
|
528
|
+
# @param set_lang [String] The language to use for user interface strings.
|
529
|
+
# Specify the language using the ISO 639-1 2-letter language code. For example,
|
530
|
+
# the language code for English is EN. The default is EN (English). Although
|
531
|
+
# optional, you should always specify the language. Typically, you set setLang
|
532
|
+
# to the same language specified by mkt unless the user wants the user
|
533
|
+
# interface strings displayed in a different language. This parameter and the
|
534
|
+
# Accept-Language header are mutually exclusive; do not specify both. A user
|
535
|
+
# interface string is a string that's used as a label in a user interface.
|
536
|
+
# There are few user interface strings in the JSON response objects. Also, any
|
537
|
+
# links to Bing.com properties in the response objects apply the specified
|
538
|
+
# language.
|
539
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
540
|
+
# to the HTTP request.
|
541
|
+
#
|
542
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
543
|
+
#
|
544
|
+
def search_async(query, accept_language:nil, pragma:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, market:'en-us', local_categories:nil, local_circular_view:nil, local_map_view:nil, count:nil, first:nil, response_format:nil, safe_search:nil, set_lang:nil, custom_headers:nil)
|
545
|
+
x_bing_apis_sdk = 'true'
|
546
|
+
fail ArgumentError, 'query is nil' if query.nil?
|
547
|
+
|
548
|
+
|
549
|
+
request_headers = {}
|
550
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
551
|
+
|
552
|
+
# Set Headers
|
553
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
554
|
+
request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
|
555
|
+
request_headers['Accept-Language'] = accept_language unless accept_language.nil?
|
556
|
+
request_headers['Pragma'] = pragma unless pragma.nil?
|
557
|
+
request_headers['User-Agent'] = user_agent unless user_agent.nil?
|
558
|
+
request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
|
559
|
+
request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
|
560
|
+
request_headers['X-Search-Location'] = location unless location.nil?
|
561
|
+
path_template = 'localbusinesses/v7.0/search'
|
562
|
+
|
563
|
+
request_url = @base_url || @client.base_url
|
564
|
+
|
565
|
+
options = {
|
566
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
567
|
+
query_params: {'cc' => country_code,'mkt' => market,'q' => query,'localcategories' => local_categories,'localcircularview' => local_circular_view,'localmapview' => local_map_view,'count' => count,'first' => first,'ResponseFormat' => response_format.nil? ? nil : response_format.join(','),'SafeSearch' => safe_search,'SetLang' => set_lang},
|
568
|
+
headers: request_headers.merge(custom_headers || {}),
|
569
|
+
base_url: request_url
|
570
|
+
}
|
571
|
+
promise = @client.make_request_async(:get, path_template, options)
|
572
|
+
|
573
|
+
promise = promise.then do |result|
|
574
|
+
http_response = result.response
|
575
|
+
status_code = http_response.status
|
576
|
+
response_content = http_response.body
|
577
|
+
unless status_code == 200
|
578
|
+
error_model = JSON.load(response_content)
|
579
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
580
|
+
end
|
581
|
+
|
582
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
583
|
+
# Deserialize Response
|
584
|
+
if status_code == 200
|
585
|
+
begin
|
586
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
587
|
+
result_mapper = Azure::CognitiveServices::LocalSearch::V1_0::Models::SearchResponse.mapper()
|
588
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
589
|
+
rescue Exception => e
|
590
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
result
|
595
|
+
end
|
596
|
+
|
597
|
+
promise.execute
|
598
|
+
end
|
599
|
+
|
600
|
+
end
|
601
|
+
end
|