diff --git a/lib/services/cognitiveServicesLocalSearch/LICENSE.txt b/lib/services/cognitiveServicesLocalSearch/LICENSE.txt new file mode 100644 index 0000000000..a70e8cf660 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/lib/services/cognitiveServicesLocalSearch/README.md b/lib/services/cognitiveServicesLocalSearch/README.md new file mode 100644 index 0000000000..4fba0a89e9 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/README.md @@ -0,0 +1,61 @@ +--- +uid: azure-cognitiveservices-localsearch +summary: *content + +--- +**This SDK will be deprecated next year and will be replaced by a new TypeScript-based isomorphic SDK (found at https://github.com/Azure/azure-sdk-for-js) which works on Node.js and browsers.** +## Microsoft Azure SDK for Node.js - LocalSearchClient + +This project provides a Node.js package for accessing Azure. Right now it supports: +- **Node.js version 6.x.x or higher** + +### Features + + +### How to Install + +```bash +npm install azure-cognitiveservices-localsearch +``` + +### How to use + +#### Authentication, client creation, and search local as an example. + +```javascript +const msRest = require("ms-rest"); +const LocalSearchClient = require("azure-cognitiveservices-localsearch"); +const token = ""; +const creds = new msRest.TokenCredentials(token); +const subscriptionId = ""; +const client = new LocalSearchClient(creds, subscriptionId); +const query = "testquery"; +const acceptLanguage = "testacceptLanguage"; +const pragma = "testpragma"; +const userAgent = "testuserAgent"; +const clientId = "testclientId"; +const clientIp = "testclientIp"; +const location = "westus"; +const countryCode = "testcountryCode"; +const market = "testmarket"; +const localCategories = "testlocalCategories"; +const localCircularView = "testlocalCircularView"; +const localMapView = "testlocalMapView"; +const count = "testcount"; +const first = "testfirst"; +const responseFormat = ["Json"]; +const safeSearch = "Off"; +const setLang = "testsetLang"; + +client.local.search(query, acceptLanguage, pragma, userAgent, clientId, clientIp, location, countryCode, market, localCategories, localCircularView, localMapView, count, first, responseFormat, safeSearch, setLang).then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log('An error occurred:'); + console.dir(err, {depth: null, colors: true}); +}); +``` + +### Related projects + +- [Microsoft Azure SDK for Node.js](https://github.com/Azure/azure-sdk-for-node) diff --git a/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.d.ts b/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.d.ts new file mode 100644 index 0000000000..e33e22e8aa --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.d.ts @@ -0,0 +1,43 @@ +/* + * 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. + */ + +import { ServiceClient, ServiceClientOptions, ServiceClientCredentials } from 'ms-rest'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class LocalSearchClient extends ServiceClient { + /** + * @class + * Initializes a new instance of the LocalSearchClient class. + * @constructor + * + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + */ + constructor(credentials: ServiceClientCredentials, baseUri?: string, options?: ServiceClientOptions); + + credentials: ServiceClientCredentials; + + // Operation groups + local: operations.Local; +} + +export { LocalSearchClient, models as LocalSearchModels }; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.js b/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.js new file mode 100644 index 0000000000..4a30d52de7 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/localSearchClient.js @@ -0,0 +1,63 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const ServiceClient = msRest.ServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a LocalSearchClient. */ +class LocalSearchClient extends ServiceClient { + /** + * Create a LocalSearchClient. + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + */ + constructor(credentials, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://api.cognitive.microsoft.com/localbusinesses/v7.0/search'; + } + this.credentials = credentials; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + this.local = new operations.Local(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = LocalSearchClient; +module.exports['default'] = LocalSearchClient; +module.exports.LocalSearchClient = LocalSearchClient; +module.exports.LocalSearchModels = models; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/action.js b/lib/services/cognitiveServicesLocalSearch/lib/models/action.js new file mode 100644 index 0000000000..e4600f18aa --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/action.js @@ -0,0 +1,439 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines an action. + * + * @extends models['CreativeWork'] + */ +class Action extends models['CreativeWork'] { + /** + * Create a Action. + * @property {array} [location] + * @property {array} [result] The result produced in the action. + * @property {string} [displayName] A display name for the action. + * @property {boolean} [isTopAction] A Boolean representing whether this + * result is the top action. + * @property {string} [serviceUrl] Use this URL to get additional data to + * determine how to take the appropriate action. For example, the serviceUrl + * might return JSON along with an image URL. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Action + * + * @returns {object} metadata of Action + * + */ + mapper() { + return { + required: false, + serializedName: 'Action', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PlaceElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Place' + } + } + } + }, + result: { + required: false, + readOnly: true, + serializedName: 'result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + isTopAction: { + required: false, + readOnly: true, + serializedName: 'isTopAction', + type: { + name: 'Boolean' + } + }, + serviceUrl: { + required: false, + readOnly: true, + serializedName: 'serviceUrl', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Action; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/answer.js b/lib/services/cognitiveServicesLocalSearch/lib/models/answer.js new file mode 100644 index 0000000000..4a784445c9 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/answer.js @@ -0,0 +1,143 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines an answer. + * + * @extends models['Response'] + */ +class Answer extends models['Response'] { + /** + * Create a Answer. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Answer + * + * @returns {object} metadata of Answer + * + */ + mapper() { + return { + required: false, + serializedName: 'Answer', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Answer', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Answer; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/creativeWork.js b/lib/services/cognitiveServicesLocalSearch/lib/models/creativeWork.js new file mode 100644 index 0000000000..eb6c5c8197 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/creativeWork.js @@ -0,0 +1,451 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The most generic kind of creative work, including books, movies, + * photographs, software programs, etc. + * + * @extends models['Thing'] + */ +class CreativeWork extends models['Thing'] { + /** + * Create a CreativeWork. + * @property {string} [thumbnailUrl] The URL to a thumbnail of the item. + * @property {array} [about] For internal use only. + * @property {array} [mentions] For internal use only. + * @property {array} [provider] The source of the creative work. + * @property {object} [creator] + * @property {string} [creator.name] The name of the thing represented by + * this object. + * @property {string} [creator.url] The URL to get more information about the + * thing represented by this object. + * @property {object} [creator.entityPresentationInfo] Additional information + * about the entity such as hints that you can use to determine the entity's + * type. To determine the entity's type, use the entityScenario and + * entityTypeHint fields. + * @property {string} [creator.entityPresentationInfo.entityScenario] The + * supported scenario. Possible values include: 'DominantEntity', + * 'DisambiguationItem', 'ListItem' + * @property {array} [creator.entityPresentationInfo.entityTypeHints] A list + * of hints that indicate the entity's type. The list could contain a single + * hint such as Movie or a list of hints such as Place, LocalBusiness, + * Restaurant. Each successive hint in the array narrows the entity's type. + * @property {string} [creator.entityPresentationInfo.entityTypeDisplayHint] + * A display version of the entity hint. For example, if entityTypeHints is + * Artist, this field may be set to American Singer. + * @property {string} [creator.entityPresentationInfo.query] + * @property {array} [creator.entityPresentationInfo.entitySubTypeHints] + * @property {string} [creator.entityPresentationInfo._type] Polymorphic + * Discriminator + * @property {string} [text] Text content of this creative work + * @property {string} [discussionUrl] + * @property {number} [commentCount] + * @property {object} [mainEntity] + * @property {string} [mainEntity.name] The name of the thing represented by + * this object. + * @property {string} [mainEntity.url] The URL to get more information about + * the thing represented by this object. + * @property {object} [mainEntity.entityPresentationInfo] Additional + * information about the entity such as hints that you can use to determine + * the entity's type. To determine the entity's type, use the entityScenario + * and entityTypeHint fields. + * @property {string} [mainEntity.entityPresentationInfo.entityScenario] The + * supported scenario. Possible values include: 'DominantEntity', + * 'DisambiguationItem', 'ListItem' + * @property {array} [mainEntity.entityPresentationInfo.entityTypeHints] A + * list of hints that indicate the entity's type. The list could contain a + * single hint such as Movie or a list of hints such as Place, LocalBusiness, + * Restaurant. Each successive hint in the array narrows the entity's type. + * @property {string} + * [mainEntity.entityPresentationInfo.entityTypeDisplayHint] A display + * version of the entity hint. For example, if entityTypeHints is Artist, + * this field may be set to American Singer. + * @property {string} [mainEntity.entityPresentationInfo.query] + * @property {array} [mainEntity.entityPresentationInfo.entitySubTypeHints] + * @property {string} [mainEntity.entityPresentationInfo._type] Polymorphic + * Discriminator + * @property {string} [headLine] + * @property {object} [copyrightHolder] + * @property {string} [copyrightHolder.name] The name of the thing + * represented by this object. + * @property {string} [copyrightHolder.url] The URL to get more information + * about the thing represented by this object. + * @property {object} [copyrightHolder.entityPresentationInfo] Additional + * information about the entity such as hints that you can use to determine + * the entity's type. To determine the entity's type, use the entityScenario + * and entityTypeHint fields. + * @property {string} [copyrightHolder.entityPresentationInfo.entityScenario] + * The supported scenario. Possible values include: 'DominantEntity', + * 'DisambiguationItem', 'ListItem' + * @property {array} [copyrightHolder.entityPresentationInfo.entityTypeHints] + * A list of hints that indicate the entity's type. The list could contain a + * single hint such as Movie or a list of hints such as Place, LocalBusiness, + * Restaurant. Each successive hint in the array narrows the entity's type. + * @property {string} + * [copyrightHolder.entityPresentationInfo.entityTypeDisplayHint] A display + * version of the entity hint. For example, if entityTypeHints is Artist, + * this field may be set to American Singer. + * @property {string} [copyrightHolder.entityPresentationInfo.query] + * @property {array} + * [copyrightHolder.entityPresentationInfo.entitySubTypeHints] + * @property {string} [copyrightHolder.entityPresentationInfo._type] + * Polymorphic Discriminator + * @property {number} [copyrightYear] + * @property {string} [disclaimer] + * @property {boolean} [isAccessibleForFree] + * @property {array} [genre] + * @property {boolean} [isFamilyFriendly] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CreativeWork + * + * @returns {object} metadata of CreativeWork + * + */ + mapper() { + return { + required: false, + serializedName: 'CreativeWork', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'CreativeWork', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = CreativeWork; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/entitiesEntityPresentationInfo.js b/lib/services/cognitiveServicesLocalSearch/lib/models/entitiesEntityPresentationInfo.js new file mode 100644 index 0000000000..bbde088e45 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/entitiesEntityPresentationInfo.js @@ -0,0 +1,124 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Defines additional information about an entity such as type hints. + * + */ +class EntitiesEntityPresentationInfo { + /** + * Create a EntitiesEntityPresentationInfo. + * @property {string} entityScenario The supported scenario. Possible values + * include: 'DominantEntity', 'DisambiguationItem', 'ListItem'. Default + * value: 'DominantEntity' . + * @property {array} [entityTypeHints] A list of hints that indicate the + * entity's type. The list could contain a single hint such as Movie or a + * list of hints such as Place, LocalBusiness, Restaurant. Each successive + * hint in the array narrows the entity's type. + * @property {string} [entityTypeDisplayHint] A display version of the entity + * hint. For example, if entityTypeHints is Artist, this field may be set to + * American Singer. + * @property {string} [query] + * @property {array} [entitySubTypeHints] + * @property {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of EntitiesEntityPresentationInfo + * + * @returns {object} metadata of EntitiesEntityPresentationInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'Entities/EntityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo', + modelProperties: { + entityScenario: { + required: true, + serializedName: 'entityScenario', + defaultValue: 'DominantEntity', + type: { + name: 'String' + } + }, + entityTypeHints: { + required: false, + readOnly: true, + serializedName: 'entityTypeHints', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EntityTypeElementType', + type: { + name: 'String' + } + } + } + }, + entityTypeDisplayHint: { + required: false, + readOnly: true, + serializedName: 'entityTypeDisplayHint', + type: { + name: 'String' + } + }, + query: { + required: false, + readOnly: true, + serializedName: 'query', + type: { + name: 'String' + } + }, + entitySubTypeHints: { + required: false, + readOnly: true, + serializedName: 'entitySubTypeHints', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EntitiesEntityPresentationInfo; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/errorModel.js b/lib/services/cognitiveServicesLocalSearch/lib/models/errorModel.js new file mode 100644 index 0000000000..af2c8369ba --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/errorModel.js @@ -0,0 +1,121 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Defines the error that occurred. + * + */ +class ErrorModel { + /** + * Create a ErrorModel. + * @property {string} code The error code that identifies the category of + * error. Possible values include: 'None', 'ServerError', 'InvalidRequest', + * 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. + * Default value: 'None' . + * @property {string} [subCode] The error code that further helps to identify + * the error. Possible values include: 'UnexpectedError', 'ResourceError', + * 'NotImplemented', 'ParameterMissing', 'ParameterInvalidValue', + * 'HttpNotAllowed', 'Blocked', 'AuthorizationMissing', + * 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' + * @property {string} message A description of the error. + * @property {string} [moreDetails] A description that provides additional + * information about the error. + * @property {string} [parameter] The parameter in the request that caused + * the error. + * @property {string} [value] The parameter's value in the request that was + * not valid. + * @property {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ErrorModel + * + * @returns {object} metadata of ErrorModel + * + */ + mapper() { + return { + required: false, + serializedName: 'Error', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ErrorModel', + className: 'ErrorModel', + modelProperties: { + code: { + required: true, + serializedName: 'code', + defaultValue: 'None', + type: { + name: 'String' + } + }, + subCode: { + required: false, + readOnly: true, + serializedName: 'subCode', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + }, + moreDetails: { + required: false, + readOnly: true, + serializedName: 'moreDetails', + type: { + name: 'String' + } + }, + parameter: { + required: false, + readOnly: true, + serializedName: 'parameter', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'String' + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorModel; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/errorResponse.js b/lib/services/cognitiveServicesLocalSearch/lib/models/errorResponse.js new file mode 100644 index 0000000000..09482bbeb9 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/errorResponse.js @@ -0,0 +1,165 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The top-level response that represents a failed request. + * + * @extends models['Response'] + */ +class ErrorResponse extends models['Response'] { + /** + * Create a ErrorResponse. + * @property {array} errors A list of errors that describe the reasons why + * the request failed. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponse', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'ErrorResponse', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + errors: { + required: true, + serializedName: 'errors', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorModelElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ErrorModel', + className: 'ErrorModel' + } + } + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/geoCoordinates.js b/lib/services/cognitiveServicesLocalSearch/lib/models/geoCoordinates.js new file mode 100644 index 0000000000..ef54fcbf8d --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/geoCoordinates.js @@ -0,0 +1,82 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Class representing a GeoCoordinates. + */ +class GeoCoordinates { + /** + * Create a GeoCoordinates. + * @property {number} latitude + * @property {number} longitude + * @property {number} [elevation] + * @property {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of GeoCoordinates + * + * @returns {object} metadata of GeoCoordinates + * + */ + mapper() { + return { + required: false, + serializedName: 'GeoCoordinates', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'GeoCoordinates', + className: 'GeoCoordinates', + modelProperties: { + latitude: { + required: true, + serializedName: 'latitude', + type: { + name: 'Number' + } + }, + longitude: { + required: true, + serializedName: 'longitude', + type: { + name: 'Number' + } + }, + elevation: { + required: false, + readOnly: true, + serializedName: 'elevation', + type: { + name: 'Number' + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = GeoCoordinates; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/identifiable.js b/lib/services/cognitiveServicesLocalSearch/lib/models/identifiable.js new file mode 100644 index 0000000000..51ceb85de4 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/identifiable.js @@ -0,0 +1,70 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines the identity of a resource. + * + * @extends models['ResponseBase'] + */ +class Identifiable extends models['ResponseBase'] { + /** + * Create a Identifiable. + * @property {string} [id] A String identifier. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Identifiable + * + * @returns {object} metadata of Identifiable + * + */ + mapper() { + return { + required: false, + serializedName: 'Identifiable', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Identifiable', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Identifiable; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/index.d.ts b/lib/services/cognitiveServicesLocalSearch/lib/models/index.d.ts new file mode 100644 index 0000000000..b94a00a728 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/index.d.ts @@ -0,0 +1,392 @@ +/* + * 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. + */ + +import * as moment from "moment"; + +/** + * Defines the query context that Bing used for the request. + */ +export interface QueryContext { + /** + * The query string as specified in the request. + */ + originalQuery: string; + /** + * The query string used by Bing to perform the query. Bing uses the altered query string if the + * original query string contained spelling mistakes. For example, if the query string is "saling + * downwind", the altered query string will be "sailing downwind". This field is included only if + * the original query string contains a spelling mistake. + */ + readonly alteredQuery?: string; + /** + * AlteredQuery that is formatted for display purpose. The query string in the + * AlterationDisplayQuery can be html-escaped and can contain hit-highlighting characters + */ + readonly alterationDisplayQuery?: string; + /** + * The query string to use to force Bing to use the original string. For example, if the query + * string is "saling downwind", the override query string will be "+saling downwind". Remember to + * encode the query string which results in "%2Bsaling+downwind". This field is included only if + * the original query string contains a spelling mistake. + */ + readonly alterationOverrideQuery?: string; + /** + * A Boolean value that indicates whether the specified query has adult intent. The value is true + * if the query has adult intent; otherwise, false. + */ + readonly adultIntent?: boolean; + /** + * A Boolean value that indicates whether Bing requires the user's location to provide accurate + * results. If you specified the user's location by using the X-MSEdge-ClientIP and + * X-Search-Location headers, you can ignore this field. For location aware queries, such as + * "today's weather" or "restaurants near me" that need the user's location to provide accurate + * results, this field is set to true. For location aware queries that include the location (for + * example, "Seattle weather"), this field is set to false. This field is also set to false for + * queries that are not location aware, such as "best sellers". + */ + readonly askUserForLocation?: boolean; + readonly isTransactional?: boolean; + /** + * Polymorphic Discriminator + */ + _type: string; +} + +/** + * Defines additional information about an entity such as type hints. +*/ +export interface EntitiesEntityPresentationInfo { + /** + * The supported scenario. Possible values include: 'DominantEntity', 'DisambiguationItem', + * 'ListItem' + */ + entityScenario: string; + /** + * A list of hints that indicate the entity's type. The list could contain a single hint such as + * Movie or a list of hints such as Place, LocalBusiness, Restaurant. Each successive hint in the + * array narrows the entity's type. + */ + readonly entityTypeHints?: string[]; + /** + * A display version of the entity hint. For example, if entityTypeHints is Artist, this field + * may be set to American Singer. + */ + readonly entityTypeDisplayHint?: string; + readonly query?: string; + readonly entitySubTypeHints?: string[]; + /** + * Polymorphic Discriminator + */ + _type: string; +} + +/** + * Response base +*/ +export interface ResponseBase { + /** + * Polymorphic Discriminator + */ + _type: string; +} + +/** + * Defines the identity of a resource. +*/ +export interface Identifiable extends ResponseBase { + /** + * A String identifier. + */ + readonly id?: string; +} + +/** + * Defines a response. All schemas that return at the root of the response must inherit from this + * object. +*/ +export interface Response extends Identifiable { + /** + * The URL that returns this resource. + */ + readonly readLink?: string; + /** + * The URL to Bing's search result for this item. + */ + readonly webSearchUrl?: string; + readonly potentialAction?: Action[]; + readonly immediateAction?: Action[]; + readonly preferredClickthroughUrl?: string; + readonly adaptiveCard?: string; +} + +/** + * Defines a thing. +*/ +export interface Thing extends Response { + /** + * The name of the thing represented by this object. + */ + readonly name?: string; + /** + * The URL to get more information about the thing represented by this object. + */ + readonly url?: string; + /** + * Additional information about the entity such as hints that you can use to determine the + * entity's type. To determine the entity's type, use the entityScenario and entityTypeHint + * fields. + */ + readonly entityPresentationInfo?: EntitiesEntityPresentationInfo; +} + +/** + * Defines an answer. +*/ +export interface Answer extends Response { +} + +/** + * Defines a search result answer. +*/ +export interface SearchResultsAnswer extends Answer { + readonly queryContext?: QueryContext; + /** + * The estimated number of webpages that are relevant to the query. Use this number along with + * the count and offset query parameters to page the results. + */ + readonly totalEstimatedMatches?: number; + readonly isFamilyFriendly?: boolean; +} + +/** + * Defines a local entity answer. +*/ +export interface Places extends SearchResultsAnswer { + /** + * A list of local entities, such as restaurants or hotels. + */ + value: Thing[]; +} + +/** + * Defines the top-level object that the response includes when the request succeeds. +*/ +export interface SearchResponse extends Response { + /** + * An object that contains the query string that Bing used for the request. This object contains + * the query string as entered by the user. It may also contain an altered query string that Bing + * used for the query if the query string contained a spelling mistake. + */ + readonly queryContext?: QueryContext; + /** + * A list of local entities such as restaurants or hotels that are relevant to the query. + */ + readonly places?: Places; + readonly lottery?: SearchResultsAnswer; + readonly searchResultsConfidenceScore?: number; +} + +export interface GeoCoordinates { + latitude: number; + longitude: number; + readonly elevation?: number; + /** + * Polymorphic Discriminator + */ + _type: string; +} + +/** + * A utility class that serves as the umbrella for a number of 'intangible' things such as + * quantities, structured values, etc. +*/ +export interface Intangible extends Thing { +} + +export interface StructuredValue extends Intangible { +} + +/** + * Defines a postal address. +*/ +export interface PostalAddress extends StructuredValue { + readonly streetAddress?: string; + /** + * The city where the street address is located. For example, Seattle. + */ + readonly addressLocality?: string; + readonly addressSubregion?: string; + /** + * The state or province code where the street address is located. This could be the two-letter + * code. For example, WA, or the full name , Washington. + */ + readonly addressRegion?: string; + /** + * The zip code or postal code where the street address is located. For example, 98052. + */ + readonly postalCode?: string; + readonly postOfficeBoxNumber?: string; + /** + * The country/region where the street address is located. This could be the two-letter ISO code. + * For example, US, or the full name, United States. + */ + readonly addressCountry?: string; + /** + * The two letter ISO code of this country. For example, US. + */ + readonly countryIso?: string; + /** + * The neighborhood where the street address is located. For example, Westlake. + */ + readonly neighborhood?: string; + /** + * Region Abbreviation. For example, WA. + */ + readonly addressRegionAbbreviation?: string; + /** + * The complete address. For example, 2100 Westlake Ave N, Bellevue, WA 98052. + */ + readonly text?: string; + readonly houseNumber?: string; + readonly streetName?: string; + readonly formattingRuleId?: string; +} + +/** + * Defines information about a local entity, such as a restaurant or hotel. +*/ +export interface Place extends Thing { + readonly geo?: GeoCoordinates; + readonly routablePoint?: GeoCoordinates; + /** + * The postal address of where the entity is located + */ + readonly address?: PostalAddress; + /** + * The entity's telephone number + */ + readonly telephone?: string; +} + +/** + * The most generic kind of creative work, including books, movies, photographs, software programs, + * etc. +*/ +export interface CreativeWork extends Thing { + /** + * The URL to a thumbnail of the item. + */ + readonly thumbnailUrl?: string; + /** + * For internal use only. + */ + readonly about?: Thing[]; + /** + * For internal use only. + */ + readonly mentions?: Thing[]; + /** + * The source of the creative work. + */ + readonly provider?: Thing[]; + readonly creator?: Thing; + /** + * Text content of this creative work + */ + readonly text?: string; + readonly discussionUrl?: string; + readonly commentCount?: number; + readonly mainEntity?: Thing; + readonly headLine?: string; + readonly copyrightHolder?: Thing; + readonly copyrightYear?: number; + readonly disclaimer?: string; + readonly isAccessibleForFree?: boolean; + readonly genre?: string[]; + readonly isFamilyFriendly?: boolean; +} + +/** + * Defines an action. +*/ +export interface Action extends CreativeWork { + readonly location?: Place[]; + /** + * The result produced in the action. + */ + readonly result?: Thing[]; + /** + * A display name for the action. + */ + readonly displayName?: string; + /** + * A Boolean representing whether this result is the top action. + */ + readonly isTopAction?: boolean; + /** + * Use this URL to get additional data to determine how to take the appropriate action. For + * example, the serviceUrl might return JSON along with an image URL. + */ + readonly serviceUrl?: string; +} + +/** + * Defines the error that occurred. +*/ +export interface ErrorModel { + /** + * The error code that identifies the category of error. Possible values include: 'None', + * 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', + * 'InsufficientAuthorization' + */ + code: string; + /** + * The error code that further helps to identify the error. Possible values include: + * 'UnexpectedError', 'ResourceError', 'NotImplemented', 'ParameterMissing', + * 'ParameterInvalidValue', 'HttpNotAllowed', 'Blocked', 'AuthorizationMissing', + * 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' + */ + readonly subCode?: string; + /** + * A description of the error. + */ + message: string; + /** + * A description that provides additional information about the error. + */ + readonly moreDetails?: string; + /** + * The parameter in the request that caused the error. + */ + readonly parameter?: string; + /** + * The parameter's value in the request that was not valid. + */ + readonly value?: string; + /** + * Polymorphic Discriminator + */ + _type: string; +} + +/** + * The top-level response that represents a failed request. +*/ +export interface ErrorResponse extends Response { + /** + * A list of errors that describe the reasons why the request failed. + */ + errors: ErrorModel[]; +} + +export interface SearchAction extends Action { + readonly displayText?: string; + readonly query?: string; + readonly richContent?: Answer[]; + readonly formattingRuleId?: string; +} diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/index.js b/lib/services/cognitiveServicesLocalSearch/lib/models/index.js new file mode 100644 index 0000000000..69c321cc3b --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/index.js @@ -0,0 +1,58 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.QueryContext = require('./queryContext'); +exports.EntitiesEntityPresentationInfo = require('./entitiesEntityPresentationInfo'); +exports.ResponseBase = require('./responseBase'); +exports.Identifiable = require('./identifiable'); +exports.Response = require('./response'); +exports.Thing = require('./thing'); +exports.Answer = require('./answer'); +exports.SearchResultsAnswer = require('./searchResultsAnswer'); +exports.Places = require('./places'); +exports.SearchResponse = require('./searchResponse'); +exports.GeoCoordinates = require('./geoCoordinates'); +exports.Intangible = require('./intangible'); +exports.StructuredValue = require('./structuredValue'); +exports.PostalAddress = require('./postalAddress'); +exports.Place = require('./place'); +exports.CreativeWork = require('./creativeWork'); +exports.Action = require('./action'); +exports.ErrorModel = require('./errorModel'); +exports.ErrorResponse = require('./errorResponse'); +exports.SearchAction = require('./searchAction'); +exports.discriminators = { + 'QueryContext' : exports.QueryContext, + 'Entities/EntityPresentationInfo' : exports.EntitiesEntityPresentationInfo, + 'ResponseBase.Thing' : exports.Thing, + 'ResponseBase.Places' : exports.Places, + 'ResponseBase.SearchResultsAnswer' : exports.SearchResultsAnswer, + 'ResponseBase.SearchResponse' : exports.SearchResponse, + 'GeoCoordinates' : exports.GeoCoordinates, + 'ResponseBase.PostalAddress' : exports.PostalAddress, + 'ResponseBase.Place' : exports.Place, + 'ResponseBase.Action' : exports.Action, + 'ResponseBase.Response' : exports.Response, + 'ResponseBase.Identifiable' : exports.Identifiable, + 'ResponseBase.Answer' : exports.Answer, + 'Error' : exports.ErrorModel, + 'ResponseBase.ErrorResponse' : exports.ErrorResponse, + 'ResponseBase.CreativeWork' : exports.CreativeWork, + 'ResponseBase' : exports.ResponseBase, + 'ResponseBase.Intangible' : exports.Intangible, + 'ResponseBase.SearchAction' : exports.SearchAction, + 'ResponseBase.StructuredValue' : exports.StructuredValue +}; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/intangible.js b/lib/services/cognitiveServicesLocalSearch/lib/models/intangible.js new file mode 100644 index 0000000000..e7ad7197ac --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/intangible.js @@ -0,0 +1,174 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A utility class that serves as the umbrella for a number of 'intangible' + * things such as quantities, structured values, etc. + * + * @extends models['Thing'] + */ +class Intangible extends models['Thing'] { + /** + * Create a Intangible. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Intangible + * + * @returns {object} metadata of Intangible + * + */ + mapper() { + return { + required: false, + serializedName: 'Intangible', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Intangible', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + } + } + } + }; + } +} + +module.exports = Intangible; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/place.js b/lib/services/cognitiveServicesLocalSearch/lib/models/place.js new file mode 100644 index 0000000000..13940fc854 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/place.js @@ -0,0 +1,260 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines information about a local entity, such as a restaurant or hotel. + * + * @extends models['Thing'] + */ +class Place extends models['Thing'] { + /** + * Create a Place. + * @property {object} [geo] + * @property {number} [geo.latitude] + * @property {number} [geo.longitude] + * @property {number} [geo.elevation] + * @property {string} [geo._type] Polymorphic Discriminator + * @property {object} [routablePoint] + * @property {number} [routablePoint.latitude] + * @property {number} [routablePoint.longitude] + * @property {number} [routablePoint.elevation] + * @property {string} [routablePoint._type] Polymorphic Discriminator + * @property {object} [address] The postal address of where the entity is + * located + * @property {string} [address.streetAddress] + * @property {string} [address.addressLocality] The city where the street + * address is located. For example, Seattle. + * @property {string} [address.addressSubregion] + * @property {string} [address.addressRegion] The state or province code + * where the street address is located. This could be the two-letter code. + * For example, WA, or the full name , Washington. + * @property {string} [address.postalCode] The zip code or postal code where + * the street address is located. For example, 98052. + * @property {string} [address.postOfficeBoxNumber] + * @property {string} [address.addressCountry] The country/region where the + * street address is located. This could be the two-letter ISO code. For + * example, US, or the full name, United States. + * @property {string} [address.countryIso] The two letter ISO code of this + * country. For example, US. + * @property {string} [address.neighborhood] The neighborhood where the + * street address is located. For example, Westlake. + * @property {string} [address.addressRegionAbbreviation] Region + * Abbreviation. For example, WA. + * @property {string} [address.text] The complete address. For example, 2100 + * Westlake Ave N, Bellevue, WA 98052. + * @property {string} [address.houseNumber] + * @property {string} [address.streetName] + * @property {string} [address.formattingRuleId] + * @property {string} [telephone] The entity's telephone number + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Place + * + * @returns {object} metadata of Place + * + */ + mapper() { + return { + required: false, + serializedName: 'Place', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Place', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + }, + geo: { + required: false, + readOnly: true, + serializedName: 'geo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'GeoCoordinates', + className: 'GeoCoordinates' + } + }, + routablePoint: { + required: false, + readOnly: true, + serializedName: 'routablePoint', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'GeoCoordinates', + className: 'GeoCoordinates' + } + }, + address: { + required: false, + readOnly: true, + serializedName: 'address', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'PostalAddress' + } + }, + telephone: { + required: false, + readOnly: true, + serializedName: 'telephone', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Place; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/places.js b/lib/services/cognitiveServicesLocalSearch/lib/models/places.js new file mode 100644 index 0000000000..327befca04 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/places.js @@ -0,0 +1,195 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a local entity answer. + * + * @extends models['SearchResultsAnswer'] + */ +class Places extends models['SearchResultsAnswer'] { + /** + * Create a Places. + * @property {array} value A list of local entities, such as restaurants or + * hotels. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Places + * + * @returns {object} metadata of Places + * + */ + mapper() { + return { + required: false, + serializedName: 'Places', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Places', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext' + } + }, + totalEstimatedMatches: { + required: false, + readOnly: true, + serializedName: 'totalEstimatedMatches', + type: { + name: 'Number' + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + }, + value: { + required: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + } + } + } + }; + } +} + +module.exports = Places; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/postalAddress.js b/lib/services/cognitiveServicesLocalSearch/lib/models/postalAddress.js new file mode 100644 index 0000000000..2dad9e3aeb --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/postalAddress.js @@ -0,0 +1,309 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a postal address. + * + * @extends models['StructuredValue'] + */ +class PostalAddress extends models['StructuredValue'] { + /** + * Create a PostalAddress. + * @property {string} [streetAddress] + * @property {string} [addressLocality] The city where the street address is + * located. For example, Seattle. + * @property {string} [addressSubregion] + * @property {string} [addressRegion] The state or province code where the + * street address is located. This could be the two-letter code. For example, + * WA, or the full name , Washington. + * @property {string} [postalCode] The zip code or postal code where the + * street address is located. For example, 98052. + * @property {string} [postOfficeBoxNumber] + * @property {string} [addressCountry] The country/region where the street + * address is located. This could be the two-letter ISO code. For example, + * US, or the full name, United States. + * @property {string} [countryIso] The two letter ISO code of this country. + * For example, US. + * @property {string} [neighborhood] The neighborhood where the street + * address is located. For example, Westlake. + * @property {string} [addressRegionAbbreviation] Region Abbreviation. For + * example, WA. + * @property {string} [text] The complete address. For example, 2100 Westlake + * Ave N, Bellevue, WA 98052. + * @property {string} [houseNumber] + * @property {string} [streetName] + * @property {string} [formattingRuleId] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of PostalAddress + * + * @returns {object} metadata of PostalAddress + * + */ + mapper() { + return { + required: false, + serializedName: 'PostalAddress', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'PostalAddress', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + }, + streetAddress: { + required: false, + readOnly: true, + serializedName: 'streetAddress', + type: { + name: 'String' + } + }, + addressLocality: { + required: false, + readOnly: true, + serializedName: 'addressLocality', + type: { + name: 'String' + } + }, + addressSubregion: { + required: false, + readOnly: true, + serializedName: 'addressSubregion', + type: { + name: 'String' + } + }, + addressRegion: { + required: false, + readOnly: true, + serializedName: 'addressRegion', + type: { + name: 'String' + } + }, + postalCode: { + required: false, + readOnly: true, + serializedName: 'postalCode', + type: { + name: 'String' + } + }, + postOfficeBoxNumber: { + required: false, + readOnly: true, + serializedName: 'postOfficeBoxNumber', + type: { + name: 'String' + } + }, + addressCountry: { + required: false, + readOnly: true, + serializedName: 'addressCountry', + type: { + name: 'String' + } + }, + countryIso: { + required: false, + readOnly: true, + serializedName: 'countryIso', + type: { + name: 'String' + } + }, + neighborhood: { + required: false, + readOnly: true, + serializedName: 'neighborhood', + type: { + name: 'String' + } + }, + addressRegionAbbreviation: { + required: false, + readOnly: true, + serializedName: 'addressRegionAbbreviation', + type: { + name: 'String' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + houseNumber: { + required: false, + readOnly: true, + serializedName: 'houseNumber', + type: { + name: 'String' + } + }, + streetName: { + required: false, + readOnly: true, + serializedName: 'streetName', + type: { + name: 'String' + } + }, + formattingRuleId: { + required: false, + readOnly: true, + serializedName: 'formattingRuleId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = PostalAddress; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/queryContext.js b/lib/services/cognitiveServicesLocalSearch/lib/models/queryContext.js new file mode 100644 index 0000000000..778db58076 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/queryContext.js @@ -0,0 +1,142 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Defines the query context that Bing used for the request. + * + */ +class QueryContext { + /** + * Create a QueryContext. + * @property {string} originalQuery The query string as specified in the + * request. + * @property {string} [alteredQuery] The query string used by Bing to perform + * the query. Bing uses the altered query string if the original query string + * contained spelling mistakes. For example, if the query string is "saling + * downwind", the altered query string will be "sailing downwind". This field + * is included only if the original query string contains a spelling mistake. + * @property {string} [alterationDisplayQuery] AlteredQuery that is formatted + * for display purpose. The query string in the AlterationDisplayQuery can be + * html-escaped and can contain hit-highlighting characters + * @property {string} [alterationOverrideQuery] The query string to use to + * force Bing to use the original string. For example, if the query string is + * "saling downwind", the override query string will be "+saling downwind". + * Remember to encode the query string which results in "%2Bsaling+downwind". + * This field is included only if the original query string contains a + * spelling mistake. + * @property {boolean} [adultIntent] A Boolean value that indicates whether + * the specified query has adult intent. The value is true if the query has + * adult intent; otherwise, false. + * @property {boolean} [askUserForLocation] A Boolean value that indicates + * whether Bing requires the user's location to provide accurate results. If + * you specified the user's location by using the X-MSEdge-ClientIP and + * X-Search-Location headers, you can ignore this field. For location aware + * queries, such as "today's weather" or "restaurants near me" that need the + * user's location to provide accurate results, this field is set to true. + * For location aware queries that include the location (for example, + * "Seattle weather"), this field is set to false. This field is also set to + * false for queries that are not location aware, such as "best sellers". + * @property {boolean} [isTransactional] + * @property {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of QueryContext + * + * @returns {object} metadata of QueryContext + * + */ + mapper() { + return { + required: false, + serializedName: 'QueryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext', + modelProperties: { + originalQuery: { + required: true, + serializedName: 'originalQuery', + type: { + name: 'String' + } + }, + alteredQuery: { + required: false, + readOnly: true, + serializedName: 'alteredQuery', + type: { + name: 'String' + } + }, + alterationDisplayQuery: { + required: false, + readOnly: true, + serializedName: 'alterationDisplayQuery', + type: { + name: 'String' + } + }, + alterationOverrideQuery: { + required: false, + readOnly: true, + serializedName: 'alterationOverrideQuery', + type: { + name: 'String' + } + }, + adultIntent: { + required: false, + readOnly: true, + serializedName: 'adultIntent', + type: { + name: 'Boolean' + } + }, + askUserForLocation: { + required: false, + readOnly: true, + serializedName: 'askUserForLocation', + type: { + name: 'Boolean' + } + }, + isTransactional: { + required: false, + readOnly: true, + serializedName: 'isTransactional', + type: { + name: 'Boolean' + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = QueryContext; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/response.js b/lib/services/cognitiveServicesLocalSearch/lib/models/response.js new file mode 100644 index 0000000000..1e78e3d0d9 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/response.js @@ -0,0 +1,151 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a response. All schemas that return at the root of the response must + * inherit from this object. + * + * @extends models['Identifiable'] + */ +class Response extends models['Identifiable'] { + /** + * Create a Response. + * @property {string} [readLink] The URL that returns this resource. + * @property {string} [webSearchUrl] The URL to Bing's search result for this + * item. + * @property {array} [potentialAction] + * @property {array} [immediateAction] + * @property {string} [preferredClickthroughUrl] + * @property {string} [adaptiveCard] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Response + * + * @returns {object} metadata of Response + * + */ + mapper() { + return { + required: false, + serializedName: 'Response', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Response', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Response; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/responseBase.js b/lib/services/cognitiveServicesLocalSearch/lib/models/responseBase.js new file mode 100644 index 0000000000..902b737a95 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/responseBase.js @@ -0,0 +1,58 @@ +/* + * 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. + */ + +'use strict'; + +/** + * Response base + * + */ +class ResponseBase { + /** + * Create a ResponseBase. + * @property {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ResponseBase + * + * @returns {object} metadata of ResponseBase + * + */ + mapper() { + return { + required: false, + serializedName: 'ResponseBase', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'ResponseBase', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResponseBase; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/searchAction.js b/lib/services/cognitiveServicesLocalSearch/lib/models/searchAction.js new file mode 100644 index 0000000000..3ea54822cf --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/searchAction.js @@ -0,0 +1,479 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a SearchAction. + * @extends models['Action'] + */ +class SearchAction extends models['Action'] { + /** + * Create a SearchAction. + * @property {string} [displayText] + * @property {string} [query] + * @property {array} [richContent] + * @property {string} [formattingRuleId] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of SearchAction + * + * @returns {object} metadata of SearchAction + * + */ + mapper() { + return { + required: false, + serializedName: 'SearchAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchAction', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + }, + location: { + required: false, + readOnly: true, + serializedName: 'location', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'PlaceElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Place' + } + } + } + }, + result: { + required: false, + readOnly: true, + serializedName: 'result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + isTopAction: { + required: false, + readOnly: true, + serializedName: 'isTopAction', + type: { + name: 'Boolean' + } + }, + serviceUrl: { + required: false, + readOnly: true, + serializedName: 'serviceUrl', + type: { + name: 'String' + } + }, + displayText: { + required: false, + readOnly: true, + serializedName: 'displayText', + type: { + name: 'String' + } + }, + query: { + required: false, + readOnly: true, + serializedName: 'query', + type: { + name: 'String' + } + }, + richContent: { + required: false, + readOnly: true, + serializedName: 'richContent', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AnswerElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Answer' + } + } + } + }, + formattingRuleId: { + required: false, + readOnly: true, + serializedName: 'formattingRuleId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = SearchAction; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/searchResponse.js b/lib/services/cognitiveServicesLocalSearch/lib/models/searchResponse.js new file mode 100644 index 0000000000..5b72ef64a7 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/searchResponse.js @@ -0,0 +1,275 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines the top-level object that the response includes when the request + * succeeds. + * + * @extends models['Response'] + */ +class SearchResponse extends models['Response'] { + /** + * Create a SearchResponse. + * @property {object} [queryContext] An object that contains the query string + * that Bing used for the request. This object contains the query string as + * entered by the user. It may also contain an altered query string that Bing + * used for the query if the query string contained a spelling mistake. + * @property {string} [queryContext.originalQuery] The query string as + * specified in the request. + * @property {string} [queryContext.alteredQuery] The query string used by + * Bing to perform the query. Bing uses the altered query string if the + * original query string contained spelling mistakes. For example, if the + * query string is "saling downwind", the altered query string will be + * "sailing downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {string} [queryContext.alterationDisplayQuery] AlteredQuery that + * is formatted for display purpose. The query string in the + * AlterationDisplayQuery can be html-escaped and can contain + * hit-highlighting characters + * @property {string} [queryContext.alterationOverrideQuery] The query string + * to use to force Bing to use the original string. For example, if the query + * string is "saling downwind", the override query string will be "+saling + * downwind". Remember to encode the query string which results in + * "%2Bsaling+downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {boolean} [queryContext.adultIntent] A Boolean value that + * indicates whether the specified query has adult intent. The value is true + * if the query has adult intent; otherwise, false. + * @property {boolean} [queryContext.askUserForLocation] A Boolean value that + * indicates whether Bing requires the user's location to provide accurate + * results. If you specified the user's location by using the + * X-MSEdge-ClientIP and X-Search-Location headers, you can ignore this + * field. For location aware queries, such as "today's weather" or + * "restaurants near me" that need the user's location to provide accurate + * results, this field is set to true. For location aware queries that + * include the location (for example, "Seattle weather"), this field is set + * to false. This field is also set to false for queries that are not + * location aware, such as "best sellers". + * @property {boolean} [queryContext.isTransactional] + * @property {string} [queryContext._type] Polymorphic Discriminator + * @property {object} [places] A list of local entities such as restaurants + * or hotels that are relevant to the query. + * @property {array} [places.value] A list of local entities, such as + * restaurants or hotels. + * @property {object} [lottery] + * @property {object} [lottery.queryContext] + * @property {string} [lottery.queryContext.originalQuery] The query string + * as specified in the request. + * @property {string} [lottery.queryContext.alteredQuery] The query string + * used by Bing to perform the query. Bing uses the altered query string if + * the original query string contained spelling mistakes. For example, if the + * query string is "saling downwind", the altered query string will be + * "sailing downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {string} [lottery.queryContext.alterationDisplayQuery] + * AlteredQuery that is formatted for display purpose. The query string in + * the AlterationDisplayQuery can be html-escaped and can contain + * hit-highlighting characters + * @property {string} [lottery.queryContext.alterationOverrideQuery] The + * query string to use to force Bing to use the original string. For example, + * if the query string is "saling downwind", the override query string will + * be "+saling downwind". Remember to encode the query string which results + * in "%2Bsaling+downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {boolean} [lottery.queryContext.adultIntent] A Boolean value + * that indicates whether the specified query has adult intent. The value is + * true if the query has adult intent; otherwise, false. + * @property {boolean} [lottery.queryContext.askUserForLocation] A Boolean + * value that indicates whether Bing requires the user's location to provide + * accurate results. If you specified the user's location by using the + * X-MSEdge-ClientIP and X-Search-Location headers, you can ignore this + * field. For location aware queries, such as "today's weather" or + * "restaurants near me" that need the user's location to provide accurate + * results, this field is set to true. For location aware queries that + * include the location (for example, "Seattle weather"), this field is set + * to false. This field is also set to false for queries that are not + * location aware, such as "best sellers". + * @property {boolean} [lottery.queryContext.isTransactional] + * @property {string} [lottery.queryContext._type] Polymorphic Discriminator + * @property {number} [lottery.totalEstimatedMatches] The estimated number of + * webpages that are relevant to the query. Use this number along with the + * count and offset query parameters to page the results. + * @property {boolean} [lottery.isFamilyFriendly] + * @property {number} [searchResultsConfidenceScore] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of SearchResponse + * + * @returns {object} metadata of SearchResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'SearchResponse', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchResponse', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext' + } + }, + places: { + required: false, + readOnly: true, + serializedName: 'places', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Places' + } + }, + lottery: { + required: false, + readOnly: true, + serializedName: 'lottery', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchResultsAnswer' + } + }, + searchResultsConfidenceScore: { + required: false, + readOnly: true, + serializedName: 'searchResultsConfidenceScore', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = SearchResponse; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/searchResultsAnswer.js b/lib/services/cognitiveServicesLocalSearch/lib/models/searchResultsAnswer.js new file mode 100644 index 0000000000..e25f942678 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/searchResultsAnswer.js @@ -0,0 +1,211 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a search result answer. + * + * @extends models['Answer'] + */ +class SearchResultsAnswer extends models['Answer'] { + /** + * Create a SearchResultsAnswer. + * @property {object} [queryContext] + * @property {string} [queryContext.originalQuery] The query string as + * specified in the request. + * @property {string} [queryContext.alteredQuery] The query string used by + * Bing to perform the query. Bing uses the altered query string if the + * original query string contained spelling mistakes. For example, if the + * query string is "saling downwind", the altered query string will be + * "sailing downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {string} [queryContext.alterationDisplayQuery] AlteredQuery that + * is formatted for display purpose. The query string in the + * AlterationDisplayQuery can be html-escaped and can contain + * hit-highlighting characters + * @property {string} [queryContext.alterationOverrideQuery] The query string + * to use to force Bing to use the original string. For example, if the query + * string is "saling downwind", the override query string will be "+saling + * downwind". Remember to encode the query string which results in + * "%2Bsaling+downwind". This field is included only if the original query + * string contains a spelling mistake. + * @property {boolean} [queryContext.adultIntent] A Boolean value that + * indicates whether the specified query has adult intent. The value is true + * if the query has adult intent; otherwise, false. + * @property {boolean} [queryContext.askUserForLocation] A Boolean value that + * indicates whether Bing requires the user's location to provide accurate + * results. If you specified the user's location by using the + * X-MSEdge-ClientIP and X-Search-Location headers, you can ignore this + * field. For location aware queries, such as "today's weather" or + * "restaurants near me" that need the user's location to provide accurate + * results, this field is set to true. For location aware queries that + * include the location (for example, "Seattle weather"), this field is set + * to false. This field is also set to false for queries that are not + * location aware, such as "best sellers". + * @property {boolean} [queryContext.isTransactional] + * @property {string} [queryContext._type] Polymorphic Discriminator + * @property {number} [totalEstimatedMatches] The estimated number of + * webpages that are relevant to the query. Use this number along with the + * count and offset query parameters to page the results. + * @property {boolean} [isFamilyFriendly] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of SearchResultsAnswer + * + * @returns {object} metadata of SearchResultsAnswer + * + */ + mapper() { + return { + required: false, + serializedName: 'SearchResultsAnswer', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchResultsAnswer', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext' + } + }, + totalEstimatedMatches: { + required: false, + readOnly: true, + serializedName: 'totalEstimatedMatches', + type: { + name: 'Number' + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = SearchResultsAnswer; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/structuredValue.js b/lib/services/cognitiveServicesLocalSearch/lib/models/structuredValue.js new file mode 100644 index 0000000000..9a4600b667 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/structuredValue.js @@ -0,0 +1,172 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a StructuredValue. + * @extends models['Intangible'] + */ +class StructuredValue extends models['Intangible'] { + /** + * Create a StructuredValue. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of StructuredValue + * + * @returns {object} metadata of StructuredValue + * + */ + mapper() { + return { + required: false, + serializedName: 'StructuredValue', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'StructuredValue', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + } + } + } + }; + } +} + +module.exports = StructuredValue; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/models/thing.js b/lib/services/cognitiveServicesLocalSearch/lib/models/thing.js new file mode 100644 index 0000000000..e6a5b4467e --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/models/thing.js @@ -0,0 +1,195 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a thing. + * + * @extends models['Response'] + */ +class Thing extends models['Response'] { + /** + * Create a Thing. + * @property {string} [name] The name of the thing represented by this + * object. + * @property {string} [url] The URL to get more information about the thing + * represented by this object. + * @property {object} [entityPresentationInfo] Additional information about + * the entity such as hints that you can use to determine the entity's type. + * To determine the entity's type, use the entityScenario and entityTypeHint + * fields. + * @property {string} [entityPresentationInfo.entityScenario] The supported + * scenario. Possible values include: 'DominantEntity', 'DisambiguationItem', + * 'ListItem' + * @property {array} [entityPresentationInfo.entityTypeHints] A list of hints + * that indicate the entity's type. The list could contain a single hint such + * as Movie or a list of hints such as Place, LocalBusiness, Restaurant. Each + * successive hint in the array narrows the entity's type. + * @property {string} [entityPresentationInfo.entityTypeDisplayHint] A + * display version of the entity hint. For example, if entityTypeHints is + * Artist, this field may be set to American Singer. + * @property {string} [entityPresentationInfo.query] + * @property {array} [entityPresentationInfo.entitySubTypeHints] + * @property {string} [entityPresentationInfo._type] Polymorphic + * Discriminator + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Thing + * + * @returns {object} metadata of Thing + * + */ + mapper() { + return { + required: false, + serializedName: 'Thing', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + entityPresentationInfo: { + required: false, + readOnly: true, + serializedName: 'entityPresentationInfo', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'EntitiesEntityPresentationInfo', + className: 'EntitiesEntityPresentationInfo' + } + } + } + } + }; + } +} + +module.exports = Thing; diff --git a/lib/services/cognitiveServicesLocalSearch/lib/operations/index.d.ts b/lib/services/cognitiveServicesLocalSearch/lib/operations/index.d.ts new file mode 100644 index 0000000000..3026fc65a0 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/operations/index.d.ts @@ -0,0 +1,435 @@ +/* + * 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. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * Local + * __NOTE__: An instance of this class is automatically created for an + * instance of the LocalSearchClient. + */ +export interface Local { + + + /** + * @summary The Local Search API lets you send a search query to Bing and get + * back search results that include local businesses such as restaurants, + * hotels, retail stores, or other local businesses. The query can specify the + * name of the local business or it can ask for a list (for example, + * restaurants near me). + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.acceptLanguage] A comma-delimited list of one or + * more languages to use for user interface strings. The list is in decreasing + * order of preference. For additional information, including expected format, + * see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This + * header and the setLang query parameter are mutually exclusive; do not + * specify both. If you set this header, you must also specify the cc query + * parameter. Bing will use the first supported language it finds from the + * list, and combine that language with the cc parameter value to determine the + * market to return results for. If the list does not include a supported + * language, Bing will find the closest language and market that supports the + * request, and may use an aggregated or default market for the results instead + * of a specified one. You should use this header and the cc query parameter + * only if you specify multiple languages; otherwise, you should use the mkt + * and setLang query parameters. A user interface string is a string that's + * used as a label in a user interface. There are very few user interface + * strings in the JSON response objects. Any links in the response objects to + * Bing.com properties will apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are strongly encouraged to always specify + * this header. The user-agent should be the same string that any commonly used + * browser would send. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + * + * @param {string} [options.clientId] Bing uses this header to provide users + * with consistent behavior across Bing API calls. Bing often flights new + * features and improvements, and it uses the client ID as a key for assigning + * traffic on different flights. If you do not use the same client ID for a + * user across multiple requests, then Bing may assign the user to multiple + * conflicting flights. Being assigned to multiple conflicting flights can lead + * to an inconsistent user experience. For example, if the second request has a + * different flight assignment than the first, the experience may be + * unexpected. Also, Bing can use the client ID to tailor web results to that + * client ID’s search history, providing a richer experience for the user. Bing + * also uses this header to help improve result rankings by analyzing the + * activity generated by a client ID. The relevance improvements help with + * better quality of results delivered by Bing APIs and in turn enables higher + * click-through rates for the API consumer. IMPORTANT: Although optional, you + * should consider this header required. Persisting the client ID across + * multiple requests for the same end user and device combination enables 1) + * the API consumer to receive a consistent user experience, and 2) higher + * click-through rates via better quality of results from the Bing APIs. Each + * user that uses your application on the device must have a unique, Bing + * generated client ID. If you do not include this header in the request, Bing + * generates an ID and returns it in the X-MSEdge-ClientID response header. The + * only time that you should NOT include this header in a request is the first + * time the user uses your app on that device. Use the client ID for each Bing + * API request that your app makes for this user on the device. Persist the + * client ID. To persist the ID in a browser app, use a persistent HTTP cookie + * to ensure the ID is used across all sessions. Do not use a session cookie. + * For other apps such as mobile apps, use the device's persistent storage to + * persist the ID. The next time the user uses your app on that device, get the + * client ID that you persisted. Bing responses may or may not include this + * header. If the response includes this header, capture the client ID and use + * it for all subsequent Bing requests for the user on that device. If you + * include the X-MSEdge-ClientID, you must not include cookies in the request. + * + * @param {string} [options.clientIp] The IPv4 or IPv6 address of the client + * device. The IP address is used to discover the user's location. Bing uses + * the location information to determine safe search behavior. Although + * optional, you are encouraged to always specify this header and the + * X-Search-Location header. Do not obfuscate the address (for example, by + * changing the last octet to 0). Obfuscating the address results in the + * location not being anywhere near the device's actual location, which may + * result in Bing serving erroneous results. + * + * @param {string} [options.location] A semicolon-delimited list of key/value + * pairs that describe the client's geographical location. Bing uses the + * location information to determine safe search behavior and to return + * relevant local content. Specify the key/value pair as :. The + * following are the keys that you use to specify the user's location. lat + * (required): The latitude of the client's location, in degrees. The latitude + * must be greater than or equal to -90.0 and less than or equal to +90.0. + * Negative values indicate southern latitudes and positive values indicate + * northern latitudes. long (required): The longitude of the client's location, + * in degrees. The longitude must be greater than or equal to -180.0 and less + * than or equal to +180.0. Negative values indicate western longitudes and + * positive values indicate eastern longitudes. re (required): The radius, in + * meters, which specifies the horizontal accuracy of the coordinates. Pass the + * value returned by the device's location service. Typical values might be 22m + * for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP + * lookup. ts (optional): The UTC UNIX timestamp of when the client was at the + * location. (The UNIX timestamp is the number of seconds since January 1, + * 1970.) head (optional): The client's relative heading or direction of + * travel. Specify the direction of travel as degrees from 0 through 360, + * counting clockwise relative to true north. Specify this key only if the sp + * key is nonzero. sp (optional): The horizontal velocity (speed), in meters + * per second, that the client device is traveling. alt (optional): The + * altitude of the client device, in meters. are (optional): The radius, in + * meters, that specifies the vertical accuracy of the coordinates. Specify + * this key only if you specify the alt key. Although many of the keys are + * optional, the more information that you provide, the more accurate the + * location results are. Although optional, you are encouraged to always + * specify the user's geographical location. Providing the location is + * especially important if the client's IP address does not accurately reflect + * the user's physical location (for example, if the client uses VPN). For + * optimal results, you should include this header and the X-MSEdge-ClientIP + * header, but at a minimum, you should include this header. + * + * @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 + * you set this parameter, you must also specify the Accept-Language header. + * Bing uses the first supported language it finds from the languages list, and + * combine that language with the country code that you specify to determine + * the market to return results for. If the languages list does not include a + * supported language, Bing finds the closest language and market that supports + * the request, or it may use an aggregated or default market for the results + * instead of a specified one. You should use this query parameter and the + * Accept-Language query parameter only if you specify multiple languages; + * otherwise, you should use the mkt and setLang query parameters. This + * parameter and the mkt query parameter are mutually exclusive—do not specify + * both. + * + * @param {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.localCategories] comma-delimited list of business + * categories to search for. Supported categories can be high-level such as + * EatDrink, Shop, SeeDo. + * + * @param {string} [options.localCircularView] Preferred location to search + * around, expressed as Latitude, longitude and radius in meters. For example + * 47.61503,-122.1719,5000. Note that circular view should only be used to + * indicate a search around a point on the map, not as an approximation for a + * view port of a map rectangle. + * + * @param {string} [options.localMapView] Preferred bounding box for results, + * specified in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. + * For example 47.64,-122.13,47.63,-122.12. These values are lat, long pairs + * for the Northwest corner and the Southeast corner of a rectangle. + * + * @param {string} [options.count] Preferred number of results to return. If + * not specified, then Bing returns 1-20 of the most relevant results. + * + * @param {string} [options.first] First result to return. zero-based. default + * is 0. + * + * @param {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {string} [options.safeSearch] A filter used to filter adult content. + * Off: Return webpages with adult text, images, or videos. Moderate: Return + * webpages with adult text, but not adult images or videos. Strict: Do not + * return webpages with adult text, images, or videos. The default is Moderate. + * If the request comes from a market that Bing's adult policy requires that + * safeSearch is set to Strict, Bing ignores the safeSearch value and uses + * Strict. If you use the site: query operator, there is the chance that the + * response may contain adult content regardless of what the safeSearch query + * parameter is set to. Use site: only if you are aware of the content on the + * site and your scenario supports the possibility of adult content. Possible + * values include: 'Off', 'Moderate', 'Strict' + * + * @param {string} [options.setLang] The language to use for user interface + * strings. Specify the language using the ISO 639-1 2-letter language code. + * For example, the language code for English is EN. The default is EN + * (English). Although optional, you should always specify the language. + * Typically, you set setLang to the same language specified by mkt unless the + * user wants the user interface strings displayed in a different language. + * This parameter and the Accept-Language header are mutually exclusive; do not + * specify both. A user interface string is a string that's used as a label in + * a user interface. There are few user interface strings in the JSON response + * objects. Also, any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + searchWithHttpOperationResponse(query: string, options?: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, localCategories? : string, localCircularView? : string, localMapView? : string, count? : string, first? : string, responseFormat? : string[], safeSearch? : string, setLang? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary The Local Search API lets you send a search query to Bing and get + * back search results that include local businesses such as restaurants, + * hotels, retail stores, or other local businesses. The query can specify the + * name of the local business or it can ask for a list (for example, + * restaurants near me). + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.acceptLanguage] A comma-delimited list of one or + * more languages to use for user interface strings. The list is in decreasing + * order of preference. For additional information, including expected format, + * see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This + * header and the setLang query parameter are mutually exclusive; do not + * specify both. If you set this header, you must also specify the cc query + * parameter. Bing will use the first supported language it finds from the + * list, and combine that language with the cc parameter value to determine the + * market to return results for. If the list does not include a supported + * language, Bing will find the closest language and market that supports the + * request, and may use an aggregated or default market for the results instead + * of a specified one. You should use this header and the cc query parameter + * only if you specify multiple languages; otherwise, you should use the mkt + * and setLang query parameters. A user interface string is a string that's + * used as a label in a user interface. There are very few user interface + * strings in the JSON response objects. Any links in the response objects to + * Bing.com properties will apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are strongly encouraged to always specify + * this header. The user-agent should be the same string that any commonly used + * browser would send. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + * + * @param {string} [options.clientId] Bing uses this header to provide users + * with consistent behavior across Bing API calls. Bing often flights new + * features and improvements, and it uses the client ID as a key for assigning + * traffic on different flights. If you do not use the same client ID for a + * user across multiple requests, then Bing may assign the user to multiple + * conflicting flights. Being assigned to multiple conflicting flights can lead + * to an inconsistent user experience. For example, if the second request has a + * different flight assignment than the first, the experience may be + * unexpected. Also, Bing can use the client ID to tailor web results to that + * client ID’s search history, providing a richer experience for the user. Bing + * also uses this header to help improve result rankings by analyzing the + * activity generated by a client ID. The relevance improvements help with + * better quality of results delivered by Bing APIs and in turn enables higher + * click-through rates for the API consumer. IMPORTANT: Although optional, you + * should consider this header required. Persisting the client ID across + * multiple requests for the same end user and device combination enables 1) + * the API consumer to receive a consistent user experience, and 2) higher + * click-through rates via better quality of results from the Bing APIs. Each + * user that uses your application on the device must have a unique, Bing + * generated client ID. If you do not include this header in the request, Bing + * generates an ID and returns it in the X-MSEdge-ClientID response header. The + * only time that you should NOT include this header in a request is the first + * time the user uses your app on that device. Use the client ID for each Bing + * API request that your app makes for this user on the device. Persist the + * client ID. To persist the ID in a browser app, use a persistent HTTP cookie + * to ensure the ID is used across all sessions. Do not use a session cookie. + * For other apps such as mobile apps, use the device's persistent storage to + * persist the ID. The next time the user uses your app on that device, get the + * client ID that you persisted. Bing responses may or may not include this + * header. If the response includes this header, capture the client ID and use + * it for all subsequent Bing requests for the user on that device. If you + * include the X-MSEdge-ClientID, you must not include cookies in the request. + * + * @param {string} [options.clientIp] The IPv4 or IPv6 address of the client + * device. The IP address is used to discover the user's location. Bing uses + * the location information to determine safe search behavior. Although + * optional, you are encouraged to always specify this header and the + * X-Search-Location header. Do not obfuscate the address (for example, by + * changing the last octet to 0). Obfuscating the address results in the + * location not being anywhere near the device's actual location, which may + * result in Bing serving erroneous results. + * + * @param {string} [options.location] A semicolon-delimited list of key/value + * pairs that describe the client's geographical location. Bing uses the + * location information to determine safe search behavior and to return + * relevant local content. Specify the key/value pair as :. The + * following are the keys that you use to specify the user's location. lat + * (required): The latitude of the client's location, in degrees. The latitude + * must be greater than or equal to -90.0 and less than or equal to +90.0. + * Negative values indicate southern latitudes and positive values indicate + * northern latitudes. long (required): The longitude of the client's location, + * in degrees. The longitude must be greater than or equal to -180.0 and less + * than or equal to +180.0. Negative values indicate western longitudes and + * positive values indicate eastern longitudes. re (required): The radius, in + * meters, which specifies the horizontal accuracy of the coordinates. Pass the + * value returned by the device's location service. Typical values might be 22m + * for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP + * lookup. ts (optional): The UTC UNIX timestamp of when the client was at the + * location. (The UNIX timestamp is the number of seconds since January 1, + * 1970.) head (optional): The client's relative heading or direction of + * travel. Specify the direction of travel as degrees from 0 through 360, + * counting clockwise relative to true north. Specify this key only if the sp + * key is nonzero. sp (optional): The horizontal velocity (speed), in meters + * per second, that the client device is traveling. alt (optional): The + * altitude of the client device, in meters. are (optional): The radius, in + * meters, that specifies the vertical accuracy of the coordinates. Specify + * this key only if you specify the alt key. Although many of the keys are + * optional, the more information that you provide, the more accurate the + * location results are. Although optional, you are encouraged to always + * specify the user's geographical location. Providing the location is + * especially important if the client's IP address does not accurately reflect + * the user's physical location (for example, if the client uses VPN). For + * optimal results, you should include this header and the X-MSEdge-ClientIP + * header, but at a minimum, you should include this header. + * + * @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 + * you set this parameter, you must also specify the Accept-Language header. + * Bing uses the first supported language it finds from the languages list, and + * combine that language with the country code that you specify to determine + * the market to return results for. If the languages list does not include a + * supported language, Bing finds the closest language and market that supports + * the request, or it may use an aggregated or default market for the results + * instead of a specified one. You should use this query parameter and the + * Accept-Language query parameter only if you specify multiple languages; + * otherwise, you should use the mkt and setLang query parameters. This + * parameter and the mkt query parameter are mutually exclusive—do not specify + * both. + * + * @param {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.localCategories] comma-delimited list of business + * categories to search for. Supported categories can be high-level such as + * EatDrink, Shop, SeeDo. + * + * @param {string} [options.localCircularView] Preferred location to search + * around, expressed as Latitude, longitude and radius in meters. For example + * 47.61503,-122.1719,5000. Note that circular view should only be used to + * indicate a search around a point on the map, not as an approximation for a + * view port of a map rectangle. + * + * @param {string} [options.localMapView] Preferred bounding box for results, + * specified in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. + * For example 47.64,-122.13,47.63,-122.12. These values are lat, long pairs + * for the Northwest corner and the Southeast corner of a rectangle. + * + * @param {string} [options.count] Preferred number of results to return. If + * not specified, then Bing returns 1-20 of the most relevant results. + * + * @param {string} [options.first] First result to return. zero-based. default + * is 0. + * + * @param {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {string} [options.safeSearch] A filter used to filter adult content. + * Off: Return webpages with adult text, images, or videos. Moderate: Return + * webpages with adult text, but not adult images or videos. Strict: Do not + * return webpages with adult text, images, or videos. The default is Moderate. + * If the request comes from a market that Bing's adult policy requires that + * safeSearch is set to Strict, Bing ignores the safeSearch value and uses + * Strict. If you use the site: query operator, there is the chance that the + * response may contain adult content regardless of what the safeSearch query + * parameter is set to. Use site: only if you are aware of the content on the + * site and your scenario supports the possibility of adult content. Possible + * values include: 'Off', 'Moderate', 'Strict' + * + * @param {string} [options.setLang] The language to use for user interface + * strings. Specify the language using the ISO 639-1 2-letter language code. + * For example, the language code for English is EN. The default is EN + * (English). Although optional, you should always specify the language. + * Typically, you set setLang to the same language specified by mkt unless the + * user wants the user interface strings displayed in a different language. + * This parameter and the Accept-Language header are mutually exclusive; do not + * specify both. A user interface string is a string that's used as a label in + * a user interface. There are few user interface strings in the JSON response + * objects. Also, any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {SearchResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {SearchResponse} [result] - The deserialized result object if an error did not occur. + * See {@link SearchResponse} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + search(query: string, options?: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, localCategories? : string, localCircularView? : string, localMapView? : string, count? : string, first? : string, responseFormat? : string[], safeSearch? : string, setLang? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + search(query: string, callback: ServiceCallback): void; + search(query: string, options: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, localCategories? : string, localCircularView? : string, localMapView? : string, count? : string, first? : string, responseFormat? : string[], safeSearch? : string, setLang? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/cognitiveServicesLocalSearch/lib/operations/index.js b/lib/services/cognitiveServicesLocalSearch/lib/operations/index.js new file mode 100644 index 0000000000..46ad369459 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/operations/index.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.Local = require('./local'); diff --git a/lib/services/cognitiveServicesLocalSearch/lib/operations/local.js b/lib/services/cognitiveServicesLocalSearch/lib/operations/local.js new file mode 100644 index 0000000000..f4c8d2afb1 --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/lib/operations/local.js @@ -0,0 +1,891 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const WebResource = msRest.WebResource; + +/** + * @summary The Local Search API lets you send a search query to Bing and get + * back search results that include local businesses such as restaurants, + * hotels, retail stores, or other local businesses. The query can specify the + * name of the local business or it can ask for a list (for example, + * restaurants near me). + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.acceptLanguage] A comma-delimited list of one or + * more languages to use for user interface strings. The list is in decreasing + * order of preference. For additional information, including expected format, + * see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This + * header and the setLang query parameter are mutually exclusive; do not + * specify both. If you set this header, you must also specify the cc query + * parameter. Bing will use the first supported language it finds from the + * list, and combine that language with the cc parameter value to determine the + * market to return results for. If the list does not include a supported + * language, Bing will find the closest language and market that supports the + * request, and may use an aggregated or default market for the results instead + * of a specified one. You should use this header and the cc query parameter + * only if you specify multiple languages; otherwise, you should use the mkt + * and setLang query parameters. A user interface string is a string that's + * used as a label in a user interface. There are very few user interface + * strings in the JSON response objects. Any links in the response objects to + * Bing.com properties will apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are strongly encouraged to always specify + * this header. The user-agent should be the same string that any commonly used + * browser would send. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + * + * @param {string} [options.clientId] Bing uses this header to provide users + * with consistent behavior across Bing API calls. Bing often flights new + * features and improvements, and it uses the client ID as a key for assigning + * traffic on different flights. If you do not use the same client ID for a + * user across multiple requests, then Bing may assign the user to multiple + * conflicting flights. Being assigned to multiple conflicting flights can lead + * to an inconsistent user experience. For example, if the second request has a + * different flight assignment than the first, the experience may be + * unexpected. Also, Bing can use the client ID to tailor web results to that + * client ID’s search history, providing a richer experience for the user. Bing + * also uses this header to help improve result rankings by analyzing the + * activity generated by a client ID. The relevance improvements help with + * better quality of results delivered by Bing APIs and in turn enables higher + * click-through rates for the API consumer. IMPORTANT: Although optional, you + * should consider this header required. Persisting the client ID across + * multiple requests for the same end user and device combination enables 1) + * the API consumer to receive a consistent user experience, and 2) higher + * click-through rates via better quality of results from the Bing APIs. Each + * user that uses your application on the device must have a unique, Bing + * generated client ID. If you do not include this header in the request, Bing + * generates an ID and returns it in the X-MSEdge-ClientID response header. The + * only time that you should NOT include this header in a request is the first + * time the user uses your app on that device. Use the client ID for each Bing + * API request that your app makes for this user on the device. Persist the + * client ID. To persist the ID in a browser app, use a persistent HTTP cookie + * to ensure the ID is used across all sessions. Do not use a session cookie. + * For other apps such as mobile apps, use the device's persistent storage to + * persist the ID. The next time the user uses your app on that device, get the + * client ID that you persisted. Bing responses may or may not include this + * header. If the response includes this header, capture the client ID and use + * it for all subsequent Bing requests for the user on that device. If you + * include the X-MSEdge-ClientID, you must not include cookies in the request. + * + * @param {string} [options.clientIp] The IPv4 or IPv6 address of the client + * device. The IP address is used to discover the user's location. Bing uses + * the location information to determine safe search behavior. Although + * optional, you are encouraged to always specify this header and the + * X-Search-Location header. Do not obfuscate the address (for example, by + * changing the last octet to 0). Obfuscating the address results in the + * location not being anywhere near the device's actual location, which may + * result in Bing serving erroneous results. + * + * @param {string} [options.location] A semicolon-delimited list of key/value + * pairs that describe the client's geographical location. Bing uses the + * location information to determine safe search behavior and to return + * relevant local content. Specify the key/value pair as :. The + * following are the keys that you use to specify the user's location. lat + * (required): The latitude of the client's location, in degrees. The latitude + * must be greater than or equal to -90.0 and less than or equal to +90.0. + * Negative values indicate southern latitudes and positive values indicate + * northern latitudes. long (required): The longitude of the client's location, + * in degrees. The longitude must be greater than or equal to -180.0 and less + * than or equal to +180.0. Negative values indicate western longitudes and + * positive values indicate eastern longitudes. re (required): The radius, in + * meters, which specifies the horizontal accuracy of the coordinates. Pass the + * value returned by the device's location service. Typical values might be 22m + * for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP + * lookup. ts (optional): The UTC UNIX timestamp of when the client was at the + * location. (The UNIX timestamp is the number of seconds since January 1, + * 1970.) head (optional): The client's relative heading or direction of + * travel. Specify the direction of travel as degrees from 0 through 360, + * counting clockwise relative to true north. Specify this key only if the sp + * key is nonzero. sp (optional): The horizontal velocity (speed), in meters + * per second, that the client device is traveling. alt (optional): The + * altitude of the client device, in meters. are (optional): The radius, in + * meters, that specifies the vertical accuracy of the coordinates. Specify + * this key only if you specify the alt key. Although many of the keys are + * optional, the more information that you provide, the more accurate the + * location results are. Although optional, you are encouraged to always + * specify the user's geographical location. Providing the location is + * especially important if the client's IP address does not accurately reflect + * the user's physical location (for example, if the client uses VPN). For + * optimal results, you should include this header and the X-MSEdge-ClientIP + * header, but at a minimum, you should include this header. + * + * @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 + * you set this parameter, you must also specify the Accept-Language header. + * Bing uses the first supported language it finds from the languages list, and + * combine that language with the country code that you specify to determine + * the market to return results for. If the languages list does not include a + * supported language, Bing finds the closest language and market that supports + * the request, or it may use an aggregated or default market for the results + * instead of a specified one. You should use this query parameter and the + * Accept-Language query parameter only if you specify multiple languages; + * otherwise, you should use the mkt and setLang query parameters. This + * parameter and the mkt query parameter are mutually exclusive—do not specify + * both. + * + * @param {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.localCategories] comma-delimited list of business + * categories to search for. Supported categories can be high-level such as + * EatDrink, Shop, SeeDo. + * + * @param {string} [options.localCircularView] Preferred location to search + * around, expressed as Latitude, longitude and radius in meters. For example + * 47.61503,-122.1719,5000. Note that circular view should only be used to + * indicate a search around a point on the map, not as an approximation for a + * view port of a map rectangle. + * + * @param {string} [options.localMapView] Preferred bounding box for results, + * specified in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. + * For example 47.64,-122.13,47.63,-122.12. These values are lat, long pairs + * for the Northwest corner and the Southeast corner of a rectangle. + * + * @param {string} [options.count] Preferred number of results to return. If + * not specified, then Bing returns 1-20 of the most relevant results. + * + * @param {string} [options.first] First result to return. zero-based. default + * is 0. + * + * @param {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {string} [options.safeSearch] A filter used to filter adult content. + * Off: Return webpages with adult text, images, or videos. Moderate: Return + * webpages with adult text, but not adult images or videos. Strict: Do not + * return webpages with adult text, images, or videos. The default is Moderate. + * If the request comes from a market that Bing's adult policy requires that + * safeSearch is set to Strict, Bing ignores the safeSearch value and uses + * Strict. If you use the site: query operator, there is the chance that the + * response may contain adult content regardless of what the safeSearch query + * parameter is set to. Use site: only if you are aware of the content on the + * site and your scenario supports the possibility of adult content. Possible + * values include: 'Off', 'Moderate', 'Strict' + * + * @param {string} [options.setLang] The language to use for user interface + * strings. Specify the language using the ISO 639-1 2-letter language code. + * For example, the language code for English is EN. The default is EN + * (English). Although optional, you should always specify the language. + * Typically, you set setLang to the same language specified by mkt unless the + * user wants the user interface strings displayed in a different language. + * This parameter and the Accept-Language header are mutually exclusive; do not + * specify both. A user interface string is a string that's used as a label in + * a user interface. There are few user interface strings in the JSON response + * objects. Also, any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link SearchResponse} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _search(query, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let acceptLanguage = (options && options.acceptLanguage !== undefined) ? options.acceptLanguage : undefined; + let pragma = (options && options.pragma !== undefined) ? options.pragma : undefined; + let userAgent = (options && options.userAgent !== undefined) ? options.userAgent : undefined; + 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 countryCode = (options && options.countryCode !== undefined) ? options.countryCode : undefined; + let market = (options && options.market !== undefined) ? options.market : 'en-us'; + let localCategories = (options && options.localCategories !== undefined) ? options.localCategories : undefined; + let localCircularView = (options && options.localCircularView !== undefined) ? options.localCircularView : undefined; + let localMapView = (options && options.localMapView !== undefined) ? options.localMapView : undefined; + let count = (options && options.count !== undefined) ? options.count : undefined; + let first = (options && options.first !== undefined) ? options.first : undefined; + let responseFormat = (options && options.responseFormat !== undefined) ? options.responseFormat : undefined; + let safeSearch = (options && options.safeSearch !== undefined) ? options.safeSearch : undefined; + let setLang = (options && options.setLang !== undefined) ? options.setLang : undefined; + let xBingApisSDK = 'true'; + // Validate + try { + if (acceptLanguage !== null && acceptLanguage !== undefined && typeof acceptLanguage.valueOf() !== 'string') { + throw new Error('acceptLanguage must be of type string.'); + } + if (pragma !== null && pragma !== undefined && typeof pragma.valueOf() !== 'string') { + throw new Error('pragma must be of type string.'); + } + if (userAgent !== null && userAgent !== undefined && typeof userAgent.valueOf() !== 'string') { + throw new Error('userAgent must be of type string.'); + } + if (clientId !== null && clientId !== undefined && typeof clientId.valueOf() !== 'string') { + throw new Error('clientId must be of type string.'); + } + if (clientIp !== null && clientIp !== undefined && typeof clientIp.valueOf() !== 'string') { + throw new Error('clientIp must be of type string.'); + } + if (location !== null && location !== undefined && typeof location.valueOf() !== 'string') { + throw new Error('location must be of type string.'); + } + if (countryCode !== null && countryCode !== undefined && typeof countryCode.valueOf() !== 'string') { + throw new Error('countryCode must be of type string.'); + } + if (market !== null && market !== undefined && typeof market.valueOf() !== 'string') { + throw new Error('market must be of type string.'); + } + if (query === null || query === undefined || typeof query.valueOf() !== 'string') { + throw new Error('query cannot be null or undefined and it must be of type string.'); + } + if (localCategories !== null && localCategories !== undefined && typeof localCategories.valueOf() !== 'string') { + throw new Error('localCategories must be of type string.'); + } + if (localCircularView !== null && localCircularView !== undefined && typeof localCircularView.valueOf() !== 'string') { + throw new Error('localCircularView must be of type string.'); + } + if (localMapView !== null && localMapView !== undefined && typeof localMapView.valueOf() !== 'string') { + throw new Error('localMapView must be of type string.'); + } + if (count !== null && count !== undefined && typeof count.valueOf() !== 'string') { + throw new Error('count must be of type string.'); + } + if (first !== null && first !== undefined && typeof first.valueOf() !== 'string') { + throw new Error('first must be of type string.'); + } + if (Array.isArray(responseFormat)) { + for (let i = 0; i < responseFormat.length; i++) { + if (responseFormat[i] !== null && responseFormat[i] !== undefined && typeof responseFormat[i].valueOf() !== 'string') { + throw new Error('responseFormat[i] must be of type string.'); + } + } + } + if (safeSearch !== null && safeSearch !== undefined && typeof safeSearch.valueOf() !== 'string') { + throw new Error('safeSearch must be of type string.'); + } + if (setLang !== null && setLang !== undefined && typeof setLang.valueOf() !== 'string') { + throw new Error('setLang must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'localbusinesses/v7.0/search'; + let queryParameters = []; + if (countryCode !== null && countryCode !== undefined) { + queryParameters.push('cc=' + encodeURIComponent(countryCode)); + } + if (market !== null && market !== undefined) { + queryParameters.push('mkt=' + encodeURIComponent(market)); + } + queryParameters.push('q=' + encodeURIComponent(query)); + if (localCategories !== null && localCategories !== undefined) { + queryParameters.push('localcategories=' + encodeURIComponent(localCategories)); + } + if (localCircularView !== null && localCircularView !== undefined) { + queryParameters.push('localcircularview=' + encodeURIComponent(localCircularView)); + } + if (localMapView !== null && localMapView !== undefined) { + queryParameters.push('localmapview=' + encodeURIComponent(localMapView)); + } + if (count !== null && count !== undefined) { + queryParameters.push('count=' + encodeURIComponent(count)); + } + if (first !== null && first !== undefined) { + queryParameters.push('first=' + encodeURIComponent(first)); + } + if (responseFormat !== null && responseFormat !== undefined) { + queryParameters.push('ResponseFormat=' + encodeURIComponent(responseFormat.join(','))); + } + if (safeSearch !== null && safeSearch !== undefined) { + queryParameters.push('SafeSearch=' + encodeURIComponent(safeSearch)); + } + if (setLang !== null && setLang !== undefined) { + queryParameters.push('SetLang=' + encodeURIComponent(setLang)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (xBingApisSDK !== undefined && xBingApisSDK !== null) { + httpRequest.headers['X-BingApis-SDK'] = xBingApisSDK; + } + if (acceptLanguage !== undefined && acceptLanguage !== null) { + httpRequest.headers['Accept-Language'] = acceptLanguage; + } + if (pragma !== undefined && pragma !== null) { + httpRequest.headers['Pragma'] = pragma; + } + if (userAgent !== undefined && userAgent !== null) { + httpRequest.headers['User-Agent'] = userAgent; + } + if (clientId !== undefined && clientId !== null) { + httpRequest.headers['X-MSEdge-ClientID'] = clientId; + } + if (clientIp !== undefined && clientIp !== null) { + httpRequest.headers['X-MSEdge-ClientIP'] = clientIp; + } + if (location !== undefined && location !== null) { + httpRequest.headers['X-Search-Location'] = location; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['SearchResponse']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Local. */ +class Local { + /** + * Create a Local. + * @param {LocalSearchClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._search = _search; + } + + /** + * @summary The Local Search API lets you send a search query to Bing and get + * back search results that include local businesses such as restaurants, + * hotels, retail stores, or other local businesses. The query can specify the + * name of the local business or it can ask for a list (for example, + * restaurants near me). + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.acceptLanguage] A comma-delimited list of one or + * more languages to use for user interface strings. The list is in decreasing + * order of preference. For additional information, including expected format, + * see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This + * header and the setLang query parameter are mutually exclusive; do not + * specify both. If you set this header, you must also specify the cc query + * parameter. Bing will use the first supported language it finds from the + * list, and combine that language with the cc parameter value to determine the + * market to return results for. If the list does not include a supported + * language, Bing will find the closest language and market that supports the + * request, and may use an aggregated or default market for the results instead + * of a specified one. You should use this header and the cc query parameter + * only if you specify multiple languages; otherwise, you should use the mkt + * and setLang query parameters. A user interface string is a string that's + * used as a label in a user interface. There are very few user interface + * strings in the JSON response objects. Any links in the response objects to + * Bing.com properties will apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are strongly encouraged to always specify + * this header. The user-agent should be the same string that any commonly used + * browser would send. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + * + * @param {string} [options.clientId] Bing uses this header to provide users + * with consistent behavior across Bing API calls. Bing often flights new + * features and improvements, and it uses the client ID as a key for assigning + * traffic on different flights. If you do not use the same client ID for a + * user across multiple requests, then Bing may assign the user to multiple + * conflicting flights. Being assigned to multiple conflicting flights can lead + * to an inconsistent user experience. For example, if the second request has a + * different flight assignment than the first, the experience may be + * unexpected. Also, Bing can use the client ID to tailor web results to that + * client ID’s search history, providing a richer experience for the user. Bing + * also uses this header to help improve result rankings by analyzing the + * activity generated by a client ID. The relevance improvements help with + * better quality of results delivered by Bing APIs and in turn enables higher + * click-through rates for the API consumer. IMPORTANT: Although optional, you + * should consider this header required. Persisting the client ID across + * multiple requests for the same end user and device combination enables 1) + * the API consumer to receive a consistent user experience, and 2) higher + * click-through rates via better quality of results from the Bing APIs. Each + * user that uses your application on the device must have a unique, Bing + * generated client ID. If you do not include this header in the request, Bing + * generates an ID and returns it in the X-MSEdge-ClientID response header. The + * only time that you should NOT include this header in a request is the first + * time the user uses your app on that device. Use the client ID for each Bing + * API request that your app makes for this user on the device. Persist the + * client ID. To persist the ID in a browser app, use a persistent HTTP cookie + * to ensure the ID is used across all sessions. Do not use a session cookie. + * For other apps such as mobile apps, use the device's persistent storage to + * persist the ID. The next time the user uses your app on that device, get the + * client ID that you persisted. Bing responses may or may not include this + * header. If the response includes this header, capture the client ID and use + * it for all subsequent Bing requests for the user on that device. If you + * include the X-MSEdge-ClientID, you must not include cookies in the request. + * + * @param {string} [options.clientIp] The IPv4 or IPv6 address of the client + * device. The IP address is used to discover the user's location. Bing uses + * the location information to determine safe search behavior. Although + * optional, you are encouraged to always specify this header and the + * X-Search-Location header. Do not obfuscate the address (for example, by + * changing the last octet to 0). Obfuscating the address results in the + * location not being anywhere near the device's actual location, which may + * result in Bing serving erroneous results. + * + * @param {string} [options.location] A semicolon-delimited list of key/value + * pairs that describe the client's geographical location. Bing uses the + * location information to determine safe search behavior and to return + * relevant local content. Specify the key/value pair as :. The + * following are the keys that you use to specify the user's location. lat + * (required): The latitude of the client's location, in degrees. The latitude + * must be greater than or equal to -90.0 and less than or equal to +90.0. + * Negative values indicate southern latitudes and positive values indicate + * northern latitudes. long (required): The longitude of the client's location, + * in degrees. The longitude must be greater than or equal to -180.0 and less + * than or equal to +180.0. Negative values indicate western longitudes and + * positive values indicate eastern longitudes. re (required): The radius, in + * meters, which specifies the horizontal accuracy of the coordinates. Pass the + * value returned by the device's location service. Typical values might be 22m + * for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP + * lookup. ts (optional): The UTC UNIX timestamp of when the client was at the + * location. (The UNIX timestamp is the number of seconds since January 1, + * 1970.) head (optional): The client's relative heading or direction of + * travel. Specify the direction of travel as degrees from 0 through 360, + * counting clockwise relative to true north. Specify this key only if the sp + * key is nonzero. sp (optional): The horizontal velocity (speed), in meters + * per second, that the client device is traveling. alt (optional): The + * altitude of the client device, in meters. are (optional): The radius, in + * meters, that specifies the vertical accuracy of the coordinates. Specify + * this key only if you specify the alt key. Although many of the keys are + * optional, the more information that you provide, the more accurate the + * location results are. Although optional, you are encouraged to always + * specify the user's geographical location. Providing the location is + * especially important if the client's IP address does not accurately reflect + * the user's physical location (for example, if the client uses VPN). For + * optimal results, you should include this header and the X-MSEdge-ClientIP + * header, but at a minimum, you should include this header. + * + * @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 + * you set this parameter, you must also specify the Accept-Language header. + * Bing uses the first supported language it finds from the languages list, and + * combine that language with the country code that you specify to determine + * the market to return results for. If the languages list does not include a + * supported language, Bing finds the closest language and market that supports + * the request, or it may use an aggregated or default market for the results + * instead of a specified one. You should use this query parameter and the + * Accept-Language query parameter only if you specify multiple languages; + * otherwise, you should use the mkt and setLang query parameters. This + * parameter and the mkt query parameter are mutually exclusive—do not specify + * both. + * + * @param {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.localCategories] comma-delimited list of business + * categories to search for. Supported categories can be high-level such as + * EatDrink, Shop, SeeDo. + * + * @param {string} [options.localCircularView] Preferred location to search + * around, expressed as Latitude, longitude and radius in meters. For example + * 47.61503,-122.1719,5000. Note that circular view should only be used to + * indicate a search around a point on the map, not as an approximation for a + * view port of a map rectangle. + * + * @param {string} [options.localMapView] Preferred bounding box for results, + * specified in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. + * For example 47.64,-122.13,47.63,-122.12. These values are lat, long pairs + * for the Northwest corner and the Southeast corner of a rectangle. + * + * @param {string} [options.count] Preferred number of results to return. If + * not specified, then Bing returns 1-20 of the most relevant results. + * + * @param {string} [options.first] First result to return. zero-based. default + * is 0. + * + * @param {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {string} [options.safeSearch] A filter used to filter adult content. + * Off: Return webpages with adult text, images, or videos. Moderate: Return + * webpages with adult text, but not adult images or videos. Strict: Do not + * return webpages with adult text, images, or videos. The default is Moderate. + * If the request comes from a market that Bing's adult policy requires that + * safeSearch is set to Strict, Bing ignores the safeSearch value and uses + * Strict. If you use the site: query operator, there is the chance that the + * response may contain adult content regardless of what the safeSearch query + * parameter is set to. Use site: only if you are aware of the content on the + * site and your scenario supports the possibility of adult content. Possible + * values include: 'Off', 'Moderate', 'Strict' + * + * @param {string} [options.setLang] The language to use for user interface + * strings. Specify the language using the ISO 639-1 2-letter language code. + * For example, the language code for English is EN. The default is EN + * (English). Although optional, you should always specify the language. + * Typically, you set setLang to the same language specified by mkt unless the + * user wants the user interface strings displayed in a different language. + * This parameter and the Accept-Language header are mutually exclusive; do not + * specify both. A user interface string is a string that's used as a label in + * a user interface. There are few user interface strings in the JSON response + * objects. Also, any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + searchWithHttpOperationResponse(query, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._search(query, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary The Local Search API lets you send a search query to Bing and get + * back search results that include local businesses such as restaurants, + * hotels, retail stores, or other local businesses. The query can specify the + * name of the local business or it can ask for a list (for example, + * restaurants near me). + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.acceptLanguage] A comma-delimited list of one or + * more languages to use for user interface strings. The list is in decreasing + * order of preference. For additional information, including expected format, + * see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This + * header and the setLang query parameter are mutually exclusive; do not + * specify both. If you set this header, you must also specify the cc query + * parameter. Bing will use the first supported language it finds from the + * list, and combine that language with the cc parameter value to determine the + * market to return results for. If the list does not include a supported + * language, Bing will find the closest language and market that supports the + * request, and may use an aggregated or default market for the results instead + * of a specified one. You should use this header and the cc query parameter + * only if you specify multiple languages; otherwise, you should use the mkt + * and setLang query parameters. A user interface string is a string that's + * used as a label in a user interface. There are very few user interface + * strings in the JSON response objects. Any links in the response objects to + * Bing.com properties will apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are strongly encouraged to always specify + * this header. The user-agent should be the same string that any commonly used + * browser would send. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + * + * @param {string} [options.clientId] Bing uses this header to provide users + * with consistent behavior across Bing API calls. Bing often flights new + * features and improvements, and it uses the client ID as a key for assigning + * traffic on different flights. If you do not use the same client ID for a + * user across multiple requests, then Bing may assign the user to multiple + * conflicting flights. Being assigned to multiple conflicting flights can lead + * to an inconsistent user experience. For example, if the second request has a + * different flight assignment than the first, the experience may be + * unexpected. Also, Bing can use the client ID to tailor web results to that + * client ID’s search history, providing a richer experience for the user. Bing + * also uses this header to help improve result rankings by analyzing the + * activity generated by a client ID. The relevance improvements help with + * better quality of results delivered by Bing APIs and in turn enables higher + * click-through rates for the API consumer. IMPORTANT: Although optional, you + * should consider this header required. Persisting the client ID across + * multiple requests for the same end user and device combination enables 1) + * the API consumer to receive a consistent user experience, and 2) higher + * click-through rates via better quality of results from the Bing APIs. Each + * user that uses your application on the device must have a unique, Bing + * generated client ID. If you do not include this header in the request, Bing + * generates an ID and returns it in the X-MSEdge-ClientID response header. The + * only time that you should NOT include this header in a request is the first + * time the user uses your app on that device. Use the client ID for each Bing + * API request that your app makes for this user on the device. Persist the + * client ID. To persist the ID in a browser app, use a persistent HTTP cookie + * to ensure the ID is used across all sessions. Do not use a session cookie. + * For other apps such as mobile apps, use the device's persistent storage to + * persist the ID. The next time the user uses your app on that device, get the + * client ID that you persisted. Bing responses may or may not include this + * header. If the response includes this header, capture the client ID and use + * it for all subsequent Bing requests for the user on that device. If you + * include the X-MSEdge-ClientID, you must not include cookies in the request. + * + * @param {string} [options.clientIp] The IPv4 or IPv6 address of the client + * device. The IP address is used to discover the user's location. Bing uses + * the location information to determine safe search behavior. Although + * optional, you are encouraged to always specify this header and the + * X-Search-Location header. Do not obfuscate the address (for example, by + * changing the last octet to 0). Obfuscating the address results in the + * location not being anywhere near the device's actual location, which may + * result in Bing serving erroneous results. + * + * @param {string} [options.location] A semicolon-delimited list of key/value + * pairs that describe the client's geographical location. Bing uses the + * location information to determine safe search behavior and to return + * relevant local content. Specify the key/value pair as :. The + * following are the keys that you use to specify the user's location. lat + * (required): The latitude of the client's location, in degrees. The latitude + * must be greater than or equal to -90.0 and less than or equal to +90.0. + * Negative values indicate southern latitudes and positive values indicate + * northern latitudes. long (required): The longitude of the client's location, + * in degrees. The longitude must be greater than or equal to -180.0 and less + * than or equal to +180.0. Negative values indicate western longitudes and + * positive values indicate eastern longitudes. re (required): The radius, in + * meters, which specifies the horizontal accuracy of the coordinates. Pass the + * value returned by the device's location service. Typical values might be 22m + * for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP + * lookup. ts (optional): The UTC UNIX timestamp of when the client was at the + * location. (The UNIX timestamp is the number of seconds since January 1, + * 1970.) head (optional): The client's relative heading or direction of + * travel. Specify the direction of travel as degrees from 0 through 360, + * counting clockwise relative to true north. Specify this key only if the sp + * key is nonzero. sp (optional): The horizontal velocity (speed), in meters + * per second, that the client device is traveling. alt (optional): The + * altitude of the client device, in meters. are (optional): The radius, in + * meters, that specifies the vertical accuracy of the coordinates. Specify + * this key only if you specify the alt key. Although many of the keys are + * optional, the more information that you provide, the more accurate the + * location results are. Although optional, you are encouraged to always + * specify the user's geographical location. Providing the location is + * especially important if the client's IP address does not accurately reflect + * the user's physical location (for example, if the client uses VPN). For + * optimal results, you should include this header and the X-MSEdge-ClientIP + * header, but at a minimum, you should include this header. + * + * @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 + * you set this parameter, you must also specify the Accept-Language header. + * Bing uses the first supported language it finds from the languages list, and + * combine that language with the country code that you specify to determine + * the market to return results for. If the languages list does not include a + * supported language, Bing finds the closest language and market that supports + * the request, or it may use an aggregated or default market for the results + * instead of a specified one. You should use this query parameter and the + * Accept-Language query parameter only if you specify multiple languages; + * otherwise, you should use the mkt and setLang query parameters. This + * parameter and the mkt query parameter are mutually exclusive—do not specify + * both. + * + * @param {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.localCategories] comma-delimited list of business + * categories to search for. Supported categories can be high-level such as + * EatDrink, Shop, SeeDo. + * + * @param {string} [options.localCircularView] Preferred location to search + * around, expressed as Latitude, longitude and radius in meters. For example + * 47.61503,-122.1719,5000. Note that circular view should only be used to + * indicate a search around a point on the map, not as an approximation for a + * view port of a map rectangle. + * + * @param {string} [options.localMapView] Preferred bounding box for results, + * specified in NW_latitude, NW_Longitude, SE_Latitude, SE_Longitude format. + * For example 47.64,-122.13,47.63,-122.12. These values are lat, long pairs + * for the Northwest corner and the Southeast corner of a rectangle. + * + * @param {string} [options.count] Preferred number of results to return. If + * not specified, then Bing returns 1-20 of the most relevant results. + * + * @param {string} [options.first] First result to return. zero-based. default + * is 0. + * + * @param {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {string} [options.safeSearch] A filter used to filter adult content. + * Off: Return webpages with adult text, images, or videos. Moderate: Return + * webpages with adult text, but not adult images or videos. Strict: Do not + * return webpages with adult text, images, or videos. The default is Moderate. + * If the request comes from a market that Bing's adult policy requires that + * safeSearch is set to Strict, Bing ignores the safeSearch value and uses + * Strict. If you use the site: query operator, there is the chance that the + * response may contain adult content regardless of what the safeSearch query + * parameter is set to. Use site: only if you are aware of the content on the + * site and your scenario supports the possibility of adult content. Possible + * values include: 'Off', 'Moderate', 'Strict' + * + * @param {string} [options.setLang] The language to use for user interface + * strings. Specify the language using the ISO 639-1 2-letter language code. + * For example, the language code for English is EN. The default is EN + * (English). Although optional, you should always specify the language. + * Typically, you set setLang to the same language specified by mkt unless the + * user wants the user interface strings displayed in a different language. + * This parameter and the Accept-Language header are mutually exclusive; do not + * specify both. A user interface string is a string that's used as a label in + * a user interface. There are few user interface strings in the JSON response + * objects. Also, any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {SearchResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link SearchResponse} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + search(query, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._search(query, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._search(query, options, optionalCallback); + } + } + +} + +module.exports = Local; diff --git a/lib/services/cognitiveServicesLocalSearch/package.json b/lib/services/cognitiveServicesLocalSearch/package.json new file mode 100644 index 0000000000..156da1ec6b --- /dev/null +++ b/lib/services/cognitiveServicesLocalSearch/package.json @@ -0,0 +1,24 @@ +{ + "name": "azure-cognitiveservices-localsearch", + "author": "Microsoft Corporation", + "description": "LocalSearchClient Library with typescript type definitions for node", + "version": "1.0.0", + "dependencies": { + "ms-rest": "^2.3.3" + }, + "keywords": [ + "node", + "azure" + ], + "license": "MIT", + "main": "./lib/localSearchClient.js", + "types": "./lib/localSearchClient.d.ts", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/cognitiveServicesLocalSearch", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-node/issues" + } +}