예제 #1
0
        private Task UpdateContactAsync(TContact contact, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(contact, nameof(contact));
            Preconditions.NotNullOrEmpty(contact.Id, $"{nameof(contact)}.{nameof(contact.Id)}");

            contact.Initialize(Client, contact.Id);
            return(PatchPopulateDirtyAsync(contact.Id, JsonStreamContent.Create(contact), nameof(UpdateContactAsync), contact.Id, contact, populate, cancellationToken));
        }
예제 #2
0
        private Task UpdateNoteAsync(ContactNote note, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(note, nameof(note));
            Preconditions.NotNullOrEmpty(note.NoteId, $"{nameof(note)}.{nameof(note.NoteId)}");

            note.Dirty = true; // To be removed if Ellie Mae updates API to only update provided properties.
            return(PatchPopulateDirtyAsync(note.NoteId, JsonStreamContent.Create(note), nameof(UpdateNoteAsync), note.NoteId, note, populate, cancellationToken));
        }
예제 #3
0
        /// <summary>
        /// Updates properties for a specified file attachment and optionally populates the attachment object with the response's body through the use of the entity view query parameter.
        /// </summary>
        /// <param name="attachment">The attachment properties to update.</param>
        /// <param name="populate">Indicates if the attachment object should be populated with the response's body through the use of the entity view query parameter.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task UpdateAttachmentAsync(LoanAttachment attachment, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(attachment, nameof(attachment));
            Preconditions.NotNullOrEmpty(attachment.AttachmentId, $"{nameof(attachment)}{nameof(attachment.AttachmentId)}");

            attachment.Attachments = this;
            return(PatchPopulateDirtyAsync(attachment.AttachmentId, JsonStreamContent.Create(attachment), nameof(UpdateAttachmentAsync), attachment.AttachmentId, attachment, populate, cancellationToken));
        }
        /// <inheritdoc/>
        public Task AssignAssociateAsync(string logId, LoanAssociate associate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(logId, nameof(logId));
            Preconditions.NotNull(associate, nameof(associate));
            Preconditions.NotNullOrEmpty(associate.Id, $"{nameof(associate)}.{nameof(associate.Id)}");
            Preconditions.NotNullOrEmpty(associate.LoanAssociateType.Value, $"{nameof(associate)}.{nameof(associate.LoanAssociateType)}");

            return(PutAsync(logId, null, JsonStreamContent.Create(associate), nameof(AssignAssociateAsync), logId, cancellationToken));
        }
예제 #5
0
        private Task UpdateContactAsync(TContact contact, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(contact, nameof(contact));
            Preconditions.NotNullOrEmpty(contact.Id, $"{nameof(contact)}.{nameof(contact.Id)}");

            contact.Initialize(Client, contact.Id);
            contact.Dirty = true; // To be removed if Ellie Mae updates API to only update provided properties.
            return(PatchPopulateDirtyAsync(contact.Id, JsonStreamContent.Create(contact), nameof(UpdateContactAsync), contact.Id, contact, populate, cancellationToken));
        }
예제 #6
0
        /// <summary>
        /// Adds or removes contacts in a contact group.
        /// </summary>
        /// <param name="groupId">The unique identifier of the contact group to update.</param>
        /// <param name="action">Whether to add or remove the contact.</param>
        /// <param name="contacts">The contacts to add or remove.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task AssignGroupContactsAsync(string groupId, string action, IEnumerable <EntityReference> contacts, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(groupId, nameof(groupId));
            Preconditions.NotNullOrEmpty(action, nameof(action));
            Preconditions.NotNullOrEmpty(contacts, nameof(contacts));

            var queryParameters = new QueryParameters(new QueryParameter(nameof(action), action));

            return(PatchAsync($"{groupId}/contacts", queryParameters.ToString(), JsonStreamContent.Create(contacts), nameof(AssignGroupContactsAsync), groupId, cancellationToken));
        }
        /// <inheritdoc/>
        public Task <RateLockRequest> DenyRateLockRequestAsync(string requestId, RateLockCancelDenyOptions?denialOptions = null, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(requestId, nameof(requestId));

            denialOptions = denialOptions ?? new RateLockCancelDenyOptions();

            var queryParameters = new QueryParameters();

            queryParameters.Add("view", "entity");

            return(PutAsync($"{requestId}/denial", queryParameters.ToString(), JsonStreamContent.Create(denialOptions), nameof(DenyRateLockRequestAsync), requestId, cancellationToken, FuncCache <RateLockRequest> .ReadAsFunc));
        }
