Migrate currency converter endpoints (#524)

We are migrating the REST endpoint that Currency Converter uses. The REST endpoint is not licensed for your use. To continue to enable community participation in the development of the feature, developer builds will use an alternate REST endpoint that serves mock data (clearly identifiable as it references planets instead of countries).
This commit is contained in:
Pepe Rivera 2019-05-31 12:55:06 -07:00 committed by Matt Cooley
parent 2fd8dc1f9d
commit 2b17f82652
7 changed files with 67 additions and 4 deletions

1
.gitignore vendored
View File

@ -290,6 +290,7 @@ __pycache__/
# Calculator specific
Generated Files/
src/GraphControl/GraphingImplOverrides.props
src/CalcViewModel/DataLoaders/DataLoaderConstants.h
!/build/config/TRexDefs/**
!src/Calculator/TemporaryKey.pfx
!src/CalculatorUnitTests/CalculatorUnitTests_TemporaryKey.pfx

View File

@ -54,6 +54,12 @@ Read our [privacy statement](https://go.microsoft.com/fwlink/?LinkId=521839) to
Telemetry is disabled in development builds by default, and can be enabled with the `SEND_TELEMETRY`
build flag.
## Currency Converter
Windows Calculator includes a currency converter feature that uses mock data in developer builds. The data that
Microsoft uses for the currency converter feature (e.g., in the retail version of the application) is not licensed
for your use. The mock data will be clearly identifiable as it references planets instead of countries,
and remains static regardless of selected inputs.
## Reporting Security Issues
Security issues and bugs should be reported privately, via email, to the
Microsoft Security Response Center (MSRC) at <[secure@microsoft.com](mailto:secure@microsoft.com)>.

View File

@ -408,6 +408,23 @@
<Project>{311e866d-8b93-4609-a691-265941fee101}</Project>
</ProjectReference>
</ItemGroup>
<ItemDefinitionGroup Condition="!Exists('DataLoaders\DataLoaderConstants.h')">
<ClCompile>
<AdditionalOptions>/DUSE_MOCK_DATA %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<Choose>
<When Condition="Exists('DataLoaders\DataLoaderConstants.h')">
<ItemGroup>
<ClInclude Include="DataLoaders\DataLoaderConstants.h" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<ClInclude Include="DataLoaders\DataLoaderMockConstants.h" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<None Include="DataLoaders\DefaultFromToCurrency.json" />
<None Include="packages.config" />

View File

@ -213,6 +213,12 @@
<ClInclude Include="Common\TraceActivity.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="DataLoaders\DataLoaderMockConstants.h">
<Filter>DataLoaders</Filter>
</ClInclude>
<ClInclude Include="DataLoaders\DataLoaderConstants.h">
<Filter>DataLoaders</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="DataLoaders\DefaultFromToCurrency.json">

View File

@ -644,6 +644,23 @@ void CurrencyDataLoader::GuaranteeSelectedUnits()
isConversionTargetSet = true;
}
}
// If still not set for either source or target, just select the first currency in the list
if (!m_currencyUnits.empty())
{
if (!isConversionSourceSet)
{
m_currencyUnits[0].isConversionSource = true;
isConversionSourceSet = true;
}
if (!isConversionTargetSet)
{
m_currencyUnits[0].isConversionTarget = true;
isConversionTargetSet = true;
}
}
}
void CurrencyDataLoader::NotifyDataLoadFinished(bool didLoad)

View File

@ -1,18 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "CurrencyHttpClient.h"
#ifdef USE_MOCK_DATA
#include "DataLoaderMockConstants.h"
#else
#include "DataLoaderConstants.h"
#endif
using namespace CalculatorApp::DataLoaders;
using namespace Platform;
using namespace std;
using namespace Windows::Foundation;
using namespace Windows::Web::Http;
static constexpr auto sc_MetadataUriLocalizeFor = L"https://go.microsoft.com/fwlink/?linkid=2041093&localizeFor=";
static constexpr auto sc_RatiosUriRelativeTo = L"https://go.microsoft.com/fwlink/?linkid=2041339&localCurrency=";
CurrencyHttpClient::CurrencyHttpClient()
: m_client(ref new HttpClient())
, m_responseLanguage(L"en-US")

View File

@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
namespace CalculatorApp
{
namespace DataLoaders
{
static constexpr auto sc_MetadataUriLocalizeFor = L"https://go.microsoft.com/fwlink/?linkid=2091028&localizeFor=";
static constexpr auto sc_RatiosUriRelativeTo = L"https://go.microsoft.com/fwlink/?linkid=2091307&localCurrency=";
}
}