Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.
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
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Microsoft
Copyright (c) 2018 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
*/

import { ServiceClient, ServiceClientOptions, ServiceClientCredentials } from 'ms-rest';
import * as models from "./models";
import * as operations from "./operations";

declare class CustomSearchAPIClient extends ServiceClient {
export default class CustomSearchAPIClient extends ServiceClient {
/**
* @class
* Initializes a new instance of the CustomSearchAPIClient class.
Expand Down Expand Up @@ -39,4 +40,4 @@ declare class CustomSearchAPIClient extends ServiceClient {
customInstance: operations.CustomInstance;
}

export = CustomSearchAPIClient;
export { CustomSearchAPIClient, models as CustomSearchAPIModels };
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ class CustomSearchAPIClient extends ServiceClient {
}

module.exports = CustomSearchAPIClient;
module.exports['default'] = CustomSearchAPIClient;
module.exports.CustomSearchAPIClient = CustomSearchAPIClient;
module.exports.CustomSearchAPIModels = models;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const WebResource = msRest.WebResource;
* @summary 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.
*
* @param {number} customConfig The identifier for the custom search
* configuration
*
* @param {string} 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 specific domain, use the site: operator.
Expand Down Expand Up @@ -123,9 +126,6 @@ const WebResource = msRest.WebResource;
* optimal results, you should include this header and the X-MSEdge-ClientIP
* header, but at a minimum, you should include this header.
*
* @param {number} [options.customConfig] The identifier for the custom search
* configuration
*
* @param {string} [options.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 parameter, it must be set to us. If
Expand Down Expand Up @@ -229,7 +229,7 @@ const WebResource = msRest.WebResource;
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _search(query, options, callback) {
function _search(customConfig, query, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
Expand All @@ -244,7 +244,6 @@ function _search(query, options, callback) {
let clientId = (options && options.clientId !== undefined) ? options.clientId : undefined;
let clientIp = (options && options.clientIp !== undefined) ? options.clientIp : undefined;
let location = (options && options.location !== undefined) ? options.location : undefined;
let customConfig = (options && options.customConfig !== undefined) ? options.customConfig : undefined;
let countryCode = (options && options.countryCode !== undefined) ? options.countryCode : undefined;
let count = (options && options.count !== undefined) ? options.count : undefined;
let market = (options && options.market !== undefined) ? options.market : 'en-us';
Expand All @@ -271,8 +270,14 @@ function _search(query, options, callback) {
if (location !== null && location !== undefined && typeof location.valueOf() !== 'string') {
throw new Error('location must be of type string.');
}
if (customConfig !== null && customConfig !== undefined && typeof customConfig !== 'number') {
throw new Error('customConfig must be of type number.');
if (customConfig === null || customConfig === undefined || typeof customConfig !== 'number') {
throw new Error('customConfig cannot be null or undefined and it must be of type number.');
}
if (customConfig !== null && customConfig !== undefined) {
if (customConfig < 0)
{
throw new Error('"customConfig" should satisfy the constraint - "InclusiveMinimum": 0');
}
}
if (countryCode !== null && countryCode !== undefined && typeof countryCode.valueOf() !== 'string') {
throw new Error('countryCode must be of type string.');
Expand Down Expand Up @@ -309,9 +314,7 @@ function _search(query, options, callback) {
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'search';
let queryParameters = [];
if (customConfig !== null && customConfig !== undefined) {
queryParameters.push('customConfig=' + encodeURIComponent(customConfig.toString()));
}
queryParameters.push('customConfig=' + encodeURIComponent(customConfig.toString()));
if (countryCode !== null && countryCode !== undefined) {
queryParameters.push('cc=' + encodeURIComponent(countryCode));
}
Expand Down Expand Up @@ -446,6 +449,9 @@ class CustomInstance {
* @summary 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.
*
* @param {number} customConfig The identifier for the custom search
* configuration
*
* @param {string} 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 specific domain, use the site: operator.
Expand Down Expand Up @@ -552,9 +558,6 @@ class CustomInstance {
* optimal results, you should include this header and the X-MSEdge-ClientIP
* header, but at a minimum, you should include this header.
*
* @param {number} [options.customConfig] The identifier for the custom search
* configuration
*
* @param {string} [options.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 parameter, it must be set to us. If
Expand Down Expand Up @@ -651,11 +654,11 @@ class CustomInstance {
*
* @reject {Error} - The error object.
*/
searchWithHttpOperationResponse(query, options) {
searchWithHttpOperationResponse(customConfig, query, options) {
let client = this.client;
let self = this;
return new Promise((resolve, reject) => {
self._search(query, options, (err, result, request, response) => {
self._search(customConfig, query, options, (err, result, request, response) => {
let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
httpOperationResponse.body = result;
if (err) { reject(err); }
Expand All @@ -669,6 +672,9 @@ class CustomInstance {
* @summary 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.
*
* @param {number} customConfig The identifier for the custom search
* configuration
*
* @param {string} 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 specific domain, use the site: operator.
Expand Down Expand Up @@ -775,9 +781,6 @@ class CustomInstance {
* optimal results, you should include this header and the X-MSEdge-ClientIP
* header, but at a minimum, you should include this header.
*
* @param {number} [options.customConfig] The identifier for the custom search
* configuration
*
* @param {string} [options.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 parameter, it must be set to us. If
Expand Down Expand Up @@ -890,7 +893,7 @@ class CustomInstance {
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
search(query, options, optionalCallback) {
search(customConfig, query, options, optionalCallback) {
let client = this.client;
let self = this;
if (!optionalCallback && typeof options === 'function') {
Expand All @@ -899,14 +902,14 @@ class CustomInstance {
}
if (!optionalCallback) {
return new Promise((resolve, reject) => {
self._search(query, options, (err, result, request, response) => {
self._search(customConfig, query, options, (err, result, request, response) => {
if (err) { reject(err); }
else { resolve(result); }
return;
});
});
} else {
return self._search(query, options, optionalCallback);
return self._search(customConfig, query, options, optionalCallback);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export interface CustomInstance {
* @summary 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.
*
* @param {number} customConfig The identifier for the custom search
* configuration
*
* @param {string} 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 specific domain, use the site: operator.
Expand Down Expand Up @@ -131,9 +134,6 @@ export interface CustomInstance {
* optimal results, you should include this header and the X-MSEdge-ClientIP
* header, but at a minimum, you should include this header.
*
* @param {number} [options.customConfig] The identifier for the custom search
* configuration
*
* @param {string} [options.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 parameter, it must be set to us. If
Expand Down Expand Up @@ -230,12 +230,15 @@ export interface CustomInstance {
*
* @reject {Error|ServiceError} - The error object.
*/
searchWithHttpOperationResponse(query: string, options?: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, customConfig? : number, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.SearchResponse>>;
searchWithHttpOperationResponse(customConfig: number, query: string, options?: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }): Promise<HttpOperationResponse<models.SearchResponse>>;

/**
* @summary 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.
*
* @param {number} customConfig The identifier for the custom search
* configuration
*
* @param {string} 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 specific domain, use the site: operator.
Expand Down Expand Up @@ -342,9 +345,6 @@ export interface CustomInstance {
* optimal results, you should include this header and the X-MSEdge-ClientIP
* header, but at a minimum, you should include this header.
*
* @param {number} [options.customConfig] The identifier for the custom search
* configuration
*
* @param {string} [options.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 parameter, it must be set to us. If
Expand Down Expand Up @@ -457,7 +457,7 @@ export interface CustomInstance {
*
* {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur.
*/
search(query: string, options?: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, customConfig? : number, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.SearchResponse>;
search(query: string, callback: ServiceCallback<models.SearchResponse>): void;
search(query: string, options: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, customConfig? : number, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.SearchResponse>): void;
search(customConfig: number, query: string, options?: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }): Promise<models.SearchResponse>;
search(customConfig: number, query: string, callback: ServiceCallback<models.SearchResponse>): void;
search(customConfig: number, query: string, options: { acceptLanguage? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, count? : number, market? : string, offset? : number, safeSearch? : string, setLang? : string, textDecorations? : boolean, textFormat? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback<models.SearchResponse>): void;
}
Loading