Skip to content

Commit

Permalink
Add max stake operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Srđan Tot authored and zb-sr committed Dec 4, 2024
1 parent 0c5b5ab commit d4e4b4c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override ContentRequestBase Read(ref Utf8JsonReader reader, Type typeToCo
"ext-settlement-ack" => JsonSerializer.Deserialize<ExtSettlementAckRequest>(root.GetRawText()),
"balance-change-inform" => JsonSerializer.Deserialize<BalanceChangeInformRequest>(root.GetRawText()),
"cashout-inform" => JsonSerializer.Deserialize<CashoutInformRequest>(root.GetRawText()),
"max-stake" => JsonSerializer.Deserialize<MaxStakeRequest>(root.GetRawText()),
_ => throw new JsonException("Unknown type of ContentRequestBase: " + type)
};
return result ?? throw new NullReferenceException("Null ContentRequestBase: " + type);
Expand Down
19 changes: 19 additions & 0 deletions src/Sportradar.Mbs.Sdk/Entities/Request/MaxStakeRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Text.Json.Serialization;

namespace Sportradar.Mbs.Sdk.Entities.Request;

/// <summary>
/// Represents a max stake request.
/// </summary>
public class MaxStakeRequest : ContentRequestBase
{
[JsonInclude]
[JsonPropertyName("type")]
private string Type => "max-stake";

/// <summary>
/// Gets or sets the ticket request.
/// </summary>
[JsonPropertyName("ticket")]
public TicketRequest? Ticket { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public override ContentResponseBase Read(ref Utf8JsonReader reader, Type typeToC
"ticket-reply" => JsonSerializer.Deserialize<TicketResponse>(root.GetRawText()),
"withdrawal-inform-reply" => JsonSerializer.Deserialize<WithdrawalInformResponse>(root.GetRawText()),
"cashout-inform-reply" => JsonSerializer.Deserialize<CashoutInformResponse>(root.GetRawText()),
"max-stake-reply" => JsonSerializer.Deserialize<MaxStakeResponse>(root.GetRawText()),
_ => throw new JsonException("Unknown type of ContentResponseBase: " + type)
};
return result ?? throw new NullReferenceException("Null ContentResponseBase: " + type);
Expand Down
32 changes: 32 additions & 0 deletions src/Sportradar.Mbs.Sdk/Entities/Response/MaxStakeResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Text.Json.Serialization;
using Sportradar.Mbs.Sdk.Entities.Common;

namespace Sportradar.Mbs.Sdk.Entities.Response;

/// <summary>
/// Represents the response received from max stake API.
/// </summary>
public class MaxStakeResponse : ContentResponseBase
{
[JsonInclude]
[JsonPropertyName("type")]
private string Type => "max-stake-reply";

/// <summary>
/// Gets or sets the code of the max stake response.
/// </summary>
[JsonPropertyName("code")]
public int Code { get; set; }

/// <summary>
/// Gets or sets the bets associated with the max stake response.
/// </summary>
[JsonPropertyName("bets")]
public Bet[]? Bets { get; set; }

/// <summary>
/// Gets or sets the message of the max stake response.
/// </summary>
[JsonPropertyName("message")]
public String? Message { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public async Task<ExtSettlementAckResponse> SendExtSettlementAckAsync(ExtSettlem
{
return await ProcessRequestAsync<ExtSettlementAckResponse>("ticket-ext-settlement-ack", request).ConfigureAwait(false);
}

public async Task<MaxStakeResponse> SendMaxStakeAsync(MaxStakeRequest request)
{
return await ProcessRequestAsync<MaxStakeResponse>("max-stake", request).ConfigureAwait(false);
}
}
8 changes: 8 additions & 0 deletions src/Sportradar.Mbs.Sdk/Protocol/ITicketProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@ public interface ITicketProtocol
/// <returns>A task that represents the asynchronous operation. The task result contains the external settlement acknowledgement response.</returns>
/// <exception cref="SdkException">Thrown when operation has failed.</exception>
Task<ExtSettlementAckResponse> SendExtSettlementAckAsync(ExtSettlementAckRequest request);

/// <summary>
/// Sends a max stake request asynchronously.
/// </summary>
/// <param name="request">The max stake request to send.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the max stake response.</returns>
/// <exception cref="SdkException">Thrown when operation has failed.</exception>
Task<MaxStakeResponse> SendMaxStakeAsync(MaxStakeRequest request);
}

0 comments on commit d4e4b4c

Please sign in to comment.