@vqnguyen1/piece-icemortgage-encompass 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/package.json +3 -5
  2. package/project.json +22 -0
  3. package/publish.sh +33 -0
  4. package/src/index.ts +52 -0
  5. package/src/lib/actions/create-loan.ts +99 -0
  6. package/src/lib/actions/delete-loan.ts +43 -0
  7. package/src/lib/actions/document-add-comments.ts +66 -0
  8. package/src/lib/actions/document-assign-attachments.ts +53 -0
  9. package/src/lib/actions/document-create.ts +61 -0
  10. package/src/lib/actions/document-list.ts +71 -0
  11. package/src/lib/actions/document-retrieve.ts +44 -0
  12. package/src/lib/actions/document-update.ts +61 -0
  13. package/src/lib/actions/manage-field-locks.ts +62 -0
  14. package/src/lib/actions/retrieve-loan.ts +39 -0
  15. package/src/lib/actions/update-loan.ts +105 -0
  16. package/src/lib/common/auth.ts +28 -0
  17. package/src/lib/common/helpers.ts +21 -0
  18. package/tsconfig.json +19 -0
  19. package/tsconfig.lib.json +10 -0
  20. package/src/index.d.ts +0 -8
  21. package/src/index.js +0 -55
  22. package/src/index.js.map +0 -1
  23. package/src/lib/actions/create-loan.d.ts +0 -12
  24. package/src/lib/actions/create-loan.js +0 -101
  25. package/src/lib/actions/create-loan.js.map +0 -1
  26. package/src/lib/actions/delete-loan.d.ts +0 -8
  27. package/src/lib/actions/delete-loan.js +0 -43
  28. package/src/lib/actions/delete-loan.js.map +0 -1
  29. package/src/lib/actions/document-add-comments.d.ts +0 -11
  30. package/src/lib/actions/document-add-comments.js +0 -66
  31. package/src/lib/actions/document-add-comments.js.map +0 -1
  32. package/src/lib/actions/document-assign-attachments.d.ts +0 -10
  33. package/src/lib/actions/document-assign-attachments.js +0 -52
  34. package/src/lib/actions/document-assign-attachments.js.map +0 -1
  35. package/src/lib/actions/document-create.d.ts +0 -10
  36. package/src/lib/actions/document-create.js +0 -61
  37. package/src/lib/actions/document-create.js.map +0 -1
  38. package/src/lib/actions/document-list.d.ts +0 -11
  39. package/src/lib/actions/document-list.js +0 -72
  40. package/src/lib/actions/document-list.js.map +0 -1
  41. package/src/lib/actions/document-retrieve.d.ts +0 -9
  42. package/src/lib/actions/document-retrieve.js +0 -44
  43. package/src/lib/actions/document-retrieve.js.map +0 -1
  44. package/src/lib/actions/document-update.d.ts +0 -10
  45. package/src/lib/actions/document-update.js +0 -61
  46. package/src/lib/actions/document-update.js.map +0 -1
  47. package/src/lib/actions/manage-field-locks.d.ts +0 -10
  48. package/src/lib/actions/manage-field-locks.js +0 -62
  49. package/src/lib/actions/manage-field-locks.js.map +0 -1
  50. package/src/lib/actions/retrieve-loan.d.ts +0 -8
  51. package/src/lib/actions/retrieve-loan.js +0 -39
  52. package/src/lib/actions/retrieve-loan.js.map +0 -1
  53. package/src/lib/actions/update-loan.d.ts +0 -14
  54. package/src/lib/actions/update-loan.js +0 -100
  55. package/src/lib/actions/update-loan.js.map +0 -1
  56. package/src/lib/common/auth.d.ts +0 -6
  57. package/src/lib/common/auth.js +0 -31
  58. package/src/lib/common/auth.js.map +0 -1
  59. package/src/lib/common/helpers.d.ts +0 -1
  60. package/src/lib/common/helpers.js +0 -26
  61. package/src/lib/common/helpers.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vqnguyen1/piece-icemortgage-encompass",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "peerDependencies": {
