blob: 05d0af90d91421072b9ffd40d5c6e44077725946 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using System.Net.Http.Json;
namespace SafeNSound.Sdk;
public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken)
{
public WrappedHttpClient HttpClient { get; } = new()
{
BaseAddress = new Uri(config.BaseUri),
DefaultRequestHeaders =
{
Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken)
}
};
#region Alarm
public async Task<AlarmDto> GetAlarm(string userId = "@me") {
var res = await HttpClient.GetAsync($"/alarm/{userId}");
res.EnsureSuccessStatusCode();
return (await res.Content.ReadFromJsonAsync<AlarmDto>())!;
}
public async Task SetAlarm(AlarmDto alarm) {
var res = await HttpClient.PutAsJsonAsync("/alarm/@me", alarm);
res.EnsureSuccessStatusCode();
}
public async Task DeleteAlarm(string userId = "@me") {
var res = await HttpClient.DeleteAsync($"/alarm/{userId}");
res.EnsureSuccessStatusCode();
}
#endregion
#region Budget
#endregion
}
public class AlarmDto {
}
|