using System; using System.Threading.Tasks; using TINK.Model; using TINK.Model.Device; using TINK.Repository.Request; using TINK.Repository.Response; namespace TINK.Repository { public class CopriCallsMemory : ICopriServer { /// Part in file specifying apiserver. private static string CopriDevelHostUri = @"https://tinkwwp.copri-bike.de/APIjsonserver"; public const string DO_AUTH_Unknown_User_FILE = @" { ""shareejson"" : { ""response"" : ""authorization"", ""authcookie"" : 0, ""response_state"" : ""Failure: cannot generate authcookie"", ""apiserver"" : ""https://tinkwwp.copri-bike.de"" } }"; public const string DO_AUTH_SET02_001_FILE = @" { ""shareejson"" : { ""response"" : ""authorization"", ""authcookie"" : ""4da3044c8657a04ba60e2eaa753bc51a"", ""user_group"" : [""TINK""], ""response_state"" : ""OK"", ""apiserver"" : ""https://tinkwwp.copri-bike.de"" } }"; public const string DO_AUTHOUT_SET02_001_FILE = @"{ ""shareejson"" : { ""apiserver"" : ""https://app.tink-konstanz.de"", ""user_id"" : ""ohauff@posteo.de"", ""response_state"" : ""OK"", ""authcookie"" : ""1"", ""response"" : ""authout"", ""user_group"" : [ """" ], ""debuglevel"" : ""1"", ""copri_version"" : ""4.1.0.0"" } }"; /// /// Station TINK: 4, 5, 7, 8, 10, 11, 12, 31 /// Station Konrad: 14, 31 /// Stations: /// 4. Available: 26 Trike, 14, Cargo, 5 Cargo /// 5. Available: 45 Cargo, 11 Cargo T, 2 Cargo, 52 Sr /// 7. Available: 20 Cargo, /// 8. Available: 19 Cargo /// 10. Available: 18 Cargo /// 11. Available: 17 Cargo /// 12. Available: 13 Cargo /// /// /// public const string STATIONS_SET02_001_FILE = @" { ""shareejson"": { ""authcookie"": 0, ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""response"": ""stations_all"", ""stations"": { ""5786"": { ""station"" : ""4"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.6586936667"", ""longitude"": ""9.16863116667"" } }, ""2456"": { ""station"" : ""5"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.6675153333"", ""longitude"": ""9.16473216667"" } }, ""2798"": { ""station"" : ""12"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.6748671667"", ""longitude"": ""9.17326583333"" } }, ""3214"": { ""station"" : ""8"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.666401"", ""longitude"": ""9.175902"" } }, ""5462"": { ""station"" : ""11"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.672231"", ""longitude"": ""9.175862"" } }, ""3965"": { ""station"" : ""10"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.665556"", ""longitude"": ""9.17095133333"" } }, ""5423"": { ""station"" : ""7"", ""station_group"" : [ ""TINK"" ], ""gps"" : { ""latitude"": ""47.6612413333"", ""longitude"": ""9.16641016667"" } }, ""14"": { ""station_group"" : [ ""Konrad"" ], ""description"": """", ""station"" : ""14"", ""gps"" : { ""latitude"": ""47.66698054007847"", ""longitude"": ""9.169303178787231"" } }, ""31"": { ""station_group"": [ ""TINK"" , ""Konrad""], ""description"": ""Südstadt Station"", ""station"" : ""31"", ""gps"" : { ""latitude"": ""47.69489"", ""longitude"": ""9.19"" } } }, ""response_state"": ""OK"", ""copri_version"" : ""4.1.0.0"" } }"; const string BOOKING_REQUEST_SET02_001_FILE = @" { ""shareejson"" : { ""response_state"" : ""OK: requested bike 8"", ""bikes_occupied"" : { ""87781"" : { ""timeCode"" : ""3630"", ""state"" : ""occupied"", ""station"" : ""5"", ""description"" : ""Cargo Long"", ""start_time"" : ""2017-11-28 11:01:51.637747+01"", ""bike"" : ""8"" }, ""87780"" : { ""timeCode"" : ""1056"", ""state"" : ""occupied"", ""station"" : ""4"", ""description"" : ""Cargo Long"", ""start_time"" : ""2017-11-28 10:43:24.886288+01"", ""bike"" : ""7"" } }, ""timeCode"" : ""3630"", ""response"" : ""booking_request"", ""authcookie"" : ""4da3044c8657a04ba60e2eaa753bc51aoiF2kahH"", ""apiserver"" : ""https://tinkwwp.copri-bike.de"" } } "; const string BIKES_OCCUPIED_REQUEST_SET01_001_FILE = @" { ""shareejson"" : { ""apiserver"" : ""https://tinkwwp.copri-bike.de"", ""bikes_occupied"" : { ""87785"" : { ""station"" : ""2"", ""state"" : ""occupied"", ""bike"" : ""20"", ""description"" : ""Cargo Long"", ""start_time"" : ""2017-12-01 22:21:57.740069+01"", ""timeCode"" : ""6603"" }, ""87782"" : { ""station"" : ""4"", ""state"" : ""occupied"", ""bike"" : ""7"", ""description"" : ""Cargo Long"", ""start_time"" : ""2017-11-28 13:06:55.147368+01"", ""timeCode"" : ""2931"" }, ""87781"" : { ""station"" : ""5"", ""state"" : ""occupied"", ""bike"" : ""8"", ""description"" : ""Cargo Long"", ""start_time"" : ""2017-11-28 11:01:51.637747+01"", ""timeCode"" : ""3630"" }, }, ""response_state"" : ""OK"", ""authcookie"" : ""4da3044c8657a04ba60e2eaa753bc51a"", ""response"" : ""user_bikes_occupied"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_OCCUPIED_REQUEST_SET02_001_FILE = @" { ""shareejson"": { ""response_state"": ""OK"", ""bikes_occupied"": { ""87781"": { ""timeCode"": ""3630"", ""state"": ""occupied"", ""station"" : ""5"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 11:01:51.637747+01"", ""bike"": ""8"" }, ""87782"": { ""timeCode"": ""2931"", ""state"": ""occupied"", ""station"" : ""4"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 13:06:55.147368+01"", ""bike"": ""7"" } }, ""authcookie"": ""4da3044c8657a04ba60e2eaa753bc51a"", ""response"": ""user_bikes_occupied"", ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_OCCUPIED_REQUEST_SET02_002_FILE = @" { ""shareejson"": { ""response_state"": ""OK"", ""bikes_occupied"": { ""87781"": { ""timeCode"": ""3630"", ""state"": ""occupied"", ""station"" : ""5"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 11:01:51.637747+01"", ""bike"": ""8"" }, ""87782"": { ""timeCode"": ""2931"", ""state"": ""occupied"", ""station"" : ""4"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 13:06:55.147368+01"", ""bike"": ""7"" }, ""2360"": { ""timeCode"": ""2360"", ""state"": ""reserved"", ""station"" : ""4"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 14:07:13.745568+01"", ""bike"": ""5"" } }, ""authcookie"": ""4da3044c8657a04ba60e2eaa753bc51a"", ""response"": ""user_bikes_occupied"", ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_OCCUPIED_REQUEST_SET02_003_FILE = @" { ""shareejson"": { ""response_state"": ""OK"", ""bikes_occupied"": { ""87781"": { ""timeCode"": ""3630"", ""state"": ""occupied"", ""station"" : ""5"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 11:01:51.637747+01"", ""bike"": ""8"" }, ""87782"": { ""timeCode"": ""2931"", ""state"": ""occupied"", ""station"" : ""4"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 13:06:55.147368+01"", ""bike"": ""7"" }, ""2360"": { ""timeCode"": ""2360"", ""state"": ""occupied"", ""station"" : ""4"", ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""start_time"": ""2017-11-28 14:08:32.756368+01"", ""bike"": ""5"" } }, ""authcookie"": ""4da3044c8657a04ba60e2eaa753bc51a"", ""response"": ""user_bikes_occupied"", ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET1_FILE = @" { ""shareejson"": { ""privacy_html"": ""site/privacy.html"", ""response"": ""user_bikes_occupied"", ""apiserver"": ""https://shareeapp-fr01.copri.eu"", ""authcookie"": ""5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH"", ""impress_html"": ""site/impress.html"", ""tariff_info_html"": ""site/tariff_info.html"", ""bikes_occupied"": { ""155776"": { ""K_a"": ""[-83, 104, 55, -74, 16, -105, 124, -103, -68, -17, -127, -113, 56, 43, -61, -86, 124, -54, 63, 57, 0, 0, 0, 0]"", ""real_hours"": ""49.3"", ""bike"": ""1545"", ""tariff_description"": { ""eur_per_hour"" : ""2.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""max_eur_per_day"" : ""10.00"" }, ""lock_state"": ""unlocked"", ""total_price"": ""23.75"", ""station"" : ""103"", ""gps"" : { ""latitude"": ""47.9980383301154"", ""longitude"": ""7.78496129438281"" }, ""system"": ""Ilockit"", ""end_time"": ""2020-11-08 19:11:27"", ""bike_group"" : [ ""300029"" ], ""Ilockit_ID"": ""ISHAREIT-2200545"", ""start_time"": ""2020-11-06 17:53:22.784681+01"", ""unit_price"": ""2.50"", ""request_time"": ""2020-11-06 17:52:56.832138+01"", ""state"": ""occupied"", ""Ilockit_GUID"": ""00000000-0000-0000-0000-e38bf9d32234"", ""computed_hours"": ""9.50"", ""K_u"": ""[53, 92, -55, -109, 112, 38, -35, 43, -18, 122, 115, 50, -85, -57, 62, -57, -112, 2, 117, -47, 0, 0, 0, 0]"", ""description"": ""Tester-bike (Ilockit)"", ""K_seed"": ""[119, -47, -91, -36, -29, -17, 35, 47, -80, -112, -55, 2, 70, -45, 60, -62]"" }, ""155744"": { ""Ilockit_GUID"": ""00000000-0000-0000-0000-d589a8023487"", ""unit_price"": ""2.50"", ""start_time"": ""2020-10-12 08:38:30.401679+02"", ""request_time"": ""2020-10-12 08:38:12.374231+02"", ""state"": ""occupied"", ""K_u"": ""[93, -45, -89, -38, 50, 107, 21, -119, -26, -90, -15, 99, 17, 44, -20, 24, 34, -111, 125, -31, 0, 0, 0, 0]"", ""computed_hours"": ""112"", ""K_seed"": ""[24, 69, -21, 52, 55, 3, -71, 30, -71, 43, 108, -100, 15, 126, -117, 40]"", ""description"": ""Oliver (Ilockit)"", ""tariff_description"": { ""eur_per_hour"" : ""2.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""max_eur_per_day"" : ""10.00"" }, ""bike"": ""1537"", ""real_hours"": ""659.55"", ""lock_state"": ""locked"", ""K_a"": ""[109, 35, -55, 78, -65, 87, -43, -4, -90, -104, -16, -45, -80, -80, 106, -25, -77, 111, -79, 58, 0, 0, 0, 0]"", ""system"": ""Ilockit"", ""gps"" : { ""latitude"": ""47.9977741744369"", ""longitude"": ""7.78484562411904"" }, ""station"" : ""103"", ""total_price"": ""280.00"", ""Ilockit_ID"": ""ISHAREIT-2200537"", ""bike_group"" : [ ""300029"" ], ""end_time"": ""2020-11-08 19:11:25"" } }, ""bike_info_html"": ""site/bike_info.html"", ""agb_html"": ""site/agb.html"", ""agb_checked"": ""1"", ""user_id"": ""ohauff@posteo.de"", ""response_state"": ""OK: nothing todo "", ""lang"": ""DE"", ""user_group"": [ ""300029"", ""300001"" ], ""debuglevel"": ""1"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_AVAILABLE_SET01_001_FILE = @" { ""shareejson"" : { ""bikes"" : { ""2352"" : { ""description"" : ""Cargo Long"", ""state"" : ""available"", ""bike"" : ""1"", ""gps"" : { ""latitude"": ""47.669888"", ""longitude"": ""9.167749"" }, ""station"" : ""9"" }, ""2379"" : { ""description"" : ""Cargo Long"", ""state"" : ""available"", ""bike"" : ""19"", ""gps"" : { ""latitude"": ""47.6597846667"", ""longitude"": ""9.177439"" }, ""station"" : ""3"" }, ""2354"" : { ""description"" : ""Cargo Long"", ""state"" : ""available"", ""bike"" : ""2"", ""gps"" : { ""latitude"": ""47.6721741667"", ""longitude"": ""9.176165"" }, ""station"" : ""11"" } }, ""response_state"" : ""OK"", ""authcookie"" : ""4da3044c8657a04ba60e2eaa753bc51a"", ""apiserver"" : ""https://tinkwwp.copri-bike.de"", ""response"" : ""bikes_available"", ""copri_version"" : ""4.1.0.0"" } } "; const string BIKES_AVAILABLE_SET02_001_FILE = @" { ""shareejson"" : { ""authcookie"" : 0, ""apiserver"" : ""https://tinkwwp.copri-bike.de"", ""response"" : ""bikes_available"", ""bikes"" : { ""3399"" : { ""description"" : ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""26"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.6586936667"", ""longitude"": ""9.16863116667"" }, ""system"" : ""BC"", ""station"" : ""4"" }, ""3398"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""25"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168173"" }, ""system"" : ""BC"", ""station"" : ""5"" }, ""2374"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""14"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""0.0"", ""longitude"": ""0.0"" }, ""system"" : ""BC"", ""station"" : ""4"" }, ""2373"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""13"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.6748671667"", ""longitude"": ""9.17326583333"" }, ""system"" : ""BC"", ""station"" : ""12"" }, ""2366"" : { ""description"" : ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""11"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.667938"", ""longitude"": ""9.164895"" }, ""system"" : ""BC"", ""station"" : ""5"" }, ""2379"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""19"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.666401"", ""longitude"": ""9.175902"" }, ""system"" : ""BC"", ""station"" : ""8"" }, ""2377"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""17"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.672231"", ""longitude"": ""9.175862"" }, ""system"" : ""BC"", ""station"" : ""11"" }, ""2378"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""18"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.665556"", ""longitude"": ""9.17095133333"" }, ""system"" : ""BC"", ""station"" : ""10"" }, ""2354"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""2"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168159"" }, ""system"" : ""BC"", ""station"" : ""5"" }, ""2360"" : { ""description"" : ""Cargo long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""5"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.672082"", ""longitude"": ""9.17655283333"" }, ""system"" : ""BC"", ""station"" : ""4"" }, ""2380"" : { ""description"" : ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"" : ""20"", ""state"" : ""available"", ""gps"" : { ""latitude"": ""47.6612413333"", ""longitude"": ""9.16641016667"" }, ""system"" : ""BC"", ""station"" : ""7"" }, ""52"" : { ""state"" : ""available"", ""bike"" : ""52"", ""description"" : ""Stadtflitzer"", ""bike_group"" : [ ""Konrad"" ], ""station"" : ""31"", ""system"" : ""BC"", ""gps"" : { ""latitude"": ""47.67484"", ""longitude"": ""9.17254"" } } }, ""response_state"" : ""OK"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_AVAILABLE_SET02_002_FILE = @" { ""shareejson"": { ""authcookie"": 0, ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""response"": ""bikes_available"", ""bikes"": { ""3399"": { ""description"": ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"": 26, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6586936667"", ""longitude"": ""9.16863116667"" }, ""station"" : ""4"" }, ""3398"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 25, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168173"" }, ""station"" : ""5"" }, ""2374"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 14, ""state"": ""available"", ""gps"" : { ""latitude"": ""0.0"", ""longitude"": ""0.0"" }, ""station"" : ""4"" }, ""2373"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 13, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6748671667"", ""longitude"": ""9.17326583333"" }, ""station"" : ""12"" }, ""2366"": { ""description"": ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"": 11, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.667938"", ""longitude"": ""9.164895"" }, ""station"" : ""5"" }, ""2379"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 19, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.666401"", ""longitude"": ""9.175902"" }, ""station"" : ""8"" }, ""2377"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 17, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.672231"", ""longitude"": ""9.175862"" }, ""station"" : ""11"" }, ""2378"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 18, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.665556"", ""longitude"": ""9.17095133333"" }, ""station"" : ""10"" }, ""2354"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 2, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168159"" }, ""station"" : ""5"" }, ""2380"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 20, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6612413333"", ""longitude"": ""9.16641016667"" }, ""station"" : ""7"" }, ""52"" : { ""state"" : ""available"", ""bike"" : ""52"", ""description"" : ""Stadtflitzer"", ""bike_group"" : [ ""Konrad"" ], ""station"" : ""5"", ""gps"" : { ""latitude"": ""47.67484"", ""longitude"": ""9.17254"" } } }, ""response_state"": ""OK"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_AVAILABLE_SET02_003_FILE = @" { ""shareejson"": { ""authcookie"": 0, ""apiserver"": ""https://tinkwwp.copri-bike.de"", ""response"": ""bikes_available"", ""bikes"": { ""3399"": { ""description"": ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"": 26, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6586936667"", ""longitude"": ""9.16863116667"" }, ""station"" : ""4"" }, ""3398"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 25, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168173"" }, ""station"" : ""5"" }, ""2374"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 14, ""state"": ""available"", ""gps"" : { ""latitude"": ""0.0"", ""longitude"": ""0.0"" }, ""station"" : ""4"" }, ""2373"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 13, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6748671667"", ""longitude"": ""9.17326583333"" }, ""station"" : ""12"" }, ""2366"": { ""description"": ""Cargo Trike"", ""bike_group"" : [ ""TINK"" ], ""bike"": 11, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.667938"", ""longitude"": ""9.164895"" }, ""station"" : ""5"" }, ""2379"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 19, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.666401"", ""longitude"": ""9.175902"" }, ""station"" : ""8"" }, ""2377"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 17, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.672231"", ""longitude"": ""9.175862"" }, ""station"" : ""11"" }, ""2378"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 18, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.665556"", ""longitude"": ""9.17095133333"" }, ""station"" : ""10"" }, ""2354"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 2, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.669895"", ""longitude"": ""9.168159"" }, ""station"" : ""5"" }, ""2380"": { ""description"": ""Cargo Long"", ""bike_group"" : [ ""TINK"" ], ""bike"": 20, ""state"": ""available"", ""gps"" : { ""latitude"": ""47.6612413333"", ""longitude"": ""9.16641016667"" }, ""station"" : ""7"" }, ""52"" : { ""state"" : ""available"", ""bike"" : ""52"", ""description"" : ""Stadtflitzer"", ""bike_group"" : [ ""Konrad"" ], ""station"" : ""5"", ""gps"" : { ""latitude"": ""47.67484"", ""longitude"": ""9.17254"" } } }, ""response_state"": ""OK"", ""copri_version"" : ""4.1.0.0"" } }"; const string BIKES_AVAILABLE_REQUEST_SHAREEFR01_SET1_FILE = @" { ""shareejson"": { ""user_id"": ""ohauff@posteo.de"", ""privacy_html"": ""site/privacy.html"", ""agb_checked"": ""1"", ""debuglevel"": ""1"", ""agb_html"": ""site/agb.html"", ""bike_info_html"": ""site/bike_info.html"", ""copri_version"": ""4.1.0.0"", ""apiserver"": ""https://shareeapp-fr01.copri.eu"", ""lang"": ""DE"", ""impress_html"": ""site/impress.html"", ""response"": ""bikes_available"", ""tariff_info_html"": ""site/tariff_info.html"", ""user_group"": [ ""300029"", ""300001"" ], ""authcookie"": ""5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH"", ""response_state"": ""OK: nothing todo "", ""bikes"": { ""1536"": { ""bike"": ""1536"", ""tariff_description"": { ""eur_per_hour"" : ""3.00"", ""number"" : ""5491"", ""name"" : ""Vauban Basic"", ""max_eur_per_day"" : ""15.00"" }, ""description"": ""Vauban-bike (Ilockit)"", ""state"": ""available"", ""station"" : ""101"", ""gps"" : { ""latitude"": ""47.976741"", ""longitude"": ""7.8257615"" }, ""lock_state"": ""locked"", ""Ilockit_ID"": ""ISHAREIT-2200536"", ""Ilockit_GUID"": ""00000000-0000-0000-0000-caa87760e53e"", ""system"": ""Ilockit"", ""bike_group"" : [ ""300001"" ] }, ""1539"": { ""gps"" : { ""latitude"": ""47.992718"", ""longitude"": ""7.833071"" }, ""station"" : ""104"", ""tariff_description"": { ""eur_per_hour"" : ""3.00"", ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""max_eur_per_day"" : ""10.00"" }, ""description"": ""Tester-bike (Ilockit)"", ""bike"": ""1539"", ""state"": ""available"", ""bike_group"" : [ ""300029"" ], ""system"": ""Ilockit"", ""lock_state"": ""unlocked"", ""Ilockit_ID"": ""ISHAREIT-2200539"", ""Ilockit_GUID"": ""00000000-0000-0000-0000-f0b4a692e169"" }, ""1315"": { ""system"": ""Ilockit"", ""bike_group"" : [ ""300029"" ], ""Ilockit_GUID"": ""00000000-0000-0000-e57e6b9aee16"", ""Ilockit_ID"": ""ISHAREIT-2200315"", ""lock_state"": ""locked"", ""gps"" : { ""latitude"": ""47.997930"", ""longitude"": ""7.785428"" }, ""station"" : ""103"", ""state"": ""available"", ""bike"": ""1315"", ""description"": ""Tester-bike (Ilockit)"", ""tariff_description"": { ""eur_per_hour"" : ""3.00"", ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""max_eur_per_day"" : ""10.00"" }, }, ""1544"": { ""station"" : ""101"", ""gps"" : { ""latitude"": ""47.976634"", ""longitude"": ""7.825490"" }, ""state"": ""available"", ""tariff_description"": { ""eur_per_hour"" : ""3.00"", ""number"" : ""5491"", ""name"" : ""Vauban Basic"", ""max_eur_per_day"" : ""15.00"" }, ""description"": ""Vauban-bike (Ilockit)"", ""bike"": ""1544"", ""bike_group"" : [ ""300001"" ], ""system"": ""Ilockit"", ""Ilockit_GUID"": ""00000000-0000-0000-0000-dc969f648732"", ""Ilockit_ID"": ""ISHAREIT-2200544"", ""lock_state"": ""locked"" }, ""1543"": { ""gps"" : { ""latitude"": ""47.9979824"", ""longitude"": ""7.7848131"" }, ""station"" : ""103"", ""bike"": ""1543"", ""description"": ""Tester-bike (Ilockit)"", ""tariff_description"": { ""eur_per_hour"" : ""3.00"", ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""max_eur_per_day"" : ""10.00"" }, ""state"": ""available"", ""system"": ""Ilockit"", ""bike_group"" : [ ""300029"" ], ""Ilockit_ID"": ""ISHAREIT-2200543"", ""lock_state"": ""locked"", ""Ilockit_GUID"": ""00000000-0000-0000-0000-cc141a6f68bb"" } } } }"; private const SampleSets DEFAULT_SAMPLE_SET = SampleSets.Set2; private const int DEFAULT_STAGE_INDEX = 1; private IRequestBuilder requestBuilder; public CopriCallsMemory( SampleSets? sampleSet = null, int? index = null, string sessionCookie = null) { ActiveSampleSet = sampleSet ?? DEFAULT_SAMPLE_SET; ActiveStageIndex = index ?? DEFAULT_STAGE_INDEX; SessionCookie = sessionCookie; requestBuilder = string.IsNullOrEmpty(sessionCookie) ? new RequestBuilder(MerchantId) as IRequestBuilder : new RequestBuilderLoggedIn(MerchantId, sessionCookie); } /// Holds the session id of the logged in user, null otherwise. public string SessionCookie { get; private set; } /// Logs user in. /// User to log in. /// Id specifying user and hardware. /// Mailaddress of user to log in. /// Password to log in. /// Response which holds auth cookie public async Task DoAuthorizationAsync( string p_strMailAddress, string p_strPassword, string p_strDeviceId) { return await Task.Run(() => DoAuthorize(p_strMailAddress, p_strPassword, p_strDeviceId)); } /// Logs user out. /// User to log in. /// Response which holds auth cookie public async Task DoAuthoutAsync() { return await Task.Run(() => DoAuthout(SessionCookie)); } /// /// Gets list of bikes from memory. /// /// public async Task GetBikesAvailableAsync() { return await Task.Run(() => GetBikesAvailable(null, SessionCookie, ActiveSampleSet, ActiveStageIndex)); } /// /// Gets a list of bikes reserved/ booked by acctive user from Copri. /// /// Cookie to authenticate user. /// Response holding list of bikes. public async Task GetBikesOccupiedAsync() { try { requestBuilder.GetBikesOccupied(); // Non mock implementation if ICopriServer call this member as well. To ensure comparable behaviour this member is called here as well. } catch (NotSupportedException) { // No user logged in. await Task.CompletedTask; return ResponseHelper.GetBikesOccupiedNone(); } return await Task.Run(() => GetBikesOccupied(SessionCookie, ActiveSampleSet, ActiveStageIndex)); } /// /// Get list of stations from file. /// /// Auto cookie of user if user is logged in. /// List of files. public async Task GetStationsAsync() { return await Task.Run(() => GetStationsAll(null, SessionCookie, ActiveSampleSet, ActiveStageIndex)); } /// /// Gets booking request response. /// /// Id of the bike to book. /// Booking response. public async Task DoReserveAsync(string bikeId, Uri operatorUri) { return await Task.Run(() => DoReserve(bikeId, SessionCookie, ActiveSampleSet, ActiveStageIndex)); } /// /// Gets canel booking request response. /// /// Id of the bike to book. /// Cookie of the logged in user. /// Response on cancel booking request. public async Task DoCancelReservationAsync(string bikeId, Uri operatorUri) { return await Task.Run(() => DoCancelReservation(bikeId, SessionCookie, ActiveSampleSet, ActiveStageIndex)); } /// /// Gets the count of stages that exist for a given sample set. /// /// /// public int StagesCount { get { var l_iCount = 1; while (GetBikesAvailable(CopriDevelHostUri, TinkApp.MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null) { l_iCount++; } return l_iCount - 1; } } /// Gets the merchant id. public string MerchantId => TinkApp.MerchantId; /// /// Gets the active sample set. /// public SampleSets ActiveSampleSet { get; } /// /// Gets the active stage index. /// public int ActiveStageIndex { get; } /// Returns false because cached values are returned. public bool IsConnected => false; /// Logs user in. /// User to log in. /// Id specifying user and hardware. /// Mailaddress of user to log in. /// Password to log in. /// Response which holds auth cookie public static AuthorizationResponse DoAuthorize( string p_strMailAddress, string p_strPassword, string p_strDeviceId, SampleSets p_eSampleSet = DEFAULT_SAMPLE_SET, long p_lStageIndex = DEFAULT_STAGE_INDEX) { switch (p_eSampleSet) { case SampleSets.Set2: switch (p_lStageIndex) { case 1: // Response contains auth cookie of user "JavaministerHardwareNr1" // For this reason do not return answer if mail and pwd do not match. return p_strMailAddress == "javaminister@gmail.com" && p_strPassword == "javaminister" && p_strDeviceId == "HwId1000000000000" ? JsonConvertRethrow.DeserializeObject>(DO_AUTH_SET02_001_FILE).shareejson : JsonConvertRethrow.DeserializeObject>(DO_AUTH_Unknown_User_FILE).shareejson; default: return null; } default: return null; } } /// Logs user in. /// Response which holds auth cookie public static AuthorizationoutResponse DoAuthout( string sessionCookie, SampleSets p_eSampleSet = DEFAULT_SAMPLE_SET, long p_lStageIndex = DEFAULT_STAGE_INDEX) { switch (p_eSampleSet) { case SampleSets.Set2: switch (p_lStageIndex) { case 1: // Response contains auth cookie of user "JavaministerHardwareNr1" // For this reason do not return answer if mail and pwd do not match. return !string.IsNullOrEmpty(sessionCookie) ? JsonConvertRethrow.DeserializeObject>(DO_AUTHOUT_SET02_001_FILE).shareejson : throw new NotSupportedException(); default: return null; } default: return null; } } /// /// Gets list of bikes from memory. /// /// Id of the merchant. /// Auto cookie of user if user is logged in. /// Set of samples. /// Index of the stage. /// public static BikesAvailableResponse GetBikesAvailable( string p_strMerchantId, string p_strSessionCookie = null, SampleSets p_eSampleSet = DEFAULT_SAMPLE_SET, long p_lStageIndex = DEFAULT_STAGE_INDEX) { switch (p_eSampleSet) { case SampleSets.Set1: switch (p_lStageIndex) { case 1: return CopriCallsStatic.DeserializeResponse(BIKES_AVAILABLE_SET01_001_FILE); default: return null; } case SampleSets.Set2: switch (p_lStageIndex) { case 1: return CopriCallsStatic.DeserializeResponse(BIKES_AVAILABLE_SET02_001_FILE); case 2: return CopriCallsStatic.DeserializeResponse(BIKES_AVAILABLE_SET02_002_FILE); case 3: return CopriCallsStatic.DeserializeResponse(BIKES_AVAILABLE_SET02_003_FILE); default: return null; } case SampleSets.ShareeFr01_Set1: switch (p_lStageIndex) { case 1: return CopriCallsStatic.DeserializeResponse(BIKES_AVAILABLE_REQUEST_SHAREEFR01_SET1_FILE); default: return null; } default: return null; } } /// /// Gets stations response. /// /// Id of the merchant. /// Auto cookie of user if user is logged in. /// /// /// public static StationsAllResponse GetStationsAll( string p_strMerchantId, string p_strCookie = null, SampleSets p_eSampleSet = DEFAULT_SAMPLE_SET, long p_lStageIndex = DEFAULT_STAGE_INDEX) { switch (p_eSampleSet) { case SampleSets.Set2: switch (p_lStageIndex) { case 1: return JsonConvertRethrow.DeserializeObject>(STATIONS_SET02_001_FILE).shareejson; default: return null; } default: return null; } } /// /// Gets booking request response. /// /// Id of the bike. /// Identifies the logged in user. /// Sample set to use. /// Index of the stage. /// public static ReservationBookingResponse DoReserve( string bikeId, string sessionCookie, SampleSets sampleSet = DEFAULT_SAMPLE_SET, long stageIndex = DEFAULT_STAGE_INDEX) { ReservationBookingResponse l_oResponse; switch (sampleSet) { case SampleSets.Set2: switch (stageIndex) { case 1: l_oResponse = JsonConvertRethrow.DeserializeObject>(BOOKING_REQUEST_SET02_001_FILE).shareejson; break; default: return null; } break; default: return null; } return l_oResponse; } /// /// Gets canel booking request response. /// /// Id of the bike to book. /// Cookie of the logged in user. /// Response on cancel booking request. public static ReservationCancelReturnResponse DoCancelReservation( string bikeId, string cookie, SampleSets sampleSet = DEFAULT_SAMPLE_SET, long stageIndex = DEFAULT_STAGE_INDEX) { return null; } public Task CalculateAuthKeysAsync(string bikeId, Uri operatorUri) => null; public Task UpdateLockingStateAsync( string bikeId, LocationDto geolocation, lock_state state, double batteryLevel, Uri operatorUri) => null; public Task DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri) { return null; } public Task DoReturn( string bikeId, LocationDto geolocation, ISmartDevice smartDevice, Uri operatorUri) { return null; } public Task DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) => null; /// /// Gets a list of bikes reserved/ booked by acctive user from Copri. /// /// Cookie to authenticate user. /// Sample set to use. /// Index of the stage. /// Response holding list of bikes. public static BikesReservedOccupiedResponse GetBikesOccupied( string p_strSessionCookie = null, SampleSets sampleSet = DEFAULT_SAMPLE_SET, long stageIndex = DEFAULT_STAGE_INDEX) { BikesReservedOccupiedResponse response; switch (sampleSet) { case SampleSets.Set1: switch (stageIndex) { case 1: response = CopriCallsStatic.DeserializeResponse(BIKES_OCCUPIED_REQUEST_SET01_001_FILE); break; default: return null; } break; case SampleSets.Set2: switch (stageIndex) { case 1: response = CopriCallsStatic.DeserializeResponse(BIKES_OCCUPIED_REQUEST_SET02_001_FILE); break; case 2: response = CopriCallsStatic.DeserializeResponse(BIKES_OCCUPIED_REQUEST_SET02_002_FILE); break; case 3: response = CopriCallsStatic.DeserializeResponse(BIKES_OCCUPIED_REQUEST_SET02_003_FILE); break; default: return null; } break; case SampleSets.ShareeFr01_Set1: switch (stageIndex) { case 1: response = CopriCallsStatic.DeserializeResponse(BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET1_FILE); break; default: return null; } break; default: return null; } return p_strSessionCookie == null || response?.authcookie == p_strSessionCookie ? response : ResponseHelper.GetBikesOccupiedNone(p_strSessionCookie); } public enum SampleSets { /// Used for tests and demo GUI. Set1, /// /// Sample set nr. 2. /// Bikes values from first Copri- JSON returns these values. /// Set2, /// /// Sharee server /// ShareeFr01_Set1, } } }