using System; using System.Collections.Generic; using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock; using ShareeBike.Model.Connector; namespace ShareeBike.Repository.Request { /// Defines members to create requests. public interface IRequestBuilder { /// Holds the id denoting the merchant (ShareeBike app). string MerchantId { get; } /// Gets the session cookie if user is logged in, an empty string otherwise. string SessionCookie { get; } /// Gets request to log user in. /// Mail address of user to log in. /// Password to log in. /// Id specifying user and hardware. /// Request which holds auth cookie string DoAuthorization( string mailAddress, string password, string deviceId); /// Logs user out. /// Id of the merchant. /// Cookie which identifies user. string DoAuthout(); /// Get list of stations from file. /// Request to query list of station. string GetStations(); /// Gets bikes available. /// Id of station which is used for filtering bikes. Null if no filtering should be applied. /// Id of bike to get. /// Request to query list of bikes available. string GetBikesAvailable(string stationId = null, string bikeId = null); /// Gets a list of bikes reserved/ booked by active user from Copri. /// Request to query list of bikes occupied. string GetBikesOccupied(); /// Gets reservation request (synonym: reservation == request == reservieren). /// Id of the bike to reserve. /// Request to reserve bike. string DoReserve(string bikeId); /// Gets request to cancel reservation. /// Id of the bike to cancel reservation for. /// Request on cancel booking request. string DoCancelReservation(string bikeId); /// Request to get keys. /// Id of the bike to get keys for. /// Request to get keys. string CalculateAuthParameters(string bikeId); /// 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. string StartReturningBike(string bikeId); /// Gets the request for updating lock state for a booked bike. /// Id of the bike to update locking state for. /// New locking state. /// Geolocation of lock when state change occurred. /// Information about lock (firmware version, hardware version, ...). /// Request to update locking state. string UpdateLockingState( string bikeId, lock_state state, LocationDto location = null, double batteryPercentage = double.NaN, IVersionInfo versionInfo = null); /// Gets the booking request (synonym: booking == renting == mieten). /// Id of the bike to book. /// Used to publish GUID from app to copri. Used for initial setup of bike in copri. /// Holds the filling level percentage of the battery. /// If not null next locking action which is performed after booking. /// Request to booking bike. string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null); /// Gets the request to book and start opening the bike (synonym: booking == renting == mieten). /// Id of the bike to book. /// Request to booking bike. string BookAvailableAndStartOpening(string bikeId); /// Gets the request to book and start opening the bike (synonym: booking == renting == mieten). /// Id of the bike to book. /// Request to booking bike. string BookReservedAndStartOpening(string bikeId); /// Gets request for returning the bike. /// Id of the bike to return. /// Geolocation of lock when returning bike. /// Request on returning request. string DoReturn(string bikeId, LocationDto location); /// Returns a bike and starts closing. /// Id of the bike to return. /// Provides info about hard and software. /// Response to send to copri. string ReturnAndStartClosing(string bikeId); /// /// Gets request for submitting feedback to copri server. /// /// Id of the bike to which the feedback is related to. /// Null if bike has no engine or charge is unknown. Otherwise the charge filling level of the drive battery. /// General purpose message or error description. /// True if bike is broken. string DoSubmitFeedback( string bikeId, int? currentChargeBars, string message = null, bool isBikeBroken = false); /// /// Gets request for submitting mini survey to copri server. /// /// Collection of answers. string DoSubmitMiniSurvey(IDictionary answers); } /// Copri locking states public enum lock_state { /// Request to backend to close lock in context of pausing ride. locking, /// Lock is closed. locked, /// Request to backend to close lock either in context of resuming ride or starting a rental. unlocking, /// Lock is open. unlocked, /// Lock is unknown state. unspecific, } /// Holds location info. public class LocationDto { public double Latitude { get; private set; } public double Longitude { get; private set; } /// Accuracy of location in meters. public double? Accuracy { get; private set; } public TimeSpan Age { get; private set; } public class Builder { public double Latitude { get; set; } public double Longitude { get; set; } public double? Accuracy { get; set; } public TimeSpan Age { get; set; } public LocationDto Build() { return new LocationDto { Latitude = Latitude, Longitude = Longitude, Accuracy = Accuracy, Age = Age }; } } } }