chore: added smappee api
This commit is contained in:
@@ -33,11 +33,11 @@ internal class SmappeeChargerService : IChargerService
|
||||
var response = request switch
|
||||
{
|
||||
ChargerRequests.Enable => await httpClient.PutAsJsonAsync<SmappeeRequestBody>(
|
||||
$"/dev/v3/chargingstations/${options.ChargingStation}/connectors/{options.Connector}/mode",
|
||||
$"/dev/v3/chargingstations/{options.ChargingStation}/connectors/{options.Connector}/mode",
|
||||
new SmappeeRequestBody("NORMAL", new Limit("AMPERE", 6))
|
||||
),
|
||||
ChargerRequests.Disable => await httpClient.PutAsJsonAsync(
|
||||
"/dev/v3/chargingstations",
|
||||
$"/dev/v3/chargingstations/{options.ChargingStation}/connectors/{options.Connector}/mode",
|
||||
new SmappeeRequestBody("PAUSED", null)
|
||||
),
|
||||
_ => throw new NotImplementedException(),
|
||||
|
||||
@@ -39,14 +39,17 @@ internal class SmappeeTokenService : IBearerTokenService
|
||||
var httpClient = httpClientFactory.CreateClient("smappeeTokenService");
|
||||
httpClient.BaseAddress = options.Url;
|
||||
|
||||
var result = await httpClient.PostAsJsonAsync<TokenRequestBody>(
|
||||
var result = await httpClient.PostAsync(
|
||||
"/dev/v3/oauth2/token",
|
||||
new TokenRequestBody(
|
||||
"password",
|
||||
options.ClientId,
|
||||
options.ClientSecret,
|
||||
options.UserName,
|
||||
options.Password
|
||||
new FormUrlEncodedContent(
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
["grant_type"] = "password",
|
||||
["client_id"] = options.ClientId,
|
||||
["client_secret"] = options.ClientSecret,
|
||||
["username"] = options.UserName,
|
||||
["password"] = options.Password,
|
||||
}
|
||||
)
|
||||
);
|
||||
result.EnsureSuccessStatusCode();
|
||||
@@ -59,14 +62,6 @@ internal class SmappeeTokenService : IBearerTokenService
|
||||
);
|
||||
}
|
||||
|
||||
record TokenRequestBody(
|
||||
string grant_type,
|
||||
string client_id,
|
||||
string client_secret,
|
||||
string username,
|
||||
string password
|
||||
);
|
||||
|
||||
record TokenResponse(string access_token, int expires_in);
|
||||
|
||||
record TokenData(string Token, DateTime Expiration);
|
||||
|
||||
Reference in New Issue
Block a user