예제 #1
0
 /// <summary>
 /// Requests the specified request asynchronously
 /// </summary>
 /// <typeparam name="TResponse">The type of the response.</typeparam>
 /// <param name="request">The request.</param>
 public static Task <TResponse> RequestAsync <TResponse>(this IGenericWebClient client, object request)
     where TResponse : new()
 {
     return(client.RequestAsync <TResponse>(request, CancellationToken.None));
 }
예제 #2
0
        public async Task <string[]> AttachToTangle(string[] trytes,
                                                    string trunkTransaction, string branchTransaction, CancellationToken cancellationToken)
        {
            InputValidator.CheckIfArrayOfTrytes(trytes);

            AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(
                trunkTransaction, branchTransaction,
                trytes, MinWeightMagnitude);
            var response = await genericClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken);

            if (response == null)
            {
                throw new NullReferenceException(nameof(response));
            }

            return(response.Trytes);
        }
예제 #3
0
        public async Task <APIResult <string[]> > AttachToTangle(string[] trytes,
                                                                 string trunkTransaction, string branchTransaction, CancellationToken cancellationToken)
        {
            InputValidator.CheckIfArrayOfTrytes(trytes);

            AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(trunkTransaction, branchTransaction, trytes, MinWeightMagnitude);

            var response = await genericWebClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken);

            return(response?.RePackage(r => r.Trytes) ?? new APIResult <string[]>(null, "Null response from API"));
        }