Beispiel #1
0
        /// <summary>
        /// Creates a new loan in Encompass with the optionally specified <paramref name="createLoanOptions"/> and returns the loan id of the loan created.
        /// </summary>
        /// <param name="loan">The loan to create.</param>
        /// <param name="createLoanOptions">The loan creation 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 <string> CreateLoanAsync(Loan loan, CreateLoanOptions createLoanOptions, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(loan, nameof(loan));
            Preconditions.NullOrEmpty(loan.EncompassId, $"{nameof(loan)}.{nameof(loan.EncompassId)}");

            var loanId = await PostPopulateDirtyAsync(null, createLoanOptions?.ToQueryParameters().ToString(), nameof(CreateLoanAsync), loan, createLoanOptions?.Populate == true, cancellationToken).ConfigureAwait(false);

            loan.Initialize(Client, loanId);
            return(loanId);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new loan in Encompass using loan data imported from a Fannie Mae 3.x loan file and returns the loan id of the loan created.
        /// </summary>
        /// <param name="importFileType">The format of the file being sent in the request body.</param>
        /// <param name="importFile">The Fannie Mae loan file to import.</param>
        /// <param name="createLoanOptions">The loan creation options.</param>
        /// <param name="loan">Returns a loan object if <paramref name="createLoanOptions"/>.Populate is <c>true</c>.</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> CreateLoanFromImportFileAsync(string importFileType, Stream importFile, CreateLoanOptions createLoanOptions, out Loan loan, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNullOrEmpty(importFileType, nameof(importFileType));
            Preconditions.NotNull(importFile, nameof(importFile));

            var populate = createLoanOptions?.Populate == true;

            loan = populate ? new Loan(Client) : null;
            var content = new StreamContent(importFile);

            content.Headers.ContentType = new MediaTypeHeaderValue(importFileType);
            return(CreateLoanFromImportFileInternalAsync(content, loan, populate, createLoanOptions, cancellationToken));
        }
Beispiel #3
0
        private async Task <string> CreateLoanFromImportFileInternalAsync(HttpContent content, Loan loan, bool populate, CreateLoanOptions createLoanOptions, CancellationToken cancellationToken)
        {
            var loanId = await PostPopulateDirtyAsync("importers/loan", createLoanOptions?.ToQueryParameters().ToString(), content, nameof(CreateLoanFromImportFileAsync), loan, populate, cancellationToken).ConfigureAwait(false);

            loan?.Initialize(Client, loanId);
            return(loanId);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new loan in Encompass using loan data imported from a Fannie Mae 3.x loan file and returns the loan id of the loan created.
        /// </summary>
        /// <param name="importFileType">The format of the file being sent in the request body.</param>
        /// <param name="importFile">The Fannie Mae loan file to import.</param>
        /// <param name="createLoanOptions">The loan creation 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 <string> CreateLoanFromImportFileAsync(string importFileType, Stream importFile, CreateLoanOptions createLoanOptions = null, CancellationToken cancellationToken = default)
        {
            if (createLoanOptions?.Populate == true)
            {
                throw new InvalidOperationException("Use other CreateLoanFromImportFileAsync overload to populate a loan object.");
            }

            return(CreateLoanFromImportFileAsync(importFileType, importFile, createLoanOptions, out _, cancellationToken));
        }