n8n-nodes-peak 0.1.0
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.
- package/LICENSE.md +19 -0
- package/README.md +127 -0
- package/dist/assets/PEAK.svg +13 -0
- package/dist/credentials/PEAKApi.credentials.d.ts +7 -0
- package/dist/credentials/PEAKApi.credentials.js +40 -0
- package/dist/credentials/PEAKApi.credentials.js.map +1 -0
- package/dist/helpers/time.d.ts +2 -0
- package/dist/helpers/time.js +23 -0
- package/dist/helpers/time.js.map +1 -0
- package/dist/nodes/Contact/GetContact.node.d.ts +5 -0
- package/dist/nodes/Contact/GetContact.node.js +145 -0
- package/dist/nodes/Contact/GetContact.node.js.map +1 -0
- package/dist/nodes/DailyJournal/CreateDailyJournal.node.d.ts +5 -0
- package/dist/nodes/DailyJournal/CreateDailyJournal.node.js +139 -0
- package/dist/nodes/DailyJournal/CreateDailyJournal.node.js.map +1 -0
- package/dist/nodes/DailyJournal/GetAccountCode.node.d.ts +5 -0
- package/dist/nodes/DailyJournal/GetAccountCode.node.js +118 -0
- package/dist/nodes/DailyJournal/GetAccountCode.node.js.map +1 -0
- package/dist/nodes/Invoice/CreateExpense.node.d.ts +5 -0
- package/dist/nodes/Invoice/CreateExpense.node.js +139 -0
- package/dist/nodes/Invoice/CreateExpense.node.js.map +1 -0
- package/dist/nodes/Invoice/CreateInvoice.node.d.ts +5 -0
- package/dist/nodes/Invoice/CreateInvoice.node.js +140 -0
- package/dist/nodes/Invoice/CreateInvoice.node.js.map +1 -0
- package/dist/nodes/Invoice/CreateInvoice.node.json +13 -0
- package/dist/nodes/PaymentMethod/GetPaymentMethod.node.d.ts +5 -0
- package/dist/nodes/PaymentMethod/GetPaymentMethod.node.js +145 -0
- package/dist/nodes/PaymentMethod/GetPaymentMethod.node.js.map +1 -0
- package/dist/nodes/Product/GetProduct.node.d.ts +5 -0
- package/dist/nodes/Product/GetProduct.node.js +146 -0
- package/dist/nodes/Product/GetProduct.node.js.map +1 -0
- package/dist/nodes/Product/GetService.node.d.ts +5 -0
- package/dist/nodes/Product/GetService.node.js +145 -0
- package/dist/nodes/Product/GetService.node.js.map +1 -0
- package/dist/nodes/Receipt/CreateReceipt.node.d.ts +5 -0
- package/dist/nodes/Receipt/CreateReceipt.node.js +139 -0
- package/dist/nodes/Receipt/CreateReceipt.node.js.map +1 -0
- package/dist/nodes/Receipt/CreateReceipt.node.json +13 -0
- package/dist/package.json +73 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.js +0 -0
- package/package.json +73 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2022 n8n
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# 🧩 n8n-nodes-peak
|
|
2
|
+
Official n8n community node for integrating with **PEAK Accounting Platform**.
|
|
3
|
+
|
|
4
|
+
PEAK is a cloud-based accounting and financial automation platform that helps businesses automate receipts, expenses, invoices, order synchronization, and workflow integrations with marketplaces.
|
|
5
|
+
|
|
6
|
+
With this node, you can build automated workflows that interact directly with your PEAK business.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
## 🚀 Features
|
|
10
|
+
This node allows you to perform a variety of accounting operations, including:
|
|
11
|
+
|
|
12
|
+
- **Create Daily Journal** – Create daily journal documents via API
|
|
13
|
+
- **Create Receipt** – Create receipt documents via API
|
|
14
|
+
- **Create Invoice** – Create invoice documents via API
|
|
15
|
+
- **Create Expense** – Create expense documents via API
|
|
16
|
+
- **Get Master Data** – Retrieve contacts, products, payment methods, and other essential master data
|
|
17
|
+
|
|
18
|
+
Additional operations may be added in future releases.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 Installation
|
|
23
|
+
Follow the installation guide in the [**n8n Community Nodes documentation**](https://docs.n8n.io/integrations/community-nodes/installation/)
|
|
24
|
+
|
|
25
|
+
Once installed, you'll be able to use all PEAK-related operations.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🔐 Credentials (Required Before Use)
|
|
30
|
+
|
|
31
|
+
To use this node, you must obtain **PEAK API Credentials**.
|
|
32
|
+
These credentials are issued **only** by the PEAK Sales / Partner team.
|
|
33
|
+
|
|
34
|
+
### Your credential will consist of four fields:
|
|
35
|
+
|
|
36
|
+
| Field | Description |
|
|
37
|
+
|-------|-------------|
|
|
38
|
+
| **Connect ID** | Used only for requesting a Client Token and identifying your integration |
|
|
39
|
+
| **Connect Key** | Secret used together with Connect ID when requesting a Client Token |
|
|
40
|
+
| **Application Code** | Code required for generate User Token |
|
|
41
|
+
| **User Token** | Access token linked to a specific user & merchant |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 🧭 How to Obtain PEAK API Credentials
|
|
46
|
+
|
|
47
|
+
### 1️⃣ Contact PEAK Sales Team
|
|
48
|
+
Request API integration access.
|
|
49
|
+
You will receive:
|
|
50
|
+
- Connect ID
|
|
51
|
+
- Connect Key
|
|
52
|
+
- Application Code
|
|
53
|
+
|
|
54
|
+
### 2️⃣ Generate the User Token inside PEAK
|
|
55
|
+
1. Log in to the PEAK web app
|
|
56
|
+
2. Open the merchant you want to connect
|
|
57
|
+
3. Navigate to **Connect Apps Setting -> Connect Partner App -> Connect Non-Partner App** in Setting
|
|
58
|
+
4. Enter your **Application Code**
|
|
59
|
+
5. PEAK will generate a **User Token**
|
|
60
|
+
|
|
61
|
+
Once you have all four values, create a new credential in n8n:
|
|
62
|
+
|
|
63
|
+
**Settings → Credentials → New → PEAK API**
|
|
64
|
+
|
|
65
|
+
After saving, all PEAK nodes will be ready to use.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ⚙️ Authentication
|
|
70
|
+
Every PEAK request requires:
|
|
71
|
+
|
|
72
|
+
- `Time-Stamp`
|
|
73
|
+
- `Time-Signature`
|
|
74
|
+
- `User-Token`
|
|
75
|
+
- `Client-Token`
|
|
76
|
+
|
|
77
|
+
The PEAK n8n node **automatically handles all signature generation**, timestamps, and headers — no manual work required.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🛠 Operations
|
|
82
|
+
### **PEAK Node**
|
|
83
|
+
Available actions:
|
|
84
|
+
|
|
85
|
+
| Resource | Operation | Description |
|
|
86
|
+
|----------|-----------|-------------|
|
|
87
|
+
| Daily Journal | Create | Create a daily Journal document |
|
|
88
|
+
| Receipt | Create | Create a receipt document |
|
|
89
|
+
| Invoice | Create | Create a invoice document |
|
|
90
|
+
| Expense | Create | Create an expense document |
|
|
91
|
+
|
|
92
|
+
More resources will be added in future versions.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 📘 Usage
|
|
97
|
+
|
|
98
|
+
### **Action Node (PEAK)**
|
|
99
|
+
1. Drag the **PEAK** node into your workflow
|
|
100
|
+
2. Select the resource (e.g., Receipt, Expense)
|
|
101
|
+
3. Choose an operation
|
|
102
|
+
4. Fill in required fields
|
|
103
|
+
5. Run the workflow
|
|
104
|
+
|
|
105
|
+
### Example Use Cases
|
|
106
|
+
- **Shopee Webhook → PEAK Create Receipt**
|
|
107
|
+
- **Google Sheets → PEAK Create Expense**
|
|
108
|
+
- **Internal System → Automated Accounting Workflows**
|
|
109
|
+
- **Marketplace Sync → PEAK Billing or Receipt Generation**
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🔗 Resources
|
|
113
|
+
- [n8n Community Nodes Documentation](https://docs.n8n.io/integrations/community-nodes/)
|
|
114
|
+
- [PEAK API Documentation](https://developers.peakaccount.com/reference/peak-open-api)
|
|
115
|
+
- [n8n Official Docs](https://docs.n8n.io/)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🧩 Version History
|
|
120
|
+
|
|
121
|
+
### **0.1.0**
|
|
122
|
+
- Initial release
|
|
123
|
+
- Added:
|
|
124
|
+
- Create Receipt
|
|
125
|
+
- Create Expense
|
|
126
|
+
- Fetch Master Data
|
|
127
|
+
---
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1200px" height="1200px" viewBox="0 0 600 600" version="1.1">
|
|
3
|
+
<g id="surface1">
|
|
4
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(20%,52.156866%,91.764706%);fill-opacity:1;" d="M 289.367188 -0.101562 C 289.761719 -0.101562 290.152344 -0.105469 290.558594 -0.105469 C 292.644531 -0.113281 294.730469 -0.117188 296.820312 -0.121094 C 298.503906 -0.121094 300.191406 -0.128906 301.875 -0.140625 C 313.179688 -0.214844 324.269531 0.203125 335.5 1.5 C 335.957031 1.550781 336.417969 1.605469 336.890625 1.660156 C 339.257812 1.9375 341.613281 2.261719 343.96875 2.625 C 344.308594 2.675781 344.648438 2.726562 344.996094 2.78125 C 364.695312 5.765625 383.707031 10.929688 402.5 17.5 C 403.070312 17.699219 403.640625 17.898438 404.230469 18.101562 C 421.613281 24.230469 438.230469 32.507812 454 42 C 454.804688 42.480469 455.609375 42.957031 456.414062 43.4375 C 461.933594 46.734375 467.242188 50.304688 472.5 54 C 472.882812 54.269531 473.269531 54.539062 473.664062 54.816406 C 478.816406 58.445312 483.777344 62.25 488.625 66.277344 C 489.875 67.308594 491.140625 68.324219 492.40625 69.34375 C 494.707031 71.226562 496.914062 73.203125 499.101562 75.222656 C 500.195312 76.222656 501.296875 77.199219 502.414062 78.171875 C 508.652344 83.617188 514.480469 89.421875 520.085938 95.511719 C 520.945312 96.441406 521.808594 97.363281 522.675781 98.289062 C 525.761719 101.582031 528.675781 104.976562 531.5 108.5 C 531.992188 109.097656 532.484375 109.691406 532.976562 110.289062 C 543.09375 122.535156 552.089844 135.726562 560 149.5 C 560.207031 149.863281 560.417969 150.222656 560.628906 150.597656 C 562.125 153.210938 563.570312 155.851562 565 158.5 C 565.363281 159.167969 565.363281 159.167969 565.734375 159.851562 C 583.015625 191.726562 593.566406 226.882812 598.125 262.78125 C 598.199219 263.375 598.277344 263.964844 598.355469 264.578125 C 598.589844 266.550781 598.800781 268.523438 599 270.5 C 599.042969 270.925781 599.085938 271.351562 599.132812 271.792969 C 600.046875 280.996094 600.179688 290.167969 600.15625 299.40625 C 600.15625 300.152344 600.152344 300.898438 600.152344 301.648438 C 600.132812 312.65625 599.921875 323.570312 598.5 334.5 C 598.453125 334.882812 598.402344 335.265625 598.351562 335.660156 C 593.351562 375.003906 581.347656 413.542969 561.5 448 C 561.277344 448.394531 561.050781 448.785156 560.820312 449.191406 C 554.1875 460.757812 546.609375 471.921875 538.5 482.5 C 538.257812 482.816406 538.019531 483.132812 537.769531 483.457031 C 533.316406 489.277344 528.558594 494.835938 523.628906 500.253906 C 522.9375 501.019531 522.25 501.785156 521.570312 502.558594 C 518.34375 506.210938 514.921875 509.65625 511.472656 513.09375 C 510.46875 514.09375 509.464844 515.101562 508.464844 516.105469 C 505.394531 519.175781 502.328125 522.207031 499 525 C 498.402344 525.523438 497.808594 526.046875 497.214844 526.570312 C 493.082031 530.191406 488.871094 533.667969 484.5 537 C 484.121094 537.289062 483.742188 537.582031 483.347656 537.878906 C 477.835938 542.078125 472.269531 546.160156 466.5 550 C 466.171875 550.21875 465.84375 550.4375 465.507812 550.664062 C 433.160156 572.1875 396.628906 587.246094 337.125 598.15625 C 336.542969 598.230469 335.964844 598.304688 335.363281 598.378906 C 333.410156 598.609375 331.457031 598.8125 329.5 599 C 329.058594 599.042969 328.617188 599.085938 328.160156 599.128906 C 319.238281 599.976562 310.339844 600.183594 301.386719 600.160156 C 300.292969 600.15625 299.203125 600.15625 298.113281 600.152344 C 287.53125 600.136719 277.019531 599.949219 266.507812 598.625 C 265.453125 598.496094 264.402344 598.367188 263.347656 598.238281 C 222.59375 593.253906 182.625 579.941406 118 539 C 117.523438 538.636719 117.523438 538.636719 117.035156 538.265625 C 112.550781 534.835938 108.253906 531.207031 104 527.5 C 103.621094 527.171875 103.238281 526.839844 102.847656 526.5 C 101.894531 525.671875 100.945312 524.839844 100 524 C 99.652344 523.691406 99.304688 523.386719 98.945312 523.070312 C 97.621094 521.890625 96.308594 520.699219 95 519.5 C 94.691406 519.21875 94.382812 518.9375 94.066406 518.644531 C 89.121094 514.097656 84.402344 509.398438 79.863281 504.441406 C 79.035156 503.535156 78.195312 502.640625 77.359375 501.746094 C 74.257812 498.4375 71.335938 495.035156 68.5 491.5 C 68.007812 490.902344 67.515625 490.308594 67.023438 489.714844 C 56.292969 476.726562 46.773438 462.671875 38.5 448 C 38.136719 447.363281 38.136719 447.363281 37.769531 446.714844 C 17.625 411.222656 5.253906 371.550781 1 331 C 0.933594 330.410156 0.933594 330.410156 0.867188 329.804688 C -0.191406 319.96875 -0.199219 310.132812 -0.1875 300.25 C -0.1875 299.824219 -0.1875 299.398438 -0.1875 298.957031 C -0.183594 286.421875 -0.0351562 274.011719 1.835938 261.589844 C 2.007812 260.445312 2.171875 259.300781 2.332031 258.15625 C 7.027344 225.183594 17.039062 193.707031 32 164 C 32.378906 163.238281 32.378906 163.238281 32.769531 162.460938 C 42.441406 143.160156 54.644531 125.046875 68.5 108.5 C 68.710938 108.246094 68.917969 107.996094 69.136719 107.734375 C 72.269531 103.972656 75.496094 100.316406 78.828125 96.730469 C 79.476562 96.027344 80.113281 95.316406 80.753906 94.609375 C 83.613281 91.433594 86.578125 88.371094 89.59375 85.34375 C 89.96875 84.96875 90.34375 84.589844 90.726562 84.203125 C 92.785156 82.152344 94.882812 80.1875 97.082031 78.292969 C 98.386719 77.164062 99.644531 75.988281 100.90625 74.8125 C 103.679688 72.253906 106.554688 69.855469 109.5 67.5 C 110.058594 67.042969 110.617188 66.589844 111.179688 66.132812 C 122.617188 56.835938 134.785156 48.464844 147.5 41 C 147.910156 40.757812 148.320312 40.515625 148.746094 40.265625 C 162.132812 32.40625 176.054688 25.675781 190.5 20 C 190.808594 19.878906 191.117188 19.757812 191.433594 19.632812 C 218.046875 9.1875 246.058594 3.050781 274.5 0.5 C 274.960938 0.457031 275.425781 0.414062 275.898438 0.367188 C 280.390625 -0.0195312 284.863281 -0.0898438 289.367188 -0.101562 Z M 289.367188 -0.101562 "/>
|
|
5
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(99.607843%,99.607843%,99.607843%);fill-opacity:1;" d="M 82 245.5 C 136.3125 245.5 136.3125 245.5 146 255 C 152.640625 262.730469 155.070312 270.644531 154.609375 280.738281 C 153.898438 288.808594 149.75 296.414062 143.65625 301.65625 C 140.320312 304.296875 137.011719 306.101562 133 307.5 C 132.519531 307.675781 132.039062 307.851562 131.542969 308.03125 C 127.847656 309.152344 124.191406 309.066406 120.359375 309.046875 C 119.84375 309.046875 119.328125 309.046875 118.792969 309.046875 C 116.871094 309.042969 114.953125 309.039062 113.03125 309.03125 C 106.582031 309.015625 106.582031 309.015625 100 309 C 100 324.015625 100 339.03125 100 354.5 C 94.058594 354.5 88.121094 354.5 82 354.5 C 82 318.53125 82 282.558594 82 245.5 Z M 82 245.5 "/>
|
|
6
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(99.607843%,99.607843%,99.607843%);fill-opacity:1;" d="M 445.5 245.5 C 451.441406 245.5 457.378906 245.5 463.5 245.5 C 463.664062 261.175781 463.828125 276.851562 464 293 C 466.308594 289.535156 468.621094 286.070312 471 282.5 C 472.210938 280.695312 473.425781 278.890625 474.644531 277.085938 C 474.941406 276.648438 475.238281 276.207031 475.546875 275.75 C 476.46875 274.386719 477.390625 273.019531 478.3125 271.65625 C 479.539062 269.84375 480.761719 268.027344 481.988281 266.210938 C 482.285156 265.773438 482.582031 265.332031 482.886719 264.878906 C 484.570312 262.386719 486.246094 259.890625 487.90625 257.382812 C 488.40625 256.628906 488.914062 255.878906 489.425781 255.132812 C 490.566406 253.464844 491.609375 251.839844 492.476562 250.011719 C 493.414062 248.144531 494.316406 246.804688 496 245.5 C 499.648438 244.476562 503.542969 244.890625 507.28125 245.09375 C 508.320312 245.125 509.359375 245.15625 510.398438 245.183594 C 512.933594 245.253906 515.464844 245.367188 518 245.5 C 517.601562 246.226562 517.199219 246.949219 516.800781 247.675781 C 516.578125 248.078125 516.355469 248.480469 516.125 248.898438 C 515.46875 250.058594 514.757812 251.140625 513.96875 252.21875 C 512.347656 254.476562 510.800781 256.777344 509.265625 259.089844 C 509.003906 259.484375 508.742188 259.875 508.472656 260.28125 C 507.648438 261.519531 506.824219 262.761719 506 264 C 504.195312 266.710938 502.394531 269.421875 500.589844 272.128906 C 499.757812 273.378906 498.925781 274.628906 498.097656 275.878906 C 495.367188 279.984375 492.617188 284.074219 489.804688 288.125 C 489.308594 288.839844 488.8125 289.554688 488.320312 290.273438 C 487.398438 291.609375 486.464844 292.933594 485.53125 294.257812 C 485.117188 294.855469 484.703125 295.453125 484.289062 296.050781 C 483.929688 296.5625 483.570312 297.074219 483.199219 297.601562 C 482.417969 298.914062 482.417969 298.914062 482.46875 300.171875 C 483.277344 302.195312 484.476562 303.890625 485.710938 305.671875 C 485.992188 306.089844 486.273438 306.503906 486.566406 306.929688 C 487.175781 307.828125 487.792969 308.726562 488.40625 309.621094 C 490.0625 312.03125 491.707031 314.453125 493.351562 316.875 C 493.863281 317.628906 493.863281 317.628906 494.382812 318.394531 C 498.070312 323.820312 501.679688 329.296875 505.28125 334.78125 C 505.578125 335.230469 505.871094 335.679688 506.175781 336.144531 C 506.464844 336.582031 506.753906 337.023438 507.050781 337.476562 C 507.335938 337.90625 507.617188 338.339844 507.910156 338.785156 C 508.464844 339.625 509.015625 340.46875 509.570312 341.3125 C 510.957031 343.421875 512.347656 345.523438 513.75 347.617188 C 514.03125 348.039062 514.3125 348.457031 514.601562 348.886719 C 515.136719 349.683594 515.671875 350.480469 516.207031 351.277344 C 518 353.945312 518 353.945312 518 354.5 C 498.917969 356.769531 498.917969 356.769531 494.257812 353.472656 C 491.546875 350.746094 489.917969 347.382812 488.269531 343.945312 C 486.011719 339.304688 482.992188 335.160156 480.058594 330.925781 C 478.527344 328.707031 477.023438 326.472656 475.523438 324.234375 C 475.234375 323.808594 474.949219 323.382812 474.652344 322.945312 C 471.632812 318.460938 468.636719 313.964844 465.644531 309.46875 C 465.097656 308.644531 464.546875 307.820312 464 307 C 463.835938 322.675781 463.671875 338.351562 463.5 354.5 C 457.558594 354.5 451.621094 354.5 445.5 354.5 C 445.5 318.53125 445.5 282.558594 445.5 245.5 Z M 445.5 245.5 "/>
|
|
7
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(99.215686%,99.607843%,99.607843%);fill-opacity:1;" d="M 354 245.5 C 354.328125 245.5 354.660156 245.5 355 245.5 C 355.269531 246.074219 355.539062 246.648438 355.816406 247.238281 C 360.617188 257.410156 365.695312 267.445312 370.734375 277.5 C 372.0625 280.15625 373.390625 282.8125 374.722656 285.46875 C 378.082031 292.1875 381.449219 298.90625 384.8125 305.625 C 388.464844 312.917969 392.113281 320.207031 395.761719 327.5 C 397.34375 330.65625 398.921875 333.808594 400.503906 336.964844 C 401.480469 338.917969 402.460938 340.871094 403.4375 342.828125 C 403.890625 343.734375 404.34375 344.640625 404.800781 345.546875 C 405.417969 346.78125 406.039062 348.015625 406.65625 349.253906 C 406.835938 349.613281 407.019531 349.976562 407.203125 350.347656 C 407.890625 351.71875 408.515625 353.042969 409 354.5 C 402.234375 354.5 395.46875 354.5 388.5 354.5 C 384.128906 345.78125 379.761719 337.0625 375.394531 328.34375 C 373.371094 324.296875 371.34375 320.25 369.3125 316.199219 C 367.542969 312.675781 365.777344 309.148438 364.011719 305.621094 C 363.078125 303.75 362.140625 301.882812 361.203125 300.015625 C 360.324219 298.257812 359.441406 296.5 358.5625 294.742188 C 358.242188 294.09375 357.917969 293.449219 357.59375 292.804688 C 357.148438 291.925781 356.710938 291.042969 356.273438 290.164062 C 356.023438 289.671875 355.777344 289.175781 355.523438 288.667969 C 355 287.5 355 287.5 355 286.5 C 354.671875 286.5 354.339844 286.5 354 286.5 C 353.863281 286.9375 353.726562 287.375 353.585938 287.824219 C 353.035156 289.402344 352.394531 290.835938 351.644531 292.328125 C 351.371094 292.878906 351.097656 293.429688 350.8125 294 C 350.511719 294.601562 350.207031 295.203125 349.902344 295.808594 C 349.582031 296.449219 349.261719 297.089844 348.941406 297.730469 C 348.074219 299.464844 347.207031 301.195312 346.335938 302.929688 C 345.425781 304.742188 344.519531 306.558594 343.609375 308.371094 C 341.894531 311.804688 340.171875 315.234375 338.453125 318.664062 C 336.492188 322.574219 334.535156 326.480469 332.578125 330.390625 C 328.554688 338.429688 324.527344 346.464844 320.5 354.5 C 313.734375 354.5 306.96875 354.5 300 354.5 C 301.125 351.125 301.125 351.125 301.949219 349.476562 C 302.136719 349.101562 302.324219 348.726562 302.515625 348.339844 C 302.71875 347.933594 302.921875 347.53125 303.132812 347.113281 C 303.351562 346.679688 303.566406 346.246094 303.789062 345.796875 C 304.519531 344.339844 305.25 342.882812 305.980469 341.429688 C 306.5 340.382812 307.023438 339.339844 307.546875 338.292969 C 308.964844 335.460938 310.382812 332.625 311.804688 329.792969 C 313.136719 327.128906 314.46875 324.464844 315.800781 321.804688 C 318.4375 316.53125 321.078125 311.257812 323.71875 305.984375 C 326.285156 300.867188 328.847656 295.746094 331.410156 290.625 C 331.570312 290.308594 331.726562 289.992188 331.890625 289.667969 C 332.683594 288.082031 333.476562 286.496094 334.269531 284.914062 C 340.84375 271.773438 347.421875 258.636719 354 245.5 Z M 354 245.5 "/>
|
|
8
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(98.431373%,99.215686%,99.607843%);fill-opacity:1;" d="M 191 336 C 214.925781 336 238.851562 336 263.5 336 C 263.5 342.105469 263.5 348.210938 263.5 354.5 C 239.574219 354.5 215.648438 354.5 191 354.5 C 191 348.394531 191 342.289062 191 336 Z M 191 336 "/>
|
|
9
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 191 291 C 214.925781 291 238.851562 291 263.5 291 C 263.5 296.941406 263.5 302.878906 263.5 309 C 239.574219 309 215.648438 309 191 309 C 191 303.058594 191 297.121094 191 291 Z M 191 291 "/>
|
|
10
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 191 245.5 C 214.925781 245.5 238.851562 245.5 263.5 245.5 C 263.5 251.441406 263.5 257.378906 263.5 263.5 C 239.574219 263.5 215.648438 263.5 191 263.5 C 191 257.558594 191 251.621094 191 245.5 Z M 191 245.5 "/>
|
|
11
|
+
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(20%,52.156866%,91.764706%);fill-opacity:1;" d="M 100 263.5 C 104.082031 263.4375 108.167969 263.375 112.375 263.3125 C 113.652344 263.285156 114.929688 263.257812 116.242188 263.230469 C 127.828125 263.085938 127.828125 263.085938 132.496094 267.425781 C 135.542969 270.621094 136.296875 273.960938 136.273438 278.261719 C 136.140625 282.140625 134.863281 284.738281 132.03125 287.414062 C 128.019531 290.636719 124.617188 291.21875 119.578125 291.148438 C 119.082031 291.144531 118.585938 291.144531 118.070312 291.140625 C 116.226562 291.132812 114.378906 291.113281 112.53125 291.09375 C 108.394531 291.0625 104.261719 291.03125 100 291 C 100 281.925781 100 272.851562 100 263.5 Z M 100 263.5 "/>
|
|
12
|
+
</g>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PEAKApi = void 0;
|
|
4
|
+
class PEAKApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'PEAKApi';
|
|
7
|
+
this.displayName = 'PEAK API';
|
|
8
|
+
this.documentationUrl = 'https://peak-api-core.readme.io/reference/peak-open-api';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'User Token (static)',
|
|
12
|
+
name: 'userToken',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Client Token (24h)',
|
|
20
|
+
name: 'clientToken',
|
|
21
|
+
type: 'string',
|
|
22
|
+
typeOptions: { password: true },
|
|
23
|
+
default: '',
|
|
24
|
+
required: true,
|
|
25
|
+
description: 'Expires every 24 hours',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Connect ID (HMAC key)',
|
|
29
|
+
name: 'connectId',
|
|
30
|
+
type: 'string',
|
|
31
|
+
typeOptions: { password: true },
|
|
32
|
+
default: '',
|
|
33
|
+
required: true,
|
|
34
|
+
description: 'Used to sign Time-Signature = HMAC-SHA1(Time-Stamp, connectId)',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.PEAKApi = PEAKApi;
|
|
40
|
+
//# sourceMappingURL=PEAKApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PEAKApi.credentials.js","sourceRoot":"","sources":["../../credentials/PEAKApi.credentials.ts"],"names":[],"mappings":";;;AAKA,MAAa,OAAO;IAApB;QACC,SAAI,GAAG,SAAS,CAAC;QACjB,gBAAW,GAAG,UAAU,CAAC;QACzB,qBAAgB,GAAG,yDAAyD,CAAC;QAE7E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,wBAAwB;aACrC;YACD;gBACC,WAAW,EAAE,uBAAuB;gBACpC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,gEAAgE;aAC7E;SACD,CAAC;IACH,CAAC;CAAA;AAjCD,0BAiCC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatTimestamp = formatTimestamp;
|
|
7
|
+
exports.hmacSha1Hex = hmacSha1Hex;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
function formatTimestamp(date, useLocal = false) {
|
|
10
|
+
const d = date;
|
|
11
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
12
|
+
const yyyy = useLocal ? d.getFullYear() : d.getUTCFullYear();
|
|
13
|
+
const MM = pad((useLocal ? d.getMonth() : d.getUTCMonth()) + 1);
|
|
14
|
+
const dd = pad(useLocal ? d.getDate() : d.getUTCDate());
|
|
15
|
+
const HH = pad(useLocal ? d.getHours() : d.getUTCHours());
|
|
16
|
+
const mm = pad(useLocal ? d.getMinutes() : d.getUTCMinutes());
|
|
17
|
+
const ss = pad(useLocal ? d.getSeconds() : d.getUTCSeconds());
|
|
18
|
+
return `${yyyy}${MM}${dd}${HH}${mm}${ss}`;
|
|
19
|
+
}
|
|
20
|
+
function hmacSha1Hex(key, message) {
|
|
21
|
+
return crypto_1.default.createHmac('sha1', key).update(message, 'utf8').digest('hex');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../helpers/time.ts"],"names":[],"mappings":";;;;;AAGA,0CAUC;AAGD,kCAEC;AAlBD,oDAA4B;AAG5B,SAAgB,eAAe,CAAC,IAAU,EAAE,QAAQ,GAAG,KAAK;IAC1D,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;IAC7D,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IACxD,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;IAC9D,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;IAC9D,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;AAC5C,CAAC;AAGD,SAAgB,WAAW,CAAC,GAAW,EAAE,OAAe;IACtD,OAAO,gBAAM,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class GetContact implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetContact = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const time_1 = require("../../helpers/time");
|
|
6
|
+
class GetContact {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'Get Contact',
|
|
10
|
+
name: 'getContact',
|
|
11
|
+
icon: 'file:../../assets/PEAK.svg',
|
|
12
|
+
group: ['input'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
15
|
+
description: 'Send parameter to get contact via PEAK API',
|
|
16
|
+
defaults: {
|
|
17
|
+
name: 'Get Contact',
|
|
18
|
+
},
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
credentials: [{ name: 'PEAKApi', required: true }],
|
|
22
|
+
usableAsTool: true,
|
|
23
|
+
properties: [
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Server Environment',
|
|
26
|
+
name: 'serverEnvironment',
|
|
27
|
+
type: 'options',
|
|
28
|
+
typeOptions: { rows: 1 },
|
|
29
|
+
default: 'production',
|
|
30
|
+
required: true,
|
|
31
|
+
description: 'Product ID to retrieve',
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
name: 'UAT',
|
|
35
|
+
value: 'uat',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Production',
|
|
39
|
+
value: 'production',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Contact ID',
|
|
45
|
+
name: 'contactId',
|
|
46
|
+
type: 'string',
|
|
47
|
+
typeOptions: { rows: 1 },
|
|
48
|
+
default: '',
|
|
49
|
+
required: false,
|
|
50
|
+
description: 'Contact ID to retrieve',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Contact Code',
|
|
54
|
+
name: 'contactCode',
|
|
55
|
+
type: 'string',
|
|
56
|
+
typeOptions: { rows: 1 },
|
|
57
|
+
default: '',
|
|
58
|
+
required: false,
|
|
59
|
+
description: 'Contact code to retrieve',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Client Token (override)',
|
|
63
|
+
name: 'clientTokenOverride',
|
|
64
|
+
type: 'string',
|
|
65
|
+
typeOptions: { password: true },
|
|
66
|
+
default: '',
|
|
67
|
+
description: 'Optional override (useful when token refreshes every 24h)',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async execute() {
|
|
73
|
+
const items = this.getInputData();
|
|
74
|
+
const returnData = [];
|
|
75
|
+
const creds = (await this.getCredentials('PEAKApi'));
|
|
76
|
+
const userToken = creds.userToken;
|
|
77
|
+
const connectId = creds.connectId;
|
|
78
|
+
const endpointUrl = 'https://peakengineapidev.azurewebsites.net/api/v1/contacts';
|
|
79
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
80
|
+
try {
|
|
81
|
+
const serverEnv = this.getNodeParameter('serverEnvironment', itemIndex, '');
|
|
82
|
+
const contactId = this.getNodeParameter('contactId', itemIndex, '');
|
|
83
|
+
const contactCode = this.getNodeParameter('contactCode', itemIndex, '');
|
|
84
|
+
const clientTokenOverride = this.getNodeParameter('clientTokenOverride', itemIndex, '');
|
|
85
|
+
if (serverEnv === 'production') {
|
|
86
|
+
endpointUrl.replace('peakengineapidev.azurewebsites.net', 'api.peakaccount.com');
|
|
87
|
+
}
|
|
88
|
+
let endpointWithParams = endpointUrl + '?';
|
|
89
|
+
const clientToken = clientTokenOverride || creds.clientToken;
|
|
90
|
+
if (!clientToken)
|
|
91
|
+
throw new Error('Client Token is required (credentials or override).');
|
|
92
|
+
if (contactId !== '') {
|
|
93
|
+
endpointWithParams += `id=${encodeURIComponent(contactId)}`;
|
|
94
|
+
}
|
|
95
|
+
if (contactCode !== '') {
|
|
96
|
+
endpointWithParams += `code=${encodeURIComponent(contactCode)}`;
|
|
97
|
+
}
|
|
98
|
+
const timeStamp = (0, time_1.formatTimestamp)(new Date(), false);
|
|
99
|
+
const timeSignature = (0, time_1.hmacSha1Hex)(connectId, timeStamp);
|
|
100
|
+
const headers = {
|
|
101
|
+
'User-Token': userToken,
|
|
102
|
+
'Client-Token': clientToken,
|
|
103
|
+
'Time-Stamp': timeStamp,
|
|
104
|
+
'Time-Signature': timeSignature,
|
|
105
|
+
'Content-Type': 'application/json',
|
|
106
|
+
};
|
|
107
|
+
const options = {
|
|
108
|
+
method: 'GET',
|
|
109
|
+
url: endpointWithParams,
|
|
110
|
+
headers,
|
|
111
|
+
json: true,
|
|
112
|
+
};
|
|
113
|
+
const response = await this.helpers.request(options);
|
|
114
|
+
returnData.push({
|
|
115
|
+
json: {
|
|
116
|
+
success: true,
|
|
117
|
+
statusCode: 200,
|
|
118
|
+
data: response,
|
|
119
|
+
headers,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (this.continueOnFail()) {
|
|
125
|
+
returnData.push({
|
|
126
|
+
json: { error: error.message },
|
|
127
|
+
pairedItem: { item: itemIndex },
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (error.context) {
|
|
132
|
+
error.context.itemIndex = itemIndex;
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
136
|
+
itemIndex,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return [returnData];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.GetContact = GetContact;
|
|
145
|
+
//# sourceMappingURL=GetContact.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetContact.node.js","sourceRoot":"","sources":["../../../nodes/Contact/GetContact.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAClD,6CAAkE;AAQlE,MAAa,UAAU;IAAvB;QACI,gBAAW,GAAyB;YAChC,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,YAAY;YACxB,IAAI,EAAE,4BAA4B;YAC5B,KAAK,EAAE,CAAC,OAAO,CAAC;YAChB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8BAA8B;YACxC,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE;gBACN,IAAI,EAAE,aAAa;aACtB;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAClD,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE;gBACR;oBACI,WAAW,EAAE,oBAAoB;oBACjC,IAAI,EAAE,mBAAmB;oBACzB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;oBACxB,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,wBAAwB;oBACrC,OAAO,EAAE;wBACL;4BACI,IAAI,EAAE,KAAK;4BACX,KAAK,EAAE,KAAK;yBACf;wBACD;4BACI,IAAI,EAAE,YAAY;4BAClB,KAAK,EAAE,YAAY;yBACtB;qBACJ;iBACJ;gBAED;oBACI,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;oBACxB,OAAO,EAAE,EAAE;oBACX,QAAQ,EAAE,KAAK;oBACf,WAAW,EAAE,wBAAwB;iBACxC;gBAED;oBACI,WAAW,EAAE,cAAc;oBAC3B,I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BACf,IAAI,EAAE,QAAQ;wBACd,OAAO;qBACV;iBACJ,CAAC,CAAC;YAEP,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBACxB,UAAU,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE;wBACzC,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;qBAClC,CAAC,CAAC;gBACP,CAAC;qBAAM,CAAC;oBACJ,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;wBAChB,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;wBACpC,MAAM,KAAK,CAAC;oBAChB,CAAC;oBACD,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE;wBAChD,SAAS;qBACZ,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AAvJD,gCAuJC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CreateDailyJournal implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateDailyJournal = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const time_1 = require("../../helpers/time");
|
|
6
|
+
class CreateDailyJournal {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'Create Daily Journal',
|
|
10
|
+
name: 'createDailyJournal',
|
|
11
|
+
icon: 'file:../../assets/PEAK.svg',
|
|
12
|
+
group: ['output'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
15
|
+
description: 'Send JSON payload to create daily journal via PEAK API',
|
|
16
|
+
defaults: {
|
|
17
|
+
name: 'Create DailyJournal',
|
|
18
|
+
},
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
credentials: [{ name: 'PEAKApi', required: true }],
|
|
22
|
+
usableAsTool: true,
|
|
23
|
+
properties: [
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Server Environment',
|
|
26
|
+
name: 'serverEnvironment',
|
|
27
|
+
type: 'options',
|
|
28
|
+
typeOptions: { rows: 1 },
|
|
29
|
+
default: 'production',
|
|
30
|
+
required: true,
|
|
31
|
+
description: 'Product ID to retrieve',
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
name: 'UAT',
|
|
35
|
+
value: 'uat',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Production',
|
|
39
|
+
value: 'production',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'JSON Body',
|
|
45
|
+
name: 'jsonBody',
|
|
46
|
+
type: 'string',
|
|
47
|
+
typeOptions: { rows: 10 },
|
|
48
|
+
default: '{\n "merchantId": "241027",\n "issueDate": "2025-10-16",\n "items": []\n}',
|
|
49
|
+
required: true,
|
|
50
|
+
description: 'Raw JSON payload (you can map from previous node with {{$json}})',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Client Token (override)',
|
|
54
|
+
name: 'clientTokenOverride',
|
|
55
|
+
type: 'string',
|
|
56
|
+
typeOptions: { password: true },
|
|
57
|
+
default: '',
|
|
58
|
+
description: 'Optional override (useful when token refreshes every 24h)',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async execute() {
|
|
64
|
+
const items = this.getInputData();
|
|
65
|
+
const returnData = [];
|
|
66
|
+
const creds = (await this.getCredentials('PEAKApi'));
|
|
67
|
+
const userToken = creds.userToken;
|
|
68
|
+
const connectId = creds.connectId;
|
|
69
|
+
const endpointUrl = 'https://peakengineapidev.azurewebsites.net/api/v1/dailyJournals';
|
|
70
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
71
|
+
try {
|
|
72
|
+
const serverEnv = this.getNodeParameter('serverEnvironment', itemIndex, '');
|
|
73
|
+
const jsonBodyStr = this.getNodeParameter('jsonBody', itemIndex);
|
|
74
|
+
const clientTokenOverride = this.getNodeParameter('clientTokenOverride', itemIndex, '');
|
|
75
|
+
if (serverEnv === 'production') {
|
|
76
|
+
endpointUrl.replace('peakengineapidev.azurewebsites.net', 'api.peakaccount.com');
|
|
77
|
+
}
|
|
78
|
+
const clientToken = clientTokenOverride || creds.clientToken;
|
|
79
|
+
if (!clientToken)
|
|
80
|
+
throw new Error('Client Token is required (credentials or override).');
|
|
81
|
+
let bodyObj;
|
|
82
|
+
try {
|
|
83
|
+
bodyObj = JSON.parse(jsonBodyStr);
|
|
84
|
+
if (typeof bodyObj !== 'object' || bodyObj === null) {
|
|
85
|
+
throw new Error('JSON Body must be an object.');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
throw new Error('Invalid JSON Body.');
|
|
90
|
+
}
|
|
91
|
+
const timeStamp = (0, time_1.formatTimestamp)(new Date(), false);
|
|
92
|
+
const timeSignature = (0, time_1.hmacSha1Hex)(connectId, timeStamp);
|
|
93
|
+
const headers = {
|
|
94
|
+
'User-Token': userToken,
|
|
95
|
+
'Client-Token': clientToken,
|
|
96
|
+
'Time-Stamp': timeStamp,
|
|
97
|
+
'Time-Signature': timeSignature,
|
|
98
|
+
'Content-Type': 'application/json',
|
|
99
|
+
};
|
|
100
|
+
const options = {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
url: endpointUrl,
|
|
103
|
+
headers,
|
|
104
|
+
body: bodyObj,
|
|
105
|
+
json: true,
|
|
106
|
+
};
|
|
107
|
+
const response = await this.helpers.request(options);
|
|
108
|
+
returnData.push({
|
|
109
|
+
json: {
|
|
110
|
+
success: true,
|
|
111
|
+
statusCode: 200,
|
|
112
|
+
data: response,
|
|
113
|
+
headers,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (this.continueOnFail()) {
|
|
119
|
+
returnData.push({
|
|
120
|
+
json: { error: error.message },
|
|
121
|
+
pairedItem: { item: itemIndex },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
if (error.context) {
|
|
126
|
+
error.context.itemIndex = itemIndex;
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
130
|
+
itemIndex,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [returnData];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.CreateDailyJournal = CreateDailyJournal;
|
|
139
|
+
//# sourceMappingURL=CreateDailyJournal.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateDailyJournal.node.js","sourceRoot":"","sources":["../../../nodes/DailyJournal/CreateDailyJournal.node.ts"],"names":[],"mappings":";;;AAOA,+CAAkD;AAClD,6CAAkE;AAQlE,MAAa,kBAAkB;IAA/B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,sBAAsB;YACnC,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,4BAA4B;YAClC,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8BAA8B;YACxC,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE;gBACT,IAAI,EAA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AC;IACrB,CAAC;CACD;AA9ID,gDA8IC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class GetAccountCode implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|