Skip to content

Commit ed01fc8

Browse files
committed
Balance protocol
1 parent aeb7fca commit ed01fc8

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

src/Sportradar.Mbs.Sdk/Internal/Connection/TokenProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal async Task<string> GetAuthTokenAsync(CancellationToken cancellationToke
5353
{
5454
Exception? possibleExc = null;
5555
string? token = null;
56-
for (var i = 0; i < 10 && token == null; i++)
56+
for (var i = 0; i < 3 && token == null; i++)
5757
try
5858
{
5959
token = GetToken() ?? await FetchTokenAsync(cancellationToken).ConfigureAwait(false);
@@ -149,15 +149,15 @@ internal async Task<string> GetAuthTokenAsync(CancellationToken cancellationToke
149149

150150
var msg = new StringBuilder();
151151
msg.Append("Auth error");
152-
if (!string.IsNullOrEmpty(authResponse.Error))
152+
if (!string.IsNullOrEmpty(authResponse.Error))
153153
{
154154
msg.Append(": ").Append(authResponse.Error.NotNull());
155155
}
156156
if (!string.IsNullOrEmpty(authResponse.ErrorDescription))
157157
{
158158
msg.Append(": ").Append(authResponse.ErrorDescription.NotNull());
159159
}
160-
160+
161161
throw new AuthTokenFailureException(msg.ToString());
162162
}
163163

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Sportradar.Mbs.Sdk.Entities.Request;
2+
using Sportradar.Mbs.Sdk.Entities.Response;
3+
using Sportradar.Mbs.Sdk.Protocol;
4+
5+
namespace Sportradar.Mbs.Sdk.Internal.Protocol;
6+
7+
internal partial class ProtocolProvider : IBalanceProtocol
8+
{
9+
internal IBalanceProtocol BalanceProtocol => this;
10+
11+
/// <summary>
12+
/// Sends a deposit inform request.
13+
/// </summary>
14+
/// <param name="request">The deposit request to send.</param>
15+
/// <returns>The response indicating the status of the deposit notification.</returns>
16+
public async Task<DepositInformResponse> SendDepositInformAsync(DepositInformRequest request)
17+
{
18+
return await ProcessRequestAsync<DepositInformResponse>(
19+
"balance-deposit-inform", request).ConfigureAwait(false);
20+
}
21+
22+
/// <summary>
23+
/// Sends a withdrawal inform request.
24+
/// </summary>
25+
/// <param name="request">The withdrawal request to send.</param>
26+
/// <returns>The response indicating the status of the withdrawal notification.</returns>
27+
public async Task<WithdrawalInformResponse> SendWithdrawalInformAsync(WithdrawalInformRequest request)
28+
{
29+
return await ProcessRequestAsync<WithdrawalInformResponse>(
30+
"balance-withdrawal-inform", request).ConfigureAwait(false);
31+
}
32+
}

src/Sportradar.Mbs.Sdk/MbsSdk.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public MbsSdk(MbsSdkConfig config)
3838
/// </summary>
3939
public IAccountProtocol AccountProtocol => _protocolProvider.AccountProtocol;
4040

41+
/// <summary>
42+
/// Gets the balance protocol.
43+
/// </summary>
44+
public IBalanceProtocol BalanceProtocol => _protocolProvider.BalanceProtocol;
45+
4146
/// <summary>
4247
/// Disposes the SDK and releases all resources.
4348
/// </summary>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Sportradar.Mbs.Sdk.Entities.Request;
2+
using Sportradar.Mbs.Sdk.Entities.Response;
3+
4+
namespace Sportradar.Mbs.Sdk.Protocol;
5+
6+
/// <summary>
7+
/// Defines the contract for handling balance-related protocol operations.
8+
/// </summary>
9+
public interface IBalanceProtocol
10+
{
11+
/// <summary>
12+
/// Sends a deposit inform request.
13+
/// </summary>
14+
/// <param name="request">The deposit request to send.</param>
15+
/// <returns>The response indicating the status of the deposit notification.</returns>
16+
Task<DepositInformResponse> SendDepositInformAsync(DepositInformRequest request);
17+
18+
/// <summary>
19+
/// Sends a withdrawal inform request.
20+
/// </summary>
21+
/// <param name="request">The withdrawal request to send.</param>
22+
/// <returns>The response indicating the status of the withdrawal notification.</returns>
23+
Task<WithdrawalInformResponse> SendWithdrawalInformAsync(WithdrawalInformRequest request);
24+
}

0 commit comments

Comments
 (0)