Skip to content

Commit ca816a1

Browse files
committed
google_appsheet init
1 parent d18cfcb commit ca816a1

File tree

4 files changed

+183
-0
lines changed

4 files changed

+183
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import appsheet from "../../appsheet.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "appsheet-add-row",
6+
name: "Add Row",
7+
description: "Adds a new row to a specific table in an AppSheet app. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
appsheet,
12+
rowData: {
13+
type: "object",
14+
label: "Row Data",
15+
description: "JSON object representing the new row data",
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.appsheet.addRow(this.rowData);
20+
$.export("$summary", "Added a new row successfully");
21+
return response;
22+
},
23+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import google_appsheet from "../../google_appsheet.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "google_appsheet-delete-row",
6+
name: "Delete Row",
7+
description: "Deletes a specific row from a table in an AppSheet app. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
google_appsheet: {
12+
type: "app",
13+
app: "google_appsheet",
14+
},
15+
rowId: {
16+
type: "string",
17+
label: "Row ID",
18+
description: "The ID of the row to delete",
19+
},
20+
},
21+
async run({ $ }) {
22+
const response = await this.google_appsheet.deleteRow(this.rowId);
23+
$.export("$summary", `Deleted row with ID ${this.rowId}`);
24+
return response;
25+
},
26+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import google_appsheet from "../../google_appsheet.app.mjs";
2+
3+
export default {
4+
key: "google_appsheet-update-row",
5+
name: "Update Row",
6+
description: "Updates an existing row in a specific table in an AppSheet app. [See the documentation]()",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
google_appsheet,
11+
rowId: {
12+
type: "string",
13+
label: "Row ID",
14+
description: "The ID of the row to update",
15+
},
16+
fieldsToUpdate: {
17+
type: "object",
18+
label: "Fields to Update",
19+
description: "Key-value pairs of fields to update",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.google_appsheet.updateRow(this.rowId, this.fieldsToUpdate);
24+
$.export("$summary", `Updated row with ID ${this.rowId}`);
25+
return response;
26+
},
27+
};
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "appsheet",
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
appsheetRegion: {
9+
type: "string",
10+
label: "AppSheet Region",
11+
description: "Domain used to invoke the API based on data residency regions",
12+
options: [
13+
{
14+
label: "Global (www.appsheet.com)",
15+
value: "www.appsheet.com",
16+
},
17+
{
18+
label: "EU (eu.appsheet.com)",
19+
value: "eu.appsheet.com",
20+
},
21+
],
22+
},
23+
appId: {
24+
type: "string",
25+
label: "App ID",
26+
description: "ID of the AppSheet app",
27+
},
28+
tableName: {
29+
type: "string",
30+
label: "Table Name",
31+
description: "Name of the table",
32+
},
33+
applicationAccessKey: {
34+
type: "string",
35+
label: "Application Access Key",
36+
description: "Access key for the AppSheet API",
37+
secret: true,
38+
},
39+
},
40+
methods: {
41+
_baseUrl() {
42+
return `https://${this.appsheetRegion}/api/v2/apps/${this.appId}/tables/${encodeURIComponent(this.tableName)}/Action`;
43+
},
44+
async _makeRequest(opts = {}) {
45+
const {
46+
$, method = "POST", data, headers = {}, ...otherOpts
47+
} = opts;
48+
return axios($, {
49+
method,
50+
url: `${this._baseUrl()}?applicationAccessKey=${this.applicationAccessKey}`,
51+
data,
52+
headers: {
53+
...headers,
54+
"Content-Type": "application/json",
55+
},
56+
...otherOpts,
57+
});
58+
},
59+
async addRow(rowData) {
60+
const requestBody = {
61+
Action: "Add",
62+
Properties: {
63+
Locale: "en-US",
64+
},
65+
Rows: [
66+
rowData,
67+
],
68+
};
69+
return this._makeRequest({
70+
data: requestBody,
71+
});
72+
},
73+
async updateRow(rowId, fieldsToUpdate) {
74+
const requestBody = {
75+
Action: "Edit",
76+
Properties: {
77+
Locale: "en-US",
78+
},
79+
Rows: [
80+
{
81+
RowId: rowId,
82+
...fieldsToUpdate,
83+
},
84+
],
85+
};
86+
return this._makeRequest({
87+
data: requestBody,
88+
});
89+
},
90+
async deleteRow(rowId) {
91+
const requestBody = {
92+
Action: "Delete",
93+
Properties: {
94+
Locale: "en-US",
95+
},
96+
Rows: [
97+
{
98+
RowId: rowId,
99+
},
100+
],
101+
};
102+
return this._makeRequest({
103+
data: requestBody,
104+
});
105+
},
106+
},
107+
};

0 commit comments

Comments
 (0)