Skip to content

Commit 874a7cf

Browse files
lcaresiasergio-eliot-rodriguez
authored andcommitted
Merging pull request PipedreamHQ#18376
1 parent e35feaf commit 874a7cf

File tree

6 files changed

+151
-7
lines changed

6 files changed

+151
-7
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../redcircle_api.app.mjs";
2+
3+
export default {
4+
key: "redcircle_api-add-zipcode",
5+
name: "Add Zipcode",
6+
description: "Add a zipcode to Redcircle API. [See the documentation](https://docs.trajectdata.com/redcircleapi/zipcodes-api/add)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
zipcode: {
12+
propDefinition: [
13+
app,
14+
"zipcode",
15+
],
16+
},
17+
domain: {
18+
propDefinition: [
19+
app,
20+
"domain",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.app.addZipcode({
26+
$,
27+
data: [
28+
{
29+
zipcode: this.zipcode,
30+
domain: this.domain,
31+
},
32+
],
33+
});
34+
$.export("$summary", "Successfully sent the request");
35+
return response;
36+
},
37+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import app from "../../redcircle_api.app.mjs";
2+
3+
export default {
4+
key: "redcircle_api-get-account-data",
5+
name: "Get Account Data",
6+
description: "Get your account details. [See the documentation](https://docs.trajectdata.com/redcircleapi/account-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
async run({ $ }) {
13+
const response = await this.app.getAccountData({
14+
$,
15+
});
16+
$.export("$summary", "Successfully retrieved the account data");
17+
return response;
18+
},
19+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import app from "../../redcircle_api.app.mjs";
2+
3+
export default {
4+
key: "redcircle_api-search-categories",
5+
name: "Search Categories",
6+
description: "Search for a category in Redcirle API. [See the documentation](https://docs.trajectdata.com/redcircleapi/categories-api/list-and-search)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
searchTerm: {
12+
propDefinition: [
13+
app,
14+
"searchTerm",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.searchCategories({
20+
$,
21+
params: {
22+
"search_term": this.searchTerm,
23+
},
24+
});
25+
$.export("$summary", "Successfully sent the request and retrieved " + response.categories.length + " categories");
26+
return response;
27+
},
28+
};

components/redcircle_api/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/redcircle_api",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream RedCircle API Components",
55
"main": "redcircle_api.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}
Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,64 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "redcircle_api",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
searchTerm: {
8+
type: "string",
9+
label: "Search Term",
10+
description: "The term to search for a category",
11+
optional: true,
12+
},
13+
zipcode: {
14+
type: "string",
15+
label: "Zipcode",
16+
description: "Description for zipcode",
17+
},
18+
domain: {
19+
type: "string",
20+
label: "Domain",
21+
description: "Description for domain",
22+
},
23+
},
524
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
25+
_baseUrl() {
26+
return "https://api.redcircleapi.com";
27+
},
28+
async _makeRequest(opts = {}) {
29+
const {
30+
$ = this,
31+
path,
32+
params,
33+
...otherOpts
34+
} = opts;
35+
return axios($, {
36+
...otherOpts,
37+
url: this._baseUrl() + path,
38+
params: {
39+
api_key: `${this.$auth.api_key}`,
40+
...params,
41+
},
42+
});
43+
},
44+
async searchCategories(args = {}) {
45+
return this._makeRequest({
46+
path: "/categories",
47+
...args,
48+
});
49+
},
50+
async getAccountData(args = {}) {
51+
return this._makeRequest({
52+
path: "/account",
53+
...args,
54+
});
55+
},
56+
async addZipcode(args = {}) {
57+
return this._makeRequest({
58+
path: "/zipcodes",
59+
method: "post",
60+
...args,
61+
});
962
},
1063
},
11-
};
64+
};

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)