@@ -8,7 +8,5 @@
8
8
  "@activepieces/pieces-common": "*",
9
9
  "@activepieces/shared": "*"
10
10
  },
11
- "dependencies": {},
12
- "types": "./src/index.d.ts",
13
- "type": "commonjs"
14
- }
11
+ "dependencies": {}
12
+ }
package/project.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "pieces-icemortgage-encompass",
3
+ "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/pieces/custom/icemortgage-encompass/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@nx/js:tsc",
9
+ "outputs": ["{options.outputPath}"],
10
+ "options": {
11
+ "outputPath": "dist/packages/pieces/custom/icemortgage-encompass",
12
+ "main": "packages/pieces/custom/icemortgage-encompass/src/index.ts",
13
+ "tsConfig": "packages/pieces/custom/icemortgage-encompass/tsconfig.lib.json",
14
+ "assets": [
15
+ "packages/pieces/custom/icemortgage-encompass/*.md",
16
+ "packages/pieces/custom/icemortgage-encompass/*.png"
17
+ ]
18
+ }
19
+ }
20
+ },
21
+ "tags": []
22
+ }
package/publish.sh ADDED
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+
3
+ # Script to build, version, and publish IceMortgage Encompass piece to npm
4
+ # Usage: ./publish.sh [patch|minor|major]
5
+
6
+ set -e # Exit on error
7
+
8
+ VERSION_TYPE="${1:-patch}"
9
+ PIECE_NAME="icemortgage-encompass"
10
+ ROOT_DIR="$(pwd)/../../../.."
11
+
12
+ GREEN='\033[0;32m'
13
+ BLUE='\033[0;34m'
14
+ YELLOW='\033[1;33m'
15
+ RED='\033[0;31m'
16
+ NC='\033[0m'
17
+
18
+ echo -e "${BLUE}Publishing: ${PIECE_NAME}${NC}"
19
+
20
+ npm whoami &> /dev/null || { echo -e "${RED}Not logged in to npm${NC}"; exit 1; }
21
+
22
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
23
+ echo -e "Current: ${YELLOW}${CURRENT_VERSION}${NC}"
24
+
25
+ npm version $VERSION_TYPE --no-git-tag-version
26
+ NEW_VERSION=$(node -p "require('./package.json').version")
27
+ echo -e "New: ${GREEN}${NEW_VERSION}${NC}"
28
+
29
+ cd "$ROOT_DIR" && bunx nx build "pieces-${PIECE_NAME}" --skip-nx-cache
30
+ cd "${ROOT_DIR}/dist/packages/pieces/custom/${PIECE_NAME}"
31
+ npm publish --access public
32
+
33
+ echo -e "${GREEN}✓ Published @vqnguyen1/piece-${PIECE_NAME}@${NEW_VERSION}${NC}"
package/src/index.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { createPiece } from '@activepieces/pieces-framework';
2
+ import { PieceCategory } from '@activepieces/shared';
3
+ import { createCustomApiCallAction } from '@activepieces/pieces-common';
4
+ import { icemortgageEncompassAuth } from './lib/common/auth';
5
+ import { createLoan } from './lib/actions/create-loan';
6
+ import { retrieveLoan } from './lib/actions/retrieve-loan';
7
+ import { updateLoan } from './lib/actions/update-loan';
8
+ import { deleteLoan } from './lib/actions/delete-loan';
9
+ import { manageFieldLocks } from './lib/actions/manage-field-locks';
10
+ import { createDocument } from './lib/actions/document-create';
11
+ import { retrieveDocument } from './lib/actions/document-retrieve';
12
+ import { listDocuments } from './lib/actions/document-list';
13
+ import { updateDocument } from './lib/actions/document-update';
14
+ import { addDocumentComments } from './lib/actions/document-add-comments';
15
+ import { assignDocumentAttachments } from './lib/actions/document-assign-attachments';
16
+
17
+ export const icemortgageEncompass = createPiece({
18
+ displayName: 'IceMortgage Encompass',
19
+ auth: icemortgageEncompassAuth,
20
+ minimumSupportedRelease: '0.20.0',
21
+ logoUrl: 'https://i.imgur.com/UqqkpPQ.png',
22
+ authors: ['vqnguyen1'],
23
+ categories: [PieceCategory.BUSINESS_INTELLIGENCE],
24
+ actions: [
25
+ createLoan,
26
+ retrieveLoan,
27
+ updateLoan,
28
+ deleteLoan,
29
+ manageFieldLocks,
30
+ createDocument,
31
+ retrieveDocument,
32
+ listDocuments,
33
+ updateDocument,
34
+ addDocumentComments,
35
+ assignDocumentAttachments,
36
+ createCustomApiCallAction({
37
+ baseUrl: (auth) => (auth as any).baseUrl || 'https://api.elliemae.com',
38
+ auth: icemortgageEncompassAuth,
39
+ authMapping: async (auth) => {
40
+ // Note: Encompass uses OAuth2, this is a simplified version
41
+ // In production, you'd need to handle token refresh
42
+ return {
43
+ 'Authorization': `Bearer ${(auth as any).clientSecret}`,
44
+ 'Content-Type': 'application/json',
45
+ };
46
+ },
47
+ }),
48
+ ],
49
+ triggers: [],
50
+ });
51
+
52
+ export { icemortgageEncompassAuth };
@@ -0,0 +1,99 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const createLoan = createAction({
10
+ name: 'loan_create',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Loan - Create',
13
+ description: 'Create a new loan in Encompass',
14
+ props: {
15
+ loanData: Property.Json({
16
+ displayName: 'Loan Data',
17
+ description: 'The complete loan information as JSON object',
18
+ required: true,
19
+ }),
20
+ loanFolder: Property.ShortText({
21
+ displayName: 'Loan Folder',
22
+ description: 'The folder where the loan will be created (e.g., "My Pipeline")',
23
+ required: false,
24
+ }),
25
+ view: Property.StaticDropdown({
26
+ displayName: 'View',
27
+ description: 'The view to return in the response',
28
+ required: false,
29
+ options: {
30
+ options: [
31
+ { label: 'Entity', value: 'entity' },
32
+ { label: 'ID', value: 'id' },
33
+ ],
34
+ },
35
+ defaultValue: 'entity',
36
+ }),
37
+ templateType: Property.StaticDropdown({
38
+ displayName: 'Template Type',
39
+ description: 'Type of template to apply when creating the loan',
40
+ required: false,
41
+ options: {
42
+ options: [
43
+ { label: 'None', value: '' },
44
+ { label: 'Template Set', value: 'templateSet' },
45
+ { label: 'Loan Program', value: 'loanProgram' },
46
+ { label: 'Closing Cost', value: 'closingCost' },
47
+ ],
48
+ },
49
+ }),
50
+ templatePath: Property.ShortText({
51
+ displayName: 'Template Path',
52
+ description: 'Path to the template (e.g., "Public:\\Companywide\\Template Name")',
53
+ required: false,
54
+ }),
55
+ },
56
+ async run(context) {
57
+ const auth = context.auth as any;
58
+ const baseUrl = auth.baseUrl;
59
+ const { loanData, loanFolder, view, templateType, templatePath } = context.propsValue;
60
+
61
+ // Get access token
62
+ const accessToken = await getAccessToken(auth);
63
+
64
+ // Build query parameters
65
+ const queryParams = new URLSearchParams();
66
+ if (loanFolder) queryParams.append('loanFolder', loanFolder);
67
+ if (view) queryParams.append('view', view);
68
+ if (templateType) queryParams.append('templateType', templateType);
69
+ if (templatePath) queryParams.append('templatePath', templatePath);
70
+
71
+ const url = `${baseUrl}/encompass/v3/loans${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
72
+
73
+ const response = await httpClient.sendRequest({
74
+ method: HttpMethod.POST,
75
+ url,
76
+ headers: {
77
+ 'Content-Type': 'application/json',
78
+ 'Authorization': `Bearer ${accessToken}`,
79
+ },
80
+ body: loanData,
81
+ });
82
+
83
+ // Extract loan ID from Location header if present
84
+ const locationHeader = response.headers?.['location'] as string;
85
+ let loanId = null;
86
+ if (locationHeader) {
87
+ const match = locationHeader.match(/\/loans\/([^\/]+)$/);
88
+ if (match) {
89
+ loanId = match[1];
90
+ }
91
+ }
92
+
93
+ return {
94
+ loanId,
95
+ loanData: response.body,
96
+ statusCode: response.status,
97
+ };
98
+ },
99
+ });
@@ -0,0 +1,43 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const deleteLoan = createAction({
10
+ name: 'loan_delete',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Loan - Delete',
13
+ description: 'Delete a loan from Encompass',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan to delete',
18
+ required: true,
19
+ }),
20
+ },
21
+ async run(context) {
22
+ const auth = context.auth as any;
23
+ const baseUrl = auth.baseUrl;
24
+ const { loanId } = context.propsValue;
25
+
26
+ const accessToken = await getAccessToken(auth);
27
+
28
+ const response = await httpClient.sendRequest({
29
+ method: HttpMethod.DELETE,
30
+ url: `${baseUrl}/encompass/v3/loans/${loanId}`,
31
+ headers: {
32
+ 'Content-Type': 'application/json',
33
+ 'Authorization': `Bearer ${accessToken}`,
34
+ },
35
+ });
36
+
37
+ return {
38
+ success: true,
39
+ statusCode: response.status,
40
+ message: `Loan ${loanId} deleted successfully`,
41
+ };
42
+ },
43
+ });
@@ -0,0 +1,66 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const addDocumentComments = createAction({
10
+ name: 'document_add_comments',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - Add Comments',
13
+ description: 'Add comments to a document',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan',
18
+ required: true,
19
+ }),
20
+ documentId: Property.ShortText({
21
+ displayName: 'Document ID',
22
+ description: 'The ID of the document to add comments to',
23
+ required: true,
24
+ }),
25
+ comments: Property.Array({
26
+ displayName: 'Comments',
27
+ description: 'Array of comment objects to add',
28
+ required: true,
29
+ }),
30
+ view: Property.StaticDropdown({
31
+ displayName: 'View',
32
+ description: 'The view to return in the response',
33
+ required: false,
34
+ options: {
35
+ options: [
36
+ { label: 'Entity', value: 'entity' },
37
+ { label: 'ID', value: 'id' },
38
+ ],
39
+ },
40
+ defaultValue: 'entity',
41
+ }),
42
+ },
43
+ async run(context) {
44
+ const auth = context.auth as any;
45
+ const baseUrl = auth.baseUrl;
46
+ const { loanId, documentId, comments, view } = context.propsValue;
47
+
48
+ const accessToken = await getAccessToken(auth);
49
+
50
+ const queryParams = new URLSearchParams();
51
+ queryParams.append('action', 'add');
52
+ if (view) queryParams.append('view', view);
53
+
54
+ const response = await httpClient.sendRequest({
55
+ method: HttpMethod.PATCH,
56
+ url: `${baseUrl}/encompass/v3/loans/${loanId}/documents/${documentId}/comments?${queryParams.toString()}`,
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ 'Authorization': `Bearer ${accessToken}`,
60
+ },
61
+ body: comments,
62
+ });
63
+
64
+ return response.body;
65
+ },
66
+ });
@@ -0,0 +1,53 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const assignDocumentAttachments = createAction({
10
+ name: 'document_assign_attachments',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - Assign Attachments',
13
+ description: 'Assign attachments to a document',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan',
18
+ required: true,
19
+ }),
20
+ documentId: Property.ShortText({
21
+ displayName: 'Document ID',
22
+ description: 'The ID of the document to assign attachments to',
23
+ required: true,
24
+ }),
25
+ attachments: Property.Array({
26
+ displayName: 'Attachments',
27
+ description: 'Array of attachment objects (with entityId and entityType fields)',
28
+ required: true,
29
+ }),
30
+ },
31
+ async run(context) {
32
+ const auth = context.auth as any;
33
+ const baseUrl = auth.baseUrl;
34
+ const { loanId, documentId, attachments } = context.propsValue;
35
+
36
+ const accessToken = await getAccessToken(auth);
37
+
38
+ const queryParams = new URLSearchParams();
39
+ queryParams.append('action', 'add');
40
+
41
+ const response = await httpClient.sendRequest({
42
+ method: HttpMethod.PATCH,
43
+ url: `${baseUrl}/encompass/v3/loans/${loanId}/documents/${documentId}/attachments?${queryParams.toString()}`,
44
+ headers: {
45
+ 'Content-Type': 'application/json',
46
+ 'Authorization': `Bearer ${accessToken}`,
47
+ },
48
+ body: attachments,
49
+ });
50
+
51
+ return response.body;
52
+ },
53
+ });
@@ -0,0 +1,61 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const createDocument = createAction({
10
+ name: 'document_create',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - Create',
13
+ description: 'Create a new document for a loan in Encompass',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan to create the document for',
18
+ required: true,
19
+ }),
20
+ documents: Property.Array({
21
+ displayName: 'Documents',
22
+ description: 'Array of document objects to create',
23
+ required: true,
24
+ }),
25
+ view: Property.StaticDropdown({
26
+ displayName: 'View',
27
+ description: 'The view to return in the response',
28
+ required: false,
29
+ options: {
30
+ options: [
31
+ { label: 'Entity', value: 'entity' },
32
+ { label: 'ID', value: 'id' },
33
+ ],
34
+ },
35
+ defaultValue: 'entity',
36
+ }),
37
+ },
38
+ async run(context) {
39
+ const auth = context.auth as any;
40
+ const baseUrl = auth.baseUrl;
41
+ const { loanId, documents, view } = context.propsValue;
42
+
43
+ const accessToken = await getAccessToken(auth);
44
+
45
+ const queryParams = new URLSearchParams();
46
+ queryParams.append('action', 'add');
47
+ if (view) queryParams.append('view', view);
48
+
49
+ const response = await httpClient.sendRequest({
50
+ method: HttpMethod.PATCH,
51
+ url: `${baseUrl}/encompass/v3/loans/${loanId}/documents?${queryParams.toString()}`,
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ 'Authorization': `Bearer ${accessToken}`,
55
+ },
56
+ body: documents,
57
+ });
58
+
59
+ return response.body;
60
+ },
61
+ });
@@ -0,0 +1,71 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const listDocuments = createAction({
10
+ name: 'document_list',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - List',
13
+ description: 'Retrieve all documents for a loan',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan',
18
+ required: true,
19
+ }),
20
+ view: Property.StaticDropdown({
21
+ displayName: 'View',
22
+ description: 'The level of detail to return',
23
+ required: false,
24
+ options: {
25
+ options: [
26
+ { label: 'Detail (Default)', value: 'Detail' },
27
+ { label: 'Full', value: 'Full' },
28
+ { label: 'Summary', value: 'Summary' },
29
+ ],
30
+ },
31
+ defaultValue: 'Detail',
32
+ }),
33
+ includeRemoved: Property.Checkbox({
34
+ displayName: 'Include Removed Documents',
35
+ description: 'Whether to include removed documents in the results',
36
+ required: false,
37
+ defaultValue: false,
38
+ }),
39
+ requireActiveAttachments: Property.Checkbox({
40
+ displayName: 'Require Active Attachments',
41
+ description: 'Whether to only return documents with active attachments',
42
+ required: false,
43
+ defaultValue: false,
44
+ }),
45
+ },
46
+ async run(context) {
47
+ const auth = context.auth as any;
48
+ const baseUrl = auth.baseUrl;
49
+ const { loanId, view, includeRemoved, requireActiveAttachments } = context.propsValue;
50
+
51
+ const accessToken = await getAccessToken(auth);
52
+
53
+ const queryParams = new URLSearchParams();
54
+ if (view) queryParams.append('view', view);
55
+ if (includeRemoved) queryParams.append('includeRemoved', 'true');
56
+ if (requireActiveAttachments) queryParams.append('requireActiveAttachments', 'true');
57
+
58
+ const url = `${baseUrl}/encompass/v3/loans/${loanId}/documents${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
59
+
60
+ const response = await httpClient.sendRequest({
61
+ method: HttpMethod.GET,
62
+ url,
63
+ headers: {
64
+ 'Content-Type': 'application/json',
65
+ 'Authorization': `Bearer ${accessToken}`,
66
+ },
67
+ });
68
+
69
+ return response.body;
70
+ },
71
+ });
@@ -0,0 +1,44 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const retrieveDocument = createAction({
10
+ name: 'document_retrieve',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - Retrieve',
13
+ description: 'Retrieve a single document from a loan',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan',
18
+ required: true,
19
+ }),
20
+ documentId: Property.ShortText({
21
+ displayName: 'Document ID',
22
+ description: 'The ID of the document to retrieve',
23
+ required: true,
24
+ }),
25
+ },
26
+ async run(context) {
27
+ const auth = context.auth as any;
28
+ const baseUrl = auth.baseUrl;
29
+ const { loanId, documentId } = context.propsValue;
30
+
31
+ const accessToken = await getAccessToken(auth);
32
+
33
+ const response = await httpClient.sendRequest({
34
+ method: HttpMethod.GET,
35
+ url: `${baseUrl}/encompass/v3/loans/${loanId}/documents/${documentId}`,
36
+ headers: {
37
+ 'Content-Type': 'application/json',
38
+ 'Authorization': `Bearer ${accessToken}`,
39
+ },
40
+ });
41
+
42
+ return response.body;
43
+ },
44
+ });
@@ -0,0 +1,61 @@
1
+ import {
2
+ createAction,
3
+ Property,
4
+ } from '@activepieces/pieces-framework';
5
+ import { httpClient, HttpMethod } from '@activepieces/pieces-common';
6
+ import { icemortgageEncompassAuth } from '../common/auth';
7
+ import { getAccessToken } from '../common/helpers';
8
+
9
+ export const updateDocument = createAction({
10
+ name: 'document_update',
11
+ auth: icemortgageEncompassAuth,
12
+ displayName: 'Document - Update',
13
+ description: 'Update an existing document on a loan',
14
+ props: {
15
+ loanId: Property.ShortText({
16
+ displayName: 'Loan ID',
17
+ description: 'The ID of the loan',
18
+ required: true,
19
+ }),
20
+ documents: Property.Array({
21
+ displayName: 'Documents',
22
+ description: 'Array of document objects to update (must include id field for each)',
23
+ required: true,
24
+ }),
25
+ view: Property.StaticDropdown({
26
+ displayName: 'View',
27
+ description: 'The view to return in the response',
28
+ required: false,
29
+ options: {
30
+ options: [
31
+ { label: 'Entity', value: 'entity' },
32
+ { label: 'ID', value: 'id' },
33
+ ],
34
+ },
35
+ defaultValue: 'entity',
36
+ }),
37
+ },
38
+ async run(context) {
39
+ const auth = context.auth as any;
40
+ const baseUrl = auth.baseUrl;
41
+ const { loanId, documents, view } = context.propsValue;
42
+
43
+ const accessToken = await getAccessToken(auth);
44
+
45
+ const queryParams = new URLSearchParams();
46
+ queryParams.append('action', 'update');
47
+ if (view) queryParams.append('view', view);
48
+
49
+ const response = await httpClient.sendRequest({
50
+ method: HttpMethod.PATCH,
51
+ url: `${baseUrl}/encompass/v3/loans/${loanId}/documents?${queryParams.toString()}`,
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ 'Authorization': `Bearer ${accessToken}`,
55
+ },
56
+ body: documents,
57
+ });
58
+
59
+ return response.body;
60
+ },
61
+ });