Skip to content

Commit f4df8c0

Browse files
authored
Merge branch 'main' into nuget
2 parents b4dcdf5 + 11e8efe commit f4df8c0

9 files changed

Lines changed: 21 additions & 19 deletions

File tree

.github/workflows/unittests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- name: Build
2929
working-directory: TransformerBeeClient
30-
run: dotnet build --no-restore
30+
run: dotnet build --no-restore --configuration Release
3131

3232
- name: Run Unit Tests
3333
working-directory: TransformerBeeClient/TransformerBeeClient.UnitTest

TransformerBeeClient/TransformerBeeClient/Model/BOneyComb.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public class BOneyComb
1515
/// </summary>
1616
[JsonPropertyName("stammdaten")] // we want to support both System.Text and Newtonsoft as long as BO4E.net does so
1717
[JsonProperty(PropertyName = "stammdaten")]
18-
public List<BusinessObject> Stammdaten { get; set; }
18+
public List<BusinessObject>? Stammdaten { get; set; }
1919

2020
/// <summary>
2121
/// Transaktionsdaten are metadata related to the Marktprozess and are not related to a specific Business object.
2222
/// </summary>
2323
[JsonPropertyName("transaktionsdaten")] // we want to support both System.Text and Newtonsoft as long as BO4E.net does so
2424
[JsonProperty(PropertyName = "transaktionsdaten")]
25-
public Dictionary<string, string> Transaktionsdaten { get; set; }
25+
public Dictionary<string, string>? Transaktionsdaten { get; set; }
2626
}

TransformerBeeClient/TransformerBeeClient/Model/Bo4eTransactionToEdifactRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class Bo4eTransactionToEdifactRequest
1313
/// the BOneyComb as json string
1414
/// </summary>
1515
[System.Text.Json.Serialization.JsonPropertyName("BO4E")]
16-
public string Bo4eJsonString { get; set; }
16+
public string? Bo4eJsonString { get; set; }
1717

1818
/// <summary>
1919
/// the format version to use

TransformerBeeClient/TransformerBeeClient/Model/Bo4eTransactionToEdifactResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ internal class Bo4eTransactionToEdifactResponse
1111
/// the edifact as plain string
1212
/// </summary>
1313
[System.Text.Json.Serialization.JsonPropertyName("EDI")]
14-
public string Edifact { get; set; }
14+
public string? Edifact { get; set; }
1515
}

TransformerBeeClient/TransformerBeeClient/Model/EdifactToBo4eRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class EdifactToBo4eRequest
1313
/// the edifact as plain string
1414
/// </summary>
1515
[System.Text.Json.Serialization.JsonPropertyName("EDI")]
16-
public string Edifact { get; set; }
16+
public string? Edifact { get; set; }
1717

1818
/// <summary>
1919
/// the format version to use

TransformerBeeClient/TransformerBeeClient/Model/EdifactToBo4eResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class EdifactToBo4eResponse
1313
/// the bo4e as plain json string
1414
/// </summary>
1515
[System.Text.Json.Serialization.JsonPropertyName("BO4E")]
16-
public string Bo4eJsonString { get; set; }
16+
public string? Bo4eJsonString { get; set; }
1717

1818
/// <summary>
1919
/// the format version that was used

TransformerBeeClient/TransformerBeeClient/Model/Marktnachricht.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public class Marktnachricht
2121
/// </summary>
2222
[JsonPropertyName("transaktionen")]// we want to support both System.Text and Newtonsoft as long as BO4E.net does so
2323
[JsonProperty(PropertyName = "transaktionen")]
24-
public List<BOneyComb> Transaktionen { get; set; }
24+
public List<BOneyComb>? Transaktionen { get; set; }
2525

2626
/// <summary>
2727
/// Nachrichtendaten are similar to <see cref="BOneyComb.Transaktionsdaten"/> but are not 100% identical.
2828
/// </summary>
2929
[JsonPropertyName("nachrichtendaten")] // we want to support both System.Text and Newtonsoft as long as BO4E.net does so
3030
[JsonProperty(PropertyName = "nachrichtendaten")]
31-
public Dictionary<string, string> Nachrichtendaten { get; set; }
31+
public Dictionary<string, string>? Nachrichtendaten { get; set; }
3232
}

