change to record classes instead of structs
This commit was merged in pull request #9.
This commit is contained in:
@@ -7,44 +7,44 @@ using System.Collections.Immutable;
|
||||
|
||||
namespace dopt.DeltaBarth.DataObjects
|
||||
{
|
||||
public readonly struct ApiServerError
|
||||
public record class ApiServerError
|
||||
{
|
||||
public int status_code { get; init; }
|
||||
public string message { get; init; }
|
||||
public required int status_code { get; init; }
|
||||
public required string message { get; init; }
|
||||
public string? code { get; init; }
|
||||
public string? hints { get; init; }
|
||||
public string? type { get; init; }
|
||||
public string? title { get; init; }
|
||||
public string? traceId { get; init; }
|
||||
}
|
||||
public readonly struct Status
|
||||
public record class Status
|
||||
{
|
||||
public int code { get; init; }
|
||||
public string description { get; init; }
|
||||
public string message { get; init; }
|
||||
public required int code { get; init; }
|
||||
public required string description { get; init; }
|
||||
public required string message { get; init; }
|
||||
public ApiServerError? apiServerError { get; init; }
|
||||
|
||||
}
|
||||
public readonly struct Credentials
|
||||
public record class Credentials
|
||||
{
|
||||
public string username { get; init; }
|
||||
public string password { get; init; }
|
||||
public string database { get; init; }
|
||||
public string mandant { get; init; }
|
||||
public required string username { get; init; }
|
||||
public required string password { get; init; }
|
||||
public required string database { get; init; }
|
||||
public required string mandant { get; init; }
|
||||
}
|
||||
public readonly struct UmsatzPrognoseEinzelergebnis
|
||||
public record class UmsatzPrognoseEinzelergebnis
|
||||
{
|
||||
public int jahr { get; init; }
|
||||
public int monat { get; init; }
|
||||
public decimal vorhersage { get; init; }
|
||||
public required int jahr { get; init; }
|
||||
public required int monat { get; init; }
|
||||
public required decimal vorhersage { get; init; }
|
||||
}
|
||||
public readonly struct UmsatzPrognoseErgebnisse
|
||||
public record class UmsatzPrognoseErgebnisse
|
||||
{
|
||||
public ImmutableArray<UmsatzPrognoseEinzelergebnis> daten { get; init; }
|
||||
public required ImmutableArray<UmsatzPrognoseEinzelergebnis> daten { get; init; }
|
||||
}
|
||||
public readonly struct UmsatzPrognoseAusgabe
|
||||
public record class UmsatzPrognoseAusgabe
|
||||
{
|
||||
public UmsatzPrognoseErgebnisse response { get; init; }
|
||||
public Status status { get; init; }
|
||||
public required UmsatzPrognoseErgebnisse response { get; init; }
|
||||
public required Status status { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@ using System.Text.Json;
|
||||
|
||||
namespace dopt.DeltaBarth
|
||||
{
|
||||
public class PythonParsingException : Exception
|
||||
{
|
||||
public PythonParsingException() { }
|
||||
public PythonParsingException(string message) : base(message) { }
|
||||
}
|
||||
public class Plugin : SharpPython.BasePlugin
|
||||
{
|
||||
protected dynamic pyModManagement;
|
||||
@@ -38,6 +43,7 @@ namespace dopt.DeltaBarth
|
||||
pyJson = pyModPipeline.pipeline_sales_forecast_dummy(firmaId, buchungsDatum);
|
||||
}
|
||||
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson);
|
||||
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); }
|
||||
|
||||
return parsed;
|
||||
}
|
||||
@@ -50,6 +56,7 @@ namespace dopt.DeltaBarth
|
||||
pyJson = pyModPipeline.pipeline_sales_forecast(firmaId, buchungsDatum);
|
||||
}
|
||||
var parsed = JsonSerializer.Deserialize<DataObjects.UmsatzPrognoseAusgabe>(pyJson);
|
||||
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); }
|
||||
|
||||
return parsed;
|
||||
}
|
||||
@@ -90,9 +97,10 @@ namespace dopt.DeltaBarth
|
||||
pyJson = (string)pyModManagement.get_credentials();
|
||||
}
|
||||
|
||||
DataObjects.Credentials credentials = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson);
|
||||
DataObjects.Credentials? parsed = JsonSerializer.Deserialize<DataObjects.Credentials>(pyJson);
|
||||
if (parsed == null) { throw new PythonParsingException("Could not correctly parse object from Python"); }
|
||||
|
||||
return credentials;
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Platforms>x64</Platforms>
|
||||
<Version>0.3.0</Version>
|
||||
<Version>0.3.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user