-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added handling of srv4pos error responses. (#261)
* Added handling of srv4pos error responses. * tests fixed.
- Loading branch information
1 parent
989c89f
commit cf81e24
Showing
9 changed files
with
123 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/Sweden/Mews.Fiscalizations.Sweden/DTOs/Srv4posBasicErrorResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Mews.Fiscalizations.Sweden.DTOs; | ||
|
||
public sealed class Srv4posBasicErrorResponse | ||
{ | ||
[JsonPropertyName("error")] | ||
public string Error { get; set; } | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Sweden/Mews.Fiscalizations.Sweden/DTOs/Srv4posError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Mews.Fiscalizations.Sweden.DTOs; | ||
|
||
public sealed class Srv4posError | ||
{ | ||
[JsonPropertyName("error")] | ||
public string Error { get; set; } | ||
|
||
[JsonPropertyName("details")] | ||
public List<ErrorDetail> Details { get; set; } | ||
} | ||
|
||
public sealed class ErrorDetail | ||
{ | ||
[JsonPropertyName("field")] | ||
public string Field { get; set; } | ||
|
||
[JsonPropertyName("message")] | ||
public string Message { get; set; } | ||
|
||
[JsonPropertyName("code")] | ||
public string Code { get; set; } | ||
|
||
[JsonPropertyName("params")] | ||
public ErrorParams Params { get; set; } | ||
} | ||
|
||
public sealed class ErrorParams | ||
{ | ||
[JsonPropertyName("actualValue")] | ||
public string ActualValue { get; set; } | ||
|
||
[JsonPropertyName("pattern")] | ||
public string Pattern { get; set; } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Sweden/Mews.Fiscalizations.Sweden/Models/ErrorResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using FuncSharp; | ||
|
||
namespace Mews.Fiscalizations.Sweden.Models; | ||
|
||
public sealed class ErrorResponse(NonEmptyString error, Srv4posErrorType errorType, string message = null) | ||
{ | ||
public NonEmptyString Error { get; } = error; | ||
|
||
public Srv4posErrorType ErrorType { get; } = errorType; | ||
|
||
public Option<NonEmptyString> Message { get; } = message.AsNonEmpty(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Sweden/Mews.Fiscalizations.Sweden/Models/Srv4posErrorType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Mews.Fiscalizations.Sweden.Models; | ||
|
||
public enum Srv4posErrorType | ||
{ | ||
ServerSideError = 0, | ||
InvalidRequest = 1, | ||
InvalidCorporateId = 2, | ||
InvalidCashRegisterName = 3, | ||
InvalidFieldFormat = 4, | ||
NonUniqueCashRegisterNameOrCorporateId = 5, | ||
UnknownError = 6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters