Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag />
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<PackageId>BingLocalSearch.Tests</PackageId>
<VersionPrefix>1.0.0-preview</VersionPrefix>
<AssemblyName>BingLocalSearch.Tests</AssemblyName>
<Description>BingLocalSearch.Tests Class Library</Description>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\BingLocalSearch\BingLocalSearch.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!--Do not remove until VS Test Tools fixes #472-->
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Azure.CognitiveServices.Search.LocalSearch;
using Microsoft.Azure.CognitiveServices.Search.LocalSearch.Models;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System.Linq;
using Xunit;

namespace SearchSDK.Tests
{
public class LocalSearchTests
{
private static string SubscriptionKey = "fake";

// [Fact]
public void LocalSearch()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
HttpMockServer.Initialize(this.GetType().FullName, "LocalSearch");

ILocalSearchClient client = new LocalSearchClient(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());

var resp = client.Local.Search(query: "restaurants");

Assert.NotNull(resp);
Assert.NotNull(resp.QueryContext);
Assert.NotNull(resp.Places);
Assert.NotNull(resp.Places.Value);
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2019
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BingLocalSearch", "BingLocalSearch\BingLocalSearch.csproj", "{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9CFAA11-ADCB-4CE6-8478-ECC4753E7E8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D427FAB-986B-4B80-8831-4C6B4FCD87F0}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Please do not move/edit code below this line -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.reference.props'))" />
<!-- Please do not move/edit code below this line -->

<PropertyGroup>
<PackageId>Microsoft.Azure.CognitiveServices.Search.LocalSearch</PackageId>
<Description>Provides ability to search for businesses</Description>
<Version>0.9.0-preview</Version>
<AssemblyName>Microsoft.Azure.CognitiveServices.BingLocalSearch</AssemblyName>
<PackageTags>CognitiveServices;Bing;BingLocalSearch;LocalSearch;Local Search</PackageTags>
<PackageReleaseNotes>
<![CDATA[

This version is based on the v1.0 Bing Local Search API specification.

Features:
1. Search for businesses by name ("mcdonald's") or by category ("restaurants")
2. Search for businesses near named geographic places ("restaurants in seattle")
3. Search near specific geographic coordinates using the localCircularView and/or localMapView parameters
4. Search by category id using the localCategories parameter.
]]>
</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net452;netstandard1.4</TargetFrameworks>
</PropertyGroup>

<!-- Please do not move/edit code below this line -->
<Import Condition=" Exists('$([MSBuild]::GetPathOfFileAbove(AzSdk.RP.props))') " Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.RP.props'))" />
<!-- Please do not move/edit code above this line -->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Microsoft.Azure.CognitiveServices.Search.LocalSearch
{
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Rest;

/// <summary>
/// Allows authentication to the API using a basic apiKey mechanism
/// </summary>
public class ApiKeyServiceClientCredentials : ServiceClientCredentials
{
private readonly string subscriptionKey;

/// <summary>
/// Creates a new instance of the ApiKeyServiceClientCredentails class
/// </summary>
/// <param name="subscriptionKey">The subscription key to authenticate and authorize as</param>
public ApiKeyServiceClientCredentials(string subscriptionKey)
{
if (string.IsNullOrWhiteSpace(subscriptionKey))
throw new ArgumentNullException("subscriptionKey");

this.subscriptionKey = subscriptionKey;
}

/// <summary>
/// Add the Basic Authentication Header to each outgoing request
/// </summary>
/// <param name="request">The outgoing request</param>
/// <param name="cancellationToken">A token to cancel the operation</param>
public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request == null)
throw new ArgumentNullException("request");

request.Headers.Add("Ocp-Apim-Subscription-Key", this.subscriptionKey);

return Task.FromResult<object>(null);
}
}
}
Loading