Skip to content

Commit 6073c07

Browse files
committed
Enhance Espy component with new actions and props
- Added new props for value and searchId in espy.app.mjs to facilitate lookups. - Implemented actions for email lookup, name lookup, and retrieving lookup results, each with corresponding methods for API interaction. - Updated package version to 0.1.0 and added dependency on @pipedream/platform. - Improved API request handling with a centralized method for making requests.
1 parent 43c37a6 commit 6073c07

File tree

5 files changed

+181
-7
lines changed

5 files changed

+181
-7
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../espy.app.mjs";
2+
3+
export default {
4+
key: "espy-email-lookup",
5+
name: "Email Lookup",
6+
description: "Request a lookup for the provided email. [See the documentation](https://api-docs.espysys.com/name-socialscan/headers-and-body-request-by-name-lookup)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
value: {
12+
propDefinition: [
13+
app,
14+
"value",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.emailLookup({
21+
$,
22+
data: {
23+
value: this.value,
24+
lookupId: 67,
25+
},
26+
});
27+
$.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`);
28+
29+
return response;
30+
},
31+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import app from "../../espy.app.mjs";
2+
3+
export default {
4+
key: "espy-get-lookup-results",
5+
name: "Get Lookup Results",
6+
description: "Get the results of the lookup with the provided ID. [See the documentation](https://api-docs.espysys.com/e-mail-lookup/get-get-lookup-data-for-a-request-by-e-mail-lookup)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
value: {
12+
propDefinition: [
13+
app,
14+
"value",
15+
],
16+
},
17+
searchId: {
18+
propDefinition: [
19+
app,
20+
"searchId",
21+
],
22+
},
23+
},
24+
25+
async run({ $ }) {
26+
const response = await this.app.getLookupResults({
27+
$,
28+
searchId: this.searchId,
29+
data: {
30+
value: this.value,
31+
},
32+
params: {
33+
key: `${this.app.$auth.api_key}`,
34+
},
35+
});
36+
$.export("$summary", `Successfully retrieved the details of the request with ID: '${this.searchId}'`);
37+
return response;
38+
},
39+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import app from "../../espy.app.mjs";
2+
3+
export default {
4+
key: "espy-name-lookup",
5+
name: "Name Lookup",
6+
description: "Request a lookup for the provided name. [See the documentation](https://api-docs.espysys.com/name-socialscan/headers-and-body-request-by-name-lookup)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
value: {
12+
propDefinition: [
13+
app,
14+
"value",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.nameLookup({
21+
$,
22+
data: {
23+
value: this.value,
24+
lookupId: 149,
25+
},
26+
});
27+
$.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`);
28+
return response;
29+
},
30+
};

components/espy/espy.app.mjs

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,82 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "espy",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
value: {
8+
type: "string",
9+
label: "Value",
10+
description: "Value to lookup",
11+
},
12+
searchId: {
13+
type: "string",
14+
label: "Search ID",
15+
description: "ID of the search",
16+
async options() {
17+
const response = await this.getSearchIds();
18+
const searchIds = response.list;
19+
return searchIds.map(({ id }) => ({
20+
value: id,
21+
}));
22+
},
23+
},
24+
},
525
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
26+
_baseUrl() {
27+
return "https://irbis.espysys.com/api";
28+
},
29+
async _makeRequest({
30+
$ = this,
31+
path,
32+
headers,
33+
data,
34+
...otherOpts
35+
} = {}) {
36+
return axios($, {
37+
...otherOpts,
38+
url: this._baseUrl() + path,
39+
headers: {
40+
...headers,
41+
"accept": "application/json",
42+
"content-type": "application/json",
43+
},
44+
data: {
45+
...data,
46+
key: `${this.$auth.api_key}`,
47+
},
48+
});
49+
},
50+
async emailLookup(args = {}) {
51+
return this._makeRequest({
52+
path: "/developer/combined_email",
53+
method: "post",
54+
...args,
55+
});
56+
},
57+
async nameLookup(args = {}) {
58+
return this._makeRequest({
59+
path: "/developer/combined_name",
60+
method: "post",
61+
...args,
62+
});
63+
},
64+
async getLookupResults({
65+
searchId, ...args
66+
}) {
67+
return this._makeRequest({
68+
path: `/request-monitor/api-usage/${searchId}`,
69+
...args,
70+
});
71+
},
72+
async getSearchIds(args = {}) {
73+
return this._makeRequest({
74+
path: "/request-monitor/api-usage",
75+
params: {
76+
key: `${this.$auth.api_key}`,
77+
},
78+
...args,
79+
});
980
},
1081
},
11-
};
82+
};

components/espy/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/espy",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream ESPY Components",
55
"main": "espy.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
}
15-
}
18+
}

0 commit comments

Comments
 (0)