using System;
using System.Collections.Generic;
using System.Net;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Repository.Exception;
namespace TINK.Repository.Request
{
/// Creates requests if no user is logged in.
public class RequestBuilder : IRequestBuilder
{
/// Constructs a object for building requests.
/// Holds the id denoting the merchant.
/// Two letter ISO language name.
/// Holds info about smart device.
public RequestBuilder(
string merchantId,
string uiIsoLangugageName,
ISmartDevice smartDevice = null)
{
MerchantId = !string.IsNullOrEmpty(merchantId)
? merchantId
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(WebUtility.UrlEncode(uiIsoLangugageName));
AuthCookieParameter = $"&authcookie={WebUtility.UrlEncode(MerchantId)}";
SmartDevice = smartDevice;
}
/// Holds the id denoting the merchant.
public string MerchantId { get; }
/// Holds the session cookie if a user is logged in.
public string SessionCookie => string.Empty;
/// Holds the current ui two letter ISO language name.
private string UiIsoLanguageNameParameter { get; }
/// Auth cookie parameter.
private string AuthCookieParameter { get; }
/// Holds info about smart device.
private ISmartDevice SmartDevice { get; }
/// Gets request to log user in.
/// Mailaddress of user to log in.
/// Password to log in.
/// Id specifying user and hardware.
/// Response which holds auth cookie
public string DoAuthorization(
string mailAddress,
string password,
string deviceId)
=> "request=authorization" +
$"&merchant_id={MerchantId}" +
$"&user_id={WebUtility.UrlEncode(mailAddress)}" +
$"&user_pw={WebUtility.UrlEncode(password)}" +
$"&hw_id={WebUtility.UrlEncode(deviceId)}" +
UiIsoLanguageNameParameter;
/// Logs user out.
public string DoAuthout()
=> throw new CallNotRequiredException();
/// Gets bikes available.
/// Request to query list of bikes available.
public string GetBikesAvailable()
=> "request=bikes_available&system=all" +
AuthCookieParameter +
UiIsoLanguageNameParameter;
/// Get list of stations from file.
/// Request to query list of station.
public string GetStations()
=> "request=stations_available" +
AuthCookieParameter +
SmartDevice.GetSmartDeviceParameters() +
UiIsoLanguageNameParameter;
/// Gets a list of bikes reserved/ booked by active user from Copri.
/// Request to query list of bikes occupied.
public string GetBikesOccupied()
=> throw new NotSupportedException();
/// Gets booking request response.
/// Id of the bike to book.
/// Response on booking request.
public string DoReserve(string bikeId)
=> throw new NotSupportedException();
/// Gets cancel booking request response.
/// Id of the bike to book.
/// Response on cancel booking request.
public string DoCancelReservation(string p_iBikeId)
=> throw new NotSupportedException();
/// Request to calculate authentication keys.
/// Id of the bike to get keys for.
/// Response on request.
public string CalculateAuthParameters(string bikeId)
=> throw new NotSupportedException();
/// Gets the request for notifying about start of returning sequence.
/// Operator specific call.
/// Id of the bike to return.
/// Request to notify about start of returning sequence.
public string StartReturningBike(string bikeId)
=> throw new NotSupportedException();
///
/// Not supported if user is not logged in. Lock state is only updated after open/ close which is only possible if user is logged in.
///
///
public string UpdateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage, IVersionInfo versionInfo)
=> throw new NotSupportedException();
public string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
=> throw new NotSupportedException();
/// Gets the request to book and start opening the bike (synonym: booking == renting == mieten).
/// Id of the bike to book.
/// Request to booking bike.
public string BookAvailableAndStartOpening(string bikeId)
=> throw new NotSupportedException();
/// Gets the request to book and start opening the bike (synonym: booking == renting == mieten).
/// Id of the bike to book.
/// Request to booking bike.
public string BookReservedAndStartOpening(string bikeId)
=> throw new NotSupportedException();
public string DoReturn(string bikeId, LocationDto geolocation)
=> throw new NotSupportedException();
/// Returns a bike and starts closing.
/// Id of the bike to return.
/// Provides info about hard and software.
/// Response to send to copri.
public string ReturnAndStartClosing(string bikeId)
=> throw new NotSupportedException();
/// Gets submit feedback request.
/// Id of the bike to which the feedback is related to.
/// General purpose message or error description.
/// True if bike is broken.
/// Submit feedback request.
public string DoSubmitFeedback(string bikeId, int? currentChargeBars, string message = null, bool isBikeBroken = false)
=> throw new NotSupportedException();
///
/// Gets request for submitting mini survey to copri server.
///
/// Collection of answers.
public string DoSubmitMiniSurvey(IDictionary answers) =>
throw new NotSupportedException();
}
}