Example #1
0
        private static async Task <ExportJobStatusContract> CreateExportJob(IApiSession session, string loanId, FileAttachmentReferenceContract[] attachments)
        {
            var exportJobsApi = session.GetApi <ExportJobsApi>();

            // Build the payload to fetch documents using eFolder export job api
            var exportJobInput = new ExportJobContract()
            {
                AnnotationSettings = new AnnotationSettingsContract()
                {
                    Visibility = new VisibilityType[] { VisibilityType.Internal, VisibilityType.Private, VisibilityType.Public }
                },
                Entities = attachments.Select(attachment => new EFolderEntityRef()
                {
                    EntityId   = attachment.EntityId,
                    EntityType = EFolderEntityType.Attachment
                }).ToArray(),
                Source = new EFolderEntityRef()
                {
                    EntityId   = loanId,
                    EntityType = EFolderEntityType.Loan
                }
            };

            return(await exportJobsApi.CreateExportJob(exportJobInput));
        }
Example #2
0
        private static Task <IDisposable> AcquireSharedLock(IApiSession session, string loanId)
        {
            var resourceLockApi      = session.GetApi <ResourceLocksApi>();
            var resourceLockApiInput = new ResourceLockContract()
            {
                LockType = ResourceLockType.NGSharedLock,
                Resource = new EncompassEntityRef()
                {
                    EntityId   = loanId,
                    EntityType = EncompassEntityType.Loan
                }
            };

            return(resourceLockApi.CreateResourceLock(resourceLockApiInput));
        }
Example #3
0
        private static Task <AttachmentUploadDataContract> CreateAttachmentUploadUrl(IApiSession session, string loanId, string fileName, long fileSizeInBytes, string contentType)
        {
            var attachmentsApi = session.GetApi <AttachmentsApi>();

            return(attachmentsApi.GenerateAttachmentUploadUrl(
                       loanId,
                       new AttachmentUploadInputContract()
            {
                File = new AttachmentUploadInputContract.FileData()
                {
                    ContentType = contentType,
                    Name = fileName,
                    Size = fileSizeInBytes
                },
                Title = fileName
            }));
        }
Example #4
0
        private static async Task <DocumentContract> CreateDocument(IApiSession session, string loanId)
        {
            var documentsApi = session.GetApi <DocumentsApi>();
            var documents    = await documentsApi.AddDocuments(
                loanId,
                new DocumentContract[]
            {
                new DocumentContract()
                {
                    Title       = "Purchase Advice",
                    Description = "Purchase Advice Documents"
                }
            },
                view : "entity");

            return(documents.FirstOrDefault());
        }
Example #5
0
        private static async Task <FileAttachmentReferenceContract[]> GetLatestDocumentAttachmentRefs(IApiSession session, string loanId)
        {
            var documentsApi = session.GetApi <DocumentsApi>();

            // Get documents on the loan
            var documents = await documentsApi.GetDocuments(loanId);

            // Get the attachments linked ot the last document - this is the document we just created.
            var attachments = documents.LastOrDefault()?.Attachments;

            if (attachments?.Any() != true)
            {
                // something went wrong - we should not have endedup here
                Environment.Exit(1);
            }

            return(attachments);
        }
Example #6
0
        private static async Task <string> QueryForLoan(IApiSession session, string loanNumber, string loanFolder)
        {
            var loanPipelineApi = session.GetApi <LoanPipelineApi>();
            var pipelineItems   = await loanPipelineApi.QueryLoanPipeline(new LoanPipelineQueryContract()
            {
                Fields = new List <string>()
                {
                    "LoanId"
                },
                Filter = new QueryCriterionContract()
                {
                    Operator = BinaryOperator.And,
                    Terms    = new QueryCriterionContract[]
                    {
                        new QueryCriterionContract()
                        {
                            CanonicalName = "Loan.LoanNumber",
                            Value         = loanNumber,
                            MatchType     = MatchType.Exact
                        },
                        new QueryCriterionContract()
                        {
                            CanonicalName = "Loan.LoanFolder",
                            Value         = loanFolder,
                            MatchType     = MatchType.Exact
                        }
                    }
                }
            });


            // Get the loanId from the pipeline items
            var loanId = pipelineItems.FirstOrDefault()?.LoanId;

            if (string.IsNullOrEmpty(loanId))
            {
                // Loan not found, exiting the program!!
                Environment.Exit(1);
            }

            return(loanId);
        }
Example #7
0
 private static async Task DownloadMergedAttachments(IApiSession session, ExportJobStatusContract jobStatus, string filePath)
 {
     var exportJobsApi = session.GetApi <ExportJobsApi>();
     await exportJobsApi.DownloadExportedFile(jobStatus, filePath);
 }
Example #8
0
        private static async Task <ExportJobStatusContract> PollExportStatus(IApiSession session, string jobId)
        {
            var exportJobsApi = session.GetApi <ExportJobsApi>();

            return(await exportJobsApi.PollExportStatus(jobId, 30000));
        }
Example #9
0
        private static Task AssignAttachmentsToDocument(IApiSession session, string loanId, string documentId, FileAttachmentReferenceContract[] attachmentIds)
        {
            var documentsApi = session.GetApi <DocumentsApi>();

            return(documentsApi.LinkAttachmentsToDocument(loanId, documentId, attachmentIds));
        }
Example #10
0
 private static async Task UploadAttachment(IApiSession session, AttachmentUploadDataContract attachmentUploadUrlData, FileInfo fileInfo, string contentType)
 {
     var attachmentsApi = session.GetApi <AttachmentsApi>();
     await attachmentsApi.UploadAttachment(attachmentUploadUrlData, fileInfo, contentType);
 }