예제 #8
0
        /// <inheritdoc/>
        public Task UpdateMilestoneAsync(LoanMilestone milestone, string?action, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(milestone, nameof(milestone));
            Preconditions.NotNullOrEmpty(milestone.Id, $"{nameof(milestone)}.{nameof(milestone.Id)}");
            var queryParameters = new QueryParameters();

            if (!string.IsNullOrEmpty(action))
            {
                queryParameters.Add("action", action);
            }

            return(PatchAsync(milestone.Id, queryParameters.ToString(), JsonStreamContent.Create(milestone), nameof(UpdateMilestoneAsync), milestone.Id, cancellationToken));
        }
예제 #9
0
        /// <summary>
        /// Updates an existing loan by modifying the values of the loan data elements passed with the optionally specified <paramref name="updateLoanOptions"/>.
        /// </summary>
        /// <param name="loan">The loan to update.</param>
        /// <param name="updateLoanOptions">The loan update options.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public async Task UpdateLoanAsync(Loan loan, UpdateLoanOptions updateLoanOptions, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(loan, nameof(loan));
            Preconditions.NotNullOrEmpty(loan.EncompassId, $"{nameof(loan)}.{nameof(loan.EncompassId)}");

            loan.Initialize(Client, loan.EncompassId);
            HttpContent content;

            if (updateLoanOptions?.Persistent == false)
            {
                var body = loan.ToJson();
                content = new JsonStringContent(body);
            }
            else
            {
                var transientLoanUpdates = loan.TransientLoanUpdates;
                if (transientLoanUpdates?.Count > 0)
                {
                    foreach (var transientLoanUpdate in transientLoanUpdates)
                    {
                        await PatchAsync(loan.EncompassId, transientLoanUpdate.QueryString, new JsonStringContent(transientLoanUpdate.Body), nameof(UpdateLoanAsync), loan.EncompassId, cancellationToken).ConfigureAwait(false);
                    }
                    transientLoanUpdates.Clear();
                }
                content = JsonStreamContent.Create(loan);
            }
            await PatchAsync(loan.EncompassId, updateLoanOptions?.ToQueryParameters().ToString(), content, nameof(UpdateLoanAsync), loan.EncompassId, cancellationToken, async (HttpResponseMessage response) =>
            {
                if (updateLoanOptions?.Populate == true)
                {
                    await response.Content.PopulateAsync(loan).ConfigureAwait(false);
                }
                loan.Dirty = false;
                if (updateLoanOptions?.Persistent == false)
                {
                    var transientLoanUpdates = loan.TransientLoanUpdates;
                    if (transientLoanUpdates == null)
                    {
                        transientLoanUpdates      = new List <Loan.TransientLoanUpdate>();
                        loan.TransientLoanUpdates = transientLoanUpdates;
                    }
                    transientLoanUpdates.Add(new Loan.TransientLoanUpdate {
                        Body = ((JsonStringContent)content).Json, QueryString = updateLoanOptions.ToQueryParameters(true).ToString()
                    });
                }
                return(string.Empty);
            }).ConfigureAwait(false);
        }
