Skip to content

Commit

Permalink
refactor: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DerStimmler committed May 19, 2023
1 parent 746bc95 commit 4698d30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
16 changes: 8 additions & 8 deletions StromGedacht.NET/Models/RegionState.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
namespace StromGedacht.NET.Models;

/// <summary>
/// Describes different region states
/// Describes different region states
/// </summary>
public enum RegionState
{
/// <summary>
/// Normal operation - nothing to do
/// Normal operation - nothing to do
/// </summary>
Green = 1,

/// <summary>
/// Bring consumption forward - use electricity now
/// Bring consumption forward - use electricity now
/// </summary>
Yellow = 2,

/// <summary>
/// Reduce consumption to save costs and CO2
/// Reduce consumption to save costs and CO2
/// </summary>
Orange = 3,

/// <summary>
/// Reduce consumption to prevent power shortage
/// Reduce consumption to prevent power shortage
/// </summary>
Red = 4
}
12 changes: 6 additions & 6 deletions StromGedacht.NET/Models/RegionStatePeriod.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
namespace StromGedacht.NET.Models;

/// <summary>
/// Contains region state for a specific period
/// Contains region state for a specific period
/// </summary>
public record RegionStatePeriod
{
/// <summary>
/// Region state in this period
/// Region state in this period
/// </summary>
public RegionState State { get; set; }

/// <summary>
/// Period starting time
/// Period starting time
/// </summary>
public DateTimeOffset From { get; set; }

/// <summary>
/// Period end time
/// Period end time
/// </summary>
public DateTimeOffset To { get; set; }
}
3 changes: 2 additions & 1 deletion StromGedacht.NET/Utils/ApiAddresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ internal static class ApiAddresses
{
internal static readonly Uri BaseAddress = new("https://api.stromgedacht.de/v1/");
internal static string Now(string zip) => new($"now?zip={zip}");

internal static string States(string zip, DateTimeOffset from, DateTimeOffset to)
{
var encodedFrom = UrlEncoder.Default.Encode(from.ToString("O"));
var encodedTo = UrlEncoder.Default.Encode(to.ToString("O"));

return $"states?zip={zip}&from={encodedFrom}&to={encodedTo}";
}
}

0 comments on commit 4698d30

Please sign in to comment.