-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
140 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Text.Json.Serialization; | ||
using Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
namespace Sportradar.Mbs.Sdk.Entities.Odds; | ||
|
||
/// <summary> | ||
/// Represents fractional odds. | ||
/// </summary> | ||
public class FractionalOdds : OddsBase | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("type")] | ||
private string Type => "fractional"; | ||
|
||
/// <summary> | ||
/// Gets or sets the value of the numerator (top, first part) of the fractional odds. | ||
/// </summary> | ||
[JsonConverter(typeof(LongJsonConverter))] | ||
[JsonPropertyName("numerator")] | ||
public long? Numerator { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the value of the denominator (bottom, last part) of the fractional odds. | ||
/// </summary> | ||
[JsonConverter(typeof(LongJsonConverter))] | ||
[JsonPropertyName("denominator")] | ||
public long? Denominator { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
using Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
namespace Sportradar.Mbs.Sdk.Entities.Odds; | ||
|
||
/// <summary> | ||
/// Represents hong kong odds. | ||
/// </summary> | ||
public class HongKongOdds : OddsBase | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("type")] | ||
private string Type => "hong-kong"; | ||
|
||
/// <summary> | ||
/// Gets or sets the hong kong value of the odds: eg "0.75". | ||
/// </summary> | ||
[JsonConverter(typeof(DecimalJsonConverter))] | ||
[JsonPropertyName("value")] | ||
public decimal? Value { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
using Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
namespace Sportradar.Mbs.Sdk.Entities.Odds; | ||
|
||
/// <summary> | ||
/// Represents indonesian odds. | ||
/// </summary> | ||
public class IndonesianOdds : OddsBase | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("type")] | ||
private string Type => "indonesian"; | ||
|
||
/// <summary> | ||
/// Gets or sets the indonesian value of the odds: eg "-3.4". | ||
/// </summary> | ||
[JsonConverter(typeof(DecimalJsonConverter))] | ||
[JsonPropertyName("value")] | ||
public decimal? Value { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
using Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
namespace Sportradar.Mbs.Sdk.Entities.Odds; | ||
|
||
/// <summary> | ||
/// Represents malay odds. | ||
/// </summary> | ||
public class MalayOdds : OddsBase | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("type")] | ||
private string Type => "malay"; | ||
|
||
/// <summary> | ||
/// Gets or sets the malay value of the odds: eg "0.75". | ||
/// </summary> | ||
[JsonConverter(typeof(DecimalJsonConverter))] | ||
[JsonPropertyName("value")] | ||
public decimal? Value { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
using Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
namespace Sportradar.Mbs.Sdk.Entities.Odds; | ||
|
||
/// <summary> | ||
/// Represents moneyline odds. | ||
/// </summary> | ||
public class MoneylineOdds : OddsBase | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("type")] | ||
private string Type => "moneyline"; | ||
|
||
/// <summary> | ||
/// Gets or sets the moneyline value of the odds: eg "-340". | ||
/// </summary> | ||
[JsonConverter(typeof(LongJsonConverter))] | ||
[JsonPropertyName("value")] | ||
public long? Value { 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
22 changes: 22 additions & 0 deletions
22
src/Sportradar.Mbs.Sdk/Internal/Utils/LongJsonConverter.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,22 @@ | ||
using System.Globalization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Sportradar.Mbs.Sdk.Internal.Utils; | ||
|
||
internal class LongJsonConverter : JsonConverter<long> | ||
{ | ||
public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var jsonVal = reader.GetString(); | ||
if (long.TryParse(jsonVal, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) return result; | ||
|
||
throw new JsonException("Unknown long: " + jsonVal); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options) | ||
{ | ||
var jsonVal = value.ToString(CultureInfo.InvariantCulture); | ||
writer.WriteStringValue(jsonVal); | ||
} | ||
} |
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