예제 #10
0
        /// <summary>
        /// Retrieves the contact IDs and specified fields for the contacts specified.
        /// </summary>
        /// <param name="parameters">The contact list parameters used to specify the contacts and fields to include.</param>
        /// <param name="start">Starting index or record number from which to retrieve the contacts. The default is 1.</param>
        /// <param name="limit">The maximum number of records to return in a page. Response size is limited to 6 MB and is recalculated if the response exceeds 6 MB. The default value is 1000. The maximum value is limited to 10000.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task <List <ContactData> > GetContactListAsync(ContactListParameters parameters, int?start = null, int?limit = null, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(parameters, nameof(parameters));

            var queryParameters = new QueryParameters();

            if (start.HasValue)
            {
                queryParameters.Add("start", start.ToString());
            }
            if (limit.HasValue)
            {
                queryParameters.Add("limit", limit.ToString());
            }

            return(PostAsync <List <ContactData> >(null, queryParameters.ToString(), JsonStreamContent.Create(parameters), nameof(GetContactListAsync), null, cancellationToken));
        }
예제 #11
0
        /// <inheritdoc/>
        public Task <string> GetItemsRawAsync(int start, int?limit, IEnumerable <string>?fields, CancellationToken cancellationToken = default)
        {
            Preconditions.GreaterThanOrEquals(start, nameof(start), 0);
            Preconditions.LessThan(start, nameof(start), Count, nameof(Count));
            if (limit.HasValue)
            {
                Preconditions.GreaterThan(limit.GetValueOrDefault(), nameof(limit), 0);
            }

            var queryParameters = new QueryParameters(
                new QueryParameter("cursor", CursorId),
                new QueryParameter("start", start.ToString()));

            if (limit.HasValue)
            {
                queryParameters.Add("limit", limit.ToString());
            }
            var content = JsonStreamContent.Create(new { Fields = fields ?? Fields });

            return(_apiObject.PostRawAsync(null, queryParameters.ToString(), content, nameof(GetItemsRawAsync), null, cancellationToken));
        }
예제 #12
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="ignoreInvalidFields">Ignores the invalid fields specified in the request body if set to <c>true</c>, else will return an error with list of invalid fields.</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, bool?ignoreInvalidFields, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(parameters, nameof(parameters));

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

            if (ignoreInvalidFields.HasValue)
            {
                queryParameters.Add("ignoreInvalidFields", ignoreInvalidFields.ToString().ToLower());
            }

            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);
                }
                string?cursorId = null;
                if (count > 0)
                {
                    const string cursorIdHeaderName = "x-cursor";
                    if (!headers.TryGetValues(cursorIdHeaderName, out var cursorIds))
                    {
                        throw await EncompassRestException.CreateAsync($"{nameof(CreateCursorAsync)} missing {cursorIdHeaderName} header", response).ConfigureAwait(false);
                    }
                    cursorId = cursorIds.First();
                }
                return new LoanPipelineCursor(Client, cursorId, count, parameters.Fields);
            }));
        }
예제 #13
0
 /// <summary>
 /// Sends an HTTP POST request to the specified <paramref name="uri"/> with the specified json serializable <paramref name="content"/> and returns the response body as a <typeparamref name="TResponse"/>.
 /// </summary>
 /// <typeparam name="TResponse">The response type.</typeparam>
 /// <param name="uri">The request uri including any query parameters.</param>
 /// <param name="content">The json serializable content to send.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns></returns>
 public Task <TResponse> PostAsync <TResponse>(string uri, object content, CancellationToken cancellationToken = default) => PostAsync <TResponse>(uri, null, JsonStreamContent.Create(content), nameof(PostAsync), null, cancellationToken);
예제 #14
0
        public Task AssignDocumentAttachmentsAsync(string documentId, AssignmentAction action, IEnumerable <EntityReference> attachmentEntities, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(documentId, nameof(documentId));
            action.Validate(nameof(action));
            Preconditions.NotNullOrEmpty(attachmentEntities, nameof(attachmentEntities));

            var queryParameters = new QueryParameters(new QueryParameter(nameof(action), action.AsString(EnumJsonConverter.CamelCaseNameFormat)));

            return(PatchAsync($"{documentId}/attachments", queryParameters.ToString(), JsonStreamContent.Create(attachmentEntities), nameof(AssignDocumentAttachmentsAsync), documentId, cancellationToken));
        }
