UNPKG

encompassconnect

Version:

An Unofficial, (mostly) typed Node SDK that wraps around Ellie Mae's Encompass RESTful API.

39 lines (38 loc) 1.64 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable max-len */ const service_1 = __importDefault(require("./service")); class SchemaService extends service_1.default { /** * Takes in a value representing key value pairs of field IDs and new values and returns the correct contract shape to perform an update on a loan. * * ```typescript * const borrowerUpdateData = { * '4000': 'new first name', * '4002': 'new last name', * }; * * // returns the contract: * const updateContract = await encompass.schemas.generateContract(borrowerUpdateData); * // this value can now be used to update a loan: * await encompass.loans.update(updateContract); * ``` */ async generateContract(fields) { const contract = await this.context.fetchWithRetry('/schema/loan/contractGenerator', { method: 'POST', body: JSON.stringify(fields) }); return contract; } /** * Calls the loan schema endpoint and returns the schema. Can be filtered down by providing an optional array of entity names. */ async getLoanSchema(entities) { const entitiesString = entities ? entities.toString() : ''; const url = `/schema/loan${entitiesString ? `?entities=${entitiesString}` : ''}`; const response = await this.context.fetchWithRetry(url); return response; } } exports.default = SchemaService;