azure_cognitiveservices_newssearch 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/1.0/generated/azure_cognitiveservices_newssearch.rb +52 -0
  4. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/answer.rb +89 -0
  5. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/article.rb +182 -0
  6. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/creative_work.rb +182 -0
  7. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/error.rb +116 -0
  8. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/error_code.rb +20 -0
  9. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/error_response.rb +89 -0
  10. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/error_sub_code.rb +25 -0
  11. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/freshness.rb +17 -0
  12. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/identifiable.rb +62 -0
  13. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/image_object.rb +209 -0
  14. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/media_object.rb +206 -0
  15. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/news.rb +129 -0
  16. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/news_article.rb +228 -0
  17. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/news_topic.rb +164 -0
  18. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/organization.rb +123 -0
  19. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/query.rb +104 -0
  20. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/response.rb +72 -0
  21. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/response_base.rb +61 -0
  22. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/safe_search.rb +17 -0
  23. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/search_results_answer.rb +100 -0
  24. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/text_format.rb +16 -0
  25. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/thing.rb +142 -0
  26. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/trending_topics.rb +107 -0
  27. data/lib/1.0/generated/azure_cognitiveservices_newssearch/models/video_object.rb +305 -0
  28. data/lib/1.0/generated/azure_cognitiveservices_newssearch/module_definition.rb +9 -0
  29. data/lib/1.0/generated/azure_cognitiveservices_newssearch/news_operations.rb +2326 -0
  30. data/lib/1.0/generated/azure_cognitiveservices_newssearch/news_search_client.rb +127 -0
  31. data/lib/azure_cognitiveservices_newssearch.rb +6 -0
  32. data/lib/module_definition.rb +7 -0
  33. data/lib/profiles/latest/modules/newssearch_profile_module.rb +155 -0
  34. data/lib/profiles/latest/newssearch_latest_profile_client.rb +38 -0
  35. data/lib/profiles/latest/newssearch_module_definition.rb +8 -0
  36. data/lib/version.rb +7 -0
  37. metadata +154 -0