예제 #15
0
 internal Task <string> PostPopulateDirtyAsync <T>(string?requestUri, string?queryString, string methodName, T value, bool populate, CancellationToken cancellationToken) where T : class, IDirty, IIdentifiable => SendFullUriPopulateDirtyAsync(HttpMethod.Post, GetFullUri(requestUri), queryString, JsonStreamContent.Create(value), methodName, value, populate, cancellationToken);
예제 #16
0
        /// <summary>
        /// Retrieve values for specific fields in a loan.
        /// </summary>
        /// <param name="includeMetadata">If set to true, the response will include the metadata for the fields specified, and returns details such as format, description, type, options and readOnly indicator.Default behavior is false, in which case, only the fieldId and value are returned for the fields in the request body.</param>
        /// <param name="fieldIds">Field IDs of the values you want to retrieve from the loan.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task <List <LoanFieldValue> > GetLoanFieldValuesAsync(bool?includeMetadata, IEnumerable <string> fieldIds, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(fieldIds, nameof(fieldIds));

            QueryParameters?queryParameters = null;

            if (includeMetadata.HasValue)
            {
                queryParameters = new QueryParameters();
                queryParameters.Add("includeMetadata", includeMetadata.ToString().ToLower());
            }

            return(PostAsync <List <LoanFieldValue> >(null, queryParameters?.ToString(), JsonStreamContent.Create(fieldIds), nameof(GetLoanFieldValuesAsync), null, cancellationToken));
        }
예제 #17
0
        private Task <Dictionary <string, string> > GeneratePathsAsync(IEnumerable <string> fieldIds, string fieldNamePattern, bool?ignoreInvalidFields, CancellationToken cancellationToken)
        {
            var queryParameters = new QueryParameters();

            if (ignoreInvalidFields.HasValue)
            {
                queryParameters.Add("ignoreInvalidFields", ignoreInvalidFields.ToString().ToLower());
            }
            if (!string.IsNullOrEmpty(fieldNamePattern))
            {
                queryParameters.Add("fieldNamePattern", fieldNamePattern);
            }

            return(PostAsync <Dictionary <string, string> >("pathGenerator", queryParameters.ToString(), JsonStreamContent.Create(fieldIds ?? new string[0]), nameof(GeneratePathsAsync), null, cancellationToken));
        }
        /// <inheritdoc/>
        public Task <string> SubmitRateLockRequestRawAsync(string lockRequest, string?queryString = null, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(lockRequest, nameof(lockRequest));

            return(PostRawAsync(null, queryString, JsonStreamContent.Create(lockRequest), nameof(SubmitRateLockRequestRawAsync), null, cancellationToken));
        }
