Migrate currency converter endpoints

This commit is contained in:
Pepe Rivera 2019-05-31 12:55:06 -07:00 committed by Matt Cooley
commit f1efe82c7e
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

@ -685,6 +685,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=";
}
}