Skip to content

Commit a8ede75

Browse files
lcaresiamichelle0927vunguyenhung
authored
[Components] klipfolio #13229 (#14693)
* Added actions * Update components/klipfolio/package.json Co-authored-by: michelle0927 <[email protected]> * Update components/klipfolio/package.json Co-authored-by: michelle0927 <[email protected]> * Update components/klipfolio/actions/update-datasource/update-datasource.mjs Co-authored-by: michelle0927 <[email protected]> * Fixed requested changes * Fixed requested changes * Update components/klipfolio/actions/update-datasource/update-datasource.mjs Co-authored-by: michelle0927 <[email protected]> * Added requested changes * Added requested changes * Done requests changes * Added actions * Make additional properties optional * Update klipfolio.app.mjs --------- Co-authored-by: michelle0927 <[email protected]> Co-authored-by: Leo Vu <[email protected]>
1 parent a91585d commit a8ede75

File tree

9 files changed

+332
-20
lines changed

9 files changed

+332
-20
lines changed

components/klipfolio/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import app from "../../klipfolio.app.mjs";
2+
3+
export default {
4+
key: "klipfolio-create-datasource",
5+
name: "Create Datasource",
6+
description: "Create a data source. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#post-datasources)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
propDefinition: [
13+
app,
14+
"name",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
format: {
24+
propDefinition: [
25+
app,
26+
"format",
27+
],
28+
},
29+
connector: {
30+
propDefinition: [
31+
app,
32+
"connector",
33+
],
34+
},
35+
refreshInterval: {
36+
propDefinition: [
37+
app,
38+
"refreshInterval",
39+
],
40+
},
41+
endpointUrl: {
42+
propDefinition: [
43+
app,
44+
"endpointUrl",
45+
],
46+
},
47+
method: {
48+
propDefinition: [
49+
app,
50+
"method",
51+
],
52+
},
53+
additionalProperties: {
54+
propDefinition: [
55+
app,
56+
"additionalProperties",
57+
],
58+
},
59+
},
60+
61+
async run({ $ }) {
62+
const response = await this.app.createDatasource({
63+
$,
64+
data: {
65+
name: this.name,
66+
description: this.description,
67+
format: this.format,
68+
connector: this.connector,
69+
refresh_interval: parseInt(this.refreshInterval, 10),
70+
properties: {
71+
endpoint_url: this.endpointUrl,
72+
method: this.method,
73+
...this.additionalProperties,
74+
},
75+
},
76+
});
77+
78+
$.export("$summary", `Successfully created Datasource named '${this.name}'`);
79+
80+
return response;
81+
},
82+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../klipfolio.app.mjs";
2+
3+
export default {
4+
key: "klipfolio-delete-datasource",
5+
name: "Delete Datasource",
6+
description: "Delete the data source associated with a specific data source ID. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#delete-datasourcesid)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
datasourceId: {
12+
propDefinition: [
13+
app,
14+
"datasourceId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteDatasource({
21+
$,
22+
datasourceId: this.datasourceId,
23+
});
24+
25+
$.export("$summary", `Successfully deleted datasource with ID: ${this.datasourceId}`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import app from "../../klipfolio.app.mjs";
2+
3+
export default {
4+
key: "klipfolio-update-datasource",
5+
name: "Update Datasource",
6+
description: "Update the specified data source. [See the documentation](https://apidocs.klipfolio.com/reference/data-sources#put-datasourcesid)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
datasourceId: {
12+
propDefinition: [
13+
app,
14+
"datasourceId",
15+
],
16+
},
17+
name: {
18+
propDefinition: [
19+
app,
20+
"name",
21+
],
22+
},
23+
description: {
24+
propDefinition: [
25+
app,
26+
"description",
27+
],
28+
},
29+
refreshInterval: {
30+
propDefinition: [
31+
app,
32+
"refreshInterval",
33+
],
34+
},
35+
},
36+
37+
async run({ $ }) {
38+
const response = await this.app.updateDatasource({
39+
$,
40+
datasourceId: this.datasourceId,
41+
data: {
42+
name: this.name,
43+
description: this.description,
44+
refresh_interval: parseInt(this.refreshInterval, 10),
45+
},
46+
});
47+
48+
$.export("$summary", `Successfully updated Datasource named '${this.name}'`);
49+
50+
return response;
51+
},
52+
};

components/klipfolio/app/klipfolio.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export default {
2+
DATASOURCE_CONNECTORS: [
3+
"box",
4+
"comscore",
5+
"db",
6+
"dropbox",
7+
"facebook",
8+
"ftp",
9+
"google_adwords",
10+
"google_analytics",
11+
"google_drive",
12+
"google_spreadsheets",
13+
"hubspot",
14+
"iformbuilder",
15+
"marketo",
16+
"omniture",
17+
"radian6",
18+
"salesforce",
19+
"searchMetrics",
20+
"shopify",
21+
"simple_rest",
22+
"survey_monkey",
23+
"versature",
24+
"xero",
25+
"xmla",
26+
],
27+
REFRESH_INTERVALS: [
28+
"0",
29+
"60",
30+
"300",
31+
"900",
32+
"1800",
33+
"3600",
34+
"7200",
35+
"10800",
36+
"14400",
37+
"43200",
38+
"86400",
39+
],
40+
};
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
4+
export default {
5+
type: "app",
6+
app: "klipfolio",
7+
propDefinitions: {
8+
name: {
9+
type: "string",
10+
label: "Name",
11+
description: "Name of the Datasource",
12+
},
13+
description: {
14+
type: "string",
15+
label: "Description",
16+
description: "Description of the Datasource",
17+
},
18+
format: {
19+
type: "string",
20+
label: "Format",
21+
description: "Format of the Datasource, i.e.: `xml`",
22+
},
23+
connector: {
24+
type: "string",
25+
label: "Connector",
26+
description: "Connector of the Datasource",
27+
options: constants.DATASOURCE_CONNECTORS,
28+
},
29+
refreshInterval: {
30+
type: "string",
31+
label: "Refresh Interval",
32+
description: "Refresh Interval of the Datasource",
33+
options: constants.REFRESH_INTERVALS,
34+
},
35+
endpointUrl: {
36+
type: "string",
37+
label: "Endpoint URL",
38+
description: "Endpoint URL of the Datasource, i.e.: `http://test/data/scatter.xml`",
39+
},
40+
method: {
41+
type: "string",
42+
label: "Method",
43+
description: "Method for the endpoint, i.e.: `GET`",
44+
},
45+
datasourceId: {
46+
type: "string",
47+
label: "Datasource ID",
48+
description: "ID of the Datasource",
49+
async options() {
50+
const response = await this.getDatasources();
51+
const datasourceIds = response.data.datasources;
52+
return datasourceIds.map(({
53+
id, name,
54+
}) => ({
55+
label: name,
56+
value: id,
57+
}));
58+
},
59+
},
60+
additionalProperties: {
61+
type: "object",
62+
label: "Additional Properties",
63+
description: "Data source additional properties. For example, Google Analytics API has the following properties: `oauth_provider_id`, `oauth_user_header`, `oauth_user_token`, `token_id`, `prop:profile_id`.",
64+
optional: true,
65+
},
66+
},
67+
methods: {
68+
_baseUrl() {
69+
return "https://app.klipfolio.com/api/1.0";
70+
},
71+
async _makeRequest(opts = {}) {
72+
const {
73+
$ = this,
74+
path,
75+
headers,
76+
...otherOpts
77+
} = opts;
78+
return axios($, {
79+
...otherOpts,
80+
url: this._baseUrl() + path,
81+
headers: {
82+
...headers,
83+
"kf-api-key": `${this.$auth.api_key}`,
84+
},
85+
});
86+
},
87+
async createDatasource(args = {}) {
88+
return this._makeRequest({
89+
path: "/datasources",
90+
method: "post",
91+
...args,
92+
});
93+
},
94+
async updateDatasource({
95+
datasourceId, ...args
96+
}) {
97+
return this._makeRequest({
98+
path: `/datasources/${datasourceId}`,
99+
method: "put",
100+
...args,
101+
});
102+
},
103+
async deleteDatasource({
104+
datasourceId, ...args
105+
}) {
106+
return this._makeRequest({
107+
path: `/datasources/${datasourceId}`,
108+
method: "delete",
109+
...args,
110+
});
111+
},
112+
async getDatasources(args = {}) {
113+
return this._makeRequest({
114+
path: "/datasources",
115+
...args,
116+
});
117+
},
118+
},
119+
};

components/klipfolio/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"name": "@pipedream/klipfolio",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Klipfolio Components",
5-
"main": "dist/app/klipfolio.app.mjs",
5+
"main": "klipfolio.app.mjs",
66
"keywords": [
77
"pipedream",
88
"klipfolio"
99
],
10-
"files": ["dist"],
1110
"homepage": "https://pipedream.com/apps/klipfolio",
1211
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1312
"publishConfig": {
1413
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1517
}
1618
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)