예제 #19
0
        /// <summary>
        /// Swaps the position of borrower pairs in the loan. Note that the <see cref="Borrower.AltId"/> of the borrower and co-borrower do not change on the applications.
        /// </summary>
        /// <param name="applications">The applications to swap.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public async Task MoveBorrowerPairsAsync(IList <Application> applications, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(applications, nameof(applications));
            Preconditions.NotAnyNull(applications, nameof(applications));

            await PatchAsync(null, null, JsonStreamContent.Create(applications), nameof(MoveBorrowerPairsAsync), null, cancellationToken).ConfigureAwait(false);

            if (LoanObjectBoundApis?.ReflectToLoanObject == true)
            {
                var bps       = LoanObjectBoundApis.Loan.Applications;
                var borrowers = new Dictionary <string, Tuple <int, Borrower> >(StringComparer.OrdinalIgnoreCase);
                foreach (var bp in bps)
                {
                    var borrower = bp.Borrower;
                    var altId    = borrower.AltId;
                    if (!string.IsNullOrEmpty(altId))
                    {
                        borrowers.Add(altId !, Tuple.Create(0, borrower));
                    }
                    borrower = bp.Coborrower;
                    altId    = borrower.AltId;
                    if (!string.IsNullOrEmpty(altId))
                    {
                        borrowers.Add(altId !, Tuple.Create(1, borrower));
                    }
                }
                var altIds = bps.Select(bp => new[] { bp.Borrower.AltId, bp.Coborrower.AltId }).ToList();
                foreach (var application in applications)
                {
                    var id    = application.Id;
                    var found = false;
                    for (var i = 0; i < bps.Count; ++i)
                    {
                        var bp = bps[i];
                        if (string.Equals(id, bp.Id, StringComparison.OrdinalIgnoreCase))
                        {
                            var index = application.ApplicationIndex;
                            if (index.HasValue)
                            {
                                bp.ApplicationIndex = index;
                            }
                            var altId = application.Borrower.AltId;
                            if (string.IsNullOrEmpty(altId))
                            {
                                bp.Borrower = null;
                            }
                            else
                            {
                                if (borrowers.TryGetValue(altId !, out var tuple))
                                {
                                    bp.Borrower       = tuple.Item2;
                                    bp.Borrower.AltId = altIds[i][tuple.Item1];
                                }
                                else
                                {
                                    break;
                                }
                            }
                            altId = application.Coborrower.AltId;
                            if (string.IsNullOrEmpty(altId))
                            {
                                bp.Coborrower = null;
                            }
                            else
                            {
                                if (borrowers.TryGetValue(altId !, out var tuple))
                                {
                                    bp.Coborrower       = tuple.Item2;
                                    bp.Coborrower.AltId = altIds[i][tuple.Item1];
                                }
                                else
                                {
                                    break;
                                }
                            }
예제 #20
0
        /// <summary>
        /// Retrieve values for specific fields in a loan.
        /// </summary>
        /// <param name="fieldIds">Field IDs of the values you want to retrieve from the loan.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task <List <LoanFieldValue> > GetLoanFieldValuesAsync(IEnumerable <string> fieldIds, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(fieldIds, nameof(fieldIds));

            return(PostAsync <List <LoanFieldValue> >(null, null, JsonStreamContent.Create(fieldIds), nameof(GetLoanFieldValuesAsync), null, cancellationToken));
        }
예제 #21
0
        /// <summary>
        /// Submits a batch request to the server to update multiple loans and returns the batch update request id.
        /// </summary>
        /// <param name="parameters">The batch update parameters.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task <string> UpdateLoansAsync(BatchUpdateParameters parameters, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(parameters, nameof(parameters));

            return(PostAsync(null, null, JsonStreamContent.Create(parameters), nameof(UpdateLoansAsync), null, cancellationToken, ReadLocationFunc));
        }
예제 #22
0
        /// <inheritdoc/>
        public async Task <string> UploadAttachmentAsync(LoanAttachment attachment, Stream attachmentData, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(attachmentData, nameof(attachmentData));

            attachment.Initialize(this);
            var mediaUrlObject = await GetUploadAttachmentUrlInternalAsync(populate?ViewEntityQueryString : null, JsonStreamContent.Create(attachment), nameof(GetUploadAttachmentUrlAsync), cancellationToken, FuncCache <MediaUrlObject> .ReadAsFunc).ConfigureAwait(false);

            return(await SendFullUriPopulateDirtyAsync(HttpMethod.Put, mediaUrlObject.MediaUrl, null, new StreamContent(attachmentData), nameof(UploadAttachmentAsync), attachment, populate, cancellationToken).ConfigureAwait(false));
        }
        /// <inheritdoc/>
        public Task <string> DenyRateLockRequestRawAsync(string requestId, string denialOptions, string?queryString = null, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(requestId, nameof(requestId));

            return(PutRawAsync($"{requestId}/denial", queryString, JsonStreamContent.Create(denialOptions), nameof(DenyRateLockRequestRawAsync), requestId, cancellationToken));
        }
예제 #24
0
 /// <summary>
 /// Sends an HTTP PUT request to the specified <paramref name="uri"/> with the specified json serializable <paramref name="content"/>.
 /// </summary>
 /// <param name="uri">The request uri including any query parameters.</param>
 /// <param name="content">The json serializable content to send.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns></returns>
 public Task PutAsync(string uri, object content, CancellationToken cancellationToken = default) => PutAsync(uri, null, JsonStreamContent.Create(content), nameof(PutAsync), null, cancellationToken);
예제 #25
0
        /// <summary>
        /// Sends an HTTP PUT request to the specified <paramref name="uri"/> with the specified json serializable <paramref name="content"/> and returns the response body as a <typeparamref name="TResponse"/>.
        /// </summary>
        /// <typeparam name="TResponse">The anonymous type to return. This can't be specified traditionally and must be inferred from the anonymous type passed as a parameter.</typeparam>
        /// <param name="uri">The request uri including any query parameters.</param>
        /// <param name="content">The json serializable content to send.</param>
        /// <param name="anonymousTypeObject">The anonymous type object.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
#pragma warning disable IDE0060 // Remove unused parameter
        public Task <TResponse> PutAnonymousTypeAsync <TResponse>(string uri, object content, TResponse anonymousTypeObject, CancellationToken cancellationToken = default) => PutAsync(uri, null, JsonStreamContent.Create(content), nameof(PutAnonymousTypeAsync), null, cancellationToken, FuncCache <TResponse> .ReadAsFunc);
예제 #26
0
        /// <summary>
        /// Generates the loan contract from the specified <paramref name="fieldValues"/>.
        /// </summary>
        /// <param name="fieldValues">The field values to generate the loan contract.</param>
        /// <param name="ignoreInvalidFields">Indicates whether to ignore invalid loan fields if specified in the request.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public async Task <Loan> GenerateContractAsync(IDictionary <string, object> fieldValues, bool?ignoreInvalidFields, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(fieldValues, nameof(fieldValues));

            var queryParameters = new QueryParameters();

            if (ignoreInvalidFields.HasValue)
            {
                queryParameters.Add("ignoreInvalidFields", ignoreInvalidFields.ToString().ToLower());
            }

            var loan = await PostAsync <Loan>("contractGenerator", queryParameters.ToString(), JsonStreamContent.Create(fieldValues), nameof(GenerateContractAsync), null, cancellationToken).ConfigureAwait(false);

            loan.Client = Client;
            return(loan);
        }
예제 #27
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));
        }
        /// <inheritdoc/>
        public Task ConfirmRateLockRequestAsync(RateLockRequest lockRequest, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(lockRequest.Id, nameof(lockRequest.Id));

            return(PutPopulateDirtyAsync($"{lockRequest.Id}/confirmation", JsonStreamContent.Create(lockRequest), nameof(ConfirmRateLockRequestAsync), lockRequest.Id, lockRequest, populate, cancellationToken));
        }
