Skip to content

Commit

Permalink
IT-1948: added cashout inform operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jure Marko authored and zb-sr committed Nov 20, 2024
1 parent 29953ea commit 29c9a76
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/Sportradar.Mbs.Sdk/Entities/Common/CashoutInformValidation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;

namespace Sportradar.Mbs.Sdk.Entities.Common;

/// <summary>
/// Represents validation object.
/// </summary>
public class CashoutInformValidation
{
/// <summary>
/// Gets or sets the code.
/// </summary>
[JsonPropertyName("code")]
public int? Code { get; set; }

/// <summary>
/// Gets or sets the message.
/// </summary>
[JsonPropertyName("message")]
public string? Message { get; set; }
}
27 changes: 27 additions & 0 deletions src/Sportradar.Mbs.Sdk/Entities/Request/CashoutInformRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;
using Sportradar.Mbs.Sdk.Entities.Common;

namespace Sportradar.Mbs.Sdk.Entities.Request;

/// <summary>
/// Represents a request to acknowledge a cashout inform.
/// </summary>
public class CashoutInformRequest : ContentRequestBase
{
[JsonInclude]
[JsonPropertyName("type")]
private string Type => "cashout-inform";

/// <summary>
/// Gets or sets the cashout object.
/// </summary>
[JsonPropertyName("cashout")]
public CashoutRequest? Cashout { get; set; }

/// <summary>
/// Gets or sets the cashout inform validation object.
/// </summary>
[JsonPropertyName("validation")]
public CashoutInformValidation? Validation{ get; set; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public override ContentRequestBase Read(ref Utf8JsonReader reader, Type typeToCo
"withdrawal-inform" => JsonSerializer.Deserialize<WithdrawalInformRequest>(root.GetRawText()),
"ext-settlement-ack" => JsonSerializer.Deserialize<ExtSettlementAckRequest>(root.GetRawText()),
"balance-change-inform" => JsonSerializer.Deserialize<BalanceChangeInformRequest>(root.GetRawText()),
"cashout-inform" => JsonSerializer.Deserialize<CashoutInformRequest>(root.GetRawText()),
_ => throw new JsonException("Unknown type of ContentRequestBase: " + type)
};
return result ?? throw new NullReferenceException("Null ContentRequestBase: " + type);
Expand Down
50 changes: 50 additions & 0 deletions src/Sportradar.Mbs.Sdk/Entities/Response/CashoutInformResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Text.Json.Serialization;
using Sportradar.Mbs.Sdk.Entities.Common;

namespace Sportradar.Mbs.Sdk.Entities.Response;

/// <summary>
/// Represents a response object for a cashout inform.
/// </summary>
public class CashoutInformResponse : ContentResponseBase
{
[JsonInclude]
[JsonPropertyName("type")]
private string Type => "cashout-inform-reply";

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

/// <summary>
/// Gets or sets the signature of the cashout inform response.
/// </summary>
[JsonPropertyName("signature")]
public string? Signature { get; set; }

/// <summary>
/// Gets or sets the cashout ID of the cashout inform response.
/// </summary>
[JsonPropertyName("cashoutId")]
public string? CashoutId { get; set; }

/// <summary>
/// Gets or sets the message of the cashout inform response.
/// </summary>
[JsonPropertyName("message")]
public string? Message { get; set; }

/// <summary>
/// Gets or sets the ticket ID of the cashout inform response.
/// </summary>
[JsonPropertyName("ticketId")]
public string? TicketId { get; set; }

/// <summary>
/// Gets or sets the status of the cashout inform response.
/// </summary>
[JsonPropertyName("status")]
public AcceptanceStatus? Status { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override ContentResponseBase Read(ref Utf8JsonReader reader, Type typeToC
"cashout-ack-reply" => JsonSerializer.Deserialize<CashoutAckResponse>(root.GetRawText()),
"ticket-reply" => JsonSerializer.Deserialize<TicketResponse>(root.GetRawText()),
"withdrawal-inform-reply" => JsonSerializer.Deserialize<WithdrawalInformResponse>(root.GetRawText()),
"cashout-inform-reply" => JsonSerializer.Deserialize<CashoutInformResponse>(root.GetRawText()),
_ => throw new JsonException("Unknown type of ContentResponseBase: " + type)
};
return result ?? throw new NullReferenceException("Null ContentResponseBase: " + type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<CancelResponse> SendCancelAsync(CancelRequest request)
{
return await ProcessRequestAsync<CancelResponse>("ticket-cancel", request).ConfigureAwait(false);
}

public async Task<CancelAckResponse> SendCancelAckAsync(CancelAckRequest request)
{
return await ProcessRequestAsync<CancelAckResponse>("ticket-cancel-ack", request).ConfigureAwait(false);
Expand All @@ -37,6 +37,11 @@ public async Task<CashoutResponse> SendCashoutAsync(CashoutRequest request)
{
return await ProcessRequestAsync<CashoutResponse>("ticket-cashout", request).ConfigureAwait(false);
}

public async Task<CashoutInformResponse> SendCashoutInformAsync(CashoutInformRequest request)
{
return await ProcessRequestAsync<CashoutInformResponse>("cashout-inform", request).ConfigureAwait(false);
}

public async Task<CashoutAckResponse> SendCashoutAckAsync(CashoutAckRequest request)
{
Expand Down
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 @@ -48,6 +48,14 @@ public interface ITicketProtocol
/// <exception cref="SdkException">Thrown when operation has failed.</exception>
Task<CancelAckResponse> SendCancelAckAsync(CancelAckRequest request);

/// <summary>
/// Sends a cashout inform request asynchronously.
/// </summary>
/// <param name="request">The cashout inform request to send.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the cashout inform response.</returns>
/// <exception cref="SdkException">Thrown when operation has failed.</exception>
Task<CashoutInformResponse> SendCashoutInformAsync(CashoutInformRequest request);

/// <summary>
/// Sends a cashout request asynchronously.
/// </summary>
Expand Down

0 comments on commit 29c9a76

Please sign in to comment.