Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing customConfig to long and making it a required parameter #4017

Merged
merged 2 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void CustomSearch()
HttpMockServer.Initialize(this.GetType().FullName, "CustomSearch");

ICustomSearchAPI client = new CustomSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());
var resp = client.CustomInstance.SearchAsync(query: "tom cruise").Result;
var resp = client.CustomInstance.SearchAsync(query: "tom cruise", customConfig: 0).Result;

Assert.NotNull(resp);
Assert.NotNull(resp.WebPages);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Entries": [
{
"RequestUri": "/bingcustomsearch/v7.0/search?mkt=en-us&q=tom%20cruise",
"RequestUri": "/bingcustomsearch/v7.0/search?customConfig=0&mkt=en-us&q=tom%20cruise",
"RequestMethod": "GET",
"RequestHeaders": {
"User-Agent": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// <auto-generated>
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
Expand Down Expand Up @@ -54,6 +50,9 @@ public CustomInstance(CustomSearchAPI client)
/// The Custom Search API lets you send a search query to Bing and get back web
/// pages found in your custom view of the web.
/// </summary>
/// <param name='customConfig'>
/// The identifier for the custom search configuration
/// </param>
/// <param name='query'>
/// The user's search query term. The term may not be empty. The term may
/// contain Bing Advanced Operators. For example, to limit results to a
Expand Down Expand Up @@ -164,9 +163,6 @@ public CustomInstance(CustomSearchAPI client)
/// should include this header and the X-MSEdge-ClientIP header, but at a
/// minimum, you should include this header.
/// </param>
/// <param name='customConfig'>
/// The identifier for the custom search configuration
/// </param>
/// <param name='countryCode'>
/// A 2-character country code of the country where the results come from. This
/// API supports only the United States market. If you specify this query
Expand Down Expand Up @@ -280,8 +276,12 @@ public CustomInstance(CustomSearchAPI client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<SearchResponse>> SearchWithHttpMessagesAsync(string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), int? customConfig = default(int?), string countryCode = default(string), int? count = default(int?), string market = "en-us", int? offset = default(int?), string safeSearch = default(string), string setLang = default(string), bool? textDecorations = default(bool?), string textFormat = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<SearchResponse>> SearchWithHttpMessagesAsync(long customConfig, string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string countryCode = default(string), int? count = default(int?), string market = "en-us", int? offset = default(int?), string safeSearch = default(string), string setLang = default(string), bool? textDecorations = default(bool?), string textFormat = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (customConfig < 0)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "customConfig", 0);
}
if (query == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "query");
Expand Down Expand Up @@ -317,10 +317,7 @@ public CustomInstance(CustomSearchAPI client)
var _baseUrl = Client.BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "search").ToString();
List<string> _queryParameters = new List<string>();
if (customConfig != null)
{
_queryParameters.Add(string.Format("customConfig={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(customConfig, Client.SerializationSettings).Trim('"'))));
}
_queryParameters.Add(string.Format("customConfig={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(customConfig, Client.SerializationSettings).Trim('"'))));
if (countryCode != null)
{
_queryParameters.Add(string.Format("cc={0}", System.Uri.EscapeDataString(countryCode)));
Expand Down Expand Up @@ -431,14 +428,12 @@ public CustomInstance(CustomSearchAPI client)

// Serialize Request
string _requestContent = null;

// Set Credentials
if (Client.Credentials != null)
{
cancellationToken.ThrowIfCancellationRequested();
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
}

// Send Request
if (_shouldTrace)
{
Expand Down
Loading