예제 #29
0
        /// <summary>
        /// Updates an existing loan by modifying the values of the loan data elements passed with the optionally specified <paramref name="updateLoanOptions"/>.
        /// </summary>
        /// <param name="loan">The loan to update.</param>
        /// <param name="updateLoanOptions">The loan update options.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns></returns>
        public Task UpdateLoanAsync(Loan loan, UpdateLoanOptions updateLoanOptions, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(loan, nameof(loan));
            Preconditions.NotNullOrEmpty(loan.EncompassId, $"{nameof(loan)}.{nameof(loan.EncompassId)}");

            loan.Initialize(Client, loan.EncompassId);
            return(PatchPopulateDirtyAsync(loan.EncompassId, updateLoanOptions?.ToQueryParameters().ToString(), JsonStreamContent.Create(loan), nameof(UpdateLoanAsync), loan.EncompassId, loan, updateLoanOptions?.Populate == true, cancellationToken));
        }
예제 #30
0
        private Task UpdateSubscriptionAsync(WebhookSubscription subscription, bool populate, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(subscription, nameof(subscription));
            Preconditions.NotNullOrEmpty(subscription.SubscriptionId, $"{nameof(subscription)}.{nameof(subscription.SubscriptionId)}");

            return(PutPopulateDirtyAsync($"subscriptions/{subscription.SubscriptionId}", JsonStreamContent.Create(subscription), nameof(UpdateSubscriptionAsync), subscription.SubscriptionId, subscription, populate, cancellationToken));
        }