Skip to content

Commit deb8554

Browse files
Add Csvbox integration with import event trigger and sample row functionality (#18982)
* Code: Custom CSVBOX source implemented * code: fixes added for calling csvbox api we getting response from API * Fix: updated API from constant * Fixed: Removed unnecessory files and updated the source name * Fixed: fixed code issues for run function * Code: Fixed package json version * Code: unused code removed and improvements done * Fixed: fixed code repetation and avoiding unecessary ambiguity * Code: code improvements done * Code: fixed event name convention * Code: fixed error throw * Fix: fixed es-lint issues * pre install changes commited. Changes did by pre-push hook * Fixes: As per coe review changes has been made: 1. File rename from csvbox-new-row to new-row-instant 2. sample test file is created 3. Folder structure guidelines issue resolved * Fixed: Changed the destination folder from source to sources * Code: Pulled code changes from master * Fix: Issue resolved for not receiving multiple rows * Fix: added true property for sheetId
1 parent 2583778 commit deb8554

File tree

10 files changed

+29404
-1637
lines changed

10 files changed

+29404
-1637
lines changed

components/csvbox/actions/submit-spreadsheet/submit-spreadsheet.mjs

Lines changed: 0 additions & 119 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const BASE_URL = "https://api.csvbox.io/1.1/pipedream";
2+
3+
export default {
4+
BASE_URL,
5+
};

components/csvbox/csvbox.app.mjs

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,85 @@
11
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
23

34
export default {
45
type: "app",
56
app: "csvbox",
67
propDefinitions: {
7-
sheetLicenseKey: {
8+
sheetId: {
89
type: "string",
9-
label: "Sheet License Key",
10-
description: "The unique identifier for your CSVBox sheet. You can find it in **Sheets - Edit - Code Snippet - Sheet License Key**.",
11-
},
12-
userId: {
13-
type: "string",
14-
label: "User ID",
15-
description: "The unique identifier for the user. You can find it in the **Dashboard - Edit - Code Snippet**.",
16-
optional: true,
17-
},
18-
hasHeaders: {
19-
type: "boolean",
20-
label: "Has Headers",
21-
description: "Whether the spreadsheet has headers.",
22-
optional: true,
10+
label: "Sheet",
11+
description: "Select the sheet you want to receive data from",
12+
optional: false,
13+
async options() {
14+
const { data } = await this.listSheets();
15+
return data.map((sheet) => ({
16+
label: sheet.name,
17+
value: sheet.value,
18+
}));
19+
},
2320
},
2421
},
2522
methods: {
26-
getUrl(path) {
27-
return `https://api.csvbox.io/1.1${path}`;
23+
_getAuthKeys() {
24+
return this.$auth.api_key;
2825
},
29-
getHeaders(headers) {
26+
_getSecretAuthKeys() {
27+
return this.$auth.secret_api_key;
28+
},
29+
_getUrl(path) {
30+
return `${constants.BASE_URL}${path}`;
31+
},
32+
_getHeaders(headers) {
3033
return {
31-
"Content-Type": "application/json",
32-
"x-csvbox-api-key": `${this.$auth.api_key}`,
33-
"x-csvbox-secret-api-key": `${this.$auth.secret_api_key}`,
3434
...headers,
35+
"accept": "application/json",
36+
"Content-Type": "application/json",
37+
"x-csvbox-api-key": this._getAuthKeys(),
38+
"x-csvbox-secret-api-key": this._getSecretAuthKeys(),
3539
};
3640
},
37-
_makeRequest({
38-
$ = this, path, headers, ...args
41+
42+
async _makeRequest({
43+
$ = this, path, headers, ...otherConfig
3944
} = {}) {
40-
return axios($, {
41-
debug: true,
42-
url: this.getUrl(path),
43-
headers: this.getHeaders(headers),
45+
const config = {
46+
url: this._getUrl(path),
47+
headers: this._getHeaders(headers),
48+
returnFullResponse: true,
49+
...otherConfig,
50+
};
51+
return axios($, config);
52+
},
53+
54+
async createHook({
55+
data, ...args
56+
} = {}) {
57+
return this._makeRequest({
58+
method: "POST",
59+
path: "/register-webhook",
60+
data,
4461
...args,
4562
});
4663
},
47-
submitFile(args = {}) {
64+
65+
async deleteHook({
66+
data, ...args
67+
} = {}) {
4868
return this._makeRequest({
49-
method: "POST",
50-
path: "/file",
69+
method: "DELETE",
70+
path: "/delete-webhook",
71+
data,
72+
...args,
73+
});
74+
},
75+
76+
async listSheets(args = {}) {
77+
const res = await this._makeRequest({
78+
method: "GET",
79+
path: "/list-sheets",
5180
...args,
5281
});
82+
return res;
5383
},
5484
},
5585
};

components/csvbox/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/csvbox",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Pipedream CSVbox Components",
55
"main": "csvbox.app.mjs",
66
"keywords": [
@@ -13,7 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.1.1",
17-
"form-data": "^4.0.4"
16+
"@pipedream/platform": "^3.1.1"
1817
}
1918
}

components/csvbox/sources/new-import/new-import.mjs

Lines changed: 0 additions & 33 deletions
This file was deleted.

components/csvbox/sources/new-import/test-event.mjs

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)