Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • EncompassConnect

Index

Constructors

constructor

  • new EncompassConnect(__namedParameters: { APIsecret: string; clientId: string; instanceId: string; password: undefined | string; username: undefined | string; version: number }): EncompassConnect
  • Parameters

    • __namedParameters: { APIsecret: string; clientId: string; instanceId: string; password: undefined | string; username: undefined | string; version: number }
      • APIsecret: string
      • clientId: string
      • instanceId: string
      • password: undefined | string
      • username: undefined | string
      • version: number

    Returns EncompassConnect

Properties

Private #APIsecret

#APIsecret: string

The API key of the Encompass instance to connect to.

Private #clientId

#clientId: string

The client ID of the Encompass instance to connect to.

Private #instanceId

#instanceId: string

The Encompass instance ID of the instance to connect to.

Private #password

#password: string

The password of the account to retrieve tokens with. Only stores the value provided to the constructor.

Private #token

#token: string | null

The bearer token that is used to authenticate each request to the Encompas API. The same token will be reused until either a 401 is returned, or the value is overwritten with the setToken() or getToken() methods.

base

base: string

The domain of the Encompass API.

username

username: string

The username of the account to retrieve tokens with. Only stores the value provided to the constructor.

version

version: number

The version of the Encompass API to send requests to. Defaults to 1.

Methods

batchLoanUpdate

  • The batch update API allows your to apply the same loan data to multiple loans and can be invoked with batchLoanUpdate() method.

    This method returns an object that with it's own functionality to check the status of batch update, or to get the request ID if needed.

    Just like viewing a pipeline, either a filter or an array of lan GUIDs can be provided.

    const updateData: BatchLoanUpdateContract = {
      loanGuids: [
        // array of loan GUIDs to update
      ],
      loanData: {
        // contract of the loan data to apply to each loan
      },
    };
    
    const exampleBatchUpdate: BatchUpdate = await encompass.batchLoanUpdate(updateData);
    
    // the return value can be used to check the status:
    const latestStatus: BatchUpdateStatus = await exampleBatchUpdate.getUpdateStatus();
    console.log(latestStatus.status) // 'done' or 'error'
    
    // or if needed you can get the request ID itself:
    const exampleBatchUpdateId: string = exampleBatchUpdate.getRequestId();

    Parameters

    Returns Promise<BatchUpdate>

getCanonicalNames

  • getCanonicalNames(): Promise<any>
  • Returns the result of the 'Get Canonical Names' endpoint.

    Returns Promise<any>

getToken

  • getToken(username?: undefined | string, password?: undefined | string): Promise<void>
  • Exchanges the provided username and password for a bearer token and stores it to the #token property of the instance. If no username and password are provided, it will fallback to the username and password values provided to the constructor.

    Parameters

    • Optional username: undefined | string
    • Optional password: undefined | string

    Returns Promise<void>

introspectToken

  • Calls the token introspection API with the provided token. If a token is not provided, it will introspect the token stored to the #token property of the instance as a fallback. If the introspection returns a valid token, it will return the response body of the request, if the token is invalid, returns null.

    Parameters

    • Optional token: undefined | string

    Returns Promise<TokenIntrospection | null>

request

  • request(url: string, options: RequestInit): Promise<Response>
  • If an API is not available through an explicit method in this class, the request() method is a wrapper around fetch that allows you to request any Encompass API endpoint.

    It takes in the same arguments as any fetch API, with the exception that the first argument is appended as a path to the Encompass API domain.

    // hitting the Get Custom Fields API:
    const customFieldsResponse: Response = await encompass.request('/settings/loan/customFields');
    const data = await customFieldsResponse.json();
    console.log(data);
    
    // or update a contact:
    const options: RequestInit = {
      method: 'POST',
      body: {
        firstname: 'contact first name',
        lastname: 'contact last name',
      },
    };
    await encompass.request('/businessContacts/<some-contact-id>', options);

    Parameters

    • url: string
    • options: RequestInit

    Returns Promise<Response>

setToken

  • setToken(token: string | null): void
  • Replaces the #token property with the provided token value. The instance can be implicitly 'logged out' by setting this value to null (if it was not provided a username and password in the constructor).

    Parameters

    • token: string | null

    Returns void

viewPipeline

  • viewPipeline(options: PipeLineContract, limit?: undefined | number): Promise<any>
  • Generate a pipeline view by calling the viewPipeline() method. This method has one required argument, a PipeLineContract, and can optionally take a limit value as the second argument:

    // a pipelineContract expects either a loanGuids array, or a filter object:
    const commonFilterValues = {
      sortOrder: [
        {
          canonicalName: 'Loan.LastModified',
          order: 'desc'
        }
      ],
      fields: [
        "Loan.LoanAmount",
        "Fields.4002"
      ],
    };
    
    const pipelineWithGuids: LoanGuidsPipeLineContract = {
      ...commonFilterValues,
      loanGuids: [
        'some-loan-guid-1',
        'some-loan-guid-2',
      ],
    };
    
    const pipelineWithFilter: FilterPipeLineContract = {
      ...commonFilterValues,
      filter: {
        operator: 'and',
        terms: [
          {
            canonicalName: "Loan.LastModified",
            matchType: "greaterThanOrEquals",
            value: new Date()
          },
          {
            canonicalName: "Loan.LoanFolder",
            matchType: "exact",
            value: "My Pipeline"
          }
        ]
      },
    };
    
    const pipelineDataFromGuids = await encompass.viewPipeline(pipelineWithGuids);
    
    // or with the other contract, and a limit of the first 50 results:
    const pipelineDataFromFilter = await encompass.viewPipeline(pipelineWithFilter, 50);

    Parameters

    Returns Promise<any>

