sharee.bike-App/TINKLib/Repository/CopriCallsMemory.cs

1739 lines
77 KiB
C#
Raw Normal View History

2021-06-26 20:57:55 +02:00
using System;
2021-08-01 17:24:15 +02:00
using System.Collections.Generic;
2021-06-26 20:57:55 +02:00
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
{
/// <summary> Part in file specifying apiserver.</summary>
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""
}
}";
/// <summary>
/// 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
///
///
/// </summary>
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""
}
}";
/// <summary></summary>
public const string STATIONS_AVAILABLE_LOGGEDIN_20210720 = @"
{
""shareejson"": {
""lang"": ""DE"",
""impress_html"": ""site/impress.html"",
""tariff_info_html"": ""site/tariff_info_1.html"",
""debuglevel"": ""1"",
""user_tour"": [
null,
""""
],
""response"": ""stations_available"",
""user_id"": ""ohauff@posteo.de"",
""stations"": {
""LV_3"": {
""service_tour"": ""LV_1"",
""uri_operator"": ""https://shareeapp-lv.copri.eu"",
""authed"": ""1"",
""station"": ""LV_3"",
""gps"": {
""latitude"": ""47.9973"",
""longitude"": ""7.8585""
},
""gps_radius"": ""100"",
""description"": ""Katholische Akademie"",
""state"": ""available"",
""operator_data"": {
""operator_color"": ""#006269"",
""operator_hours"": """",
""operator_name"": ""LastenVelo Freiburg"",
""operator_email"": ""info@lastenvelofreiburg.de"",
""operator_phone"": """"
},
""station_group"": [
""LV_300005""
]
},
""LV_1"": {
""uri_operator"": ""https://shareeapp-lv.copri.eu"",
""station"": ""LV_1"",
""gps"": {
""latitude"": ""47.9848"",
""longitude"": ""7.848666""
},
""authed"": ""1"",
""service_tour"": ""LV_1"",
""operator_data"": {
""operator_hours"": """",
""operator_email"": ""info@lastenvelofreiburg.de"",
""operator_name"": ""LastenVelo Freiburg"",
""operator_color"": ""#006269"",
""operator_phone"": """"
},
""state"": ""available"",
""description"": ""Parkplatz Feuerwehr Wiehre"",
""station_group"": [
""LV_300005""
],
""gps_radius"": ""100""
},
""FR_105"": {
""gps_radius"": ""50"",
""station_group"": [
""FR_300029""
],
""state"": ""available"",
""description"": ""Contributor-Station Rainer"",
""operator_data"": {
""operator_phone"": ""+49 761 45370097"",
""operator_hours"": ""B<EFBFBD>rozeiten: Montag, Mittwoch, Freitag 9-12 Uhr"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_email"": ""hotline@sharee.bike"",
""operator_color"": ""#009699""
},
""service_tour"": ""FR_1"",
""authed"": ""1"",
""station"": ""FR_105"",
""gps"": {
""longitude"": "" 7.973855"",
""latitude"": ""47.927738""
},
""uri_operator"": ""https://shareeapp-fr01.copri.eu""
},
""FR_104"": {
""gps_radius"": ""50"",
""operator_data"": {
""operator_phone"": ""+49 761 45370097"",
""operator_color"": ""#009699"",
""operator_email"": ""hotline@sharee.bike"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_hours"": ""B<EFBFBD>rozeiten: Montag, Mittwoch, Freitag 9-12 Uhr""
},
""description"": ""Contributor-Station fahrradspezialitäten"",
""state"": ""available"",
""station_group"": [
""FR_300029""
],
""service_tour"": ""FR_1"",
""uri_operator"": ""https://shareeapp-fr01.copri.eu"",
""gps"": {
""latitude"": ""47.989807"",
""longitude"": "" 7.837621""
},
""station"": ""FR_104"",
""authed"": ""1""
},
""FR_103"": {
""uri_operator"": ""https://shareeapp-fr01.copri.eu"",
""authed"": ""1"",
""gps"": {
""longitude"": "" 7.785428"",
""latitude"": ""47.997930""
},
""station"": ""FR_103"",
""service_tour"": ""FR_1"",
""description"": ""Contributor-Station Oliver"",
""state"": ""available"",
""operator_data"": {
""operator_phone"": ""+49 761 45370097"",
""operator_hours"": ""B<EFBFBD>rozeiten: Montag, Mittwoch, Freitag 9-12 Uhr"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_email"": ""hotline@sharee.bike"",
""operator_color"": ""#009699""
},
""station_group"": [
""FR_300029""
],
""gps_radius"": ""50""
},
""LV_88"": {
""station_group"": [
""LV_300005""
],
""state"": ""available"",
""description"": ""TINK Test KN"",
""operator_data"": {
""operator_name"": ""LastenVelo Freiburg"",
""operator_email"": ""info@lastenvelofreiburg.de"",
""operator_hours"": """",
""operator_color"": ""#006269"",
""operator_phone"": """"
},
""gps_radius"": ""50"",
""authed"": ""1"",
""gps"": {
""latitude"": ""47.65934079179006"",
""longitude"": "" 9.166126178863573""
},
""station"": ""LV_88"",
""uri_operator"": ""https://shareeapp-lv.copri.eu"",
""service_tour"": ""LV_2""
},
""LV_4"": {
""uri_operator"": ""https://shareeapp-lv.copri.eu"",
""authed"": ""1"",
""station"": ""LV_4"",
""gps"": {
""latitude"": ""48.01095"",
""longitude"": ""7.8553""
},
""service_tour"": ""LV_1"",
""state"": ""available"",
""description"": ""Fabrik Habsburger Straße"",
""operator_data"": {
""operator_phone"": """",
""operator_hours"": """",
""operator_email"": ""info@lastenvelofreiburg.de"",
""operator_name"": ""LastenVelo Freiburg"",
""operator_color"": ""#006269""
},
""station_group"": [
""LV_300005""
],
""gps_radius"": ""100""
},
""LV_2"": {
""uri_operator"": ""https://shareeapp-lv.copri.eu"",
""authed"": ""1"",
""gps"": {
""longitude"": ""7.84795"",
""latitude"": ""47.99762""
},
""station"": ""LV_2"",
""service_tour"": ""LV_1"",
""description"": ""Predigertor ADAC"",
""state"": ""available"",
""operator_data"": {
""operator_phone"": """",
""operator_name"": ""LastenVelo Freiburg"",
""operator_email"": ""info@lastenvelofreiburg.de"",
""operator_hours"": """",
""operator_color"": ""#006269""
},
""station_group"": [
""LV_300005""
],
""gps_radius"": ""100""
},
""FR_102"": {
""description"": ""Contributor-Station Dieter"",
""state"": ""available"",
""operator_data"": {
""operator_phone"": ""+49 761 45370097"",
""operator_hours"": ""B<EFBFBD>rozeiten: Montag, Mittwoch, Freitag 9-12 Uhr"",
""operator_email"": ""hotline@sharee.bike"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_color"": ""#009699""
},
""station_group"": [
""FR_300029""
],
""gps_radius"": ""50"",
""uri_operator"": ""https://shareeapp-fr01.copri.eu"",
""authed"": ""1"",
""station"": ""FR_102"",
""gps"": {
""longitude"": "" 7.835669"",
""latitude"": ""47.994371""
},
""service_tour"": ""FR_1""
},
""FR_101"": {
""station_group"": [
""FR_300001""
],
""state"": ""available"",
""description"": ""Villaban sharee Station"",
""operator_data"": {
""operator_color"": ""#009699"",
""operator_email"": ""hotline@sharee.bike"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_hours"": ""B<EFBFBD>rozeiten: Montag, Mittwoch, Freitag 9-12 Uhr"",
""operator_phone"": ""+49 761 45370097""
},
""gps_radius"": ""50"",
""authed"": ""1"",
""gps"": {
""longitude"": "" 7.825490"",
""latitude"": ""47.976634""
},
""station"": ""FR_101"",
""uri_operator"": ""https://shareeapp-fr01.copri.eu"",
""service_tour"": ""FR_1""
}
},
""response_state"": ""OK, nothing todo"",
""agb_checked"": ""1"",
""agb_html"": ""site/agb.html"",
""authcookie"": ""5781_f172cf59108fe53e7524c841847fee69_oiF2kahH"",
""Ilockit_admin"": ""1"",
""copri_version"": ""4.1.0.0"",
""bike_info_html"": ""site/bike_info.html"",
""uri_operator_array"": [
""https://shareeapp-lv.copri.eu"",
""https://shareeapp-fr01.copri.eu""
],
""uri_primary"": ""https://shareeapp-primary.copri.eu"",
""apiserver"": ""https://shareeapp-primary.copri.eu"",
""last_used_operator"": {
""operator_phone"": ""+49 761 45370097"",
""operator_color"": ""#009699"",
""operator_email"": ""hotline@sharee.bike"",
""operator_name"": ""sharee.bike | TeilRad GmbH"",
""operator_hours"": ""Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr""
},
""clearing_cache"": ""0"",
""user_group"": [
""LV_300005"",
""FR_300029"",
""FR_300001""
],
""privacy_html"": ""site/privacy.html"",
""new_authcoo"": ""0""
}
}
";
2021-06-26 20:57:55 +02:00
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""
}
} ";
2021-07-12 19:30:14 +02:00
/// <summary>
/// Holds three rented bc- bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// Two rented bc bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// One reserved and two rented bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// Three rented bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// Two rented bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// One reserved and two rented bikes.
/// </summary>
/// <remarks>
/// Response from BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET2_FILE taken (does not yet contain uri_operator) and reserved bike added.
/// </remarks>
const string BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET2_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"",
""uri_operator"" : ""https://shareeapp-fr01.copri.eu"",
""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""
},
""156350"" : {
""total_price"" : ""0.00"",
""description"" : ""Tester-bike Oliver 2"",
""K_u"" : ""[-72, 88, 96, -80, -2, 82, 36, -67, 48, 101, -55, 127, -85, 95, -83, -77, 14, -103, -14, -47, 0, 0, 0, 0]"",
""real_hours"" : ""0"",
""state"" : ""requested"",
""tariff_description"" : {
""eur_per_hour"" : ""3.00"",
""max_eur_per_day"" : ""10.00"",
""number"" : ""5494"",
""name"" : ""Tester Basic""
},
""station"" : ""FR_103"",
""Ilockit_ID"" : ""ISHAREIT-2302373"",
""K_seed"" : ""[-93, -36, 49, -84, 65, 107, 74, 125, -91, -59, 43, 45, 85, -126, 91, -27]"",
""K_a"" : ""[-76, 86, 39, -62, 89, 76, 23, -37, 108, -4, 4, -36, -48, 26, -110, -75, 96, -101, -26, -51, 0, 0, 0, 0]"",
""end_time"" : ""2021-07-04 17:46:00+02"",
""system"" : ""Ilockit"",
""computed_hours"" : ""0"",
""bike"" : ""FR_1004"",
""uri_operator"" : ""https://shareeapp-fr01.copri.eu"",
""start_time"" : ""2021-07-04 17:46:36.237404+02"",
""bike_group"" : [
""FR_300029""
],
""gps"" : {
""latitude"" : ""47.9978876"",
""longitude"" : ""7.7849563""
},
""unit_price"" : ""3.00"",
""lock_state"" : ""locked"",
""Ilockit_GUID"" : ""00000000-0000-0000-0000-fe3962c08bcc"",
""request_time"" : ""2021-07-04 17:46:36.237404+02""
}
},
""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""
}
}";
2021-06-26 20:57:55 +02:00
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""
}
}";
2021-07-12 19:30:14 +02:00
/// <summary>
/// Five available bikes.
/// </summary>
2021-06-26 20:57:55 +02:00
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""
}
}
}
}";
2021-11-08 23:11:56 +01:00
private const SampleSets DEFAULT_SAMPLE_SET = SampleSets.Set2;
2021-06-26 20:57:55 +02:00
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);
}
/// <summary> Holds the session id of the logged in user, null otherwise. </summary>
public string SessionCookie { get; private set; }
/// <summary> Logs user in. </summary>
/// <param name="p_oUser">User to log in.</param>
/// <param name="p_strDeviceId">Id specifying user and hardware.</param>
/// <param name="p_strMailAddress">Mailaddress of user to log in.</param>
/// <param name="p_strPassword">Password to log in.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
public async Task<AuthorizationResponse> DoAuthorizationAsync(
string p_strMailAddress,
string p_strPassword,
string p_strDeviceId)
{
return await Task.Run(() => DoAuthorize(p_strMailAddress, p_strPassword, p_strDeviceId));
}
/// <summary> Logs user out. </summary>
/// <param name="p_strSessionCookie">User to log in.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
{
return await Task.Run(() => DoAuthout(SessionCookie));
}
/// <summary>
/// Gets list of bikes from memory.
/// </summary>
/// <returns></returns>
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
{
return await Task.Run(() => GetBikesAvailable(null, SessionCookie, ActiveSampleSet, ActiveStageIndex));
}
/// <summary>
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
/// </summary>
/// <param name="p_strSessionCookie">Cookie to authenticate user.</param>
/// <returns>Response holding list of bikes.</returns>
public async Task<BikesReservedOccupiedResponse> 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));
}
/// <summary>
/// Get list of stations from file.
/// </summary>
/// <param name="p_strCookie">Auto cookie of user if user is logged in.</param>
/// <returns>List of files.</returns>
public async Task<StationsAvailableResponse> GetStationsAsync()
2021-06-26 20:57:55 +02:00
{
return await Task.Run(() => GetStationsAll(null, SessionCookie, ActiveSampleSet, ActiveStageIndex));
}
/// <summary>
/// Gets booking request response.
/// </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <returns>Booking response.</returns>
public async Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
{
return await Task.Run(() => DoReserve(bikeId, SessionCookie, ActiveSampleSet, ActiveStageIndex));
}
/// <summary>
/// Gets canel booking request response.
/// </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="p_strCookie">Cookie of the logged in user.</param>
/// <returns>Response on cancel booking request.</returns>
public async Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
{
return await Task.Run(() => DoCancelReservation(bikeId, SessionCookie, ActiveSampleSet, ActiveStageIndex));
}
/// <summary>
/// Gets the count of stages that exist for a given sample set.
/// </summary>
/// <param name="p_eSampleSet"></param>
/// <returns></returns>
public int StagesCount
{
get
{
var l_iCount = 1;
2022-01-04 18:59:16 +01:00
while (GetBikesAvailable(CopriDevelHostUri, MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null)
2021-06-26 20:57:55 +02:00
{
l_iCount++;
}
return l_iCount - 1;
}
}
/// <summary> Gets the merchant id.</summary>
public string MerchantId => TinkApp.MerchantId;
/// <summary>
/// Gets the active sample set.
/// </summary>
public SampleSets ActiveSampleSet { get; }
/// <summary>
/// Gets the active stage index.
/// </summary>
public int ActiveStageIndex { get; }
/// <summary> Returns false because cached values are returned. </summary>
public bool IsConnected => false;
/// <summary> Logs user in. </summary>
/// <param name="p_oUser">User to log in.</param>
/// <param name="p_strDeviceId">Id specifying user and hardware.</param>
/// <param name="p_strMailAddress">Mailaddress of user to log in.</param>
/// <param name="p_strPassword">Password to log in.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
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<ResponseContainer<AuthorizationResponse>>(DO_AUTH_SET02_001_FILE).shareejson
: JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DO_AUTH_Unknown_User_FILE).shareejson;
default:
return null;
}
default:
return null;
}
}
/// <summary> Logs user in. </summary>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
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<ResponseContainer<AuthorizationoutResponse>>(DO_AUTHOUT_SET02_001_FILE).shareejson
: throw new NotSupportedException();
default:
return null;
}
default:
return null;
}
}
/// <summary>
/// Gets list of bikes from memory.
/// </summary>
/// <param name="p_strMerchantId">Id of the merchant.</param>
/// <param name="p_strSessionCookie">Auto cookie of user if user is logged in.</param>
/// <param name="p_eSampleSet">Set of samples.</param>
/// <param name="p_lStageIndex">Index of the stage.</param>
/// <returns></returns>
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<BikesAvailableResponse>(BIKES_AVAILABLE_SET01_001_FILE);
default:
return null;
}
case SampleSets.Set2:
switch (p_lStageIndex)
{
case 1:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_SET02_001_FILE);
case 2:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_SET02_002_FILE);
case 3:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_SET02_003_FILE);
default:
return null;
}
case SampleSets.ShareeFr01_Set1:
switch (p_lStageIndex)
{
case 1:
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BIKES_AVAILABLE_REQUEST_SHAREEFR01_SET1_FILE);
default:
return null;
}
default:
return null;
}
}
/// <summary>
/// Gets stations response.
/// </summary>
/// <param name="p_strMerchantId">Id of the merchant.</param>
/// <param name="p_strCookie">Auto cookie of user if user is logged in.</param>
/// <param name="p_eSampleSet"></param>
/// <param name="p_lStageIndex"></param>
/// <returns></returns>
public static StationsAvailableResponse GetStationsAll(
2021-06-26 20:57:55 +02:00
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<ResponseContainer<StationsAvailableResponse>>(STATIONS_SET02_001_FILE).shareejson;
2021-06-26 20:57:55 +02:00
default:
return null;
}
default:
return null;
}
}
/// <summary>
/// Gets booking request response.
/// </summary>
/// <param name="bikeId">Id of the bike.</param>
/// <param name="sessionCookie">Identifies the logged in user.</param>
/// <param name="sampleSet">Sample set to use.</param>
/// <param name="stageIndex">Index of the stage.</param>
/// <returns></returns>
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<ResponseContainer<ReservationBookingResponse>>(BOOKING_REQUEST_SET02_001_FILE).shareejson;
break;
default:
return null;
}
break;
default:
return null;
}
return l_oResponse;
}
/// <summary>
/// Gets canel booking request response.
/// </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="cookie">Cookie of the logged in user.</param>
/// <returns>Response on cancel booking request.</returns>
public static ReservationCancelReturnResponse DoCancelReservation(
string bikeId,
string cookie,
SampleSets sampleSet = DEFAULT_SAMPLE_SET,
long stageIndex = DEFAULT_STAGE_INDEX)
{
return null;
}
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri) => null;
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto geolocation,
lock_state state,
double batteryLevel,
Uri operatorUri) => null;
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
{
return null;
}
2021-12-08 17:57:30 +01:00
public Task<DoReturnResponse> DoReturn(
2021-06-26 20:57:55 +02:00
string bikeId,
LocationDto geolocation,
ISmartDevice smartDevice,
Uri operatorUri)
2021-12-08 17:57:30 +01:00
=> null;
2021-06-26 20:57:55 +02:00
2021-08-01 17:24:15 +02:00
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
=> null;
/// <summary> Submits mini survey to copri server. </summary>
/// <param name="answers">Collection of answers.</param>
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
=> null ;
2021-06-26 20:57:55 +02:00
/// <summary>
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
/// </summary>
2021-07-12 19:30:14 +02:00
/// <param name="sessionCookie">Cookie to authenticate user.</param>
2021-06-26 20:57:55 +02:00
/// <param name="SampleSet">Sample set to use.</param>
/// <param name="p_lStageIndex">Index of the stage.</param>
/// <returns>Response holding list of bikes.</returns>
public static BikesReservedOccupiedResponse GetBikesOccupied(
2021-07-12 19:30:14 +02:00
string sessionCookie = null,
2021-06-26 20:57:55 +02:00
SampleSets sampleSet = DEFAULT_SAMPLE_SET,
long stageIndex = DEFAULT_STAGE_INDEX)
{
BikesReservedOccupiedResponse response;
switch (sampleSet)
{
case SampleSets.Set1:
switch (stageIndex)
{
case 1:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SET01_001_FILE);
break;
default:
return null;
}
break;
case SampleSets.Set2:
switch (stageIndex)
{
case 1:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SET02_001_FILE);
break;
case 2:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SET02_002_FILE);
break;
case 3:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SET02_003_FILE);
break;
default:
return null;
}
break;
case SampleSets.ShareeFr01_Set1:
switch (stageIndex)
{
case 1:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET1_FILE);
break;
2021-07-12 19:30:14 +02:00
case 2:
response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(BIKES_OCCUPIED_REQUEST_SHAREEFR01_SET2_FILE);
break;
2021-06-26 20:57:55 +02:00
default:
return null;
}
break;
default:
return null;
}
2021-07-12 19:30:14 +02:00
return sessionCookie == null || response?.authcookie == sessionCookie
2021-06-26 20:57:55 +02:00
? response
2021-07-12 19:30:14 +02:00
: ResponseHelper.GetBikesOccupiedNone(sessionCookie);
2021-06-26 20:57:55 +02:00
}
public enum SampleSets
{
/// <summary> Used for tests and demo GUI. </summary>
Set1,
/// <summary>
/// Sample set nr. 2.
/// Bikes values from first Copri- JSON returns these values.
/// </summary>
Set2,
/// <summary>
/// Sharee server
/// </summary>
ShareeFr01_Set1,
}
}
}