mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
3.0.267 merged
This commit is contained in:
parent
b6fb6394db
commit
67999ef4ae
171 changed files with 6473 additions and 1093 deletions
35
TINKLib/Repository/AppContextInfo.cs
Normal file
35
TINKLib/Repository/AppContextInfo.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
|
||||
namespace TINK.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds info passed to COPRI.
|
||||
/// </summary>
|
||||
public class AppContextInfo
|
||||
{
|
||||
public AppContextInfo(string merchantId, string name, Version version)
|
||||
{
|
||||
Name = !string.IsNullOrEmpty(name)
|
||||
? name
|
||||
: throw new ArgumentNullException(nameof(name));
|
||||
|
||||
Version = version;
|
||||
|
||||
MerchantId = !string.IsNullOrEmpty(merchantId)
|
||||
? merchantId
|
||||
: throw new ArgumentNullException(nameof(merchantId));
|
||||
}
|
||||
|
||||
/// <summary> Name of the app. </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary> Version of the app.</summary>
|
||||
public Version Version { get; private set; }
|
||||
|
||||
/// <summary> Merchang id of the app. </summary>
|
||||
public string MerchantId { get; private set; }
|
||||
|
||||
/// <summary> Returns http- user agent.</summary>
|
||||
public string UserAgent { get => $"{Name}/{Version}"; }
|
||||
}
|
||||
}
|
|
@ -22,25 +22,23 @@ namespace TINK.Repository
|
|||
|
||||
/// <summary> Initializes a instance of the copri calls https object. </summary>
|
||||
/// <param name="copriHost">Host to connect to. </param>
|
||||
/// <param name="merchantId">Id of the merchant.</param>
|
||||
/// <param name="userAgent">Holds the name and version of the TINKApp.</param>
|
||||
/// <param name="appContextInfo">Provides app related info (app name and version, merchantid) to pass to COPRI.</param>
|
||||
/// <param name="sessionCookie">Session cookie if user is logged in, null otherwise.</param>
|
||||
public CopriCallsHttps(
|
||||
Uri copriHost,
|
||||
string merchantId,
|
||||
string userAgent,
|
||||
AppContextInfo appContextInfo,
|
||||
string sessionCookie = null)
|
||||
{
|
||||
m_oCopriHost = copriHost
|
||||
?? throw new System.Exception($"Can not construct {GetType().ToString()}- object. Uri of copri host must not be null.");
|
||||
?? throw new System.Exception($"Can not construct {GetType()}- object. Uri of copri host must not be null.");
|
||||
|
||||
UserAgent = !string.IsNullOrEmpty(userAgent)
|
||||
? userAgent
|
||||
: throw new System.Exception($"Can not construct {GetType().ToString()}- object. User agent must not be null or empty.");
|
||||
UserAgent = appContextInfo != null
|
||||
? appContextInfo.UserAgent
|
||||
: throw new System.Exception($"Can not construct {GetType()}- object. User agent must not be null or empty.");
|
||||
|
||||
requestBuilder = string.IsNullOrEmpty(sessionCookie)
|
||||
? new RequestBuilder(merchantId) as IRequestBuilder
|
||||
: new RequestBuilderLoggedIn(merchantId, sessionCookie);
|
||||
? new RequestBuilder(appContextInfo.MerchantId) as IRequestBuilder
|
||||
: new RequestBuilderLoggedIn(appContextInfo.MerchantId, sessionCookie);
|
||||
}
|
||||
|
||||
/// <summary> Holds the URL for rest calls.</summary>
|
||||
|
@ -621,10 +619,10 @@ namespace TINK.Repository
|
|||
string userAgent = null)
|
||||
{
|
||||
#if !WINDOWS_UWP
|
||||
string cancelOrReturnResponse;
|
||||
string doReturnResponse;
|
||||
try
|
||||
{
|
||||
cancelOrReturnResponse = await PostAsync(copriHost, command, userAgent);
|
||||
doReturnResponse = await PostAsync(copriHost, command, userAgent);
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
|
@ -642,7 +640,7 @@ namespace TINK.Repository
|
|||
}
|
||||
|
||||
// Extract bikes from response.
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(cancelOrReturnResponse)?.shareejson;
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<DoReturnResponse>>(doReturnResponse)?.shareejson;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
|
|
|
@ -17,6 +17,10 @@ namespace TINK.Repository.Response
|
|||
[DataMember]
|
||||
public string authcookie { get; private set; }
|
||||
|
||||
/// <summary> Message shown to user.</summary>
|
||||
[DataMember]
|
||||
public string merchant_message { get; private set; }
|
||||
|
||||
/// <summary> Textual description of response. </summary>
|
||||
public new string ToString()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue