2021-05-13 20:03:07 +02:00
|
|
|
|
using System;
|
2021-08-01 17:24:15 +02:00
|
|
|
|
using System.Collections.Generic;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
using System.Net;
|
2021-06-26 20:57:55 +02:00
|
|
|
|
using TINK.Model.Device;
|
|
|
|
|
using TINK.Repository.Exception;
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
namespace TINK.Repository.Request
|
2021-05-13 20:03:07 +02:00
|
|
|
|
{
|
|
|
|
|
/// <summary> Creates requests if no user is logged in.</summary>
|
|
|
|
|
public class RequestBuilder : IRequestBuilder
|
|
|
|
|
{
|
|
|
|
|
/// <summary> Constructs a object for building requests. </summary>
|
|
|
|
|
/// <param name="merchantId"></param>
|
|
|
|
|
public RequestBuilder(
|
|
|
|
|
string merchantId)
|
|
|
|
|
{
|
|
|
|
|
MerchantId = !string.IsNullOrEmpty(merchantId)
|
|
|
|
|
? merchantId
|
|
|
|
|
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the id denoting the merchant (TINK app). </summary>
|
|
|
|
|
public string MerchantId { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the session cookie if a user is logged in. </summary>
|
|
|
|
|
public string SessionCookie => string.Empty;
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets request to log user in. </summary>
|
|
|
|
|
/// <param name="mailAddress">Mailaddress of user to log in.</param>
|
|
|
|
|
/// <param name="password">Password to log in.</param>
|
|
|
|
|
/// <param name="deviceId">Id specifying user and hardware.</param>
|
|
|
|
|
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
|
|
|
|
public string DoAuthorization(
|
|
|
|
|
string mailAddress,
|
|
|
|
|
string password,
|
|
|
|
|
string deviceId)
|
|
|
|
|
{
|
|
|
|
|
return string.Format(
|
|
|
|
|
"request=authorization&merchant_id={0}&user_id={1}&user_pw={2}&hw_id={3}",
|
|
|
|
|
MerchantId,
|
|
|
|
|
WebUtility.UrlEncode(mailAddress),
|
|
|
|
|
WebUtility.UrlEncode(password),
|
|
|
|
|
deviceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Logs user out. </summary>
|
|
|
|
|
public string DoAuthout()
|
|
|
|
|
{
|
|
|
|
|
throw new CallNotRequiredException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets bikes available.</summary>
|
|
|
|
|
/// <returns>Request to query list of bikes available.</returns>
|
|
|
|
|
public string GetBikesAvailable()
|
|
|
|
|
{
|
|
|
|
|
return GetBikesAvailable(MerchantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets bikes available.</summary>
|
|
|
|
|
/// <returns>Request to query list of bikes available.</returns>
|
|
|
|
|
public static string GetBikesAvailable(string merchantId, string sessionCookie = null)
|
|
|
|
|
{
|
|
|
|
|
return $"request=bikes_available&system=all&authcookie={sessionCookie ?? string.Empty}{merchantId}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Get list of stations from file. </summary>
|
|
|
|
|
/// <returns>Request to query list of station.</returns>
|
|
|
|
|
public string GetStations()
|
|
|
|
|
{
|
|
|
|
|
return GetStations(MerchantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Get list of stations from file. </summary>
|
|
|
|
|
/// <returns>Request to query list of station.</returns>
|
|
|
|
|
public static string GetStations(string merchantId, string sessionCookie = null)
|
|
|
|
|
{
|
|
|
|
|
return $"request=stations_available&authcookie={sessionCookie ?? string.Empty}{merchantId}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
|
|
|
|
|
/// <returns>Request to query list of bikes occupied.</returns>
|
|
|
|
|
public string GetBikesOccupied() => throw new NotSupportedException();
|
|
|
|
|
|
|
|
|
|
/// <summary> Gets booking request response. </summary>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
/// <param name="bikeId">Id of the bike to book.</param>
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <returns>Response on booking request.</returns>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string DoReserve(string bikeId) => throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary> Gets cancel booking request response. </summary>
|
|
|
|
|
/// <param name="p_iBikeId">Id of the bike to book.</param>
|
|
|
|
|
/// <returns>Response on cancel booking request.</returns>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string DoCancelReservation(string p_iBikeId) => throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
|
|
|
|
/// <summary> Request to calculate authentication keys. </summary>
|
|
|
|
|
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
|
|
|
|
/// <returns>Response on request.</returns>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string CalculateAuthParameters(string bikeId) => throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-04-10 17:38:34 +02:00
|
|
|
|
/// <summary> Gets the request for notifying about start of returning sequence. </summary>
|
|
|
|
|
/// <remarks> Operator specific call.</remarks>
|
|
|
|
|
/// <param name="bikeId">Id of the bike to return.</param>
|
|
|
|
|
/// <returns>Request to notify about start of returning sequence.</returns>
|
|
|
|
|
public string StartReturningBike(string bikeId)
|
|
|
|
|
=> throw new NotSupportedException();
|
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage)
|
2021-05-13 20:03:07 +02:00
|
|
|
|
=> throw new NotSupportedException();
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string DoBook(string bikeId, Guid guid, double batteryPercentage) => throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
|
|
|
|
/// <param name="bikeId">Id of the bike to book.</param>
|
|
|
|
|
/// <returns>Request to booking bike.</returns>
|
|
|
|
|
public string BookAndStartOpening(string bikeId) => throw new NotSupportedException();
|
|
|
|
|
|
2021-06-26 20:57:55 +02:00
|
|
|
|
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice) => throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-04-25 22:15:15 +02:00
|
|
|
|
/// <summary> Returns a bike and starts closing. </summary>
|
|
|
|
|
/// <param name="bikeId">Id of the bike to return.</param>
|
|
|
|
|
/// <param name="smartDevice">Provides info about hard and software.</param>
|
|
|
|
|
/// <returns>Response to send to corpi.</returns>
|
|
|
|
|
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice) => throw new NotSupportedException();
|
|
|
|
|
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <summary> Gets submit feedback request. </summary>
|
2021-06-26 20:57:55 +02:00
|
|
|
|
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
|
2021-05-13 20:03:07 +02:00
|
|
|
|
/// <param name="message">General purpose message or error description.</param>
|
|
|
|
|
/// <param name="isBikeBroken">True if bike is broken.</param>
|
|
|
|
|
/// <returns>Submit feedback request.</returns>
|
|
|
|
|
public string DoSubmitFeedback(
|
2021-06-26 20:57:55 +02:00
|
|
|
|
string bikeId,
|
2021-05-13 20:03:07 +02:00
|
|
|
|
string message = null,
|
|
|
|
|
bool isBikeBroken = false) => throw new NotSupportedException();
|
2021-08-01 17:24:15 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets request for submiting mini survey to copri server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="answers">Collection of answers.</param>
|
|
|
|
|
public string DoSubmitMiniSurvey(IDictionary<string, string> answers) =>
|
|
|
|
|
throw new NotSupportedException();
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|