/// <summary> /// Example: Update Loan. For Example will be updating Loan Amount /// </summary> private static void UpdateLoan() { if (_accessToken == null) { Authenticate(); } //Initializing the API Client*/ var loanApiClient = ApiClientProvider.GetApiClient <LoansApi>(_accessToken); //Creating new loan contract for update. We are updating the loan amount. var correctVal = false; double loanAmt = 0; Console.Write("Enter Loan Amount: "); while (!correctVal) { correctVal = double.TryParse(Console.ReadLine(), out loanAmt); if (!correctVal) { Console.Write("Please enter a valid number: "); } } var loan = new LoanContract { BorrowerRequestedLoanAmount = loanAmt }; var response = loanApiClient.UpdateLoan(LoanId, null, null, null, loan, "entity"); JsonSerializerSettings serializerSettings = new JsonSerializerSettings { ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor }; LoanContract updatedLoan = JsonConvert.DeserializeObject <LoanContract>(response.ToString(), serializerSettings); }
/// <summary> /// Example: Loan Bulk Update: Updating lender's contact information. /// </summary> private static void BatchUpdate() { Console.WriteLine("Enter Loan GUIDs to update. [Comma Separated and no spaces]"); var loanGuids = Console.ReadLine()?.Split(',').ToList(); var loanBatchApiClient = ApiClientProvider.GetApiClient <LoanBatchApi>(_accessToken); var request = new LoanBatchUpdateRequestContract { LoanData = new LoanContract { Contacts = new List <LoanContractContacts> { new LoanContractContacts { ContactType = "BROKER_LENDER", Address = "123 Main St.", City = "Pleasanton", State = "CA", PostalCode = "94588" } } }, LoanGuids = loanGuids }; loanBatchApiClient.BatchUpdateRequests(request); Console.WriteLine("Request Submitted"); }
/// <summary> /// Example: Ordering a service. Example of ordring credit from Credco. /// </summary> private static void OrderService() { if (_accessToken == null) { Authenticate(); } var serviceApiClient = ApiClientProvider.GetApiClient <ServiceApi>(_accessToken); Console.Write("Enter Credco User Name : "); var userName = Console.ReadLine(); Console.Write("Enter Credco Password : "******"Enter Borrower Id : "); var borrowerId = Console.ReadLine(); //Ordering credit from credco var request = new OrderServiceRequest { Product = new Product { Credentials = new ProductCredentials { UserName = userName, Password = password }, EntityRef = new ProductEntityRef { EntityId = $"{LoanId}#{borrowerId}", EntityType = "urn:elli:encompass:loan:borrower" }, Name = "CREDITIQ", Options = new ProductOptions { DigiCert = true, CreditBureauEquifax = true, CreditBureauExperian = true, CreditBureauTransUnion = true, CreditReportIdentifier = "", Note = "", ReportOn = "Joint", ReportType = "Merge", RequestType = "NewOrder" }, Preferences = new ProductPreferences { ExcludeZeroforImportLiabilities = true, ImportLiabilities = true } } }; //Partner ID for credco is 307378 var resp = serviceApiClient.OrderServiceWithHttpInfo(307378, request); //Example Getting ID from location header _transactionId = resp.Headers["Location"].Split('/')[6]; Console.WriteLine($"Transaction ID: {_transactionId}"); }
/// <summary> /// Example: Assign associate to a milestone /// </summary> private static void AssignLoanAssociate() { if (_accessToken == null) { Authenticate(); } string loanId = LoanId; Console.Write("Enter Milestone Id : "); string milestoneId = Console.ReadLine(); Console.Write("Enter Loan Associate Id : "); string associateId = Console.ReadLine(); Console.Write("Enter Associate Type : "); string associateType = Console.ReadLine(); //Initializing the API Client LoanAssociatesApi loanAssociateApiClient = ApiClientProvider.GetApiClient <LoanAssociatesApi>(_accessToken); //Initializing the contract LoanTeamMemberContract loanAssociate = new LoanTeamMemberContract { Id = associateId, LoanAssociateType = associateType }; //Calling AssignLoanTeamMember loanAssociateApiClient.AssignLoanTeamMember(milestoneId, LoanId, loanAssociate); Console.WriteLine(""); Console.WriteLine("Associate assigned"); }
/// <summary> /// Example: Create Attachment /// Create attachment is a 2 step process /// 1. Get URL where the document should be put /// 2. Upload actual file /// </summary> private static void CreateAttachment() { if (_accessToken == null) { Authenticate(); } //Step 1: Get the url for document to be uploaded var attachmentsApiClient = ApiClientProvider.GetApiClient <AttachmentsApi>(_accessToken); Console.WriteLine("Step 1: Creating Attachment Metadata"); Console.Write("Please enter File Name with Extension: "); var fileName = Console.ReadLine(); var request = new EFolderMediaUrlContract { FileWithExtension = fileName, CreateReason = 1, Title = fileName, DocumentRefId = DocumentId }; //We need to provide id parameter in order to get the attachment id at the end of second call. var response = attachmentsApiClient.UploadAttachment(LoanId, "id", request); var urlToUpload = response.MediaUrl; Console.WriteLine("Attachment Metadata Created Successfully"); Console.WriteLine("----------------------------------------"); Console.WriteLine("Step 2: Uploading File for attachment"); bool fileReadAttemptFailed; string path; byte[] content = { }; //Reading the file path and making sure the file exists and readable do { fileReadAttemptFailed = false; Console.WriteLine("Please enter the file path to upload the attachment: "); path = Console.ReadLine() + ""; path = path.Replace("..", ""); //Fix for Path Traversal security threat try { content = File.ReadAllBytes(path); } catch { fileReadAttemptFailed = true; } } while (fileReadAttemptFailed); //Step 2: Upload the file //we are using rest client from rest sharp here to use the URL var client = new RestClient(urlToUpload); var attachRequest = new RestRequest(Method.PUT); //TODO: Remove this header in next release attachRequest.AddHeader("cache-control", "no-cache"); attachRequest.AddParameter("undefined", content, ParameterType.RequestBody); var putResponse = client.Execute(attachRequest); //Code to handle the response from file put goes here. For now we are just printing the row response Console.WriteLine(putResponse.Content); }
/// <summary> /// Example: Loan Cursor pagination /// </summary> private static void Paginate() { var loanPipelineApiClient = ApiClientProvider.GetApiClient <LoanPipelineApi>(_accessToken); //Making sure we received more than one page in the response if (_count > 100) { var paginationRequest = new LoanPipelineViewContract { Fields = new List <string> { "Loan.GUID", "Loan.LastModified" } }; var start = 0; var page = 1; for (var i = 0; i < 10; i++) { //We do not need headers anymore, hence, calling regular method, And will be paginating 10 loans at a time var resp = loanPipelineApiClient.PipelineRequest("10", null, _cursor, start.ToString(), paginationRequest); Console.WriteLine("Page {0} Loan IDs: ", page); foreach (var loanInfo in resp) { var fieldinfo = ((JObject)loanInfo.Fields).ToDictionary <string>(); Console.WriteLine("Loan ID: {0}", loanInfo.LoanGuid); Console.WriteLine("Loan Last Modified: {0}", fieldinfo["Loan.LastModified"]); } start += 10; page++; } } }
/// <summary> /// Example: Get a specific Underwriting condition for a loan /// </summary> private static void GetUnderwritingConditions() { int count = 1; if (_accessToken == null) { Authenticate(); } var conditionsApiClient = ApiClientProvider.GetApiClient <ConditionsApi>(_accessToken); var response = conditionsApiClient.GetEFolderUnderwritingConditions(LoanId); Console.WriteLine("Total count of conditions - {0}", response.Count); foreach (var condition in response) { //Printing only first five records if (count > 5) { break; } Console.WriteLine("Condition {0} - ", count); Console.WriteLine("Id - {0}", condition.Id); Console.WriteLine("ConditionType - {0}", condition.ConditionType); Console.WriteLine("Title - {0}", condition.Title); Console.WriteLine("Description - {0}", condition.Description); Console.WriteLine("Status - {0}", condition.Status); Console.WriteLine(); count++; } }
/// <summary> /// Example: Update Loan. For Example will be updating Loan Amount /// </summary> private static void UpdateLoan() { if (_accessToken == null) { Authenticate(); } //Initializing the API Client*/ var loanApiClient = ApiClientProvider.GetApiClient <LoansApi>(_accessToken); //Creating new loan contract for update. We are updating the loan amount. var correctVal = false; double loanAmt = 0; Console.Write("Enter Loan Amount: "); while (!correctVal) { correctVal = double.TryParse(Console.ReadLine(), out loanAmt); if (!correctVal) { Console.Write("Please enter a valid number: "); } } var loan = new LoanContract { BorrowerRequestedLoanAmount = loanAmt }; loanApiClient.UpdateLoan(LoanId, null, null, null, loan); }
/// <summary> /// Example: Obtaining a lock and getting lock information /// </summary> private static void LoanLock() { if (_accessToken == null) { Authenticate(); } ResourceLocksApi lockApiClient = ApiClientProvider.GetApiClient <ResourceLocksApi>(_accessToken); Console.Write("Enter the LoanId: "); var loanId = Console.ReadLine(); //This contract will get us lock on a loan and this will be a forced lock. var request = new ResourceLockContract { Resource = new ResourceLockContractResource { EntityType = "loan", EntityId = loanId }, LockType = "shared" }; var createResponse = lockApiClient.CreateResourceLockWithHttpInfo("false", "id", request); //Example of pasrsing the URL _lockId = createResponse.Headers["Location"].Split('/')[3]; var getResponse = lockApiClient.GetResourceLockByLockId(_lockId, "loan", loanId); Console.WriteLine("Lock ID: {0}", getResponse.Id); }
/// <summary> /// Example: Creating a document /// </summary> private static void CreateDocument() { if (_accessToken == null) { Authenticate(); } Console.Write("Enter Doc Title : "); var title = Console.ReadLine(); var docsApiClient = ApiClientProvider.GetApiClient <DocumentsApi>(_accessToken); var request = new EFolderDocumentContract { Title = title, Description = "Description of the document", RequestedFrom = "User", ApplicationId = "All", EmnSignature = "Signature", DateRequested = DateTime.Now.AddDays(-5), DateExpected = DateTime.Now.AddDays(5), DateReceived = DateTime.Now.AddDays(-1), DateReviewed = DateTime.Now, DateReadyForUw = DateTime.Now.AddDays(-2), DateReadyToShip = DateTime.Now.AddDays(-2), Comments = new List <EFolderDocumentContractComments>() }; var response = docsApiClient.CreateDocumentWithHttpInfo(LoanId, "id", request); var loc = response.Headers["Location"]; DocumentId = loc.Split('/')[5]; Console.WriteLine("This document can be accessed at: {0}", loc); Console.WriteLine($"Document Reference Id is: {loc.Split('/')[5]}"); }
/// <summary> /// Example: Creating a cursor to generate a pipeline view /// </summary> private static void CreateCursor() { var cursorRequest = new LoanPipelineViewContract { Filter = new LoanPipelineFilterContract { Terms = new List <LoanPipelineFilterContractTerms>() { new LoanPipelineFilterContractTerms { CanonicalName = "Loan.LoanFolder", Value = "(Trash)", MatchType = "exact", Include = false }, new LoanPipelineFilterContractTerms { CanonicalName = "Loan.LastModified", Value = "02/25/2011", MatchType = "greaterThanOrEquals", Precision = "day" }, //Rate Lock # Days new LoanPipelineFilterContractTerms { CanonicalName = "Fields.432", Value = "2", MatchType = "greaterThanOrEquals" }, new LoanPipelineFilterContractTerms { CanonicalName = "Loan.CreditScore", Value = "0", MatchType = "notEquals" } }, _Operator = "and" }, Fields = new List <string> { "Loan.GUID", "Loan.LastModified" }, SortOrder = new List <LoanPipelineViewContractSortOrder> { new LoanPipelineViewContractSortOrder { CanonicalName = "Loan.LastModified", Order = "desc" } } }; var loanPipelineApiClient = ApiClientProvider.GetApiClient <LoanPipelineApi>(_accessToken); //We will need to read headers and hence calling method with http info var resp = loanPipelineApiClient.PipelineRequestWithHttpInfo("100", "randomAccess", null, "0", cursorRequest); //Reading the cursor ID from headers _cursor = resp.Headers["x-cursor"]; _count = Convert.ToInt32(resp.Headers["x-total-count"]); }
/// <summary> /// Example: Unlock Loan /// </summary> private static void DeleteLock() { if (_accessToken == null) { Authenticate(); } ResourceLocksApi lockApiClient = ApiClientProvider.GetApiClient <ResourceLocksApi>(_accessToken); lockApiClient.Unlock(_lockId, "loan", LoanId, "true"); }
/// <summary> /// Initialize field mapping json paths. /// </summary> /// <param name="accessToken">Access token.</param> public static void InitializeFieldMapping(AccessToken accessToken) { if (_missingJsonPathsDict == null || _missingJsonPathsDict.Count == 0) { _missingJsonPathsDict = new Dictionary <string, string>(); var clientProvider = ApiClientProvider.GetApiClient <PathGeneratorApi>(accessToken); var contract = new PathGeneratorContract(); _missingJsonPathsDict = clientProvider.GetWebhookNotificationPath(contract); } }
/// <summary> /// Example: Checking the status of service we just ordered /// </summary> private static void CheckServiceStatus() { if (_accessToken == null) { Authenticate(); } var serviceApiClient = ApiClientProvider.GetApiClient <ServiceApi>(_accessToken); var response = serviceApiClient.GetOrderStatus(307378, _transactionId); Console.WriteLine($"The Transaction Status is: {response?.Status}"); }
/// <summary> /// Example: Get specific CDO /// </summary> private static void GetListOfCDOs() { Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); var response = cdoApiClient.GetLoanCustomDataObjects(loanId); //Code for handling the response response.ForEach(i => Console.WriteLine("{0}\t", i)); Console.WriteLine(); Console.WriteLine("Retrived list of CDOs"); }
/// <summary> /// Example: Update CDO /// </summary> private static void DeleteCDO() { Console.Write("Enter CDO Name: "); var cdoName = Console.ReadLine(); Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); cdoApiClient.DeleteLoanCustomDataObject(loanId, cdoName); Console.WriteLine("CDO Deleted"); }
/// <summary> /// Example: Delete Loan. /// </summary> private static void DeleteLoan() { if (_accessToken == null) { Authenticate(); } //Initializing the API Client*/ var loanApiClient = ApiClientProvider.GetApiClient <LoansApi>(_accessToken); //Calling Delete loan loanApiClient.DeleteLoan(LoanId); Console.WriteLine("Loan Deleted"); }
private static void GetUsers() { if (_accessToken == null) { Authenticate(); } Console.Write("Enter Role(Enter if don't wish to filter on role): "); string role = Console.ReadLine(); if (string.IsNullOrEmpty(role)) { role = null; } Console.Write("Enter start: "); var start = Console.ReadLine(); if (string.IsNullOrEmpty(start)) { start = null; } Console.Write("Enter limit: "); var limit = Console.ReadLine(); if (string.IsNullOrEmpty(limit)) { limit = null; } var usersApiClient = ApiClientProvider.GetApiClient <UsersApi>(_accessToken); var response = usersApiClient.GetUserProfilesWithHttpInfo(null, null, role, null, null, null, null, start, limit); var totalUsersCount = Convert.ToInt32(response.Headers["X-Total-Count"]); var responseCount = response.Data.Count; var counter = responseCount < 10 ? responseCount : 10; for (int i = 0; i < counter; i++) { Console.WriteLine(i + 1 + ") "); Console.WriteLine("\t UserId: " + response.Data[i].Id); Console.WriteLine("\t UserName: "******"Total number of users in response: " + responseCount); Console.WriteLine("Total number of users: " + totalUsersCount); }
/// <summary> /// Example: Get specific CDO /// </summary> private static void GetCDO() { Console.Write("Enter CDO Name: "); var cdoName = Console.ReadLine(); Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); var response = cdoApiClient.GetLoanCustomDataObject(loanId, cdoName); //Code for handling the response // Console.WriteLine(response.Name); Console.WriteLine(); Console.WriteLine(response?.ToJson()); Console.WriteLine(); Console.WriteLine("CDO retrieved successfully."); }
/// <summary> /// Example: Move a loan accross folders /// </summary> private static void MoveLoan() { var loanFoldersApiClient = ApiClientProvider.GetApiClient <LoanFoldersApi>(_accessToken); Console.WriteLine("Enter Loan Id : "); var loanId = Console.ReadLine(); Console.WriteLine("Enter Folder Name : "); var folderName = Console.ReadLine(); var loanFolderContract = new LoanFolderContract { LoanGuid = loanId, IsExternalOrganization = true }; loanFoldersApiClient.MoveLoanFolder(folderName, "add", loanFolderContract); }
/// <summary> /// Example: Retrieve Loan /// </summary> private static void GetLoan() { if (_accessToken == null) { Authenticate(); } //Initializing the API Client*/ var loanApiClient = ApiClientProvider.GetApiClient <LoansApi>(_accessToken); //Example: retriving the loan var loan = loanApiClient.GetLoan(LoanId); //Printing the response with couple of fields Console.WriteLine("Loan Number : {0}", loan.LoanNumber); Console.WriteLine("Borrower First Name: {0}", loan.Applications[0].Borrower.FirstName); }
public async Task Import(string source) { var client = await ApiClientProvider.CreateApiClient(); var identifierDefinitions = client.GetIdentityStoreMetadata(); Log.Debug("Available Identifiers Are {@identifiers}", identifierDefinitions); var evidenceDefinitions = client.GetConsentStoreMetadata(); Log.Debug("Available Evidences Are {@evidences}", evidenceDefinitions); var xmlParser = new XmlParser(identifierDefinitions, evidenceDefinitions); using (LogContext.PushProperty("PeopleSource", source)) using (var xmlReader = XmlReader.Create(source)) { foreach (var person in xmlParser.GetPeople(xmlReader)) { Log.Verbose("Processing {@person}", person); var api = await ApiClientProvider.CreateApiClient(); var personId = api.PutPerson(person.PersonSpecification); //TODO: handle null personId - why would this happen? Log.Debug("Person Id is {@personId}", personId); using (LogContext.PushProperty("PersonId", personId.PersonId)) { if (!person.ConsentSpecifications.Any()) { Log.Debug("No consents provided"); continue; } foreach (var consent in person.ConsentSpecifications) { using (LogContext.PushProperty("StudyId", consent.StudyId)) { RecordConsent(api, consent, personId.PersonId); } } } } } }
/// <summary> /// Example: Creating a cursor to generate a pipeline view /// This example gets top 100 loans based on last modified in its descending order. /// </summary> private static void AccessPipeline() { if (_accessToken == null) { Authenticate(); } var loanPipelineApiClient = ApiClientProvider.GetApiClient <LoanPipelineApi>(_accessToken); var cursorRequest = new LoanPipelineViewContract { Filter = new LoanPipelineFilterContract { Terms = new List <LoanPipelineFilterContractTerms>() { new LoanPipelineFilterContractTerms { CanonicalName = "Loan.LoanFolder", Value = "My Pipeline", MatchType = "exact" } } }, Fields = new List <string> { "Loan.GUID", "Loan.LastModified" }, SortOrder = new List <LoanPipelineViewContractSortOrder> { new LoanPipelineViewContractSortOrder { CanonicalName = "Loan.LastModified", Order = "desc" } } }; var loans = loanPipelineApiClient.PipelineRequest("100", "randomAccess", null, "0", cursorRequest, "true"); Console.WriteLine("Total Loans: {0}", loans.Count); foreach (var loanInfo in loans) { //Since swagger does not support Dictionary directly, we need to cast manually here. var fieldinfo = ((JObject)loanInfo.Fields).ToDictionary <string>(); Console.WriteLine("{0} | {1}", loanInfo.LoanGuid, fieldinfo["Loan.LastModified"]); } }
/// <summary> /// Example: Finish a loan milestone /// </summary> private static void CompleteMilestone() { if (_accessToken == null) { Authenticate(); } string loanId = LoanId; Console.Write("Enter Milestone Id : "); string milestoneId = Console.ReadLine(); //Initializing the API Client MilestonesApi milestoneApiClient = ApiClientProvider.GetApiClient <MilestonesApi>(_accessToken); //Calling UpdateMilestone operation which completes the milestone when action is passed as finish milestoneApiClient.UpdateMilestone(milestoneId, LoanId, action: "finish", milestoneLogContract: new MilestoneContract()); }
/// <summary> /// Example: Unassign a loan associate /// </summary> private static void UnassignLoanAssociate() { if (_accessToken == null) { Authenticate(); } string loanId = LoanId; Console.Write("Enter Milestone Id : "); string milestoneId = Console.ReadLine(); //Initializing the API Client LoanAssociatesApi loanAssociateApiClient = ApiClientProvider.GetApiClient <LoanAssociatesApi>(_accessToken); //Calling UnassignLoanAssociate loanAssociateApiClient.UnassignLoanTeamMember(milestoneId, loanId); }
/// <summary> /// Example: Create Custom Data Object(CDO) /// </summary> private static void CreateCDO() { Console.Write("Enter CDO Name : "); var cdoName = Console.ReadLine(); Console.Write("Enter File Path : "); var filePath = Console.ReadLine() ?? ""; Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); var request = new LoanCustomDataObjectContract { Name = cdoName, DataObject = File.ReadAllBytes(filePath) }; var response = cdoApiClient.CreateLoanCustomDataObject(loanId, cdoName, request); }
/// <summary> /// Example: Update CDO /// </summary> private static void UpdateCDO() { Console.Write("Enter CDO Name: "); var cdoName = Console.ReadLine(); Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); //Demonstrating to update value with plain string as well var request = new LoanCustomDataObjectContract { Name = cdoName, DataObject = Encoding.ASCII.GetBytes("This is a test value [Updated].") }; var response = cdoApiClient.AppendLoanCustomDataObject(loanId, cdoName, request); //Code for handling the response Console.WriteLine(response.Name); }
/// <summary> /// Example: Append CDO /// </summary> private static void AppendCDO() { Console.Write("Enter CDO Name: "); var cdoName = Console.ReadLine(); Console.Write("Enter Loan Id : "); var loanId = Console.ReadLine(); var cdoApiClient = ApiClientProvider.GetApiClient <LoanCustomDataObjectsApi>(_accessToken); var request = new LoanCustomDataObjectContract { Name = cdoName, DataObject = Encoding.ASCII.GetBytes("This is a test value [appended].") }; var response = cdoApiClient.AppendLoanCustomDataObject(loanId, cdoName, request); //Code for handling the response Console.WriteLine(response?.ToJson()); Console.WriteLine("CDO Appended."); }
/// <summary> /// Example: Get Loan Milestones /// </summary> private static void GetLoanMilestones() { if (_accessToken == null) { Authenticate(); } //Initializing the API Client MilestonesApi milestoneApiClient = ApiClientProvider.GetApiClient <MilestonesApi>(_accessToken); //Retrieving loan milestones var milestones = milestoneApiClient.GetMilestones(LoanId); for (int i = 0; i < milestones.Count; i++) { //Printing the response with couple of fields Console.WriteLine("{0})Milestone Id : {1}", (i + 1).ToString("00"), milestones[i].Id); Console.WriteLine(" Milestone Name : {0}", milestones[i].MilestoneName); Console.WriteLine(" Start Date : {0}", milestones[i].StartDate); } }