Skip to content

Commit

Permalink
refactor folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-raaschou committed Feb 6, 2024
1 parent c32bad9 commit 8648f48
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 88 deletions.
28 changes: 0 additions & 28 deletions src/Core/Classes.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Infrastructure/Configuration.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Net.Http.Json;
using System.Text.Json;
using MinEltavle.Core.Domain;

namespace MitElforbrug.Infrastructure;

Expand All @@ -10,6 +9,12 @@ public record HentMåleraflæsningerRequest(
string[] Målepunkter
);

public record ElForbrug(
DateTime Tidspunkt,
decimal ForbrugKwh
);


public class EloverblikHttpClient(HttpClient httpClient)
{
private static readonly JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using Google.Protobuf.WellKnownTypes;

namespace MitElforbrug.Infrastructure;

Expand Down Expand Up @@ -47,13 +46,13 @@ private async Task<string> GetAccessJwtToken(CancellationToken cancellationToken
static HttpRequestMessage GetHttpRequestMessage(Uri baseAddress)
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tokens/MinToken.txt");
var token =MyToken.Value;// File.ReadAllText(path);
var token =MyDataHubToken.Value;// File.ReadAllText(path);
var request = new HttpRequestMessage(HttpMethod.Get, $"{baseAddress}/token");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
return request;
}
}

file static class MyToken{
file static class MyDataHubToken{
public static string Value => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlblR5cGUiOiJDdXN0b21lckFQSV9SZWZyZXNoIiwidG9rZW5pZCI6IjdjYzE4ZWQzLThkNzgtNDVmMS05YzU5LTQ1MmVlODllMjRlOCIsIndlYkFwcCI6IkN1c3RvbWVyQXBwIiwidmVyc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uX3ZyYW5nZWLDuGd2ZWoiLCJhdWQiOiJFbmVyZ2luZXQifQ.L-SeQB-pMSITWKL2PF2fWt88CB1zKd3T6ZVDET6_zvE";
}
File renamed without changes.
File renamed without changes.
32 changes: 28 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,41 @@
using Microsoft.Extensions.DependencyInjection;
using MitElforbrug.Infrastructure;
using MitElforbrug.Features;
using MitElforbrug;

var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services => {
.ConfigureServices((Action<IServiceCollection>)(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.ConfigureEloverblikHttpClient();
services.AddSingleton(TimeProvider.System);
services.AddScoped<VisMålerOplysningerHandler>();
services.AddScoped<VisElforbrugOgSpotpriserHandler>();
})
services.AddHttpClient<EnerginetHttpClient>(client =>
{
client.BaseAddress = new Uri("https://api.energidataservice.dk");
});
AddEloverblikHttpClient(services);
}))
.Build();

host.Run();

static void AddEloverblikHttpClient(IServiceCollection services)
{
var eloverblikBaseAddress = new Uri("https://api.eloverblik.dk/customerapi/api");
services
.AddHttpClient<EloverblikHttpClient>(
client => client.BaseAddress = eloverblikBaseAddress)
.AddHttpMessageHandler(
services => new EloverblikJwtTokenHandler(
timeProvider: services.GetRequiredService<TimeProvider>(),
baseAddress: eloverblikBaseAddress
)
);
}
24 changes: 0 additions & 24 deletions src/TestTrigger.cs

This file was deleted.

0 comments on commit 8648f48

Please sign in to comment.