-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
be325ef
commit 03e54c0
Showing
8 changed files
with
132 additions
and
6 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
14 changes: 14 additions & 0 deletions
14
IotaSDK.NET/Contexts/ClientContext/Queries/GetNode/GetNodeQuery.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,14 @@ | ||
using IotaSDK.NET.Common.Interfaces; | ||
using IotaSDK.NET.Common.Models; | ||
using IotaSDK.NET.Domain.Network; | ||
using System; | ||
|
||
namespace IotaSDK.NET.Contexts.ClientContext.Queries.GetNode | ||
{ | ||
internal class GetNodeQuery : ClientRequest<IotaSDKResponse<Node>> | ||
{ | ||
public GetNodeQuery(IntPtr clientHandle) : base(clientHandle) | ||
{ | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
IotaSDK.NET/Contexts/ClientContext/Queries/GetNode/GetNodeQueryHandler.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,32 @@ | ||
using IotaSDK.NET.Common.Exceptions; | ||
using IotaSDK.NET.Common.Models; | ||
using IotaSDK.NET.Common.Rust; | ||
using IotaSDK.NET.Domain.Network; | ||
using MediatR; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace IotaSDK.NET.Contexts.ClientContext.Queries.GetNode | ||
{ | ||
internal class GetNodeQueryHandler : IRequestHandler<GetNodeQuery, IotaSDKResponse<Node>> | ||
{ | ||
private readonly RustBridgeClient _rustBridgeClient; | ||
|
||
public GetNodeQueryHandler(RustBridgeClient rustBridgeClient) | ||
{ | ||
_rustBridgeClient = rustBridgeClient; | ||
} | ||
|
||
public async Task<IotaSDKResponse<Node>> Handle(GetNodeQuery request, CancellationToken cancellationToken) | ||
{ | ||
IotaSDKModel model = new IotaSDKModel("getNode"); | ||
var json = model.AsJson(); | ||
|
||
string? clientResponse = await _rustBridgeClient.CallClientMethodAsync(request.ClientHandle, json); | ||
|
||
IotaSDKException.CheckForException(clientResponse!); | ||
|
||
return IotaSDKResponse<Node>.CreateInstance(clientResponse); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
IotaSDK.NET/Contexts/ClientContext/Queries/GetNodeHealthStatus/GetNodeHealthStatusQuery.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,16 @@ | ||
using IotaSDK.NET.Common.Interfaces; | ||
using IotaSDK.NET.Common.Models; | ||
using System; | ||
|
||
namespace IotaSDK.NET.Contexts.ClientContext.Queries.GetNodeHealthStatus | ||
{ | ||
internal class GetNodeHealthStatusQuery : ClientRequest<IotaSDKResponse<bool>> | ||
{ | ||
public GetNodeHealthStatusQuery(IntPtr clientHandle, string url) : base(clientHandle) | ||
{ | ||
Url = url; | ||
} | ||
|
||
public string Url { get; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...NET/Contexts/ClientContext/Queries/GetNodeHealthStatus/GetNodeHealthStatusQueryHandler.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,32 @@ | ||
using IotaSDK.NET.Common.Exceptions; | ||
using IotaSDK.NET.Common.Models; | ||
using IotaSDK.NET.Common.Rust; | ||
using MediatR; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace IotaSDK.NET.Contexts.ClientContext.Queries.GetNodeHealthStatus | ||
{ | ||
internal class GetNodeHealthStatusQueryHandler : IRequestHandler<GetNodeHealthStatusQuery, IotaSDKResponse<bool>> | ||
{ | ||
private readonly RustBridgeClient _client; | ||
|
||
public GetNodeHealthStatusQueryHandler(RustBridgeClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
public async Task<IotaSDKResponse<bool>> Handle(GetNodeHealthStatusQuery request, CancellationToken cancellationToken) | ||
{ | ||
var modelData = new GetNodeHealthStatusQueryModelData(request.Url); | ||
var model = new IotaSDKModel<GetNodeHealthStatusQueryModelData>("getHealth", modelData); | ||
var json = model.AsJson(); | ||
|
||
string? clientResponse = await _client.CallClientMethodAsync(request.ClientHandle, json); | ||
|
||
IotaSDKException.CheckForException(clientResponse!); | ||
|
||
return IotaSDKResponse<bool>.CreateInstance(clientResponse); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...T/Contexts/ClientContext/Queries/GetNodeHealthStatus/GetNodeHealthStatusQueryModelData.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 IotaSDK.NET.Contexts.ClientContext.Queries.GetNodeHealthStatus | ||
{ | ||
internal class GetNodeHealthStatusQueryModelData | ||
{ | ||
public GetNodeHealthStatusQueryModelData(string url) | ||
{ | ||
Url = url; | ||
} | ||
|
||
public string Url { get; } | ||
} | ||
} |
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