@@ -0,0 +1,305 @@
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::NewsSearch::V1_0
7
+ module Models
8
+ #
9
+ # Defines a video object that is relevant to the query.
10
+ #
11
+ class VideoObject < MediaObject
12
+
13
+ include MsRestAzure
14
+
15
+
16
+ def initialize
17
+ @_type = "VideoObject"
18
+ end
19
+
20
+ attr_accessor :_type
21
+
22
+ # @return [String]
23
+ attr_accessor :motion_thumbnail_url
24
+
25
+ # @return [String]
26
+ attr_accessor :motion_thumbnail_id
27
+
28
+ # @return [String]
29
+ attr_accessor :embed_html
30
+
31
+ # @return [Boolean]
32
+ attr_accessor :allow_https_embed
33
+
34
+ # @return [Integer]
35
+ attr_accessor :view_count
36
+
37
+ # @return [ImageObject]
38
+ attr_accessor :thumbnail
39
+
40
+ # @return [String]
41
+ attr_accessor :video_id
42
+
43
+ # @return [Boolean]
44
+ attr_accessor :allow_mobile_embed
45
+
46
+ # @return [Boolean]
47
+ attr_accessor :is_superfresh
48
+
49
+
50
+ #
51
+ # Mapper for VideoObject class as Ruby Hash.
52
+ # This will be used for serialization/deserialization.
53
+ #
54
+ def self.mapper()
55
+ {
56
+ client_side_validation: true,
57
+ required: false,
58
+ serialized_name: 'VideoObject',
59
+ type: {
60
+ name: 'Composite',
61
+ class_name: 'VideoObject',
62
+ model_properties: {
63
+ _type: {
64
+ client_side_validation: true,
65
+ required: true,
66
+ serialized_name: '_type',
67
+ type: {
68
+ name: 'String'
69
+ }
70
+ },
71
+ id: {
72
+ client_side_validation: true,
73
+ required: false,
74
+ read_only: true,
75
+ serialized_name: 'id',
76
+ type: {
77
+ name: 'String'
78
+ }
79
+ },
80
+ web_search_url: {
81
+ client_side_validation: true,
82
+ required: false,
83
+ read_only: true,
84
+ serialized_name: 'webSearchUrl',
85
+ type: {
86
+ name: 'String'
87
+ }
88
+ },
89
+ name: {
90
+ client_side_validation: true,
91
+ required: false,
92
+ read_only: true,
93
+ serialized_name: 'name',
94
+ type: {
95
+ name: 'String'
96
+ }
97
+ },
98
+ url: {
99
+ client_side_validation: true,
100
+ required: false,
101
+ read_only: true,
102
+ serialized_name: 'url',
103
+ type: {
104
+ name: 'String'
105
+ }
106
+ },
107
+ image: {
108
+ client_side_validation: true,
109
+ required: false,
110
+ read_only: true,
111
+ serialized_name: 'image',
112
+ type: {
113
+ name: 'Composite',
114
+ class_name: 'ImageObject'
115
+ }
116
+ },
117
+ description: {
118
+ client_side_validation: true,
119
+ required: false,
120
+ read_only: true,
121
+ serialized_name: 'description',
122
+ type: {
123
+ name: 'String'
124
+ }
125
+ },
126
+ alternate_name: {
127
+ client_side_validation: true,
128
+ required: false,
129
+ read_only: true,
130
+ serialized_name: 'alternateName',
131
+ type: {
132
+ name: 'String'
133
+ }
134
+ },
135
+ bing_id: {
136
+ client_side_validation: true,
137
+ required: false,
138
+ read_only: true,
139
+ serialized_name: 'bingId',
140
+ type: {
141
+ name: 'String'
142
+ }
143
+ },
144
+ thumbnail_url: {
145
+ client_side_validation: true,
146
+ required: false,
147
+ read_only: true,
148
+ serialized_name: 'thumbnailUrl',
149
+ type: {
150
+ name: 'String'
151
+ }
152
+ },
153
+ provider: {
154
+ client_side_validation: true,
155
+ required: false,
156
+ read_only: true,
157
+ serialized_name: 'provider',
158
+ type: {
159
+ name: 'Sequence',
160
+ element: {
161
+ client_side_validation: true,
162
+ required: false,
163
+ serialized_name: 'ThingElementType',
164
+ type: {
165
+ name: 'Composite',
166
+ class_name: 'Thing'
167
+ }
168
+ }
169
+ }
170
+ },
171
+ date_published: {
172
+ client_side_validation: true,
173
+ required: false,
174
+ read_only: true,
175
+ serialized_name: 'datePublished',
176
+ type: {
177
+ name: 'String'
178
+ }
179
+ },
180
+ video: {
181
+ client_side_validation: true,
182
+ required: false,
183
+ read_only: true,
184
+ serialized_name: 'video',
185
+ type: {
186
+ name: 'Composite',
187
+ class_name: 'VideoObject'
188
+ }
189
+ },
190
+ content_url: {
191
+ client_side_validation: true,
192
+ required: false,
193
+ read_only: true,
194
+ serialized_name: 'contentUrl',
195
+ type: {
196
+ name: 'String'
197
+ }
198
+ },
199
+ width: {
200
+ client_side_validation: true,
201
+ required: false,
202
+ read_only: true,
203
+ serialized_name: 'width',
204
+ type: {
205
+ name: 'Number'
206
+ }
207
+ },
208
+ height: {
209
+ client_side_validation: true,
210
+ required: false,
211
+ read_only: true,
212
+ serialized_name: 'height',
213
+ type: {
214
+ name: 'Number'
215
+ }
216
+ },
217
+ motion_thumbnail_url: {
218
+ client_side_validation: true,
219
+ required: false,
220
+ read_only: true,
221
+ serialized_name: 'motionThumbnailUrl',
222
+ type: {
223
+ name: 'String'
224
+ }
225
+ },
226
+ motion_thumbnail_id: {
227
+ client_side_validation: true,
228
+ required: false,
229
+ read_only: true,
230
+ serialized_name: 'motionThumbnailId',
231
+ type: {
232
+ name: 'String'
233
+ }
234
+ },
235
+ embed_html: {
236
+ client_side_validation: true,
237
+ required: false,
238
+ read_only: true,
239
+ serialized_name: 'embedHtml',
240
+ type: {
241
+ name: 'String'
242
+ }
243
+ },
244
+ allow_https_embed: {
245
+ client_side_validation: true,
246
+ required: false,
247
+ read_only: true,
248
+ serialized_name: 'allowHttpsEmbed',
249
+ type: {
250
+ name: 'Boolean'
251
+ }
252
+ },
253
+ view_count: {
254
+ client_side_validation: true,
255
+ required: false,
256
+ read_only: true,
257
+ serialized_name: 'viewCount',
258
+ type: {
259
+ name: 'Number'
260
+ }
261
+ },
262
+ thumbnail: {
263
+ client_side_validation: true,
264
+ required: false,
265
+ read_only: true,
266
+ serialized_name: 'thumbnail',
267
+ type: {
268
+ name: 'Composite',
269
+ class_name: 'ImageObject'
270
+ }
271
+ },
272
+ video_id: {
273
+ client_side_validation: true,
274
+ required: false,
275
+ read_only: true,
276
+ serialized_name: 'videoId',
277
+ type: {
278
+ name: 'String'
279
+ }
280
+ },
281
+ allow_mobile_embed: {
282
+ client_side_validation: true,
283
+ required: false,
284
+ read_only: true,
285
+ serialized_name: 'allowMobileEmbed',
286
+ type: {
287
+ name: 'Boolean'
288
+ }
289
+ },
290
+ is_superfresh: {
291
+ client_side_validation: true,
292
+ required: false,
293
+ read_only: true,
294
+ serialized_name: 'isSuperfresh',
295
+ type: {
296
+ name: 'Boolean'
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ end
303
+ end
304
+ end
305
+ end
@@ -0,0 +1,9 @@
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 end
7
+ module Azure::CognitiveServices end
8
+ module Azure::CognitiveServices::NewsSearch end
9
+ module Azure::CognitiveServices::NewsSearch::V1_0 end
@@ -0,0 +1,2326 @@
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::NewsSearch::V1_0
7
+ #
8
+ # The News Search API lets you send a search query to Bing and get back a
9
+ # list of news that are relevant to the search query. This section provides
10
+ # technical details about the query parameters and headers that you use to
11
+ # request news and the JSON response objects that contain them. For examples
12
+ # that show how to make requests, see [Searching the web for
13
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
14
+ #
15
+ class NewsOperations
16
+ include MsRestAzure
17
+
18
+ #
19
+ # Creates and initializes a new instance of the NewsOperations class.
20
+ # @param client service class for accessing basic functionality.
21
+ #
22
+ def initialize(client)
23
+ @client = client
24
+ end
25
+
26
+ # @return [NewsSearchClient] reference to the NewsSearchClient
27
+ attr_reader :client
28
+
29
+ #
30
+ # The News Search API lets you send a search query to Bing and get back a list
31
+ # of news that are relevant to the search query. This section provides
32
+ # technical details about the query parameters and headers that you use to
33
+ # request news and the JSON response objects that contain them. For examples
34
+ # that show how to make requests, see [Searching the web for
35
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
36
+ #
37
+ # @param query [String] The user's search query string. The query string cannot
38
+ # be empty. The query string may contain [Bing Advanced
39
+ # Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to
40
+ # limit news to a specific domain, use the
41
+ # [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. Use this
42
+ # parameter only with the News Search API. Do not specify this parameter when
43
+ # calling the Trending Topics API or News Category API.
44
+ # @param accept_language [String] A comma-delimited list of one or more
45
+ # languages to use for user interface strings. The list is in decreasing order
46
+ # of preference. For additional information, including expected format, see
47
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
48
+ # header and the
49
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
50
+ # query parameter are mutually exclusive; do not specify both. If you set this
51
+ # header, you must also specify the
52
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
53
+ # query parameter. To determine the market to return results for, Bing uses the
54
+ # first supported language it finds from the list and combines it with the cc
55
+ # parameter value. If the list does not include a supported language, Bing
56
+ # finds the closest language and market that supports the request or it uses an
57
+ # aggregated or default market for the results. To determine the market that
58
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
59
+ # parameter only if you specify multiple languages. Otherwise, use the
60
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
61
+ # and
62
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
63
+ # query parameters. A user interface string is a string that's used as a label
64
+ # in a user interface. There are few user interface strings in the JSON
65
+ # response objects. Any links to Bing.com properties in the response objects
66
+ # apply the specified language.
67
+ # @param user_agent [String] The user agent originating the request. Bing uses
68
+ # the user agent to provide mobile users with an optimized experience. Although
69
+ # optional, you are encouraged to always specify this header. The user-agent
70
+ # should be the same string that any commonly used browser sends. For
71
+ # information about user agents, see [RFC
72
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
73
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
74
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
75
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
76
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
77
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
78
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
79
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
80
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
81
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
82
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
83
+ # @param client_id [String] Bing uses this header to provide users with
84
+ # consistent behavior across Bing API calls. Bing often flights new features
85
+ # and improvements, and it uses the client ID as a key for assigning traffic on
86
+ # different flights. If you do not use the same client ID for a user across
87
+ # multiple requests, then Bing may assign the user to multiple conflicting
88
+ # flights. Being assigned to multiple conflicting flights can lead to an
89
+ # inconsistent user experience. For example, if the second request has a
90
+ # different flight assignment than the first, the experience may be unexpected.
91
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
92
+ # search history, providing a richer experience for the user. Bing also uses
93
+ # this header to help improve result rankings by analyzing the activity
94
+ # generated by a client ID. The relevance improvements help with better quality
95
+ # of results delivered by Bing APIs and in turn enables higher click-through
96
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
97
+ # this header required. Persisting the client ID across multiple requests for
98
+ # the same end user and device combination enables 1) the API consumer to
99
+ # receive a consistent user experience, and 2) higher click-through rates via
100
+ # better quality of results from the Bing APIs. Each user that uses your
101
+ # application on the device must have a unique, Bing generated client ID. If
102
+ # you do not include this header in the request, Bing generates an ID and
103
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
104
+ # should NOT include this header in a request is the first time the user uses
105
+ # your app on that device. Use the client ID for each Bing API request that
106
+ # your app makes for this user on the device. Persist the client ID. To persist
107
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
108
+ # used across all sessions. Do not use a session cookie. For other apps such as
109
+ # mobile apps, use the device's persistent storage to persist the ID. The next
110
+ # time the user uses your app on that device, get the client ID that you
111
+ # persisted. Bing responses may or may not include this header. If the response
112
+ # includes this header, capture the client ID and use it for all subsequent
113
+ # Bing requests for the user on that device. If you include the
114
+ # X-MSEdge-ClientID, you must not include cookies in the request.
115
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
116
+ # IP address is used to discover the user's location. Bing uses the location
117
+ # information to determine safe search behavior. Although optional, you are
118
+ # encouraged to always specify this header and the X-Search-Location header. Do
119
+ # not obfuscate the address (for example, by changing the last octet to 0).
120
+ # Obfuscating the address results in the location not being anywhere near the
121
+ # device's actual location, which may result in Bing serving erroneous results.
122
+ # @param location [String] A semicolon-delimited list of key/value pairs that
123
+ # describe the client's geographical location. Bing uses the location
124
+ # information to determine safe search behavior and to return relevant local
125
+ # content. Specify the key/value pair as <key>:<value>. The following are the
126
+ # keys that you use to specify the user's location. lat (required): The
127
+ # latitude of the client's location, in degrees. The latitude must be greater
128
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
129
+ # indicate southern latitudes and positive values indicate northern latitudes.
130
+ # long (required): The longitude of the client's location, in degrees. The
131
+ # longitude must be greater than or equal to -180.0 and less than or equal to
132
+ # +180.0. Negative values indicate western longitudes and positive values
133
+ # indicate eastern longitudes. re (required): The radius, in meters, which
134
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
135
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
136
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
137
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
138
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
139
+ # (optional): The client's relative heading or direction of travel. Specify the
140
+ # direction of travel as degrees from 0 through 360, counting clockwise
141
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
142
+ # (optional): The horizontal velocity (speed), in meters per second, that the
143
+ # client device is traveling. alt (optional): The altitude of the client
144
+ # device, in meters. are (optional): The radius, in meters, that specifies the
145
+ # vertical accuracy of the coordinates. Specify this key only if you specify
146
+ # the alt key. Although many of the keys are optional, the more information
147
+ # that you provide, the more accurate the location results are. Although
148
+ # optional, you are encouraged to always specify the user's geographical
149
+ # location. Providing the location is especially important if the client's IP
150
+ # address does not accurately reflect the user's physical location (for
151
+ # example, if the client uses VPN). For optimal results, you should include
152
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
153
+ # include this header.
154
+ # @param country_code [String] A 2-character country code of the country where
155
+ # the results come from. This API supports only the United States market. If
156
+ # you specify this query parameter, it must be set to us. If you set this
157
+ # parameter, you must also specify the Accept-Language header. Bing uses the
158
+ # first supported language it finds from the languages list, and combine that
159
+ # language with the country code that you specify to determine the market to
160
+ # return results for. If the languages list does not include a supported
161
+ # language, Bing finds the closest language and market that supports the
162
+ # request, or it may use an aggregated or default market for the results
163
+ # instead of a specified one. You should use this query parameter and the
164
+ # Accept-Language query parameter only if you specify multiple languages;
165
+ # otherwise, you should use the mkt and setLang query parameters. This
166
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
167
+ # both.
168
+ # @param count [Integer] The number of news articles to return in the response.
169
+ # The actual number delivered may be less than requested. The default is 10 and
170
+ # the maximum value is 100. The actual number delivered may be less than
171
+ # requested.You may use this parameter along with the offset parameter to page
172
+ # results. For example, if your user interface displays 20 articles per page,
173
+ # set count to 20 and offset to 0 to get the first page of results. For each
174
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
175
+ # possible for multiple pages to include some overlap in results.
176
+ # @param freshness [Freshness] Filter news by the date and time that Bing
177
+ # discovered the news. The following are the possible filter values. Day:
178
+ # Return news discovered within the last 24 hours. Week: Return news discovered
179
+ # within the last 7 days. Month: Return news discovered within the last 30
180
+ # days. Use this parameter only with the News Search API. Do not specify this
181
+ # parameter when calling the News Category API or the Trending Topics API.
182
+ # Possible values include: 'Day', 'Week', 'Month'
183
+ # @param market [String] The market where the results come from. Typically, mkt
184
+ # is the country where the user is making the request from. However, it could
185
+ # be a different country if the user is not located in a country where Bing
186
+ # delivers results. The market must be in the form <language code>-<country
187
+ # code>. For example, en-US. The string is case insensitive. For a list of
188
+ # possible market values, see [Market
189
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
190
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
191
+ # the market helps Bing route the request and return an appropriate and optimal
192
+ # response. If you specify a market that is not listed in [Market
193
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
194
+ # Bing uses a best fit market code based on an internal mapping that is subject
195
+ # to change. This parameter and the
196
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
197
+ # query parameter are mutually exclusive—do not specify both.
198
+ # @param offset [Integer] The zero-based offset that indicates the number of
199
+ # news to skip before returning news. The default is 0. The offset should be
200
+ # less than
201
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
202
+ # - count). Use this parameter along with the count parameter to page results.
203
+ # For example, if your user interface displays 20 news per page, set count to
204
+ # 20 and offset to 0 to get the first page of results. For each subsequent
205
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
206
+ # multiple pages to include some overlap in results.
207
+ # @param original_image [Boolean] A Boolean value that determines whether the
208
+ # image's contentUrl contains a URL that points to a thumbnail of the original
209
+ # article's image or the image itself. If the article includes an image, and
210
+ # this parameter is set to true, the image's contentUrl property contains a URL
211
+ # that you may use to download the original image from the publisher's website.
212
+ # Otherwise, if this parameter is false, the image's contentUrl and
213
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
214
+ # only with the News Search API. Do not specify this parameter when calling the
215
+ # Trending Topics API or News Category API.
216
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
217
+ # are the possible filter values. Off: Return news articles with adult text,
218
+ # images, or videos. Moderate: Return news articles with adult text but not
219
+ # adult images or videos. Strict: Do not return news articles with adult text,
220
+ # images, or videos. If the request comes from a market that Bing's adult
221
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
222
+ # value and uses Strict. If you use the site: query operator, there is the
223
+ # chance that the response may contain adult content regardless of what the
224
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
225
+ # content on the site and your scenario supports the possibility of adult
226
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
227
+ # @param set_lang [String] The language to use for user interface strings.
228
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
229
+ # the language code for English is EN. The default is EN (English). Although
230
+ # optional, you should always specify the language. Typically, you set setLang
231
+ # to the same language specified by mkt unless the user wants the user
232
+ # interface strings displayed in a different language. This parameter and the
233
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
234
+ # header are mutually exclusive; do not specify both. A user interface string
235
+ # is a string that's used as a label in a user interface. There are few user
236
+ # interface strings in the JSON response objects. Also, any links to Bing.com
237
+ # properties in the response objects apply the specified language.
238
+ # @param sort_by [String] The order to return the news in. The following are
239
+ # the possible case-insensitive values. Date: If the request is through the
240
+ # News Search API, the response returns news articles sorted by date from the
241
+ # most recent to the oldest. If the request is through the News Trending Topics
242
+ # API, the response returns trending topics sorted by date from the most recent
243
+ # to the oldest.
244
+ # @param text_decorations [Boolean] A Boolean value that determines whether
245
+ # display strings contain decoration markers such as hit highlighting
246
+ # characters. If true, the strings may include markers. The default is false.
247
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
248
+ # the
249
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
250
+ # query parameter. For information about hit highlighting, see [Hit
251
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
252
+ # @param text_format [TextFormat] The type of markers to use for text
253
+ # decorations (see the textDecorations query parameter). Possible values are
254
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
255
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
256
+ # E000 and E001 to mark the beginning and end of query terms for hit
257
+ # highlighting. HTML—Use HTML tags to mark content that needs special
258
+ # formatting. For example, use <b> tags to highlight query terms in display
259
+ # strings. The default is Raw. For display strings that contain escapable HTML
260
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
261
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
262
+ # values include: 'Raw', 'Html'
263
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
264
+ # will be added to the HTTP request.
265
+ #
266
+ # @return [News] operation results.
267
+ #
268
+ def search(query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, freshness:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
269
+ response = search_async(query, accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, freshness:freshness, market:market, offset:offset, original_image:original_image, safe_search:safe_search, set_lang:set_lang, sort_by:sort_by, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
270
+ response.body unless response.nil?
271
+ end
272
+
273
+ #
274
+ # The News Search API lets you send a search query to Bing and get back a list
275
+ # of news that are relevant to the search query. This section provides
276
+ # technical details about the query parameters and headers that you use to
277
+ # request news and the JSON response objects that contain them. For examples
278
+ # that show how to make requests, see [Searching the web for
279
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
280
+ #
281
+ # @param query [String] The user's search query string. The query string cannot
282
+ # be empty. The query string may contain [Bing Advanced
283
+ # Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to
284
+ # limit news to a specific domain, use the
285
+ # [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. Use this
286
+ # parameter only with the News Search API. Do not specify this parameter when
287
+ # calling the Trending Topics API or News Category API.
288
+ # @param accept_language [String] A comma-delimited list of one or more
289
+ # languages to use for user interface strings. The list is in decreasing order
290
+ # of preference. For additional information, including expected format, see
291
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
292
+ # header and the
293
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
294
+ # query parameter are mutually exclusive; do not specify both. If you set this
295
+ # header, you must also specify the
296
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
297
+ # query parameter. To determine the market to return results for, Bing uses the
298
+ # first supported language it finds from the list and combines it with the cc
299
+ # parameter value. If the list does not include a supported language, Bing
300
+ # finds the closest language and market that supports the request or it uses an
301
+ # aggregated or default market for the results. To determine the market that
302
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
303
+ # parameter only if you specify multiple languages. Otherwise, use the
304
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
305
+ # and
306
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
307
+ # query parameters. A user interface string is a string that's used as a label
308
+ # in a user interface. There are few user interface strings in the JSON
309
+ # response objects. Any links to Bing.com properties in the response objects
310
+ # apply the specified language.
311
+ # @param user_agent [String] The user agent originating the request. Bing uses
312
+ # the user agent to provide mobile users with an optimized experience. Although
313
+ # optional, you are encouraged to always specify this header. The user-agent
314
+ # should be the same string that any commonly used browser sends. For
315
+ # information about user agents, see [RFC
316
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
317
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
318
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
319
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
320
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
321
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
322
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
323
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
324
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
325
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
326
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
327
+ # @param client_id [String] Bing uses this header to provide users with
328
+ # consistent behavior across Bing API calls. Bing often flights new features
329
+ # and improvements, and it uses the client ID as a key for assigning traffic on
330
+ # different flights. If you do not use the same client ID for a user across
331
+ # multiple requests, then Bing may assign the user to multiple conflicting
332
+ # flights. Being assigned to multiple conflicting flights can lead to an
333
+ # inconsistent user experience. For example, if the second request has a
334
+ # different flight assignment than the first, the experience may be unexpected.
335
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
336
+ # search history, providing a richer experience for the user. Bing also uses
337
+ # this header to help improve result rankings by analyzing the activity
338
+ # generated by a client ID. The relevance improvements help with better quality
339
+ # of results delivered by Bing APIs and in turn enables higher click-through
340
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
341
+ # this header required. Persisting the client ID across multiple requests for
342
+ # the same end user and device combination enables 1) the API consumer to
343
+ # receive a consistent user experience, and 2) higher click-through rates via
344
+ # better quality of results from the Bing APIs. Each user that uses your
345
+ # application on the device must have a unique, Bing generated client ID. If
346
+ # you do not include this header in the request, Bing generates an ID and
347
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
348
+ # should NOT include this header in a request is the first time the user uses
349
+ # your app on that device. Use the client ID for each Bing API request that
350
+ # your app makes for this user on the device. Persist the client ID. To persist
351
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
352
+ # used across all sessions. Do not use a session cookie. For other apps such as
353
+ # mobile apps, use the device's persistent storage to persist the ID. The next
354
+ # time the user uses your app on that device, get the client ID that you
355
+ # persisted. Bing responses may or may not include this header. If the response
356
+ # includes this header, capture the client ID and use it for all subsequent
357
+ # Bing requests for the user on that device. If you include the
358
+ # X-MSEdge-ClientID, you must not include cookies in the request.
359
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
360
+ # IP address is used to discover the user's location. Bing uses the location
361
+ # information to determine safe search behavior. Although optional, you are
362
+ # encouraged to always specify this header and the X-Search-Location header. Do
363
+ # not obfuscate the address (for example, by changing the last octet to 0).
364
+ # Obfuscating the address results in the location not being anywhere near the
365
+ # device's actual location, which may result in Bing serving erroneous results.
366
+ # @param location [String] A semicolon-delimited list of key/value pairs that
367
+ # describe the client's geographical location. Bing uses the location
368
+ # information to determine safe search behavior and to return relevant local
369
+ # content. Specify the key/value pair as <key>:<value>. The following are the
370
+ # keys that you use to specify the user's location. lat (required): The
371
+ # latitude of the client's location, in degrees. The latitude must be greater
372
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
373
+ # indicate southern latitudes and positive values indicate northern latitudes.
374
+ # long (required): The longitude of the client's location, in degrees. The
375
+ # longitude must be greater than or equal to -180.0 and less than or equal to
376
+ # +180.0. Negative values indicate western longitudes and positive values
377
+ # indicate eastern longitudes. re (required): The radius, in meters, which
378
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
379
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
380
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
381
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
382
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
383
+ # (optional): The client's relative heading or direction of travel. Specify the
384
+ # direction of travel as degrees from 0 through 360, counting clockwise
385
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
386
+ # (optional): The horizontal velocity (speed), in meters per second, that the
387
+ # client device is traveling. alt (optional): The altitude of the client
388
+ # device, in meters. are (optional): The radius, in meters, that specifies the
389
+ # vertical accuracy of the coordinates. Specify this key only if you specify
390
+ # the alt key. Although many of the keys are optional, the more information
391
+ # that you provide, the more accurate the location results are. Although
392
+ # optional, you are encouraged to always specify the user's geographical
393
+ # location. Providing the location is especially important if the client's IP
394
+ # address does not accurately reflect the user's physical location (for
395
+ # example, if the client uses VPN). For optimal results, you should include
396
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
397
+ # include this header.
398
+ # @param country_code [String] A 2-character country code of the country where
399
+ # the results come from. This API supports only the United States market. If
400
+ # you specify this query parameter, it must be set to us. If you set this
401
+ # parameter, you must also specify the Accept-Language header. Bing uses the
402
+ # first supported language it finds from the languages list, and combine that
403
+ # language with the country code that you specify to determine the market to
404
+ # return results for. If the languages list does not include a supported
405
+ # language, Bing finds the closest language and market that supports the
406
+ # request, or it may use an aggregated or default market for the results
407
+ # instead of a specified one. You should use this query parameter and the
408
+ # Accept-Language query parameter only if you specify multiple languages;
409
+ # otherwise, you should use the mkt and setLang query parameters. This
410
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
411
+ # both.
412
+ # @param count [Integer] The number of news articles to return in the response.
413
+ # The actual number delivered may be less than requested. The default is 10 and
414
+ # the maximum value is 100. The actual number delivered may be less than
415
+ # requested.You may use this parameter along with the offset parameter to page
416
+ # results. For example, if your user interface displays 20 articles per page,
417
+ # set count to 20 and offset to 0 to get the first page of results. For each
418
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
419
+ # possible for multiple pages to include some overlap in results.
420
+ # @param freshness [Freshness] Filter news by the date and time that Bing
421
+ # discovered the news. The following are the possible filter values. Day:
422
+ # Return news discovered within the last 24 hours. Week: Return news discovered
423
+ # within the last 7 days. Month: Return news discovered within the last 30
424
+ # days. Use this parameter only with the News Search API. Do not specify this
425
+ # parameter when calling the News Category API or the Trending Topics API.
426
+ # Possible values include: 'Day', 'Week', 'Month'
427
+ # @param market [String] The market where the results come from. Typically, mkt
428
+ # is the country where the user is making the request from. However, it could
429
+ # be a different country if the user is not located in a country where Bing
430
+ # delivers results. The market must be in the form <language code>-<country
431
+ # code>. For example, en-US. The string is case insensitive. For a list of
432
+ # possible market values, see [Market
433
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
434
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
435
+ # the market helps Bing route the request and return an appropriate and optimal
436
+ # response. If you specify a market that is not listed in [Market
437
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
438
+ # Bing uses a best fit market code based on an internal mapping that is subject
439
+ # to change. This parameter and the
440
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
441
+ # query parameter are mutually exclusive—do not specify both.
442
+ # @param offset [Integer] The zero-based offset that indicates the number of
443
+ # news to skip before returning news. The default is 0. The offset should be
444
+ # less than
445
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
446
+ # - count). Use this parameter along with the count parameter to page results.
447
+ # For example, if your user interface displays 20 news per page, set count to
448
+ # 20 and offset to 0 to get the first page of results. For each subsequent
449
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
450
+ # multiple pages to include some overlap in results.
451
+ # @param original_image [Boolean] A Boolean value that determines whether the
452
+ # image's contentUrl contains a URL that points to a thumbnail of the original
453
+ # article's image or the image itself. If the article includes an image, and
454
+ # this parameter is set to true, the image's contentUrl property contains a URL
455
+ # that you may use to download the original image from the publisher's website.
456
+ # Otherwise, if this parameter is false, the image's contentUrl and
457
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
458
+ # only with the News Search API. Do not specify this parameter when calling the
459
+ # Trending Topics API or News Category API.
460
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
461
+ # are the possible filter values. Off: Return news articles with adult text,
462
+ # images, or videos. Moderate: Return news articles with adult text but not
463
+ # adult images or videos. Strict: Do not return news articles with adult text,
464
+ # images, or videos. If the request comes from a market that Bing's adult
465
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
466
+ # value and uses Strict. If you use the site: query operator, there is the
467
+ # chance that the response may contain adult content regardless of what the
468
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
469
+ # content on the site and your scenario supports the possibility of adult
470
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
471
+ # @param set_lang [String] The language to use for user interface strings.
472
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
473
+ # the language code for English is EN. The default is EN (English). Although
474
+ # optional, you should always specify the language. Typically, you set setLang
475
+ # to the same language specified by mkt unless the user wants the user
476
+ # interface strings displayed in a different language. This parameter and the
477
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
478
+ # header are mutually exclusive; do not specify both. A user interface string
479
+ # is a string that's used as a label in a user interface. There are few user
480
+ # interface strings in the JSON response objects. Also, any links to Bing.com
481
+ # properties in the response objects apply the specified language.
482
+ # @param sort_by [String] The order to return the news in. The following are
483
+ # the possible case-insensitive values. Date: If the request is through the
484
+ # News Search API, the response returns news articles sorted by date from the
485
+ # most recent to the oldest. If the request is through the News Trending Topics
486
+ # API, the response returns trending topics sorted by date from the most recent
487
+ # to the oldest.
488
+ # @param text_decorations [Boolean] A Boolean value that determines whether
489
+ # display strings contain decoration markers such as hit highlighting
490
+ # characters. If true, the strings may include markers. The default is false.
491
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
492
+ # the
493
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
494
+ # query parameter. For information about hit highlighting, see [Hit
495
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
496
+ # @param text_format [TextFormat] The type of markers to use for text
497
+ # decorations (see the textDecorations query parameter). Possible values are
498
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
499
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
500
+ # E000 and E001 to mark the beginning and end of query terms for hit
501
+ # highlighting. HTML—Use HTML tags to mark content that needs special
502
+ # formatting. For example, use <b> tags to highlight query terms in display
503
+ # strings. The default is Raw. For display strings that contain escapable HTML
504
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
505
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
506
+ # values include: 'Raw', 'Html'
507
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
508
+ # will be added to the HTTP request.
509
+ #
510
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
511
+ #
512
+ def search_with_http_info(query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, freshness:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
513
+ search_async(query, accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, freshness:freshness, market:market, offset:offset, original_image:original_image, safe_search:safe_search, set_lang:set_lang, sort_by:sort_by, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
514
+ end
515
+
516
+ #
517
+ # The News Search API lets you send a search query to Bing and get back a list
518
+ # of news that are relevant to the search query. This section provides
519
+ # technical details about the query parameters and headers that you use to
520
+ # request news and the JSON response objects that contain them. For examples
521
+ # that show how to make requests, see [Searching the web for
522
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
523
+ #
524
+ # @param query [String] The user's search query string. The query string cannot
525
+ # be empty. The query string may contain [Bing Advanced
526
+ # Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to
527
+ # limit news to a specific domain, use the
528
+ # [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. Use this
529
+ # parameter only with the News Search API. Do not specify this parameter when
530
+ # calling the Trending Topics API or News Category API.
531
+ # @param accept_language [String] A comma-delimited list of one or more
532
+ # languages to use for user interface strings. The list is in decreasing order
533
+ # of preference. For additional information, including expected format, see
534
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
535
+ # header and the
536
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
537
+ # query parameter are mutually exclusive; do not specify both. If you set this
538
+ # header, you must also specify the
539
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
540
+ # query parameter. To determine the market to return results for, Bing uses the
541
+ # first supported language it finds from the list and combines it with the cc
542
+ # parameter value. If the list does not include a supported language, Bing
543
+ # finds the closest language and market that supports the request or it uses an
544
+ # aggregated or default market for the results. To determine the market that
545
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
546
+ # parameter only if you specify multiple languages. Otherwise, use the
547
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
548
+ # and
549
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
550
+ # query parameters. A user interface string is a string that's used as a label
551
+ # in a user interface. There are few user interface strings in the JSON
552
+ # response objects. Any links to Bing.com properties in the response objects
553
+ # apply the specified language.
554
+ # @param user_agent [String] The user agent originating the request. Bing uses
555
+ # the user agent to provide mobile users with an optimized experience. Although
556
+ # optional, you are encouraged to always specify this header. The user-agent
557
+ # should be the same string that any commonly used browser sends. For
558
+ # information about user agents, see [RFC
559
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
560
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
561
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
562
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
563
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
564
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
565
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
566
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
567
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
568
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
569
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
570
+ # @param client_id [String] Bing uses this header to provide users with
571
+ # consistent behavior across Bing API calls. Bing often flights new features
572
+ # and improvements, and it uses the client ID as a key for assigning traffic on
573
+ # different flights. If you do not use the same client ID for a user across
574
+ # multiple requests, then Bing may assign the user to multiple conflicting
575
+ # flights. Being assigned to multiple conflicting flights can lead to an
576
+ # inconsistent user experience. For example, if the second request has a
577
+ # different flight assignment than the first, the experience may be unexpected.
578
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
579
+ # search history, providing a richer experience for the user. Bing also uses
580
+ # this header to help improve result rankings by analyzing the activity
581
+ # generated by a client ID. The relevance improvements help with better quality
582
+ # of results delivered by Bing APIs and in turn enables higher click-through
583
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
584
+ # this header required. Persisting the client ID across multiple requests for
585
+ # the same end user and device combination enables 1) the API consumer to
586
+ # receive a consistent user experience, and 2) higher click-through rates via
587
+ # better quality of results from the Bing APIs. Each user that uses your
588
+ # application on the device must have a unique, Bing generated client ID. If
589
+ # you do not include this header in the request, Bing generates an ID and
590
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
591
+ # should NOT include this header in a request is the first time the user uses
592
+ # your app on that device. Use the client ID for each Bing API request that
593
+ # your app makes for this user on the device. Persist the client ID. To persist
594
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
595
+ # used across all sessions. Do not use a session cookie. For other apps such as
596
+ # mobile apps, use the device's persistent storage to persist the ID. The next
597
+ # time the user uses your app on that device, get the client ID that you
598
+ # persisted. Bing responses may or may not include this header. If the response
599
+ # includes this header, capture the client ID and use it for all subsequent
600
+ # Bing requests for the user on that device. If you include the
601
+ # X-MSEdge-ClientID, you must not include cookies in the request.
602
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
603
+ # IP address is used to discover the user's location. Bing uses the location
604
+ # information to determine safe search behavior. Although optional, you are
605
+ # encouraged to always specify this header and the X-Search-Location header. Do
606
+ # not obfuscate the address (for example, by changing the last octet to 0).
607
+ # Obfuscating the address results in the location not being anywhere near the
608
+ # device's actual location, which may result in Bing serving erroneous results.
609
+ # @param location [String] A semicolon-delimited list of key/value pairs that
610
+ # describe the client's geographical location. Bing uses the location
611
+ # information to determine safe search behavior and to return relevant local
612
+ # content. Specify the key/value pair as <key>:<value>. The following are the
613
+ # keys that you use to specify the user's location. lat (required): The
614
+ # latitude of the client's location, in degrees. The latitude must be greater
615
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
616
+ # indicate southern latitudes and positive values indicate northern latitudes.
617
+ # long (required): The longitude of the client's location, in degrees. The
618
+ # longitude must be greater than or equal to -180.0 and less than or equal to
619
+ # +180.0. Negative values indicate western longitudes and positive values
620
+ # indicate eastern longitudes. re (required): The radius, in meters, which
621
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
622
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
623
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
624
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
625
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
626
+ # (optional): The client's relative heading or direction of travel. Specify the
627
+ # direction of travel as degrees from 0 through 360, counting clockwise
628
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
629
+ # (optional): The horizontal velocity (speed), in meters per second, that the
630
+ # client device is traveling. alt (optional): The altitude of the client
631
+ # device, in meters. are (optional): The radius, in meters, that specifies the
632
+ # vertical accuracy of the coordinates. Specify this key only if you specify
633
+ # the alt key. Although many of the keys are optional, the more information
634
+ # that you provide, the more accurate the location results are. Although
635
+ # optional, you are encouraged to always specify the user's geographical
636
+ # location. Providing the location is especially important if the client's IP
637
+ # address does not accurately reflect the user's physical location (for
638
+ # example, if the client uses VPN). For optimal results, you should include
639
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
640
+ # include this header.
641
+ # @param country_code [String] A 2-character country code of the country where
642
+ # the results come from. This API supports only the United States market. If
643
+ # you specify this query parameter, it must be set to us. If you set this
644
+ # parameter, you must also specify the Accept-Language header. Bing uses the
645
+ # first supported language it finds from the languages list, and combine that
646
+ # language with the country code that you specify to determine the market to
647
+ # return results for. If the languages list does not include a supported
648
+ # language, Bing finds the closest language and market that supports the
649
+ # request, or it may use an aggregated or default market for the results
650
+ # instead of a specified one. You should use this query parameter and the
651
+ # Accept-Language query parameter only if you specify multiple languages;
652
+ # otherwise, you should use the mkt and setLang query parameters. This
653
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
654
+ # both.
655
+ # @param count [Integer] The number of news articles to return in the response.
656
+ # The actual number delivered may be less than requested. The default is 10 and
657
+ # the maximum value is 100. The actual number delivered may be less than
658
+ # requested.You may use this parameter along with the offset parameter to page
659
+ # results. For example, if your user interface displays 20 articles per page,
660
+ # set count to 20 and offset to 0 to get the first page of results. For each
661
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
662
+ # possible for multiple pages to include some overlap in results.
663
+ # @param freshness [Freshness] Filter news by the date and time that Bing
664
+ # discovered the news. The following are the possible filter values. Day:
665
+ # Return news discovered within the last 24 hours. Week: Return news discovered
666
+ # within the last 7 days. Month: Return news discovered within the last 30
667
+ # days. Use this parameter only with the News Search API. Do not specify this
668
+ # parameter when calling the News Category API or the Trending Topics API.
669
+ # Possible values include: 'Day', 'Week', 'Month'
670
+ # @param market [String] The market where the results come from. Typically, mkt
671
+ # is the country where the user is making the request from. However, it could
672
+ # be a different country if the user is not located in a country where Bing
673
+ # delivers results. The market must be in the form <language code>-<country
674
+ # code>. For example, en-US. The string is case insensitive. For a list of
675
+ # possible market values, see [Market
676
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
677
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
678
+ # the market helps Bing route the request and return an appropriate and optimal
679
+ # response. If you specify a market that is not listed in [Market
680
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
681
+ # Bing uses a best fit market code based on an internal mapping that is subject
682
+ # to change. This parameter and the
683
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
684
+ # query parameter are mutually exclusive—do not specify both.
685
+ # @param offset [Integer] The zero-based offset that indicates the number of
686
+ # news to skip before returning news. The default is 0. The offset should be
687
+ # less than
688
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
689
+ # - count). Use this parameter along with the count parameter to page results.
690
+ # For example, if your user interface displays 20 news per page, set count to
691
+ # 20 and offset to 0 to get the first page of results. For each subsequent
692
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
693
+ # multiple pages to include some overlap in results.
694
+ # @param original_image [Boolean] A Boolean value that determines whether the
695
+ # image's contentUrl contains a URL that points to a thumbnail of the original
696
+ # article's image or the image itself. If the article includes an image, and
697
+ # this parameter is set to true, the image's contentUrl property contains a URL
698
+ # that you may use to download the original image from the publisher's website.
699
+ # Otherwise, if this parameter is false, the image's contentUrl and
700
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
701
+ # only with the News Search API. Do not specify this parameter when calling the
702
+ # Trending Topics API or News Category API.
703
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
704
+ # are the possible filter values. Off: Return news articles with adult text,
705
+ # images, or videos. Moderate: Return news articles with adult text but not
706
+ # adult images or videos. Strict: Do not return news articles with adult text,
707
+ # images, or videos. If the request comes from a market that Bing's adult
708
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
709
+ # value and uses Strict. If you use the site: query operator, there is the
710
+ # chance that the response may contain adult content regardless of what the
711
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
712
+ # content on the site and your scenario supports the possibility of adult
713
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
714
+ # @param set_lang [String] The language to use for user interface strings.
715
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
716
+ # the language code for English is EN. The default is EN (English). Although
717
+ # optional, you should always specify the language. Typically, you set setLang
718
+ # to the same language specified by mkt unless the user wants the user
719
+ # interface strings displayed in a different language. This parameter and the
720
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
721
+ # header are mutually exclusive; do not specify both. A user interface string
722
+ # is a string that's used as a label in a user interface. There are few user
723
+ # interface strings in the JSON response objects. Also, any links to Bing.com
724
+ # properties in the response objects apply the specified language.
725
+ # @param sort_by [String] The order to return the news in. The following are
726
+ # the possible case-insensitive values. Date: If the request is through the
727
+ # News Search API, the response returns news articles sorted by date from the
728
+ # most recent to the oldest. If the request is through the News Trending Topics
729
+ # API, the response returns trending topics sorted by date from the most recent
730
+ # to the oldest.
731
+ # @param text_decorations [Boolean] A Boolean value that determines whether
732
+ # display strings contain decoration markers such as hit highlighting
733
+ # characters. If true, the strings may include markers. The default is false.
734
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
735
+ # the
736
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
737
+ # query parameter. For information about hit highlighting, see [Hit
738
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
739
+ # @param text_format [TextFormat] The type of markers to use for text
740
+ # decorations (see the textDecorations query parameter). Possible values are
741
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
742
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
743
+ # E000 and E001 to mark the beginning and end of query terms for hit
744
+ # highlighting. HTML—Use HTML tags to mark content that needs special
745
+ # formatting. For example, use <b> tags to highlight query terms in display
746
+ # strings. The default is Raw. For display strings that contain escapable HTML
747
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
748
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
749
+ # values include: 'Raw', 'Html'
750
+ # @param [Hash{String => String}] A hash of custom headers that will be added
751
+ # to the HTTP request.
752
+ #
753
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
754
+ #
755
+ def search_async(query, accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, freshness:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
756
+ x_bing_apis_sdk = 'true'
757
+ fail ArgumentError, 'query is nil' if query.nil?
758
+
759
+
760
+ request_headers = {}
761
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
762
+
763
+ # Set Headers
764
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
765
+ request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
766
+ request_headers['Accept-Language'] = accept_language unless accept_language.nil?
767
+ request_headers['User-Agent'] = user_agent unless user_agent.nil?
768
+ request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
769
+ request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
770
+ request_headers['X-Search-Location'] = location unless location.nil?
771
+ path_template = 'news/search'
772
+
773
+ request_url = @base_url || @client.base_url
774
+
775
+ options = {
776
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
777
+ query_params: {'cc' => country_code,'count' => count,'freshness' => freshness,'mkt' => market,'offset' => offset,'originalImg' => original_image,'q' => query,'safeSearch' => safe_search,'setLang' => set_lang,'sortBy' => sort_by,'textDecorations' => text_decorations,'textFormat' => text_format},
778
+ headers: request_headers.merge(custom_headers || {}),
779
+ base_url: request_url
780
+ }
781
+ promise = @client.make_request_async(:get, path_template, options)
782
+
783
+ promise = promise.then do |result|
784
+ http_response = result.response
785
+ status_code = http_response.status
786
+ response_content = http_response.body
787
+ unless status_code == 200
788
+ error_model = JSON.load(response_content)
789
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
790
+ end
791
+
792
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
793
+ # Deserialize Response
794
+ if status_code == 200
795
+ begin
796
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
797
+ result_mapper = Azure::CognitiveServices::NewsSearch::V1_0::Models::News.mapper()
798
+ result.body = @client.deserialize(result_mapper, parsed_response)
799
+ rescue Exception => e
800
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
801
+ end
802
+ end
803
+
804
+ result
805
+ end
806
+
807
+ promise.execute
808
+ end
809
+
810
+ #
811
+ # The News Category API lets lets you search on Bing and get back a list of top
812
+ # news articles by category. This section provides technical details about the
813
+ # query parameters and headers that you use to request news and the JSON
814
+ # response objects that contain them. For examples that show how to make
815
+ # requests, see [Searching the web for
816
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
817
+ #
818
+ # @param accept_language [String] A comma-delimited list of one or more
819
+ # languages to use for user interface strings. The list is in decreasing order
820
+ # of preference. For additional information, including expected format, see
821
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
822
+ # header and the
823
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
824
+ # query parameter are mutually exclusive; do not specify both. If you set this
825
+ # header, you must also specify the
826
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
827
+ # query parameter. To determine the market to return results for, Bing uses the
828
+ # first supported language it finds from the list and combines it with the cc
829
+ # parameter value. If the list does not include a supported language, Bing
830
+ # finds the closest language and market that supports the request or it uses an
831
+ # aggregated or default market for the results. To determine the market that
832
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
833
+ # parameter only if you specify multiple languages. Otherwise, use the
834
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
835
+ # and
836
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
837
+ # query parameters. A user interface string is a string that's used as a label
838
+ # in a user interface. There are few user interface strings in the JSON
839
+ # response objects. Any links to Bing.com properties in the response objects
840
+ # apply the specified language.
841
+ # @param user_agent [String] The user agent originating the request. Bing uses
842
+ # the user agent to provide mobile users with an optimized experience. Although
843
+ # optional, you are encouraged to always specify this header. The user-agent
844
+ # should be the same string that any commonly used browser sends. For
845
+ # information about user agents, see [RFC
846
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
847
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
848
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
849
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
850
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
851
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
852
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
853
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
854
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
855
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
856
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
857
+ # @param client_id [String] Bing uses this header to provide users with
858
+ # consistent behavior across Bing API calls. Bing often flights new features
859
+ # and improvements, and it uses the client ID as a key for assigning traffic on
860
+ # different flights. If you do not use the same client ID for a user across
861
+ # multiple requests, then Bing may assign the user to multiple conflicting
862
+ # flights. Being assigned to multiple conflicting flights can lead to an
863
+ # inconsistent user experience. For example, if the second request has a
864
+ # different flight assignment than the first, the experience may be unexpected.
865
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
866
+ # search history, providing a richer experience for the user. Bing also uses
867
+ # this header to help improve result rankings by analyzing the activity
868
+ # generated by a client ID. The relevance improvements help with better quality
869
+ # of results delivered by Bing APIs and in turn enables higher click-through
870
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
871
+ # this header required. Persisting the client ID across multiple requests for
872
+ # the same end user and device combination enables 1) the API consumer to
873
+ # receive a consistent user experience, and 2) higher click-through rates via
874
+ # better quality of results from the Bing APIs. Each user that uses your
875
+ # application on the device must have a unique, Bing generated client ID. If
876
+ # you do not include this header in the request, Bing generates an ID and
877
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
878
+ # should NOT include this header in a request is the first time the user uses
879
+ # your app on that device. Use the client ID for each Bing API request that
880
+ # your app makes for this user on the device. Persist the client ID. To persist
881
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
882
+ # used across all sessions. Do not use a session cookie. For other apps such as
883
+ # mobile apps, use the device's persistent storage to persist the ID. The next
884
+ # time the user uses your app on that device, get the client ID that you
885
+ # persisted. Bing responses may or may not include this header. If the response
886
+ # includes this header, capture the client ID and use it for all subsequent
887
+ # Bing requests for the user on that device. If you include the
888
+ # X-MSEdge-ClientID, you must not include cookies in the request.
889
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
890
+ # IP address is used to discover the user's location. Bing uses the location
891
+ # information to determine safe search behavior. Although optional, you are
892
+ # encouraged to always specify this header and the X-Search-Location header. Do
893
+ # not obfuscate the address (for example, by changing the last octet to 0).
894
+ # Obfuscating the address results in the location not being anywhere near the
895
+ # device's actual location, which may result in Bing serving erroneous results.
896
+ # @param location [String] A semicolon-delimited list of key/value pairs that
897
+ # describe the client's geographical location. Bing uses the location
898
+ # information to determine safe search behavior and to return relevant local
899
+ # content. Specify the key/value pair as <key>:<value>. The following are the
900
+ # keys that you use to specify the user's location. lat (required): The
901
+ # latitude of the client's location, in degrees. The latitude must be greater
902
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
903
+ # indicate southern latitudes and positive values indicate northern latitudes.
904
+ # long (required): The longitude of the client's location, in degrees. The
905
+ # longitude must be greater than or equal to -180.0 and less than or equal to
906
+ # +180.0. Negative values indicate western longitudes and positive values
907
+ # indicate eastern longitudes. re (required): The radius, in meters, which
908
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
909
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
910
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
911
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
912
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
913
+ # (optional): The client's relative heading or direction of travel. Specify the
914
+ # direction of travel as degrees from 0 through 360, counting clockwise
915
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
916
+ # (optional): The horizontal velocity (speed), in meters per second, that the
917
+ # client device is traveling. alt (optional): The altitude of the client
918
+ # device, in meters. are (optional): The radius, in meters, that specifies the
919
+ # vertical accuracy of the coordinates. Specify this key only if you specify
920
+ # the alt key. Although many of the keys are optional, the more information
921
+ # that you provide, the more accurate the location results are. Although
922
+ # optional, you are encouraged to always specify the user's geographical
923
+ # location. Providing the location is especially important if the client's IP
924
+ # address does not accurately reflect the user's physical location (for
925
+ # example, if the client uses VPN). For optimal results, you should include
926
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
927
+ # include this header.
928
+ # @param country_code [String] A 2-character country code of the country where
929
+ # the results come from. This API supports only the United States market. If
930
+ # you specify this query parameter, it must be set to us. If you set this
931
+ # parameter, you must also specify the Accept-Language header. Bing uses the
932
+ # first supported language it finds from the languages list, and combine that
933
+ # language with the country code that you specify to determine the market to
934
+ # return results for. If the languages list does not include a supported
935
+ # language, Bing finds the closest language and market that supports the
936
+ # request, or it may use an aggregated or default market for the results
937
+ # instead of a specified one. You should use this query parameter and the
938
+ # Accept-Language query parameter only if you specify multiple languages;
939
+ # otherwise, you should use the mkt and setLang query parameters. This
940
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
941
+ # both.
942
+ # @param category [String] The category of articles to return. For example,
943
+ # Sports articles or Entertainment articles. For a list of possible categories,
944
+ # see [News Categories by
945
+ # Market](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#categories-by-market).
946
+ # Use this parameter only with News Category API. If you do not specify this
947
+ # parameter, the response includes both: Headline articles typically published
948
+ # in the last 24 hours from any category and articles from each parent category
949
+ # (up to four articles). If the article is a headline, the article's headline
950
+ # field is set to true. By default, the response includes up to 12 headline
951
+ # articles. To specify the number of headline articles to return, set the
952
+ # [headlineCount](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#headlineCount)
953
+ # query parameter.
954
+ # @param count [Integer] The number of news articles to return in the response.
955
+ # The actual number delivered may be less than requested. The default is 10 and
956
+ # the maximum value is 100. The actual number delivered may be less than
957
+ # requested.You may use this parameter along with the offset parameter to page
958
+ # results. For example, if your user interface displays 20 articles per page,
959
+ # set count to 20 and offset to 0 to get the first page of results. For each
960
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
961
+ # possible for multiple pages to include some overlap in results. If you do not
962
+ # specify the
963
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
964
+ # parameter, Bing ignores this parameter.
965
+ # @param headline_count [Integer] The number of headline articles to return in
966
+ # the response. The default is 12. Specify this parameter only if you do not
967
+ # specify the
968
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
969
+ # parameter.
970
+ # @param market [String] The market where the results come from. Typically, mkt
971
+ # is the country where the user is making the request from. However, it could
972
+ # be a different country if the user is not located in a country where Bing
973
+ # delivers results. The market must be in the form <language code>-<country
974
+ # code>. For example, en-US. The string is case insensitive. For a list of
975
+ # possible market values, see [Market
976
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
977
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
978
+ # the market helps Bing route the request and return an appropriate and optimal
979
+ # response. If you specify a market that is not listed in [Market
980
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
981
+ # Bing uses a best fit market code based on an internal mapping that is subject
982
+ # to change. This parameter and the
983
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
984
+ # query parameter are mutually exclusive—do not specify both.
985
+ # @param offset [Integer] The zero-based offset that indicates the number of
986
+ # news to skip before returning news. The default is 0. The offset should be
987
+ # less than
988
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
989
+ # - count). Use this parameter along with the count parameter to page results.
990
+ # For example, if your user interface displays 20 news per page, set count to
991
+ # 20 and offset to 0 to get the first page of results. For each subsequent
992
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
993
+ # multiple pages to include some overlap in results. If you do not specify the
994
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
995
+ # parameter, Bing ignores this parameter.
996
+ # @param original_image [Boolean] A Boolean value that determines whether the
997
+ # image's contentUrl contains a URL that points to a thumbnail of the original
998
+ # article's image or the image itself. If the article includes an image, and
999
+ # this parameter is set to true, the image's contentUrl property contains a URL
1000
+ # that you may use to download the original image from the publisher's website.
1001
+ # Otherwise, if this parameter is false, the image's contentUrl and
1002
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
1003
+ # only with the News Search API or News Category API. Trending Topics API
1004
+ # ignore this parameter.
1005
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
1006
+ # are the possible filter values. Off: Return news articles with adult text,
1007
+ # images, or videos. Moderate: Return news articles with adult text but not
1008
+ # adult images or videos. Strict: Do not return news articles with adult text,
1009
+ # images, or videos. If the request comes from a market that Bing's adult
1010
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
1011
+ # value and uses Strict. If you use the site: query operator, there is the
1012
+ # chance that the response may contain adult content regardless of what the
1013
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
1014
+ # content on the site and your scenario supports the possibility of adult
1015
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
1016
+ # @param set_lang [String] The language to use for user interface strings.
1017
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
1018
+ # the language code for English is EN. The default is EN (English). Although
1019
+ # optional, you should always specify the language. Typically, you set setLang
1020
+ # to the same language specified by mkt unless the user wants the user
1021
+ # interface strings displayed in a different language. This parameter and the
1022
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
1023
+ # header are mutually exclusive; do not specify both. A user interface string
1024
+ # is a string that's used as a label in a user interface. There are few user
1025
+ # interface strings in the JSON response objects. Also, any links to Bing.com
1026
+ # properties in the response objects apply the specified language.
1027
+ # @param text_decorations [Boolean] A Boolean value that determines whether
1028
+ # display strings contain decoration markers such as hit highlighting
1029
+ # characters. If true, the strings may include markers. The default is false.
1030
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
1031
+ # the
1032
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
1033
+ # query parameter. For information about hit highlighting, see [Hit
1034
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
1035
+ # @param text_format [TextFormat] The type of markers to use for text
1036
+ # decorations (see the textDecorations query parameter). Possible values are
1037
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
1038
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
1039
+ # E000 and E001 to mark the beginning and end of query terms for hit
1040
+ # highlighting. HTML—Use HTML tags to mark content that needs special
1041
+ # formatting. For example, use <b> tags to highlight query terms in display
1042
+ # strings. The default is Raw. For display strings that contain escapable HTML
1043
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
1044
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
1045
+ # values include: 'Raw', 'Html'
1046
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1047
+ # will be added to the HTTP request.
1048
+ #
1049
+ # @return [News] operation results.
1050
+ #
1051
+ def category(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, category:nil, count:nil, headline_count:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
1052
+ response = category_async(accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, category:category, count:count, headline_count:headline_count, market:market, offset:offset, original_image:original_image, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
1053
+ response.body unless response.nil?
1054
+ end
1055
+
1056
+ #
1057
+ # The News Category API lets lets you search on Bing and get back a list of top
1058
+ # news articles by category. This section provides technical details about the
1059
+ # query parameters and headers that you use to request news and the JSON
1060
+ # response objects that contain them. For examples that show how to make
1061
+ # requests, see [Searching the web for
1062
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
1063
+ #
1064
+ # @param accept_language [String] A comma-delimited list of one or more
1065
+ # languages to use for user interface strings. The list is in decreasing order
1066
+ # of preference. For additional information, including expected format, see
1067
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
1068
+ # header and the
1069
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1070
+ # query parameter are mutually exclusive; do not specify both. If you set this
1071
+ # header, you must also specify the
1072
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1073
+ # query parameter. To determine the market to return results for, Bing uses the
1074
+ # first supported language it finds from the list and combines it with the cc
1075
+ # parameter value. If the list does not include a supported language, Bing
1076
+ # finds the closest language and market that supports the request or it uses an
1077
+ # aggregated or default market for the results. To determine the market that
1078
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
1079
+ # parameter only if you specify multiple languages. Otherwise, use the
1080
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
1081
+ # and
1082
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1083
+ # query parameters. A user interface string is a string that's used as a label
1084
+ # in a user interface. There are few user interface strings in the JSON
1085
+ # response objects. Any links to Bing.com properties in the response objects
1086
+ # apply the specified language.
1087
+ # @param user_agent [String] The user agent originating the request. Bing uses
1088
+ # the user agent to provide mobile users with an optimized experience. Although
1089
+ # optional, you are encouraged to always specify this header. The user-agent
1090
+ # should be the same string that any commonly used browser sends. For
1091
+ # information about user agents, see [RFC
1092
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
1093
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
1094
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
1095
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
1096
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
1097
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
1098
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
1099
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
1100
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
1101
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
1102
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
1103
+ # @param client_id [String] Bing uses this header to provide users with
1104
+ # consistent behavior across Bing API calls. Bing often flights new features
1105
+ # and improvements, and it uses the client ID as a key for assigning traffic on
1106
+ # different flights. If you do not use the same client ID for a user across
1107
+ # multiple requests, then Bing may assign the user to multiple conflicting
1108
+ # flights. Being assigned to multiple conflicting flights can lead to an
1109
+ # inconsistent user experience. For example, if the second request has a
1110
+ # different flight assignment than the first, the experience may be unexpected.
1111
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
1112
+ # search history, providing a richer experience for the user. Bing also uses
1113
+ # this header to help improve result rankings by analyzing the activity
1114
+ # generated by a client ID. The relevance improvements help with better quality
1115
+ # of results delivered by Bing APIs and in turn enables higher click-through
1116
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
1117
+ # this header required. Persisting the client ID across multiple requests for
1118
+ # the same end user and device combination enables 1) the API consumer to
1119
+ # receive a consistent user experience, and 2) higher click-through rates via
1120
+ # better quality of results from the Bing APIs. Each user that uses your
1121
+ # application on the device must have a unique, Bing generated client ID. If
1122
+ # you do not include this header in the request, Bing generates an ID and
1123
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
1124
+ # should NOT include this header in a request is the first time the user uses
1125
+ # your app on that device. Use the client ID for each Bing API request that
1126
+ # your app makes for this user on the device. Persist the client ID. To persist
1127
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
1128
+ # used across all sessions. Do not use a session cookie. For other apps such as
1129
+ # mobile apps, use the device's persistent storage to persist the ID. The next
1130
+ # time the user uses your app on that device, get the client ID that you
1131
+ # persisted. Bing responses may or may not include this header. If the response
1132
+ # includes this header, capture the client ID and use it for all subsequent
1133
+ # Bing requests for the user on that device. If you include the
1134
+ # X-MSEdge-ClientID, you must not include cookies in the request.
1135
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
1136
+ # IP address is used to discover the user's location. Bing uses the location
1137
+ # information to determine safe search behavior. Although optional, you are
1138
+ # encouraged to always specify this header and the X-Search-Location header. Do
1139
+ # not obfuscate the address (for example, by changing the last octet to 0).
1140
+ # Obfuscating the address results in the location not being anywhere near the
1141
+ # device's actual location, which may result in Bing serving erroneous results.
1142
+ # @param location [String] A semicolon-delimited list of key/value pairs that
1143
+ # describe the client's geographical location. Bing uses the location
1144
+ # information to determine safe search behavior and to return relevant local
1145
+ # content. Specify the key/value pair as <key>:<value>. The following are the
1146
+ # keys that you use to specify the user's location. lat (required): The
1147
+ # latitude of the client's location, in degrees. The latitude must be greater
1148
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
1149
+ # indicate southern latitudes and positive values indicate northern latitudes.
1150
+ # long (required): The longitude of the client's location, in degrees. The
1151
+ # longitude must be greater than or equal to -180.0 and less than or equal to
1152
+ # +180.0. Negative values indicate western longitudes and positive values
1153
+ # indicate eastern longitudes. re (required): The radius, in meters, which
1154
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
1155
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
1156
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
1157
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
1158
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
1159
+ # (optional): The client's relative heading or direction of travel. Specify the
1160
+ # direction of travel as degrees from 0 through 360, counting clockwise
1161
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
1162
+ # (optional): The horizontal velocity (speed), in meters per second, that the
1163
+ # client device is traveling. alt (optional): The altitude of the client
1164
+ # device, in meters. are (optional): The radius, in meters, that specifies the
1165
+ # vertical accuracy of the coordinates. Specify this key only if you specify
1166
+ # the alt key. Although many of the keys are optional, the more information
1167
+ # that you provide, the more accurate the location results are. Although
1168
+ # optional, you are encouraged to always specify the user's geographical
1169
+ # location. Providing the location is especially important if the client's IP
1170
+ # address does not accurately reflect the user's physical location (for
1171
+ # example, if the client uses VPN). For optimal results, you should include
1172
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
1173
+ # include this header.
1174
+ # @param country_code [String] A 2-character country code of the country where
1175
+ # the results come from. This API supports only the United States market. If
1176
+ # you specify this query parameter, it must be set to us. If you set this
1177
+ # parameter, you must also specify the Accept-Language header. Bing uses the
1178
+ # first supported language it finds from the languages list, and combine that
1179
+ # language with the country code that you specify to determine the market to
1180
+ # return results for. If the languages list does not include a supported
1181
+ # language, Bing finds the closest language and market that supports the
1182
+ # request, or it may use an aggregated or default market for the results
1183
+ # instead of a specified one. You should use this query parameter and the
1184
+ # Accept-Language query parameter only if you specify multiple languages;
1185
+ # otherwise, you should use the mkt and setLang query parameters. This
1186
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
1187
+ # both.
1188
+ # @param category [String] The category of articles to return. For example,
1189
+ # Sports articles or Entertainment articles. For a list of possible categories,
1190
+ # see [News Categories by
1191
+ # Market](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#categories-by-market).
1192
+ # Use this parameter only with News Category API. If you do not specify this
1193
+ # parameter, the response includes both: Headline articles typically published
1194
+ # in the last 24 hours from any category and articles from each parent category
1195
+ # (up to four articles). If the article is a headline, the article's headline
1196
+ # field is set to true. By default, the response includes up to 12 headline
1197
+ # articles. To specify the number of headline articles to return, set the
1198
+ # [headlineCount](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#headlineCount)
1199
+ # query parameter.
1200
+ # @param count [Integer] The number of news articles to return in the response.
1201
+ # The actual number delivered may be less than requested. The default is 10 and
1202
+ # the maximum value is 100. The actual number delivered may be less than
1203
+ # requested.You may use this parameter along with the offset parameter to page
1204
+ # results. For example, if your user interface displays 20 articles per page,
1205
+ # set count to 20 and offset to 0 to get the first page of results. For each
1206
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
1207
+ # possible for multiple pages to include some overlap in results. If you do not
1208
+ # specify the
1209
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1210
+ # parameter, Bing ignores this parameter.
1211
+ # @param headline_count [Integer] The number of headline articles to return in
1212
+ # the response. The default is 12. Specify this parameter only if you do not
1213
+ # specify the
1214
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1215
+ # parameter.
1216
+ # @param market [String] The market where the results come from. Typically, mkt
1217
+ # is the country where the user is making the request from. However, it could
1218
+ # be a different country if the user is not located in a country where Bing
1219
+ # delivers results. The market must be in the form <language code>-<country
1220
+ # code>. For example, en-US. The string is case insensitive. For a list of
1221
+ # possible market values, see [Market
1222
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
1223
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
1224
+ # the market helps Bing route the request and return an appropriate and optimal
1225
+ # response. If you specify a market that is not listed in [Market
1226
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
1227
+ # Bing uses a best fit market code based on an internal mapping that is subject
1228
+ # to change. This parameter and the
1229
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1230
+ # query parameter are mutually exclusive—do not specify both.
1231
+ # @param offset [Integer] The zero-based offset that indicates the number of
1232
+ # news to skip before returning news. The default is 0. The offset should be
1233
+ # less than
1234
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
1235
+ # - count). Use this parameter along with the count parameter to page results.
1236
+ # For example, if your user interface displays 20 news per page, set count to
1237
+ # 20 and offset to 0 to get the first page of results. For each subsequent
1238
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
1239
+ # multiple pages to include some overlap in results. If you do not specify the
1240
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1241
+ # parameter, Bing ignores this parameter.
1242
+ # @param original_image [Boolean] A Boolean value that determines whether the
1243
+ # image's contentUrl contains a URL that points to a thumbnail of the original
1244
+ # article's image or the image itself. If the article includes an image, and
1245
+ # this parameter is set to true, the image's contentUrl property contains a URL
1246
+ # that you may use to download the original image from the publisher's website.
1247
+ # Otherwise, if this parameter is false, the image's contentUrl and
1248
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
1249
+ # only with the News Search API or News Category API. Trending Topics API
1250
+ # ignore this parameter.
1251
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
1252
+ # are the possible filter values. Off: Return news articles with adult text,
1253
+ # images, or videos. Moderate: Return news articles with adult text but not
1254
+ # adult images or videos. Strict: Do not return news articles with adult text,
1255
+ # images, or videos. If the request comes from a market that Bing's adult
1256
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
1257
+ # value and uses Strict. If you use the site: query operator, there is the
1258
+ # chance that the response may contain adult content regardless of what the
1259
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
1260
+ # content on the site and your scenario supports the possibility of adult
1261
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
1262
+ # @param set_lang [String] The language to use for user interface strings.
1263
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
1264
+ # the language code for English is EN. The default is EN (English). Although
1265
+ # optional, you should always specify the language. Typically, you set setLang
1266
+ # to the same language specified by mkt unless the user wants the user
1267
+ # interface strings displayed in a different language. This parameter and the
1268
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
1269
+ # header are mutually exclusive; do not specify both. A user interface string
1270
+ # is a string that's used as a label in a user interface. There are few user
1271
+ # interface strings in the JSON response objects. Also, any links to Bing.com
1272
+ # properties in the response objects apply the specified language.
1273
+ # @param text_decorations [Boolean] A Boolean value that determines whether
1274
+ # display strings contain decoration markers such as hit highlighting
1275
+ # characters. If true, the strings may include markers. The default is false.
1276
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
1277
+ # the
1278
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
1279
+ # query parameter. For information about hit highlighting, see [Hit
1280
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
1281
+ # @param text_format [TextFormat] The type of markers to use for text
1282
+ # decorations (see the textDecorations query parameter). Possible values are
1283
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
1284
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
1285
+ # E000 and E001 to mark the beginning and end of query terms for hit
1286
+ # highlighting. HTML—Use HTML tags to mark content that needs special
1287
+ # formatting. For example, use <b> tags to highlight query terms in display
1288
+ # strings. The default is Raw. For display strings that contain escapable HTML
1289
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
1290
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
1291
+ # values include: 'Raw', 'Html'
1292
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1293
+ # will be added to the HTTP request.
1294
+ #
1295
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1296
+ #
1297
+ def category_with_http_info(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, category:nil, count:nil, headline_count:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
1298
+ category_async(accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, category:category, count:count, headline_count:headline_count, market:market, offset:offset, original_image:original_image, safe_search:safe_search, set_lang:set_lang, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
1299
+ end
1300
+
1301
+ #
1302
+ # The News Category API lets lets you search on Bing and get back a list of top
1303
+ # news articles by category. This section provides technical details about the
1304
+ # query parameters and headers that you use to request news and the JSON
1305
+ # response objects that contain them. For examples that show how to make
1306
+ # requests, see [Searching the web for
1307
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
1308
+ #
1309
+ # @param accept_language [String] A comma-delimited list of one or more
1310
+ # languages to use for user interface strings. The list is in decreasing order
1311
+ # of preference. For additional information, including expected format, see
1312
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
1313
+ # header and the
1314
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1315
+ # query parameter are mutually exclusive; do not specify both. If you set this
1316
+ # header, you must also specify the
1317
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1318
+ # query parameter. To determine the market to return results for, Bing uses the
1319
+ # first supported language it finds from the list and combines it with the cc
1320
+ # parameter value. If the list does not include a supported language, Bing
1321
+ # finds the closest language and market that supports the request or it uses an
1322
+ # aggregated or default market for the results. To determine the market that
1323
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
1324
+ # parameter only if you specify multiple languages. Otherwise, use the
1325
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
1326
+ # and
1327
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1328
+ # query parameters. A user interface string is a string that's used as a label
1329
+ # in a user interface. There are few user interface strings in the JSON
1330
+ # response objects. Any links to Bing.com properties in the response objects
1331
+ # apply the specified language.
1332
+ # @param user_agent [String] The user agent originating the request. Bing uses
1333
+ # the user agent to provide mobile users with an optimized experience. Although
1334
+ # optional, you are encouraged to always specify this header. The user-agent
1335
+ # should be the same string that any commonly used browser sends. For
1336
+ # information about user agents, see [RFC
1337
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
1338
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
1339
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
1340
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
1341
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
1342
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
1343
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
1344
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
1345
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
1346
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
1347
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
1348
+ # @param client_id [String] Bing uses this header to provide users with
1349
+ # consistent behavior across Bing API calls. Bing often flights new features
1350
+ # and improvements, and it uses the client ID as a key for assigning traffic on
1351
+ # different flights. If you do not use the same client ID for a user across
1352
+ # multiple requests, then Bing may assign the user to multiple conflicting
1353
+ # flights. Being assigned to multiple conflicting flights can lead to an
1354
+ # inconsistent user experience. For example, if the second request has a
1355
+ # different flight assignment than the first, the experience may be unexpected.
1356
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
1357
+ # search history, providing a richer experience for the user. Bing also uses
1358
+ # this header to help improve result rankings by analyzing the activity
1359
+ # generated by a client ID. The relevance improvements help with better quality
1360
+ # of results delivered by Bing APIs and in turn enables higher click-through
1361
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
1362
+ # this header required. Persisting the client ID across multiple requests for
1363
+ # the same end user and device combination enables 1) the API consumer to
1364
+ # receive a consistent user experience, and 2) higher click-through rates via
1365
+ # better quality of results from the Bing APIs. Each user that uses your
1366
+ # application on the device must have a unique, Bing generated client ID. If
1367
+ # you do not include this header in the request, Bing generates an ID and
1368
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
1369
+ # should NOT include this header in a request is the first time the user uses
1370
+ # your app on that device. Use the client ID for each Bing API request that
1371
+ # your app makes for this user on the device. Persist the client ID. To persist
1372
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
1373
+ # used across all sessions. Do not use a session cookie. For other apps such as
1374
+ # mobile apps, use the device's persistent storage to persist the ID. The next
1375
+ # time the user uses your app on that device, get the client ID that you
1376
+ # persisted. Bing responses may or may not include this header. If the response
1377
+ # includes this header, capture the client ID and use it for all subsequent
1378
+ # Bing requests for the user on that device. If you include the
1379
+ # X-MSEdge-ClientID, you must not include cookies in the request.
1380
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
1381
+ # IP address is used to discover the user's location. Bing uses the location
1382
+ # information to determine safe search behavior. Although optional, you are
1383
+ # encouraged to always specify this header and the X-Search-Location header. Do
1384
+ # not obfuscate the address (for example, by changing the last octet to 0).
1385
+ # Obfuscating the address results in the location not being anywhere near the
1386
+ # device's actual location, which may result in Bing serving erroneous results.
1387
+ # @param location [String] A semicolon-delimited list of key/value pairs that
1388
+ # describe the client's geographical location. Bing uses the location
1389
+ # information to determine safe search behavior and to return relevant local
1390
+ # content. Specify the key/value pair as <key>:<value>. The following are the
1391
+ # keys that you use to specify the user's location. lat (required): The
1392
+ # latitude of the client's location, in degrees. The latitude must be greater
1393
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
1394
+ # indicate southern latitudes and positive values indicate northern latitudes.
1395
+ # long (required): The longitude of the client's location, in degrees. The
1396
+ # longitude must be greater than or equal to -180.0 and less than or equal to
1397
+ # +180.0. Negative values indicate western longitudes and positive values
1398
+ # indicate eastern longitudes. re (required): The radius, in meters, which
1399
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
1400
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
1401
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
1402
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
1403
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
1404
+ # (optional): The client's relative heading or direction of travel. Specify the
1405
+ # direction of travel as degrees from 0 through 360, counting clockwise
1406
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
1407
+ # (optional): The horizontal velocity (speed), in meters per second, that the
1408
+ # client device is traveling. alt (optional): The altitude of the client
1409
+ # device, in meters. are (optional): The radius, in meters, that specifies the
1410
+ # vertical accuracy of the coordinates. Specify this key only if you specify
1411
+ # the alt key. Although many of the keys are optional, the more information
1412
+ # that you provide, the more accurate the location results are. Although
1413
+ # optional, you are encouraged to always specify the user's geographical
1414
+ # location. Providing the location is especially important if the client's IP
1415
+ # address does not accurately reflect the user's physical location (for
1416
+ # example, if the client uses VPN). For optimal results, you should include
1417
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
1418
+ # include this header.
1419
+ # @param country_code [String] A 2-character country code of the country where
1420
+ # the results come from. This API supports only the United States market. If
1421
+ # you specify this query parameter, it must be set to us. If you set this
1422
+ # parameter, you must also specify the Accept-Language header. Bing uses the
1423
+ # first supported language it finds from the languages list, and combine that
1424
+ # language with the country code that you specify to determine the market to
1425
+ # return results for. If the languages list does not include a supported
1426
+ # language, Bing finds the closest language and market that supports the
1427
+ # request, or it may use an aggregated or default market for the results
1428
+ # instead of a specified one. You should use this query parameter and the
1429
+ # Accept-Language query parameter only if you specify multiple languages;
1430
+ # otherwise, you should use the mkt and setLang query parameters. This
1431
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
1432
+ # both.
1433
+ # @param category [String] The category of articles to return. For example,
1434
+ # Sports articles or Entertainment articles. For a list of possible categories,
1435
+ # see [News Categories by
1436
+ # Market](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#categories-by-market).
1437
+ # Use this parameter only with News Category API. If you do not specify this
1438
+ # parameter, the response includes both: Headline articles typically published
1439
+ # in the last 24 hours from any category and articles from each parent category
1440
+ # (up to four articles). If the article is a headline, the article's headline
1441
+ # field is set to true. By default, the response includes up to 12 headline
1442
+ # articles. To specify the number of headline articles to return, set the
1443
+ # [headlineCount](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#headlineCount)
1444
+ # query parameter.
1445
+ # @param count [Integer] The number of news articles to return in the response.
1446
+ # The actual number delivered may be less than requested. The default is 10 and
1447
+ # the maximum value is 100. The actual number delivered may be less than
1448
+ # requested.You may use this parameter along with the offset parameter to page
1449
+ # results. For example, if your user interface displays 20 articles per page,
1450
+ # set count to 20 and offset to 0 to get the first page of results. For each
1451
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
1452
+ # possible for multiple pages to include some overlap in results. If you do not
1453
+ # specify the
1454
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1455
+ # parameter, Bing ignores this parameter.
1456
+ # @param headline_count [Integer] The number of headline articles to return in
1457
+ # the response. The default is 12. Specify this parameter only if you do not
1458
+ # specify the
1459
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1460
+ # parameter.
1461
+ # @param market [String] The market where the results come from. Typically, mkt
1462
+ # is the country where the user is making the request from. However, it could
1463
+ # be a different country if the user is not located in a country where Bing
1464
+ # delivers results. The market must be in the form <language code>-<country
1465
+ # code>. For example, en-US. The string is case insensitive. For a list of
1466
+ # possible market values, see [Market
1467
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
1468
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
1469
+ # the market helps Bing route the request and return an appropriate and optimal
1470
+ # response. If you specify a market that is not listed in [Market
1471
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
1472
+ # Bing uses a best fit market code based on an internal mapping that is subject
1473
+ # to change. This parameter and the
1474
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1475
+ # query parameter are mutually exclusive—do not specify both.
1476
+ # @param offset [Integer] The zero-based offset that indicates the number of
1477
+ # news to skip before returning news. The default is 0. The offset should be
1478
+ # less than
1479
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
1480
+ # - count). Use this parameter along with the count parameter to page results.
1481
+ # For example, if your user interface displays 20 news per page, set count to
1482
+ # 20 and offset to 0 to get the first page of results. For each subsequent
1483
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
1484
+ # multiple pages to include some overlap in results. If you do not specify the
1485
+ # [category](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#category)
1486
+ # parameter, Bing ignores this parameter.
1487
+ # @param original_image [Boolean] A Boolean value that determines whether the
1488
+ # image's contentUrl contains a URL that points to a thumbnail of the original
1489
+ # article's image or the image itself. If the article includes an image, and
1490
+ # this parameter is set to true, the image's contentUrl property contains a URL
1491
+ # that you may use to download the original image from the publisher's website.
1492
+ # Otherwise, if this parameter is false, the image's contentUrl and
1493
+ # thumbnailUrl URLs both point to the same thumbnail image. Use this parameter
1494
+ # only with the News Search API or News Category API. Trending Topics API
1495
+ # ignore this parameter.
1496
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
1497
+ # are the possible filter values. Off: Return news articles with adult text,
1498
+ # images, or videos. Moderate: Return news articles with adult text but not
1499
+ # adult images or videos. Strict: Do not return news articles with adult text,
1500
+ # images, or videos. If the request comes from a market that Bing's adult
1501
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
1502
+ # value and uses Strict. If you use the site: query operator, there is the
1503
+ # chance that the response may contain adult content regardless of what the
1504
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
1505
+ # content on the site and your scenario supports the possibility of adult
1506
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
1507
+ # @param set_lang [String] The language to use for user interface strings.
1508
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
1509
+ # the language code for English is EN. The default is EN (English). Although
1510
+ # optional, you should always specify the language. Typically, you set setLang
1511
+ # to the same language specified by mkt unless the user wants the user
1512
+ # interface strings displayed in a different language. This parameter and the
1513
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
1514
+ # header are mutually exclusive; do not specify both. A user interface string
1515
+ # is a string that's used as a label in a user interface. There are few user
1516
+ # interface strings in the JSON response objects. Also, any links to Bing.com
1517
+ # properties in the response objects apply the specified language.
1518
+ # @param text_decorations [Boolean] A Boolean value that determines whether
1519
+ # display strings contain decoration markers such as hit highlighting
1520
+ # characters. If true, the strings may include markers. The default is false.
1521
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
1522
+ # the
1523
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
1524
+ # query parameter. For information about hit highlighting, see [Hit
1525
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
1526
+ # @param text_format [TextFormat] The type of markers to use for text
1527
+ # decorations (see the textDecorations query parameter). Possible values are
1528
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
1529
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
1530
+ # E000 and E001 to mark the beginning and end of query terms for hit
1531
+ # highlighting. HTML—Use HTML tags to mark content that needs special
1532
+ # formatting. For example, use <b> tags to highlight query terms in display
1533
+ # strings. The default is Raw. For display strings that contain escapable HTML
1534
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
1535
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
1536
+ # values include: 'Raw', 'Html'
1537
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1538
+ # to the HTTP request.
1539
+ #
1540
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1541
+ #
1542
+ def category_async(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, category:nil, count:nil, headline_count:nil, market:nil, offset:nil, original_image:nil, safe_search:nil, set_lang:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
1543
+ x_bing_apis_sdk = 'true'
1544
+
1545
+
1546
+ request_headers = {}
1547
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1548
+
1549
+ # Set Headers
1550
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1551
+ request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
1552
+ request_headers['Accept-Language'] = accept_language unless accept_language.nil?
1553
+ request_headers['User-Agent'] = user_agent unless user_agent.nil?
1554
+ request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
1555
+ request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
1556
+ request_headers['X-Search-Location'] = location unless location.nil?
1557
+ path_template = 'news'
1558
+
1559
+ request_url = @base_url || @client.base_url
1560
+
1561
+ options = {
1562
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1563
+ query_params: {'cc' => country_code,'category' => category,'count' => count,'headlineCount' => headline_count,'mkt' => market,'offset' => offset,'originalImg' => original_image,'safeSearch' => safe_search,'setLang' => set_lang,'textDecorations' => text_decorations,'textFormat' => text_format},
1564
+ headers: request_headers.merge(custom_headers || {}),
1565
+ base_url: request_url
1566
+ }
1567
+ promise = @client.make_request_async(:get, path_template, options)
1568
+
1569
+ promise = promise.then do |result|
1570
+ http_response = result.response
1571
+ status_code = http_response.status
1572
+ response_content = http_response.body
1573
+ unless status_code == 200
1574
+ error_model = JSON.load(response_content)
1575
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1576
+ end
1577
+
1578
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1579
+ # Deserialize Response
1580
+ if status_code == 200
1581
+ begin
1582
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1583
+ result_mapper = Azure::CognitiveServices::NewsSearch::V1_0::Models::News.mapper()
1584
+ result.body = @client.deserialize(result_mapper, parsed_response)
1585
+ rescue Exception => e
1586
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1587
+ end
1588
+ end
1589
+
1590
+ result
1591
+ end
1592
+
1593
+ promise.execute
1594
+ end
1595
+
1596
+ #
1597
+ # The News Trending Topics API lets lets you search on Bing and get back a list
1598
+ # of trending news topics that are currently trending on Bing. This section
1599
+ # provides technical details about the query parameters and headers that you
1600
+ # use to request news and the JSON response objects that contain them. For
1601
+ # examples that show how to make requests, see [Searching the web for
1602
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
1603
+ #
1604
+ # @param accept_language [String] A comma-delimited list of one or more
1605
+ # languages to use for user interface strings. The list is in decreasing order
1606
+ # of preference. For additional information, including expected format, see
1607
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
1608
+ # header and the
1609
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1610
+ # query parameter are mutually exclusive; do not specify both. If you set this
1611
+ # header, you must also specify the
1612
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1613
+ # query parameter. To determine the market to return results for, Bing uses the
1614
+ # first supported language it finds from the list and combines it with the cc
1615
+ # parameter value. If the list does not include a supported language, Bing
1616
+ # finds the closest language and market that supports the request or it uses an
1617
+ # aggregated or default market for the results. To determine the market that
1618
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
1619
+ # parameter only if you specify multiple languages. Otherwise, use the
1620
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
1621
+ # and
1622
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1623
+ # query parameters. A user interface string is a string that's used as a label
1624
+ # in a user interface. There are few user interface strings in the JSON
1625
+ # response objects. Any links to Bing.com properties in the response objects
1626
+ # apply the specified language.
1627
+ # @param user_agent [String] The user agent originating the request. Bing uses
1628
+ # the user agent to provide mobile users with an optimized experience. Although
1629
+ # optional, you are encouraged to always specify this header. The user-agent
1630
+ # should be the same string that any commonly used browser sends. For
1631
+ # information about user agents, see [RFC
1632
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
1633
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
1634
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
1635
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
1636
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
1637
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
1638
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
1639
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
1640
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
1641
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
1642
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
1643
+ # @param client_id [String] Bing uses this header to provide users with
1644
+ # consistent behavior across Bing API calls. Bing often flights new features
1645
+ # and improvements, and it uses the client ID as a key for assigning traffic on
1646
+ # different flights. If you do not use the same client ID for a user across
1647
+ # multiple requests, then Bing may assign the user to multiple conflicting
1648
+ # flights. Being assigned to multiple conflicting flights can lead to an
1649
+ # inconsistent user experience. For example, if the second request has a
1650
+ # different flight assignment than the first, the experience may be unexpected.
1651
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
1652
+ # search history, providing a richer experience for the user. Bing also uses
1653
+ # this header to help improve result rankings by analyzing the activity
1654
+ # generated by a client ID. The relevance improvements help with better quality
1655
+ # of results delivered by Bing APIs and in turn enables higher click-through
1656
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
1657
+ # this header required. Persisting the client ID across multiple requests for
1658
+ # the same end user and device combination enables 1) the API consumer to
1659
+ # receive a consistent user experience, and 2) higher click-through rates via
1660
+ # better quality of results from the Bing APIs. Each user that uses your
1661
+ # application on the device must have a unique, Bing generated client ID. If
1662
+ # you do not include this header in the request, Bing generates an ID and
1663
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
1664
+ # should NOT include this header in a request is the first time the user uses
1665
+ # your app on that device. Use the client ID for each Bing API request that
1666
+ # your app makes for this user on the device. Persist the client ID. To persist
1667
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
1668
+ # used across all sessions. Do not use a session cookie. For other apps such as
1669
+ # mobile apps, use the device's persistent storage to persist the ID. The next
1670
+ # time the user uses your app on that device, get the client ID that you
1671
+ # persisted. Bing responses may or may not include this header. If the response
1672
+ # includes this header, capture the client ID and use it for all subsequent
1673
+ # Bing requests for the user on that device. If you include the
1674
+ # X-MSEdge-ClientID, you must not include cookies in the request.
1675
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
1676
+ # IP address is used to discover the user's location. Bing uses the location
1677
+ # information to determine safe search behavior. Although optional, you are
1678
+ # encouraged to always specify this header and the X-Search-Location header. Do
1679
+ # not obfuscate the address (for example, by changing the last octet to 0).
1680
+ # Obfuscating the address results in the location not being anywhere near the
1681
+ # device's actual location, which may result in Bing serving erroneous results.
1682
+ # @param location [String] A semicolon-delimited list of key/value pairs that
1683
+ # describe the client's geographical location. Bing uses the location
1684
+ # information to determine safe search behavior and to return relevant local
1685
+ # content. Specify the key/value pair as <key>:<value>. The following are the
1686
+ # keys that you use to specify the user's location. lat (required): The
1687
+ # latitude of the client's location, in degrees. The latitude must be greater
1688
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
1689
+ # indicate southern latitudes and positive values indicate northern latitudes.
1690
+ # long (required): The longitude of the client's location, in degrees. The
1691
+ # longitude must be greater than or equal to -180.0 and less than or equal to
1692
+ # +180.0. Negative values indicate western longitudes and positive values
1693
+ # indicate eastern longitudes. re (required): The radius, in meters, which
1694
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
1695
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
1696
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
1697
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
1698
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
1699
+ # (optional): The client's relative heading or direction of travel. Specify the
1700
+ # direction of travel as degrees from 0 through 360, counting clockwise
1701
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
1702
+ # (optional): The horizontal velocity (speed), in meters per second, that the
1703
+ # client device is traveling. alt (optional): The altitude of the client
1704
+ # device, in meters. are (optional): The radius, in meters, that specifies the
1705
+ # vertical accuracy of the coordinates. Specify this key only if you specify
1706
+ # the alt key. Although many of the keys are optional, the more information
1707
+ # that you provide, the more accurate the location results are. Although
1708
+ # optional, you are encouraged to always specify the user's geographical
1709
+ # location. Providing the location is especially important if the client's IP
1710
+ # address does not accurately reflect the user's physical location (for
1711
+ # example, if the client uses VPN). For optimal results, you should include
1712
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
1713
+ # include this header.
1714
+ # @param country_code [String] A 2-character country code of the country where
1715
+ # the results come from. This API supports only the United States market. If
1716
+ # you specify this query parameter, it must be set to us. If you set this
1717
+ # parameter, you must also specify the Accept-Language header. Bing uses the
1718
+ # first supported language it finds from the languages list, and combine that
1719
+ # language with the country code that you specify to determine the market to
1720
+ # return results for. If the languages list does not include a supported
1721
+ # language, Bing finds the closest language and market that supports the
1722
+ # request, or it may use an aggregated or default market for the results
1723
+ # instead of a specified one. You should use this query parameter and the
1724
+ # Accept-Language query parameter only if you specify multiple languages;
1725
+ # otherwise, you should use the mkt and setLang query parameters. This
1726
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
1727
+ # both.
1728
+ # @param count [Integer] The number of news articles to return in the response.
1729
+ # The actual number delivered may be less than requested. The default is 10 and
1730
+ # the maximum value is 100. The actual number delivered may be less than
1731
+ # requested.You may use this parameter along with the offset parameter to page
1732
+ # results. For example, if your user interface displays 20 articles per page,
1733
+ # set count to 20 and offset to 0 to get the first page of results. For each
1734
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
1735
+ # possible for multiple pages to include some overlap in results.
1736
+ # @param market [String] The market where the results come from. Typically, mkt
1737
+ # is the country where the user is making the request from. However, it could
1738
+ # be a different country if the user is not located in a country where Bing
1739
+ # delivers results. The market must be in the form <language code>-<country
1740
+ # code>. For example, en-US. The string is case insensitive. For a list of
1741
+ # possible market values, see [Market
1742
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
1743
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
1744
+ # the market helps Bing route the request and return an appropriate and optimal
1745
+ # response. If you specify a market that is not listed in [Market
1746
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
1747
+ # Bing uses a best fit market code based on an internal mapping that is subject
1748
+ # to change. This parameter and the
1749
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1750
+ # query parameter are mutually exclusive—do not specify both.
1751
+ # @param offset [Integer] The zero-based offset that indicates the number of
1752
+ # news to skip before returning news. The default is 0. The offset should be
1753
+ # less than
1754
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
1755
+ # - count). Use this parameter along with the count parameter to page results.
1756
+ # For example, if your user interface displays 20 news per page, set count to
1757
+ # 20 and offset to 0 to get the first page of results. For each subsequent
1758
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
1759
+ # multiple pages to include some overlap in results.
1760
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
1761
+ # are the possible filter values. Off: Return news articles with adult text,
1762
+ # images, or videos. Moderate: Return news articles with adult text but not
1763
+ # adult images or videos. Strict: Do not return news articles with adult text,
1764
+ # images, or videos. If the request comes from a market that Bing's adult
1765
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
1766
+ # value and uses Strict. If you use the site: query operator, there is the
1767
+ # chance that the response may contain adult content regardless of what the
1768
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
1769
+ # content on the site and your scenario supports the possibility of adult
1770
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
1771
+ # @param set_lang [String] The language to use for user interface strings.
1772
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
1773
+ # the language code for English is EN. The default is EN (English). Although
1774
+ # optional, you should always specify the language. Typically, you set setLang
1775
+ # to the same language specified by mkt unless the user wants the user
1776
+ # interface strings displayed in a different language. This parameter and the
1777
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
1778
+ # header are mutually exclusive; do not specify both. A user interface string
1779
+ # is a string that's used as a label in a user interface. There are few user
1780
+ # interface strings in the JSON response objects. Also, any links to Bing.com
1781
+ # properties in the response objects apply the specified language.
1782
+ # @param since [Integer] The Unix epoch time (Unix timestamp) that Bing uses to
1783
+ # select the trending topics. Bing returns trending topics that it discovered
1784
+ # on or after the specified date and time, not the date the topic was
1785
+ # published. To use this parameter, also specify the sortBy parameter. Use this
1786
+ # parameter only with the News Trending Topics API. Do not specify this
1787
+ # parameter when calling the News Search API or News Category API.
1788
+ # @param sort_by [String] The order to return the news in. The following are
1789
+ # the possible case-insensitive values. Date: If the request is through the
1790
+ # News Search API, the response returns news articles sorted by date from the
1791
+ # most recent to the oldest. If the request is through the News Trending Topics
1792
+ # API, the response returns trending topics sorted by date from the most recent
1793
+ # to the oldest.
1794
+ # @param text_decorations [Boolean] A Boolean value that determines whether
1795
+ # display strings contain decoration markers such as hit highlighting
1796
+ # characters. If true, the strings may include markers. The default is false.
1797
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
1798
+ # the
1799
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
1800
+ # query parameter. For information about hit highlighting, see [Hit
1801
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
1802
+ # @param text_format [TextFormat] The type of markers to use for text
1803
+ # decorations (see the textDecorations query parameter). Possible values are
1804
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
1805
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
1806
+ # E000 and E001 to mark the beginning and end of query terms for hit
1807
+ # highlighting. HTML—Use HTML tags to mark content that needs special
1808
+ # formatting. For example, use <b> tags to highlight query terms in display
1809
+ # strings. The default is Raw. For display strings that contain escapable HTML
1810
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
1811
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
1812
+ # values include: 'Raw', 'Html'
1813
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1814
+ # will be added to the HTTP request.
1815
+ #
1816
+ # @return [TrendingTopics] operation results.
1817
+ #
1818
+ def trending(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:nil, offset:nil, safe_search:nil, set_lang:nil, since:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
1819
+ response = trending_async(accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, market:market, offset:offset, safe_search:safe_search, set_lang:set_lang, since:since, sort_by:sort_by, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
1820
+ response.body unless response.nil?
1821
+ end
1822
+
1823
+ #
1824
+ # The News Trending Topics API lets lets you search on Bing and get back a list
1825
+ # of trending news topics that are currently trending on Bing. This section
1826
+ # provides technical details about the query parameters and headers that you
1827
+ # use to request news and the JSON response objects that contain them. For
1828
+ # examples that show how to make requests, see [Searching the web for
1829
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
1830
+ #
1831
+ # @param accept_language [String] A comma-delimited list of one or more
1832
+ # languages to use for user interface strings. The list is in decreasing order
1833
+ # of preference. For additional information, including expected format, see
1834
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
1835
+ # header and the
1836
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1837
+ # query parameter are mutually exclusive; do not specify both. If you set this
1838
+ # header, you must also specify the
1839
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1840
+ # query parameter. To determine the market to return results for, Bing uses the
1841
+ # first supported language it finds from the list and combines it with the cc
1842
+ # parameter value. If the list does not include a supported language, Bing
1843
+ # finds the closest language and market that supports the request or it uses an
1844
+ # aggregated or default market for the results. To determine the market that
1845
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
1846
+ # parameter only if you specify multiple languages. Otherwise, use the
1847
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
1848
+ # and
1849
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
1850
+ # query parameters. A user interface string is a string that's used as a label
1851
+ # in a user interface. There are few user interface strings in the JSON
1852
+ # response objects. Any links to Bing.com properties in the response objects
1853
+ # apply the specified language.
1854
+ # @param user_agent [String] The user agent originating the request. Bing uses
1855
+ # the user agent to provide mobile users with an optimized experience. Although
1856
+ # optional, you are encouraged to always specify this header. The user-agent
1857
+ # should be the same string that any commonly used browser sends. For
1858
+ # information about user agents, see [RFC
1859
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
1860
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
1861
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
1862
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
1863
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
1864
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
1865
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
1866
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
1867
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
1868
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
1869
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
1870
+ # @param client_id [String] Bing uses this header to provide users with
1871
+ # consistent behavior across Bing API calls. Bing often flights new features
1872
+ # and improvements, and it uses the client ID as a key for assigning traffic on
1873
+ # different flights. If you do not use the same client ID for a user across
1874
+ # multiple requests, then Bing may assign the user to multiple conflicting
1875
+ # flights. Being assigned to multiple conflicting flights can lead to an
1876
+ # inconsistent user experience. For example, if the second request has a
1877
+ # different flight assignment than the first, the experience may be unexpected.
1878
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
1879
+ # search history, providing a richer experience for the user. Bing also uses
1880
+ # this header to help improve result rankings by analyzing the activity
1881
+ # generated by a client ID. The relevance improvements help with better quality
1882
+ # of results delivered by Bing APIs and in turn enables higher click-through
1883
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
1884
+ # this header required. Persisting the client ID across multiple requests for
1885
+ # the same end user and device combination enables 1) the API consumer to
1886
+ # receive a consistent user experience, and 2) higher click-through rates via
1887
+ # better quality of results from the Bing APIs. Each user that uses your
1888
+ # application on the device must have a unique, Bing generated client ID. If
1889
+ # you do not include this header in the request, Bing generates an ID and
1890
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
1891
+ # should NOT include this header in a request is the first time the user uses
1892
+ # your app on that device. Use the client ID for each Bing API request that
1893
+ # your app makes for this user on the device. Persist the client ID. To persist
1894
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
1895
+ # used across all sessions. Do not use a session cookie. For other apps such as
1896
+ # mobile apps, use the device's persistent storage to persist the ID. The next
1897
+ # time the user uses your app on that device, get the client ID that you
1898
+ # persisted. Bing responses may or may not include this header. If the response
1899
+ # includes this header, capture the client ID and use it for all subsequent
1900
+ # Bing requests for the user on that device. If you include the
1901
+ # X-MSEdge-ClientID, you must not include cookies in the request.
1902
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
1903
+ # IP address is used to discover the user's location. Bing uses the location
1904
+ # information to determine safe search behavior. Although optional, you are
1905
+ # encouraged to always specify this header and the X-Search-Location header. Do
1906
+ # not obfuscate the address (for example, by changing the last octet to 0).
1907
+ # Obfuscating the address results in the location not being anywhere near the
1908
+ # device's actual location, which may result in Bing serving erroneous results.
1909
+ # @param location [String] A semicolon-delimited list of key/value pairs that
1910
+ # describe the client's geographical location. Bing uses the location
1911
+ # information to determine safe search behavior and to return relevant local
1912
+ # content. Specify the key/value pair as <key>:<value>. The following are the
1913
+ # keys that you use to specify the user's location. lat (required): The
1914
+ # latitude of the client's location, in degrees. The latitude must be greater
1915
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
1916
+ # indicate southern latitudes and positive values indicate northern latitudes.
1917
+ # long (required): The longitude of the client's location, in degrees. The
1918
+ # longitude must be greater than or equal to -180.0 and less than or equal to
1919
+ # +180.0. Negative values indicate western longitudes and positive values
1920
+ # indicate eastern longitudes. re (required): The radius, in meters, which
1921
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
1922
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
1923
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
1924
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
1925
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
1926
+ # (optional): The client's relative heading or direction of travel. Specify the
1927
+ # direction of travel as degrees from 0 through 360, counting clockwise
1928
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
1929
+ # (optional): The horizontal velocity (speed), in meters per second, that the
1930
+ # client device is traveling. alt (optional): The altitude of the client
1931
+ # device, in meters. are (optional): The radius, in meters, that specifies the
1932
+ # vertical accuracy of the coordinates. Specify this key only if you specify
1933
+ # the alt key. Although many of the keys are optional, the more information
1934
+ # that you provide, the more accurate the location results are. Although
1935
+ # optional, you are encouraged to always specify the user's geographical
1936
+ # location. Providing the location is especially important if the client's IP
1937
+ # address does not accurately reflect the user's physical location (for
1938
+ # example, if the client uses VPN). For optimal results, you should include
1939
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
1940
+ # include this header.
1941
+ # @param country_code [String] A 2-character country code of the country where
1942
+ # the results come from. This API supports only the United States market. If
1943
+ # you specify this query parameter, it must be set to us. If you set this
1944
+ # parameter, you must also specify the Accept-Language header. Bing uses the
1945
+ # first supported language it finds from the languages list, and combine that
1946
+ # language with the country code that you specify to determine the market to
1947
+ # return results for. If the languages list does not include a supported
1948
+ # language, Bing finds the closest language and market that supports the
1949
+ # request, or it may use an aggregated or default market for the results
1950
+ # instead of a specified one. You should use this query parameter and the
1951
+ # Accept-Language query parameter only if you specify multiple languages;
1952
+ # otherwise, you should use the mkt and setLang query parameters. This
1953
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
1954
+ # both.
1955
+ # @param count [Integer] The number of news articles to return in the response.
1956
+ # The actual number delivered may be less than requested. The default is 10 and
1957
+ # the maximum value is 100. The actual number delivered may be less than
1958
+ # requested.You may use this parameter along with the offset parameter to page
1959
+ # results. For example, if your user interface displays 20 articles per page,
1960
+ # set count to 20 and offset to 0 to get the first page of results. For each
1961
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
1962
+ # possible for multiple pages to include some overlap in results.
1963
+ # @param market [String] The market where the results come from. Typically, mkt
1964
+ # is the country where the user is making the request from. However, it could
1965
+ # be a different country if the user is not located in a country where Bing
1966
+ # delivers results. The market must be in the form <language code>-<country
1967
+ # code>. For example, en-US. The string is case insensitive. For a list of
1968
+ # possible market values, see [Market
1969
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
1970
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
1971
+ # the market helps Bing route the request and return an appropriate and optimal
1972
+ # response. If you specify a market that is not listed in [Market
1973
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
1974
+ # Bing uses a best fit market code based on an internal mapping that is subject
1975
+ # to change. This parameter and the
1976
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
1977
+ # query parameter are mutually exclusive—do not specify both.
1978
+ # @param offset [Integer] The zero-based offset that indicates the number of
1979
+ # news to skip before returning news. The default is 0. The offset should be
1980
+ # less than
1981
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
1982
+ # - count). Use this parameter along with the count parameter to page results.
1983
+ # For example, if your user interface displays 20 news per page, set count to
1984
+ # 20 and offset to 0 to get the first page of results. For each subsequent
1985
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
1986
+ # multiple pages to include some overlap in results.
1987
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
1988
+ # are the possible filter values. Off: Return news articles with adult text,
1989
+ # images, or videos. Moderate: Return news articles with adult text but not
1990
+ # adult images or videos. Strict: Do not return news articles with adult text,
1991
+ # images, or videos. If the request comes from a market that Bing's adult
1992
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
1993
+ # value and uses Strict. If you use the site: query operator, there is the
1994
+ # chance that the response may contain adult content regardless of what the
1995
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
1996
+ # content on the site and your scenario supports the possibility of adult
1997
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
1998
+ # @param set_lang [String] The language to use for user interface strings.
1999
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
2000
+ # the language code for English is EN. The default is EN (English). Although
2001
+ # optional, you should always specify the language. Typically, you set setLang
2002
+ # to the same language specified by mkt unless the user wants the user
2003
+ # interface strings displayed in a different language. This parameter and the
2004
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
2005
+ # header are mutually exclusive; do not specify both. A user interface string
2006
+ # is a string that's used as a label in a user interface. There are few user
2007
+ # interface strings in the JSON response objects. Also, any links to Bing.com
2008
+ # properties in the response objects apply the specified language.
2009
+ # @param since [Integer] The Unix epoch time (Unix timestamp) that Bing uses to
2010
+ # select the trending topics. Bing returns trending topics that it discovered
2011
+ # on or after the specified date and time, not the date the topic was
2012
+ # published. To use this parameter, also specify the sortBy parameter. Use this
2013
+ # parameter only with the News Trending Topics API. Do not specify this
2014
+ # parameter when calling the News Search API or News Category API.
2015
+ # @param sort_by [String] The order to return the news in. The following are
2016
+ # the possible case-insensitive values. Date: If the request is through the
2017
+ # News Search API, the response returns news articles sorted by date from the
2018
+ # most recent to the oldest. If the request is through the News Trending Topics
2019
+ # API, the response returns trending topics sorted by date from the most recent
2020
+ # to the oldest.
2021
+ # @param text_decorations [Boolean] A Boolean value that determines whether
2022
+ # display strings contain decoration markers such as hit highlighting
2023
+ # characters. If true, the strings may include markers. The default is false.
2024
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
2025
+ # the
2026
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
2027
+ # query parameter. For information about hit highlighting, see [Hit
2028
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
2029
+ # @param text_format [TextFormat] The type of markers to use for text
2030
+ # decorations (see the textDecorations query parameter). Possible values are
2031
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
2032
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
2033
+ # E000 and E001 to mark the beginning and end of query terms for hit
2034
+ # highlighting. HTML—Use HTML tags to mark content that needs special
2035
+ # formatting. For example, use <b> tags to highlight query terms in display
2036
+ # strings. The default is Raw. For display strings that contain escapable HTML
2037
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
2038
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
2039
+ # values include: 'Raw', 'Html'
2040
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2041
+ # will be added to the HTTP request.
2042
+ #
2043
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2044
+ #
2045
+ def trending_with_http_info(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:nil, offset:nil, safe_search:nil, set_lang:nil, since:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
2046
+ trending_async(accept_language:accept_language, user_agent:user_agent, client_id:client_id, client_ip:client_ip, location:location, country_code:country_code, count:count, market:market, offset:offset, safe_search:safe_search, set_lang:set_lang, since:since, sort_by:sort_by, text_decorations:text_decorations, text_format:text_format, custom_headers:custom_headers).value!
2047
+ end
2048
+
2049
+ #
2050
+ # The News Trending Topics API lets lets you search on Bing and get back a list
2051
+ # of trending news topics that are currently trending on Bing. This section
2052
+ # provides technical details about the query parameters and headers that you
2053
+ # use to request news and the JSON response objects that contain them. For
2054
+ # examples that show how to make requests, see [Searching the web for
2055
+ # news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
2056
+ #
2057
+ # @param accept_language [String] A comma-delimited list of one or more
2058
+ # languages to use for user interface strings. The list is in decreasing order
2059
+ # of preference. For additional information, including expected format, see
2060
+ # [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
2061
+ # header and the
2062
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
2063
+ # query parameter are mutually exclusive; do not specify both. If you set this
2064
+ # header, you must also specify the
2065
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
2066
+ # query parameter. To determine the market to return results for, Bing uses the
2067
+ # first supported language it finds from the list and combines it with the cc
2068
+ # parameter value. If the list does not include a supported language, Bing
2069
+ # finds the closest language and market that supports the request or it uses an
2070
+ # aggregated or default market for the results. To determine the market that
2071
+ # Bing used, see the BingAPIs-Market header. Use this header and the cc query
2072
+ # parameter only if you specify multiple languages. Otherwise, use the
2073
+ # [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#mkt)
2074
+ # and
2075
+ # [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#setlang)
2076
+ # query parameters. A user interface string is a string that's used as a label
2077
+ # in a user interface. There are few user interface strings in the JSON
2078
+ # response objects. Any links to Bing.com properties in the response objects
2079
+ # apply the specified language.
2080
+ # @param user_agent [String] The user agent originating the request. Bing uses
2081
+ # the user agent to provide mobile users with an optimized experience. Although
2082
+ # optional, you are encouraged to always specify this header. The user-agent
2083
+ # should be the same string that any commonly used browser sends. For
2084
+ # information about user agents, see [RFC
2085
+ # 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following
2086
+ # are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible;
2087
+ # MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA;
2088
+ # Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH -
2089
+ # I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version /
2090
+ # 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1
2091
+ # like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142
2092
+ # iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
2093
+ # WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad;
2094
+ # CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version
2095
+ # / 7.0 Mobile / 11A465 Safari / 9537.53
2096
+ # @param client_id [String] Bing uses this header to provide users with
2097
+ # consistent behavior across Bing API calls. Bing often flights new features
2098
+ # and improvements, and it uses the client ID as a key for assigning traffic on
2099
+ # different flights. If you do not use the same client ID for a user across
2100
+ # multiple requests, then Bing may assign the user to multiple conflicting
2101
+ # flights. Being assigned to multiple conflicting flights can lead to an
2102
+ # inconsistent user experience. For example, if the second request has a
2103
+ # different flight assignment than the first, the experience may be unexpected.
2104
+ # Also, Bing can use the client ID to tailor web results to that client ID’s
2105
+ # search history, providing a richer experience for the user. Bing also uses
2106
+ # this header to help improve result rankings by analyzing the activity
2107
+ # generated by a client ID. The relevance improvements help with better quality
2108
+ # of results delivered by Bing APIs and in turn enables higher click-through
2109
+ # rates for the API consumer. IMPORTANT: Although optional, you should consider
2110
+ # this header required. Persisting the client ID across multiple requests for
2111
+ # the same end user and device combination enables 1) the API consumer to
2112
+ # receive a consistent user experience, and 2) higher click-through rates via
2113
+ # better quality of results from the Bing APIs. Each user that uses your
2114
+ # application on the device must have a unique, Bing generated client ID. If
2115
+ # you do not include this header in the request, Bing generates an ID and
2116
+ # returns it in the X-MSEdge-ClientID response header. The only time that you
2117
+ # should NOT include this header in a request is the first time the user uses
2118
+ # your app on that device. Use the client ID for each Bing API request that
2119
+ # your app makes for this user on the device. Persist the client ID. To persist
2120
+ # the ID in a browser app, use a persistent HTTP cookie to ensure the ID is
2121
+ # used across all sessions. Do not use a session cookie. For other apps such as
2122
+ # mobile apps, use the device's persistent storage to persist the ID. The next
2123
+ # time the user uses your app on that device, get the client ID that you
2124
+ # persisted. Bing responses may or may not include this header. If the response
2125
+ # includes this header, capture the client ID and use it for all subsequent
2126
+ # Bing requests for the user on that device. If you include the
2127
+ # X-MSEdge-ClientID, you must not include cookies in the request.
2128
+ # @param client_ip [String] The IPv4 or IPv6 address of the client device. The
2129
+ # IP address is used to discover the user's location. Bing uses the location
2130
+ # information to determine safe search behavior. Although optional, you are
2131
+ # encouraged to always specify this header and the X-Search-Location header. Do
2132
+ # not obfuscate the address (for example, by changing the last octet to 0).
2133
+ # Obfuscating the address results in the location not being anywhere near the
2134
+ # device's actual location, which may result in Bing serving erroneous results.
2135
+ # @param location [String] A semicolon-delimited list of key/value pairs that
2136
+ # describe the client's geographical location. Bing uses the location
2137
+ # information to determine safe search behavior and to return relevant local
2138
+ # content. Specify the key/value pair as <key>:<value>. The following are the
2139
+ # keys that you use to specify the user's location. lat (required): The
2140
+ # latitude of the client's location, in degrees. The latitude must be greater
2141
+ # than or equal to -90.0 and less than or equal to +90.0. Negative values
2142
+ # indicate southern latitudes and positive values indicate northern latitudes.
2143
+ # long (required): The longitude of the client's location, in degrees. The
2144
+ # longitude must be greater than or equal to -180.0 and less than or equal to
2145
+ # +180.0. Negative values indicate western longitudes and positive values
2146
+ # indicate eastern longitudes. re (required): The radius, in meters, which
2147
+ # specifies the horizontal accuracy of the coordinates. Pass the value returned
2148
+ # by the device's location service. Typical values might be 22m for GPS/Wi-Fi,
2149
+ # 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts
2150
+ # (optional): The UTC UNIX timestamp of when the client was at the location.
2151
+ # (The UNIX timestamp is the number of seconds since January 1, 1970.) head
2152
+ # (optional): The client's relative heading or direction of travel. Specify the
2153
+ # direction of travel as degrees from 0 through 360, counting clockwise
2154
+ # relative to true north. Specify this key only if the sp key is nonzero. sp
2155
+ # (optional): The horizontal velocity (speed), in meters per second, that the
2156
+ # client device is traveling. alt (optional): The altitude of the client
2157
+ # device, in meters. are (optional): The radius, in meters, that specifies the
2158
+ # vertical accuracy of the coordinates. Specify this key only if you specify
2159
+ # the alt key. Although many of the keys are optional, the more information
2160
+ # that you provide, the more accurate the location results are. Although
2161
+ # optional, you are encouraged to always specify the user's geographical
2162
+ # location. Providing the location is especially important if the client's IP
2163
+ # address does not accurately reflect the user's physical location (for
2164
+ # example, if the client uses VPN). For optimal results, you should include
2165
+ # this header and the X-MSEdge-ClientIP header, but at a minimum, you should
2166
+ # include this header.
2167
+ # @param country_code [String] A 2-character country code of the country where
2168
+ # the results come from. This API supports only the United States market. If
2169
+ # you specify this query parameter, it must be set to us. If you set this
2170
+ # parameter, you must also specify the Accept-Language header. Bing uses the
2171
+ # first supported language it finds from the languages list, and combine that
2172
+ # language with the country code that you specify to determine the market to
2173
+ # return results for. If the languages list does not include a supported
2174
+ # language, Bing finds the closest language and market that supports the
2175
+ # request, or it may use an aggregated or default market for the results
2176
+ # instead of a specified one. You should use this query parameter and the
2177
+ # Accept-Language query parameter only if you specify multiple languages;
2178
+ # otherwise, you should use the mkt and setLang query parameters. This
2179
+ # parameter and the mkt query parameter are mutually exclusive—do not specify
2180
+ # both.
2181
+ # @param count [Integer] The number of news articles to return in the response.
2182
+ # The actual number delivered may be less than requested. The default is 10 and
2183
+ # the maximum value is 100. The actual number delivered may be less than
2184
+ # requested.You may use this parameter along with the offset parameter to page
2185
+ # results. For example, if your user interface displays 20 articles per page,
2186
+ # set count to 20 and offset to 0 to get the first page of results. For each
2187
+ # subsequent page, increment offset by 20 (for example, 0, 20, 40). It is
2188
+ # possible for multiple pages to include some overlap in results.
2189
+ # @param market [String] The market where the results come from. Typically, mkt
2190
+ # is the country where the user is making the request from. However, it could
2191
+ # be a different country if the user is not located in a country where Bing
2192
+ # delivers results. The market must be in the form <language code>-<country
2193
+ # code>. For example, en-US. The string is case insensitive. For a list of
2194
+ # possible market values, see [Market
2195
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes).
2196
+ # NOTE: If known, you are encouraged to always specify the market. Specifying
2197
+ # the market helps Bing route the request and return an appropriate and optimal
2198
+ # response. If you specify a market that is not listed in [Market
2199
+ # Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#market-codes),
2200
+ # Bing uses a best fit market code based on an internal mapping that is subject
2201
+ # to change. This parameter and the
2202
+ # [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#cc)
2203
+ # query parameter are mutually exclusive—do not specify both.
2204
+ # @param offset [Integer] The zero-based offset that indicates the number of
2205
+ # news to skip before returning news. The default is 0. The offset should be
2206
+ # less than
2207
+ # ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#news-totalmatches)
2208
+ # - count). Use this parameter along with the count parameter to page results.
2209
+ # For example, if your user interface displays 20 news per page, set count to
2210
+ # 20 and offset to 0 to get the first page of results. For each subsequent
2211
+ # page, increment offset by 20 (for example, 0, 20, 40). It is possible for
2212
+ # multiple pages to include some overlap in results.
2213
+ # @param safe_search [SafeSearch] Filter news for adult content. The following
2214
+ # are the possible filter values. Off: Return news articles with adult text,
2215
+ # images, or videos. Moderate: Return news articles with adult text but not
2216
+ # adult images or videos. Strict: Do not return news articles with adult text,
2217
+ # images, or videos. If the request comes from a market that Bing's adult
2218
+ # policy requires that safeSearch is set to Strict, Bing ignores the safeSearch
2219
+ # value and uses Strict. If you use the site: query operator, there is the
2220
+ # chance that the response may contain adult content regardless of what the
2221
+ # safeSearch query parameter is set to. Use site: only if you are aware of the
2222
+ # content on the site and your scenario supports the possibility of adult
2223
+ # content. Possible values include: 'Off', 'Moderate', 'Strict'
2224
+ # @param set_lang [String] The language to use for user interface strings.
2225
+ # Specify the language using the ISO 639-1 2-letter language code. For example,
2226
+ # the language code for English is EN. The default is EN (English). Although
2227
+ # optional, you should always specify the language. Typically, you set setLang
2228
+ # to the same language specified by mkt unless the user wants the user
2229
+ # interface strings displayed in a different language. This parameter and the
2230
+ # [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#acceptlanguage)
2231
+ # header are mutually exclusive; do not specify both. A user interface string
2232
+ # is a string that's used as a label in a user interface. There are few user
2233
+ # interface strings in the JSON response objects. Also, any links to Bing.com
2234
+ # properties in the response objects apply the specified language.
2235
+ # @param since [Integer] The Unix epoch time (Unix timestamp) that Bing uses to
2236
+ # select the trending topics. Bing returns trending topics that it discovered
2237
+ # on or after the specified date and time, not the date the topic was
2238
+ # published. To use this parameter, also specify the sortBy parameter. Use this
2239
+ # parameter only with the News Trending Topics API. Do not specify this
2240
+ # parameter when calling the News Search API or News Category API.
2241
+ # @param sort_by [String] The order to return the news in. The following are
2242
+ # the possible case-insensitive values. Date: If the request is through the
2243
+ # News Search API, the response returns news articles sorted by date from the
2244
+ # most recent to the oldest. If the request is through the News Trending Topics
2245
+ # API, the response returns trending topics sorted by date from the most recent
2246
+ # to the oldest.
2247
+ # @param text_decorations [Boolean] A Boolean value that determines whether
2248
+ # display strings contain decoration markers such as hit highlighting
2249
+ # characters. If true, the strings may include markers. The default is false.
2250
+ # To specify whether to use Unicode characters or HTML tags as the markers, see
2251
+ # the
2252
+ # [textFormat](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference#textformat)
2253
+ # query parameter. For information about hit highlighting, see [Hit
2254
+ # Highlighting](https://docs.microsoft.com/azure/cognitive-services/bing-news-search/hit-highlighting).
2255
+ # @param text_format [TextFormat] The type of markers to use for text
2256
+ # decorations (see the textDecorations query parameter). Possible values are
2257
+ # Raw—Use Unicode characters to mark content that needs special formatting. The
2258
+ # Unicode characters are in the range E000 through E019. For example, Bing uses
2259
+ # E000 and E001 to mark the beginning and end of query terms for hit
2260
+ # highlighting. HTML—Use HTML tags to mark content that needs special
2261
+ # formatting. For example, use <b> tags to highlight query terms in display
2262
+ # strings. The default is Raw. For display strings that contain escapable HTML
2263
+ # characters such as <, >, and &, if textFormat is set to HTML, Bing escapes
2264
+ # the characters as appropriate (for example, < is escaped to &lt;). Possible
2265
+ # values include: 'Raw', 'Html'
2266
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2267
+ # to the HTTP request.
2268
+ #
2269
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2270
+ #
2271
+ def trending_async(accept_language:nil, user_agent:nil, client_id:nil, client_ip:nil, location:nil, country_code:nil, count:nil, market:nil, offset:nil, safe_search:nil, set_lang:nil, since:nil, sort_by:nil, text_decorations:nil, text_format:nil, custom_headers:nil)
2272
+ x_bing_apis_sdk = 'true'
2273
+
2274
+
2275
+ request_headers = {}
2276
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2277
+
2278
+ # Set Headers
2279
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2280
+ request_headers['X-BingApis-SDK'] = x_bing_apis_sdk unless x_bing_apis_sdk.nil?
2281
+ request_headers['Accept-Language'] = accept_language unless accept_language.nil?
2282
+ request_headers['User-Agent'] = user_agent unless user_agent.nil?
2283
+ request_headers['X-MSEdge-ClientID'] = client_id unless client_id.nil?
2284
+ request_headers['X-MSEdge-ClientIP'] = client_ip unless client_ip.nil?
2285
+ request_headers['X-Search-Location'] = location unless location.nil?
2286
+ path_template = 'news/trendingtopics'
2287
+
2288
+ request_url = @base_url || @client.base_url
2289
+
2290
+ options = {
2291
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2292
+ query_params: {'cc' => country_code,'count' => count,'mkt' => market,'offset' => offset,'safeSearch' => safe_search,'setLang' => set_lang,'since' => since,'sortBy' => sort_by,'textDecorations' => text_decorations,'textFormat' => text_format},
2293
+ headers: request_headers.merge(custom_headers || {}),
2294
+ base_url: request_url
2295
+ }
2296
+ promise = @client.make_request_async(:get, path_template, options)
2297
+
2298
+ promise = promise.then do |result|
2299
+ http_response = result.response
2300
+ status_code = http_response.status
2301
+ response_content = http_response.body
2302
+ unless status_code == 200
2303
+ error_model = JSON.load(response_content)
2304
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2305
+ end
2306
+
2307
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2308
+ # Deserialize Response
2309
+ if status_code == 200
2310
+ begin
2311
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2312
+ result_mapper = Azure::CognitiveServices::NewsSearch::V1_0::Models::TrendingTopics.mapper()
2313
+ result.body = @client.deserialize(result_mapper, parsed_response)
2314
+ rescue Exception => e
2315
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2316
+ end
2317
+ end
2318
+
2319
+ result
2320
+ end
2321
+
2322
+ promise.execute
2323
+ end
2324
+
2325
+ end
2326
+ end