mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 03:27:29 +02:00
Initial version.
This commit is contained in:
parent
193aaa1a56
commit
b72c67a53e
228 changed files with 25924 additions and 0 deletions
45
TINKLib/Services/CopriApi/ServerUris/CopriHelper.cs
Normal file
45
TINKLib/Services/CopriApi/ServerUris/CopriHelper.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using TINK.Model.Services.CopriApi.ServerUris;
|
||||
|
||||
namespace TINK.Services.CopriApi.ServerUris
|
||||
{
|
||||
public static class CopriHelper
|
||||
{
|
||||
public const string SHAREE_SILTEFOLDERNAME = "site";
|
||||
|
||||
/// <summary> Gets a value indicating whether a host is copri or not. </summary>
|
||||
/// <param name="hostName">Host name.</param>
|
||||
/// <returns>True if server is copri, fals if not.</returns>
|
||||
public static bool GetIsCopri(this string hostName)
|
||||
=> new Uri(CopriServerUriList.TINK_DEVEL).Host == hostName
|
||||
|| new Uri(CopriServerUriList.TINK_LIVE).Host == hostName;
|
||||
|
||||
/// <summary> Get folder name depending on host name. </summary>
|
||||
/// <param name="hostName">Host name.</param>
|
||||
/// <returns>Folder name.</returns>
|
||||
public static string GetAppFolderName(this string hostName)
|
||||
=> hostName.GetIsCopri()
|
||||
? "tinkapp" /* resource tree is more complex for TINK/ konrad*/
|
||||
: "app";
|
||||
|
||||
/// <summary> Get folder name for a static site depending on host name. </summary>
|
||||
/// <param name="hostName">Host name.</param>
|
||||
/// <returns>Folder name.</returns>
|
||||
public static string GetSiteFolderName(this string hostName)
|
||||
=> hostName.GetIsCopri()
|
||||
? "tinkapp" /* resource tree is more complex for TINK/ konrad*/
|
||||
: SHAREE_SILTEFOLDERNAME;
|
||||
|
||||
/// <summary> Get the agb resource name name depending on host name. </summary>
|
||||
/// <param name="hostName">Host name.</param>
|
||||
/// <returns>AGB resource..</returns>
|
||||
public static string GetAGBResource(this string hostName)
|
||||
=> $"{hostName.GetSiteFolderName()}/{(hostName.GetIsCopri()? "konrad-TINK-AGB" : "agb.html")}";
|
||||
|
||||
/// <summary> Get the agb resource name name depending on host name. </summary>
|
||||
/// <param name="hostName">Host name.</param>
|
||||
/// <returns>AGB resource..</returns>
|
||||
public static string GetPrivacyResource(this string hostName)
|
||||
=> $"{hostName.GetSiteFolderName()}/{(hostName.GetIsCopri() ? "Datenschutz" : "privacy.html")}";
|
||||
}
|
||||
}
|
88
TINKLib/Services/CopriApi/ServerUris/CopriServerUriList.cs
Normal file
88
TINKLib/Services/CopriApi/ServerUris/CopriServerUriList.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TINK.Model.Services.CopriApi.ServerUris
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
sealed public class CopriServerUriList
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the rest resource root name.
|
||||
/// </summary>
|
||||
public const string REST_RESOURCE_ROOT = "APIjsonserver";
|
||||
|
||||
/// <summary> Holds the URL of the TINK/Konrad test server.</summary>
|
||||
public const string TINK_DEVEL = @"https://tinkwwp.copri-bike.de/APIjsonserver";
|
||||
|
||||
/// <summary> Holds the URL the TINK/Konrad productive server.</summary>
|
||||
public const string TINK_LIVE = @"https://app.tink-konstanz.de/APIjsonserver";
|
||||
|
||||
/// <summary> Holds the URL the Sharee server.</summary>
|
||||
public const string SHAREE_DEVEL = @"https://shareeapp-primary.copri-bike.de/APIjsonserver";
|
||||
|
||||
/// <summary> Holds the URL the Sharee server.</summary>
|
||||
public const string SHAREE_LIVE = @"https://shareeapp-primary.copri.eu/APIjsonserver";
|
||||
|
||||
/// <summary>Constructs default uri list.</summary>
|
||||
public CopriServerUriList(Uri activeUri = null) : this (
|
||||
new List<Uri>
|
||||
{
|
||||
new Uri(SHAREE_LIVE),
|
||||
new Uri(TINK_LIVE),
|
||||
new Uri(SHAREE_DEVEL),
|
||||
new Uri(TINK_DEVEL)
|
||||
}.ToArray(),
|
||||
activeUri ?? new Uri(SHAREE_LIVE)) // Default URi which is used after install of app
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Constructs uris object. </summary>
|
||||
/// <param name="p_oSource">Object to copy from.</param>
|
||||
public CopriServerUriList(CopriServerUriList p_oSource) : this(
|
||||
p_oSource.Uris.ToArray(),
|
||||
p_oSource.ActiveUri)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Constructs a valid uris object. </summary>
|
||||
/// <param name="uris">Known uris.</param>
|
||||
/// <param name="p_oActiveUri">Zero based index of active uri.</param>
|
||||
/// <param name="p_oDevelUri">Uri of the development server.</param>
|
||||
public CopriServerUriList(
|
||||
Uri[] uris,
|
||||
Uri p_oActiveUri)
|
||||
{
|
||||
if (uris == null || uris.Length < 1)
|
||||
{
|
||||
throw new ArgumentException($"Can not construct {typeof(CopriServerUriList)}- object. Array of uris must not be null and contain at least one element.");
|
||||
}
|
||||
|
||||
if (!uris.Contains(p_oActiveUri))
|
||||
{
|
||||
throw new ArgumentException($"Active uri {p_oActiveUri} not contained in ({string.Join("; ", uris.Select(x => x.AbsoluteUri))}).");
|
||||
}
|
||||
|
||||
Uris = new List<Uri>(uris);
|
||||
ActiveUri = p_oActiveUri;
|
||||
}
|
||||
|
||||
/// <summary> Gets the active uri. </summary>
|
||||
[JsonProperty]
|
||||
public Uri ActiveUri { get; }
|
||||
|
||||
/// <summary> Gets the active uri. </summary>
|
||||
public static Uri DevelopUri => new(TINK_DEVEL);
|
||||
|
||||
/// <summary> Gets the known uris. </summary>
|
||||
[JsonProperty]
|
||||
public IList<Uri> Uris { get ; }
|
||||
|
||||
/// <summary> Gets the default uri which is active after first installation. </summary>
|
||||
public static Uri DefaultActiveUri
|
||||
{
|
||||
get { return new CopriServerUriList().ActiveUri; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue