Skip to content

Commit

Permalink
Merge pull request #23 from fiskaltrust/user/tsc/helipad-url
Browse files Browse the repository at this point in the history
Fixed Helipad URL in config downloader
  • Loading branch information
TSchmiedlechner committed Jun 23, 2021
2 parents 3358104 + 516dda8 commit 6d352b0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/fiskaltrust.AndroidLauncher.Common/Constants/Urls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace fiskaltrust.AndroidLauncher.Common.Constants
{
public static class Urls
{
public const string HELIPAD_SANDBOX = "https://helipad-sandbox.fiskaltrust.cloud/";
public const string HELIPAD_PRODUCTION = "https://helipad.fiskaltrust.cloud/";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using fiskaltrust.storage.serialization.V0;
using fiskaltrust.AndroidLauncher.Common.Constants;
using fiskaltrust.storage.serialization.V0;
using Newtonsoft.Json;
using System;
using System.Net.Http;
Expand All @@ -8,11 +9,10 @@ namespace fiskaltrust.AndroidLauncher.Common.Services.Configuration
{
public class HelipadConfigurationProvider : IConfigurationProvider
{
private const string HELIPAD_URL = "https://helipad-sandbox.fiskaltrust.cloud/";

public async Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken)
public async Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken, bool isSandbox)
{
using(var httpClient = new HttpClient { BaseAddress = new Uri(HELIPAD_URL) })
var helipadUrl = isSandbox ? Urls.HELIPAD_SANDBOX : Urls.HELIPAD_PRODUCTION;
using(var httpClient = new HttpClient { BaseAddress = new Uri(helipadUrl) })
{
httpClient.DefaultRequestHeaders.Add("cashboxid", cashboxId.ToString());
httpClient.DefaultRequestHeaders.Add("accesstoken", accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace fiskaltrust.AndroidLauncher.Common.Services.Configuration
{
internal interface IConfigurationProvider
{
Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken);
Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken, bool isSandbox);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task<bool> ConfigurationExistsAsync(Guid cashboxId, string accessTo
return (await SecureStorage.GetAsync($"{SETTING_CASHBOX_KEY_PREFIX}{cashboxId}")) != null;
}

public async Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken)
public async Task<ftCashBoxConfiguration> GetCashboxConfigurationAsync(Guid cashboxId, string accessToken, bool isSandbox)
{
var value = await SecureStorage.GetAsync($"{SETTING_CASHBOX_KEY_PREFIX}{cashboxId}");
if (value == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using fiskaltrust.AndroidLauncher.Common.Extensions;
using fiskaltrust.AndroidLauncher.Common.Constants;
using fiskaltrust.AndroidLauncher.Common.Extensions;
using fiskaltrust.AndroidLauncher.Common.Hosting;
using fiskaltrust.ifPOS.v1;
using fiskaltrust.Middleware.Abstractions;
Expand All @@ -13,16 +14,13 @@ namespace fiskaltrust.AndroidLauncher.Common.Services.Helper
{
public class HelipadHelperProvider
{
private const string HELIPAD_URL = "https://helipad.fiskaltrust.cloud/";
private const string HELIPAD_URL_SANDBOX = "https://helipad-sandbox.fiskaltrust.cloud/";

public IHelper CreateHelper(ftCashBoxConfiguration cashBoxConfiguration, string accessToken, bool isSandbox, LogLevel logLevel, IHost<IPOS> posHost)
{
var config = new Dictionary<string, object>();
config["cashboxid"] = cashBoxConfiguration.ftCashBoxId;
config["accesstoken"] = accessToken;
config["configuration"] = JsonConvert.SerializeObject(cashBoxConfiguration);
config["server"] = isSandbox ? HELIPAD_URL_SANDBOX : HELIPAD_URL;
config["server"] = isSandbox ? Urls.HELIPAD_SANDBOX : Urls.HELIPAD_PRODUCTION;
config["sandbox"] = isSandbox;

var bootstrapper = new HelperBootstrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public async Task StartAsync()
ftCashBoxConfiguration configuration;
try
{
configuration = await _configurationProvider.GetCashboxConfigurationAsync(_cashboxId, _accessToken);
configuration = await _configurationProvider.GetCashboxConfigurationAsync(_cashboxId, _accessToken, _isSandbox);
await _localConfigurationProvider.PersistAsync(_cashboxId, _accessToken, configuration);
}
catch (Exception)
{
configuration = await _localConfigurationProvider.GetCashboxConfigurationAsync(_cashboxId, _accessToken);
configuration = await _localConfigurationProvider.GetCashboxConfigurationAsync(_cashboxId, _accessToken, _isSandbox);
}

foreach (var scuConfig in configuration.ftSignaturCreationDevices)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Compile Include="Broadcasting\StopLauncherBroadcastReceiver.cs" />
<Compile Include="Constants\BroadcastConstants.cs" />
<Compile Include="Constants\StateReasons.cs" />
<Compile Include="Constants\Urls.cs" />
<Compile Include="Enums\LauncherState.cs" />
<Compile Include="Exceptions\ConfigurationNotFoundException.cs" />
<Compile Include="Exceptions\RemountRequiredException.cs" />
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.20-rc1",
"version": "1.3.20-rc2",
"releaseBranches": [
"^refs/heads/master$",
"^refs/heads/release/\\d+(?:\\.\\d+)*(?:-.*)?$",
Expand Down

0 comments on commit 6d352b0

Please sign in to comment.