Object literals

loans

loans: object

A collection of methods to use when working with loans. In general, these are wrappers around the 'Loan Management' API endpoints.

delete

  • delete(guid: string): Promise<void>
  • Deletes the loan that matches the provided GUID.

    Parameters

    • guid: string

    Returns Promise<void>

get

  • get(guid: string, entities?: string[]): Promise<any>
  • Retrieves the loan data of the provided loan GUID. Can optionally be filtered by providing an array of entities.

    Parameters

    • guid: string
    • Optional entities: string[]

    Returns Promise<any>

getGuidByLoanNumber

  • getGuidByLoanNumber(loanNumber: string): Promise<string>
  • Takes in a loan number (Loan.LoanNumber) and returns the matching loan's GUID. If no matching loan is found, returns null.

    Parameters

    • loanNumber: string

    Returns Promise<string>

update

  • Updates a loan object. Expects the data to already be formatted into the correct contract shape.

    const updateData: any = {
      applications: [
        borrower: {
          lastName: 'new borrower last name',
        },
      ],
      contacts: [
        {
          contactType: 'LOAN_OFFICER',
          name: 'new loan officer name',
        },
      ],
      customFields: [
        {
          fieldName: 'CX.SOME.CUSTOM.FIELD',
          stringValue: 'new value',
        },
      ],
    };
    
    // using the default options:
    await encompass.loans.update('some-loan-guid', updateData);
    
    // providing options:
    const options: LoanUpdateOptions = {
      appendData: true,
      persistent: 'transient',
      view: 'entity',
    };
    
    await encompass.loans.update('some-loan-guid', updateData, options);

    Parameters

    Returns Promise<void>

updateWithGeneratedContract

  • If the contract is not known, one can be generated before updating. The update data is expected as key value pairs (the key being the field ID), and all standard Encompass values are placed in the standardFields key, while all custom fields are placed in the customFields key.

    const updateData: UpdateLoanWithGenerateContract = {
      standardFields: {
        '4000': 'new borrower last name',
        '317': 'new loan officer name',
      },
      customFields: {
        'CX.SOME.CUSTOM.FIELD': 'new value',
      },
    };
    
    await encompass.loans.updateWithGeneratedContract('some-loan-guild', updateData);

    The updateWithGeneratedContract() method can also take the third LoanUpdateOptions as well. Keep in mind this method requires an extra call to generate the contract, and loans.update() should be used instead when possible.

    Parameters

    Returns Promise<void>

milestones

milestones: object

A collection of methods when working with milestones and associates.

assign

  • assign(__namedParameters: { loanGuid: string; milestone: string; userId: string }): Promise<void>
  • Assigns a loan associate to a milestone. The associate ID provided must be of a user who fits the persona group for that milestone.

     const guidToUpdate: string = 'some-loan-guid';
     const assignUnderwriterOptions: AssignMilestoneOptions = {
       loanGuid: guidToUpdate,
       milestone: 'Underwriting',
       userId: 'UnderwritersId',
     };
    
     await encompass.milestones.assign(assignUnderwriterOptions);

    Parameters

    • __namedParameters: { loanGuid: string; milestone: string; userId: string }
      • loanGuid: string
      • milestone: string
      • userId: string

    Returns Promise<void>

get

  • get(guid: string): Promise<any[]>
  • Returns the response of the Get All Milestone endpoints for the provided GUID.

    Parameters

    • guid: string

    Returns Promise<any[]>

update

  • update(__namedParameters: { action: undefined | "finish" | "unfinish"; loanGuid: string; milestone: string; options: any }): Promise<void>
  • Updates the matching milestone for the loan guid provided. The options key will be added to the body of the call, and the optional action key can be used to finish or unfinish a milestone.

    const updateProcessingOptions: UpdateMilestoneOptions = {
      loanGuid: guidToUpdate,
      milestone: 'Processing',
      options: {
        comments: 'this milestone is complete!',
      }
      action: 'finish',
    };
    
    await encompass.milestones.update(updateProcessingOptions);

    Parameters

    • __namedParameters: { action: undefined | "finish" | "unfinish"; loanGuid: string; milestone: string; options: any }
      • action: undefined | "finish" | "unfinish"
      • loanGuid: string
      • milestone: string
      • options: any

    Returns Promise<void>

schemas

schemas: object

A collection of methods that assist with schema operations.

generateContract

  • generateContract(fields: any): Promise<any>
  • 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.

     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);

    Parameters

    • fields: any

    Returns Promise<any>

getLoanSchema

  • getLoanSchema(entities?: string[]): Promise<any>
  • Calls the loan schema endpoint and returns the schema. Can be filtered down by providing an optional array of entity names.

    Parameters

    • Optional entities: string[]

    Returns Promise<any>

Generated using TypeDoc