From a6e2bef231c27bba2ad6f658abb4722be699ed48 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 19 Jan 2024 01:21:39 +0100 Subject: [PATCH] Update OpenShockHttp to version 2 api --- CShocker/Shockers/APIS/OpenShockHttp.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CShocker/Shockers/APIS/OpenShockHttp.cs b/CShocker/Shockers/APIS/OpenShockHttp.cs index 765ece3..0c48321 100644 --- a/CShocker/Shockers/APIS/OpenShockHttp.cs +++ b/CShocker/Shockers/APIS/OpenShockHttp.cs @@ -15,18 +15,22 @@ public class OpenShockHttp : HttpShocker { Headers = { - UserAgent = { new ProductInfoHeaderValue("OpenCS2hock", "1") }, + UserAgent = { new ProductInfoHeaderValue("CShocker", "1") }, Accept = { new MediaTypeWithQualityHeaderValue("application/json") } }, - Content = new StringContent(@"[ { "+ - $"\"id\": \"{shockerId}\"," + - $"\"type\": {ControlActionToByte(action)},"+ - $"\"intensity\": {intensity},"+ - $"\"duration\": {duration}"+ - "}]", Encoding.UTF8, new MediaTypeHeaderValue("application/json")) + Content = new StringContent("{ shocks: ["+ + "{ "+ + $"\"id\": \"{shockerId}\"," + + $"\"type\": {ControlActionToByte(action)},"+ + $"\"intensity\": {intensity},"+ + $"\"duration\": {duration}"+ + "}" + + "]," + + "customName: CShocker" + + "}", Encoding.UTF8, new MediaTypeHeaderValue("application/json")) }; request.Headers.Add("OpenShockToken", ApiKey); - HttpResponseMessage response = (HttpClient.Send(request)); + HttpResponseMessage response = HttpClient.Send(request); this.Logger?.Log(LogLevel.Debug, $"{request.RequestUri} response: {response.StatusCode}"); }