Example #1
0
        /// <summary>
        /// Posts a new <see cref="CommonConfirmationBlockMessage"/> containing information pertaining to a validator's block confirmation
        /// and returns a <see cref="ConfirmationBlockResponse"/>
        /// </summary>
        /// <param name="confirmationBlockMessage">Message containing the validator's confirmation block info</param>
        /// <returns></returns>
        public async Task <ConfirmationBlockResponse> PostConfiramtionBlockAsync(ConfirmationBlock confirmationBlockMessage)
        {
            var jsonConfirmationBlockMessage = JsonConvert.SerializeObject(confirmationBlockMessage);
            var httpContent = new StringContent(jsonConfirmationBlockMessage, Encoding.UTF8, "application/json");

            var response = await _requestSender.PostAsync("/confirmation_block", httpContent);

            if (!response.IsSuccessStatusCode)
            {
                // TODO: Add specific exceptions
                throw new Exception();
            }

            var stringResult = await response.Content.ReadAsStringAsync();

            if (string.IsNullOrEmpty(stringResult))
            {
                // TODO: Add specific exceptions
                throw new Exception();
            }

            var result = JsonConvert.DeserializeObject <ConfirmationBlockResponse>(stringResult);

            return(result);
        }
Example #2
0
        /// <summary>
        /// Provides a facility for a confirmation validator to post a new <see cref="ConfirmationBlock"/> to the
        /// receiving bank.
        /// </summary>
        /// <param name="confirmationBlock"></param>
        /// <returns><see cref="HttpResponseMessage"/></returns>
        public async Task <HttpResponseMessage> PostConfirmationBlockAsync(ConfirmationBlock confirmationBlock)
        {
            var httpContent = new StringContent(JsonConvert.SerializeObject(confirmationBlock), Encoding.UTF8, "application/json");
            var request     = await _requestSender.PostAsync("/confirmation_blocks", httpContent);

            if (!request.IsSuccessStatusCode)
            {
                // TODO: Create specific exception
                throw new Exception();
            }

            var response = new HttpResponseMessage(System.Net.HttpStatusCode.Created);

            return(response);
        }