diff --git a/GM.Api/GMClientBase.cs b/GM.Api/GMClientBase.cs index 4f4fa82..7a56b2c 100644 --- a/GM.Api/GMClientBase.cs +++ b/GM.Api/GMClientBase.cs @@ -414,11 +414,11 @@ namespace GM.Api } - JObject reqObj = new JObject(); + JObject reqObj = requestParameters; - if (requestParameters != null) + if (reqObj == null) { - reqObj[$"{command}Request"] = requestParameters; + reqObj = new JObject(); } diff --git a/GM.Api/GenericGMClient.cs b/GM.Api/GenericGMClient.cs index 27db29b..5646aa9 100644 --- a/GM.Api/GenericGMClient.cs +++ b/GM.Api/GenericGMClient.cs @@ -60,15 +60,49 @@ namespace GM.Api /// True or false for success public async Task LockDoor() { + var reqObj = new JObject() { - ["delay"] = 0 + ["lockDoorRequest"] = new JObject() + { + ["delay"] = 0 + } }; - return await InitiateCommandAndWaitForSuccess("lockDoor", reqObj); } + + /// + /// Fails when the hotspot is off... + /// Note: the app uses diagnotics that also fail when the hotpot is off + /// + /// + public async Task GetHotspotInfo() + { + var resp = await InitiateCommandAndWait("getHotspotInfo", null); + return resp.Body.HotspotInfo; + } + + + /// + /// Send a turn-by-turn destination to the vehicle + /// Requires both coordinates and address info + /// Vehicle may not respond if turned off or may take a very long time to respond + /// + /// + /// + public async Task SendTBTRoute(TbtDestination destination) + { + var reqObj = new JObject() + { + ["tbtDestination"] = new JObject(destination) + }; + + return await InitiateCommandAndWaitForSuccess("sendTBTRoute", reqObj); + } + + /// /// Unlock the active vehicles's doors and wait for completion /// Privileged Command @@ -76,10 +110,12 @@ namespace GM.Api /// True or false for success public async Task UnlockDoor() { - var reqObj = new JObject() { - ["delay"] = 0 + ["unlockDoorRequest"] = new JObject() + { + ["delay"] = 0 + } }; return await InitiateCommandAndWaitForSuccess("unlockDoor", reqObj); @@ -113,15 +149,19 @@ namespace GM.Api /// True or false for success public async Task Alert() { + + var reqObj = new JObject() { - ["action"] = new JArray() { "Honk", "Flash" }, - ["delay"] = 0, - ["duration"] = 1, - ["override"] = new JArray() { "DoorOpen", "IgnitionOn" } + ["alertRequest"] = new JObject() + { + ["action"] = new JArray() { "Honk", "Flash" }, + ["delay"] = 0, + ["duration"] = 1, + ["override"] = new JArray() { "DoorOpen", "IgnitionOn" } + } }; - return await InitiateCommandAndWaitForSuccess("alert", reqObj); } diff --git a/GM.Api/Models/CommandResponse.cs b/GM.Api/Models/CommandResponse.cs index fe7f8e7..472ea7b 100644 --- a/GM.Api/Models/CommandResponse.cs +++ b/GM.Api/Models/CommandResponse.cs @@ -54,7 +54,7 @@ namespace GM.Api.Models public string Type { get; set; } /// - /// Response boldy for commands that include a response (e.g. diagnostics, location) + /// Response body for commands that include a response (e.g. diagnostics, location) /// [JsonProperty("body")] public ResponseBody Body { get; set; } @@ -62,4 +62,32 @@ namespace GM.Api.Models } + + /// + /// Response Body + /// Note: this only contains a diagnostic response. there are likely others. + /// + public class ResponseBody + { + /// + /// Populated for diagnostics command + /// + [JsonProperty("diagnosticResponse")] + public DiagnosticResponse[] DiagnosticResponse { get; set; } + + /// + /// populated for location command + /// + [JsonProperty("location")] + public Location Location { get; set; } + + /// + /// placeholder - not yet tested + /// + [JsonProperty("hotspotInfo")] + public HotspotInfo HotspotInfo { get; set; } + + } + + } diff --git a/GM.Api/Models/Diagnostic.cs b/GM.Api/Models/Diagnostic.cs index e61edf8..32768b0 100644 --- a/GM.Api/Models/Diagnostic.cs +++ b/GM.Api/Models/Diagnostic.cs @@ -6,16 +6,6 @@ using Newtonsoft.Json; namespace GM.Api.Models { - /// - /// Response Body - /// Note: this only contains a diagnostic response. there are likely others. - /// - public class ResponseBody - { - [JsonProperty("diagnosticResponse")] - public DiagnosticResponse[] DiagnosticResponse { get; set; } - } - public class DiagnosticResponse { [JsonProperty("name")] diff --git a/GM.Api/Models/HotspotInfo.cs b/GM.Api/Models/HotspotInfo.cs new file mode 100644 index 0000000..631e59f --- /dev/null +++ b/GM.Api/Models/HotspotInfo.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GM.Api.Models +{ + /// + /// Placeholder + /// + public class HotspotInfo + { + } +} diff --git a/GM.Api/Models/Location.cs b/GM.Api/Models/Location.cs new file mode 100644 index 0000000..7806823 --- /dev/null +++ b/GM.Api/Models/Location.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace GM.Api.Models +{ + public class Location + { + [JsonProperty("lat")] + public float? Latitude { get; set; } + + [JsonProperty("long")] + public float? Longitude { get; set; } + } +} diff --git a/GM.Api/Models/TbtDestination.cs b/GM.Api/Models/TbtDestination.cs new file mode 100644 index 0000000..aa49ba7 --- /dev/null +++ b/GM.Api/Models/TbtDestination.cs @@ -0,0 +1,68 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace GM.Api.Models +{ + + public class TbtDestination + { + [JsonProperty("additionalDestinationInfo")] + public AdditionalDestinationInfo AdditionalDestinationInfo { get; set; } + + [JsonProperty("destinationLocation")] + public Location DestinationLocation { get; set; } + } + + public class AdditionalDestinationInfo + { + [JsonProperty("destinationAddress")] + public DestinationAddress DestinationAddress { get; set; } + + [JsonProperty("destinationType")] + public string DestinationType { get; set; } + } + + public class DestinationAddress + { + [JsonProperty("city")] + public string City { get; set; } + + [JsonProperty("country")] + public string Country { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("street")] + public string Street { get; set; } + + [JsonProperty("streetNo")] + public string StreetNo { get; set; } + + [JsonProperty("zipCode")] + public string ZipCode { get; set; } + } + + public class DestinationLocation + { + public void SetLatitude(float value) + { + Latitude = value.ToString("###.#####"); + } + + public void SetLongitude(float value) + { + Longitude = value.ToString("###.#####"); + } + + [JsonProperty("lat")] + public string Latitude { get; set; } + + [JsonProperty("long")] + public string Longitude { get; set; } + } + + +} diff --git a/GM.WindowsUI/MainWindow.xaml.cs b/GM.WindowsUI/MainWindow.xaml.cs index de4a7d2..20c1b7d 100644 --- a/GM.WindowsUI/MainWindow.xaml.cs +++ b/GM.WindowsUI/MainWindow.xaml.cs @@ -246,7 +246,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Locking (Please wait)"; - var success = await _client.LockDoor(txtPin.Password); + var success = await _client.LockDoor(); if (success) { lblStatus.Content = "Locked Successfully"; @@ -266,7 +266,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Unlocking (Please wait)"; - var success = await _client.UnlockDoor(txtPin.Password); + var success = await _client.UnlockDoor(); if (success) { lblStatus.Content = "Unlocked Successfully"; @@ -285,7 +285,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Starting (Please wait)"; - var success = await _client.Start(txtPin.Password); + var success = await _client.Start(); if (success) { lblStatus.Content = "Started Successfully"; @@ -304,7 +304,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Stopping (Please wait)"; - var success = await _client.CancelStart(txtPin.Password); + var success = await _client.CancelStart(); if (success) { lblStatus.Content = "Stopped Successfully"; @@ -323,7 +323,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Alarming (Please wait)"; - var success = await _client.Alert(txtPin.Password); + var success = await _client.Alert(); if (success) { lblStatus.Content = "Alarmed Successfully"; @@ -342,7 +342,7 @@ namespace GM.WindowsUI grpActions.IsEnabled = false; btnLogin.IsEnabled = false; lblStatus.Content = "Stopping Alarm (Please wait)"; - var success = await _client.CancelAlert(txtPin.Password); + var success = await _client.CancelAlert(); if (success) { lblStatus.Content = "Alarmed Stopped Successfully";