Exemple #1
0
        /// <inheritdoc/>
        public async Task <HttpResponse <TResponse> > PutAsync <TResponse>(HttpRequest request, RequestContext requestContext, CancellationToken cancellationToken)
            where TResponse : BaseResource, new()
        {
            PrepareRequest(request, requestContext);

            var body = _serializer.Serialize(request.Payload);

            var response = await _requestExecutor.PutAsync(request.Uri, request.Headers, body, cancellationToken).ConfigureAwait(false);

            EnsureResponseSuccess(response);

            var data     = _serializer.Deserialize(PayloadOrEmpty(response));
            var resource = _resourceFactory.CreateNew <TResponse>(data);

            return(CreateResourceResponse(response, resource));
        }
Exemple #2
0
        /// <inheritdoc/>
        public async Task <HttpResponse <IEnumerable <T> > > GetArrayAsync <T>(HttpRequest request, RequestContext requestContext, CancellationToken cancellationToken)
            where T : IResource
        {
            PrepareRequest(request, requestContext);

            var response = await _requestExecutor.GetAsync(request.Uri, request.Headers, cancellationToken).ConfigureAwait(false);

            EnsureResponseSuccess(response);

            var resources = _serializer
                            .DeserializeArray(PayloadOrEmpty(response))
                            .Select(x => _resourceFactory.CreateNew <T>(x));

            return(CreateResourceResponse(response, resources));
        }