using System; using System.Collections.Generic; using System.Net; using TINK.Model.Bikes.BikeInfoNS.BluetoothLock; 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. /// /// Two letter ISO language name. public RequestBuilder( string merchantId, string uiIsoLangugageName) { MerchantId = !string.IsNullOrEmpty(merchantId) ? merchantId : throw new ArgumentException("Merchant id must not be null.", nameof(merchantId)); UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(uiIsoLangugageName); AuthCookieParameter = $"&authcookie={MerchantId}"; } /// Parameter specifying current ui language. 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; } /// 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={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 + UiIsoLanguageNameParameter; /// Gets a list of bikes reserved/ booked by acctive 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 UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage, IVersionInfo versionInfo) => throw new NotSupportedException(); public string DoBook(string bikeId, Guid guid, double batteryPercentage) => 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, ISmartDevice smartDevice) => 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 corpi. public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice) => 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 submiting mini survey to copri server. /// /// Collection of answers. public string DoSubmitMiniSurvey(IDictionary answers) => throw new NotSupportedException(); } }