TransformerBeeClient/TransformerBeeClient/RestClient.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public TransformerBeeRestClient(IHttpClientFactory httpClientFactory, string cli
4646
/// </returns>
4747
public async Task<bool> IsAvailable()
4848
{
49-
var uriBuilder = new UriBuilder(_httpClient!.BaseAddress)
49+
var uriBuilder = new UriBuilder(_httpClient.BaseAddress!)
5050
{
5151
Path = "/version"
5252
};
@@ -69,7 +69,7 @@ public async Task<List<Marktnachricht>> ConvertToBo4e(string edifact, EdifactFor
6969
{
7070
throw new ArgumentNullException(nameof(edifact));
7171
}
72-
var uriBuilder = new UriBuilder(_httpClient!.BaseAddress)
72+
var uriBuilder = new UriBuilder(_httpClient!.BaseAddress!)
7373
{
7474
Path = "/v1/transformer/EdiToBo4E"
7575
};
@@ -90,10 +90,10 @@ public async Task<List<Marktnachricht>> ConvertToBo4e(string edifact, EdifactFor
9090
var responseContent = await httpResponse.Content.ReadAsStringAsync();
9191
var bo4eResponse = JsonSerializer.Deserialize<EdifactToBo4eResponse>(responseContent, _jsonSerializerOptions);
9292
// todo: handle the case that the deserialization fails and bo4eResponse is null
93-
var unescapedJson = bo4eResponse!.Bo4eJsonString.Unescape();
94-
var result = JsonSerializer.Deserialize<List<Marktnachricht>>(unescapedJson, _jsonSerializerOptions);
93+
var unescapedJson = bo4eResponse!.Bo4eJsonString!.Unescape();
94+
var result = JsonSerializer.Deserialize<List<Marktnachricht>>(unescapedJson!, _jsonSerializerOptions);
9595
// todo: handle the case that the deserialization fails and result is null
96-
return result;
96+
return result!;
9797
}
9898

9999
public async Task<string> ConvertToEdifact(BOneyComb boneyComb, EdifactFormatVersion formatVersion)
@@ -102,7 +102,7 @@ public async Task<string> ConvertToEdifact(BOneyComb boneyComb, EdifactFormatVer
102102
{
103103
throw new ArgumentNullException(nameof(boneyComb));
104104
}
105-
var uriBuilder = new UriBuilder(_httpClient!.BaseAddress)
105+
var uriBuilder = new UriBuilder(_httpClient!.BaseAddress!)
106106
{
107107
Path = "/v1/transformer/Bo4ETransactionToEdi"
108108
};
@@ -122,7 +122,9 @@ public async Task<string> ConvertToEdifact(BOneyComb boneyComb, EdifactFormatVer
122122
throw new HttpRequestException($"Could not convert to EDIFACT; Status code: {httpResponse.StatusCode}");
123123
}
124124
var responseContent = await httpResponse.Content.ReadAsStringAsync();
125-
var responseBody = JsonSerializer.Deserialize<Bo4eTransactionToEdifactResponse>(responseContent, _jsonSerializerOptions);
126-
return responseBody.Edifact;
125+
// todo: ensure that the deserialization does not fail and the response is not empty
126+
var responseBody = JsonSerializer.Deserialize<Bo4eTransactionToEdifactResponse>(responseContent!, _jsonSerializerOptions);
127+
// todo: handle case that deserialization fails and responseBody is null
128+
return responseBody!.Edifact!;
127129
}
128130
}

TransformerBeeClient/TransformerBeeClient/Utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ internal static class Utils
1010
/// </summary>
1111
/// <param name="s"></param>
1212
/// <returns></returns>
13-
internal static string Unescape(this string s)
13+
internal static string? Unescape(this string? s)
1414
{
15-
return s.Replace("\\n", "\n");
15+
return s?.Replace("\\n", "\n");
1616
}
1717
}

0 commit comments

Comments
 (0)