protected Task <Tuple <JObject, Stream> > GetResource(string queue, string action, object requestBody)
        {
            var jResult  = _amqpService.RequestReply(requestBody, action, queue);
            var response = AmqpApiUtils.ParseApiResult(jResult);

            if (!response.ResponseObject?.ContainsKey("body") ?? true)
            {
                throw new AmqpApiException("Could not read ApiResponse: body not set!");
            }

            var obj = response.ResponseObject;

            var data = System.Convert.FromBase64String(response.ResponseObject["body"].ToObject <string>());

            obj["body"] = null;
            obj["size"] = data.LongLength;
            obj["etag"] = GenerateEtag(data);
            var ms = new MemoryStream(data);

            return(Task.FromResult(new Tuple <JObject, Stream>(obj, ms)));
        }
Beispiel #2
0
        public virtual Task <IEnumerable <TodoListHeader> > GetLists(string contextDomain)
        {
            var requestBody = new
            {
                context = new { },
                domain  = contextDomain
            };

            var jResult  = _amqpService.RequestReply(requestBody, "ToDoFind", RequestQueue);
            var response = AmqpApiUtils.ParseApiResult(jResult);

            if (!response.ResponseObject.ContainsKey("headers"))
            {
                throw new AmqpApiException("Could not read ApiResponse");
            }

            var todoListHeaders = response.ResponseObject["headers"].ToObject <TodoListHeader[]>().AsEnumerable();

            return(Task.FromResult(todoListHeaders));
        }