Ejemplo n.º 1
0
        public Task <LoanPipelineCursor> CreateCursorAsync(PipelineParameters parameters, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(parameters, nameof(parameters));

            var queryParameters = new QueryParameters(
                new QueryParameter("limit", "1"),
                new QueryParameter("cursorType", "randomAccess"));

            return(PostAsync(null, queryParameters.ToString(), JsonStreamContent.Create(parameters), nameof(CreateCursorAsync), null, cancellationToken, async response =>
            {
                var headers = response.Headers;
                const string countHeaderName = "x-total-count";
                if (!headers.TryGetValues(countHeaderName, out var counts))
                {
                    throw await EncompassRestException.CreateAsync($"{nameof(CreateCursorAsync)} missing {countHeaderName} header", response).ConfigureAwait(false);
                }
                var countString = counts.First();
                if (!int.TryParse(countString, out var count) || count < 0)
                {
                    throw await EncompassRestException.CreateAsync($"{nameof(CreateCursorAsync)} invalid {countHeaderName} header value", response).ConfigureAwait(false);
                }
                if (count == 0)
                {
                    return null;
                }
                const string cursorIdHeaderName = "x-cursor";
                if (!headers.TryGetValues(cursorIdHeaderName, out var cursorIds))
                {
                    throw await EncompassRestException.CreateAsync($"{nameof(CreateCursorAsync)} missing {cursorIdHeaderName} header", response).ConfigureAwait(false);
                }
                var cursorId = cursorIds.First();
                return new LoanPipelineCursor(Client, cursorId, count, parameters.Fields);
            }));
        }
Ejemplo n.º 2
0
        public Task <List <LoanPipelineData> > ViewPipelineAsync(PipelineParameters parameters, int?limit, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(parameters, nameof(parameters));
            if (limit.HasValue)
            {
                Preconditions.GreaterThan(limit.GetValueOrDefault(), nameof(limit), 0);
            }

            var queryParameters = new QueryParameters();

            if (limit.HasValue)
            {
                queryParameters.Add(new QueryParameter("limit", limit.GetValueOrDefault().ToString()));
            }

            return(PostAsync <List <LoanPipelineData> >(null, queryParameters.ToString(), JsonStreamContent.Create(parameters), nameof(ViewPipelineAsync), null, cancellationToken));
        }
Ejemplo n.º 3
0
 public Task <List <LoanPipelineData> > ViewPipelineAsync(PipelineParameters parameters, CancellationToken cancellationToken = default) => ViewPipelineAsync(parameters, null, cancellationToken);
Ejemplo n.º 4
0
 /// <inheritdoc/>
 public Task <List <LoanPipelineData> > ViewPipelineAsync(PipelineParameters parameters, bool?ignoreInvalidFields, CancellationToken cancellationToken = default) => ViewPipelineAsync(parameters, null, ignoreInvalidFields, cancellationToken);
Ejemplo n.º 5
0
 async Task <ILoanPipelineCursor> IPipeline.CreateCursorAsync(PipelineParameters parameters, bool?ignoreInvalidFields, CancellationToken cancellationToken) => await CreateCursorAsync(parameters, ignoreInvalidFields, cancellationToken).ConfigureAwait(false);
Ejemplo n.º 6
0
 Task <ILoanPipelineCursor> IPipeline.CreateCursorAsync(PipelineParameters parameters, CancellationToken cancellationToken) => ((IPipeline)this).CreateCursorAsync(parameters, null, cancellationToken);
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a cursor to paginate large data sets.
 /// </summary>
 /// <param name="parameters">The pipeline parameters used to specify the loans and fields to include.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns></returns>
 public Task <LoanPipelineCursor> CreateCursorAsync(PipelineParameters parameters, CancellationToken cancellationToken = default) => CreateCursorAsync(parameters, null, cancellationToken);