From 83bc6456bd7dbc6f0a8f55c63fc55f9cc5aa4874 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 27 Nov 2024 12:52:11 -0300 Subject: [PATCH 1/3] Added actions --- .../actions/email-lookup/email-lookup.mjs | 32 ++++++++ .../get-lookup-results/get-lookup-results.mjs | 38 +++++++++ .../epsy/actions/name-lookup/name-lookup.mjs | 32 ++++++++ components/epsy/epsy.app.mjs | 81 +++++++++++++++++-- components/epsy/package.json | 7 +- pnpm-lock.yaml | 9 ++- 6 files changed, 189 insertions(+), 10 deletions(-) create mode 100644 components/epsy/actions/email-lookup/email-lookup.mjs create mode 100644 components/epsy/actions/get-lookup-results/get-lookup-results.mjs create mode 100644 components/epsy/actions/name-lookup/name-lookup.mjs diff --git a/components/epsy/actions/email-lookup/email-lookup.mjs b/components/epsy/actions/email-lookup/email-lookup.mjs new file mode 100644 index 0000000000000..e93e603d85abe --- /dev/null +++ b/components/epsy/actions/email-lookup/email-lookup.mjs @@ -0,0 +1,32 @@ +import app from "../../epsy.app.mjs"; + +export default { + key: "epsy-email-lookup", + name: "Email Lookup", + description: "Request a lookup for the provided email. [See the documentation](https://irbis.espysys.com/developer/)", + version: "0.0.1", + type: "action", + props: { + app, + value: { + propDefinition: [ + app, + "value", + ], + }, + }, + + async run({ $ }) { + const response = await this.app.emailLookup({ + $, + params: { + value: this.value, + lookupId: "67", + }, + }); + + $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); + + return response; + }, +}; diff --git a/components/epsy/actions/get-lookup-results/get-lookup-results.mjs b/components/epsy/actions/get-lookup-results/get-lookup-results.mjs new file mode 100644 index 0000000000000..cdffd5912de2b --- /dev/null +++ b/components/epsy/actions/get-lookup-results/get-lookup-results.mjs @@ -0,0 +1,38 @@ +import app from "../../epsy.app.mjs"; + +export default { + key: "epsy-get-lookup-results", + name: "Get Lookup Results", + description: "Get the results of the lookup with the provided ID. [See the documentation](https://irbis.espysys.com/developer/)", + version: "0.0.1", + type: "action", + props: { + app, + value: { + propDefinition: [ + app, + "value", + ], + }, + searchId: { + propDefinition: [ + app, + "searchId", + ], + }, + }, + + async run({ $ }) { + const response = await this.app.getLookupResults({ + $, + searchId: this.searchId, + params: { + value: this.value, + }, + }); + + $.export("$summary", `Successfully retrieved the details of the request with ID: '${this.searchId}'`); + + return response; + }, +}; diff --git a/components/epsy/actions/name-lookup/name-lookup.mjs b/components/epsy/actions/name-lookup/name-lookup.mjs new file mode 100644 index 0000000000000..68733e2ee94c5 --- /dev/null +++ b/components/epsy/actions/name-lookup/name-lookup.mjs @@ -0,0 +1,32 @@ +import app from "../../epsy.app.mjs"; + +export default { + key: "epsy-name-lookup", + name: "Name Lookup", + description: "Request a lookup for the provided name. [See the documentation](https://irbis.espysys.com/developer/)", + version: "0.0.1", + type: "action", + props: { + app, + value: { + propDefinition: [ + app, + "value", + ], + }, + }, + + async run({ $ }) { + const response = await this.app.nameLookup({ + $, + params: { + value: this.value, + lookupId: "149", + }, + }); + + $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); + + return response; + }, +}; diff --git a/components/epsy/epsy.app.mjs b/components/epsy/epsy.app.mjs index 6f0c39b41e25f..47fe79bb9915f 100644 --- a/components/epsy/epsy.app.mjs +++ b/components/epsy/epsy.app.mjs @@ -1,11 +1,82 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "epsy", - propDefinitions: {}, + propDefinitions: { + value: { + type: "string", + label: "Value", + description: "Value to lookup", + }, + searchId: { + type: "string", + label: "Search ID", + description: "ID of the search", + async options() { + const searchIds = await this.getSearchIds(); + return searchIds.map(({ + id, type, + }) => ({ + label: type, + value: id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://irbis.espysys.com/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + params, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + ...headers, + "accept": "application/json", + "content-type": "application/json", + }, + params: { + ...params, + key: `${this.$auth.api_key}`, + }, + }); + }, + async emailLookup(args = {}) { + return this._makeRequest({ + path: "/developer/combined_email", + method: "post", + ...args, + }); + }, + async nameLookup(args = {}) { + return this._makeRequest({ + path: "/developer/combined_name", + method: "post", + ...args, + }); + }, + async getLookupResults({ + searchId, ...args + }) { + return this._makeRequest({ + path: `/request-monitor/api-usage/${searchId}`, + ...args, + }); + }, + async getSearchIds(args = {}) { + return this._makeRequest({ + path: "/request-monitor/api-usage", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/epsy/package.json b/components/epsy/package.json index 87e1e27955783..37524ff531fa8 100644 --- a/components/epsy/package.json +++ b/components/epsy/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/epsy", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Epsy Components", "main": "epsy.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4043235b43205..7506af899a937 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -586,8 +586,7 @@ importers: components/amazon_polly: {} - components/amazon_selling_partner: - specifiers: {} + components/amazon_selling_partner: {} components/amazon_ses: dependencies: @@ -3165,7 +3164,11 @@ importers: components/eodhd_apis: {} - components/epsy: {} + components/epsy: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/equifax: {} From 75df85e8d8294a8fffafee3139ef58d7a8672572 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 5 Dec 2024 20:49:33 -0300 Subject: [PATCH 2/3] Fixed requested changes --- .../actions/email-lookup/email-lookup.mjs | 11 ++-- .../get-lookup-results/get-lookup-results.mjs | 7 +-- .../epsy/actions/name-lookup/name-lookup.mjs | 12 ++--- components/epsy/epsy.app.mjs | 52 ++++++++++++------- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/components/epsy/actions/email-lookup/email-lookup.mjs b/components/epsy/actions/email-lookup/email-lookup.mjs index e93e603d85abe..c7ae387a3fa2a 100644 --- a/components/epsy/actions/email-lookup/email-lookup.mjs +++ b/components/epsy/actions/email-lookup/email-lookup.mjs @@ -11,20 +11,19 @@ export default { value: { propDefinition: [ app, - "value", - ], + "value" + ] }, }, async run({ $ }) { const response = await this.app.emailLookup({ $, - params: { + data: { value: this.value, - lookupId: "67", - }, + lookupId: 67, + } }); - $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); return response; diff --git a/components/epsy/actions/get-lookup-results/get-lookup-results.mjs b/components/epsy/actions/get-lookup-results/get-lookup-results.mjs index cdffd5912de2b..3e29201876a5b 100644 --- a/components/epsy/actions/get-lookup-results/get-lookup-results.mjs +++ b/components/epsy/actions/get-lookup-results/get-lookup-results.mjs @@ -26,13 +26,14 @@ export default { const response = await this.app.getLookupResults({ $, searchId: this.searchId, - params: { + data: { value: this.value, }, + params: { + key: `${this.app.$auth.api_key}`, + }, }); - $.export("$summary", `Successfully retrieved the details of the request with ID: '${this.searchId}'`); - return response; }, }; diff --git a/components/epsy/actions/name-lookup/name-lookup.mjs b/components/epsy/actions/name-lookup/name-lookup.mjs index 68733e2ee94c5..59a35141ea890 100644 --- a/components/epsy/actions/name-lookup/name-lookup.mjs +++ b/components/epsy/actions/name-lookup/name-lookup.mjs @@ -11,22 +11,20 @@ export default { value: { propDefinition: [ app, - "value", - ], + "value" + ] }, }, async run({ $ }) { const response = await this.app.nameLookup({ $, - params: { + data: { value: this.value, - lookupId: "149", - }, + lookupId: 149, + } }); - $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); - return response; }, }; diff --git a/components/epsy/epsy.app.mjs b/components/epsy/epsy.app.mjs index 47fe79bb9915f..ce3881345d5ea 100644 --- a/components/epsy/epsy.app.mjs +++ b/components/epsy/epsy.app.mjs @@ -14,15 +14,13 @@ export default { label: "Search ID", description: "ID of the search", async options() { - const searchIds = await this.getSearchIds(); - return searchIds.map(({ - id, type, - }) => ({ - label: type, + const response = await this.getSearchIds(); + const searchIds = response.list; + return searchIds.map(({ id }) => ({ value: id, - })); - }, - }, + })) + } + } }, methods: { _baseUrl() { @@ -33,40 +31,51 @@ export default { $ = this, path, headers, - params, + data, ...otherOpts } = opts; + console.log("Request Options:", { + url: this._baseUrl() + path, + headers: { + ...headers, + accept: `application/json`, + "content-type": `application/json`, + }, + data: { + ...data, + key: `${this.$auth.api_key}`, + }, + ...otherOpts, + }); return axios($, { ...otherOpts, url: this._baseUrl() + path, headers: { ...headers, - "accept": "application/json", - "content-type": "application/json", + "accept": `application/json`, + "content-type": `application/json`, }, - params: { - ...params, + data: { + ...data, key: `${this.$auth.api_key}`, - }, + } }); }, async emailLookup(args = {}) { return this._makeRequest({ - path: "/developer/combined_email", + path: `/developer/combined_email`, method: "post", ...args, }); }, async nameLookup(args = {}) { return this._makeRequest({ - path: "/developer/combined_name", + path: `/developer/combined_name`, method: "post", ...args, }); }, - async getLookupResults({ - searchId, ...args - }) { + async getLookupResults({ searchId, ...args }) { return this._makeRequest({ path: `/request-monitor/api-usage/${searchId}`, ...args, @@ -74,7 +83,10 @@ export default { }, async getSearchIds(args = {}) { return this._makeRequest({ - path: "/request-monitor/api-usage", + path: `/request-monitor/api-usage`, + params: { + key: `${this.$auth.api_key}`, + }, ...args, }); }, From 59e98bac74b5f2e02dc1f3efadb92b95d78a4f85 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 5 Dec 2024 21:09:12 -0300 Subject: [PATCH 3/3] Added requested changes --- .../actions/email-lookup/email-lookup.mjs | 6 ++--- .../epsy/actions/name-lookup/name-lookup.mjs | 6 ++--- components/epsy/epsy.app.mjs | 26 ++++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/components/epsy/actions/email-lookup/email-lookup.mjs b/components/epsy/actions/email-lookup/email-lookup.mjs index c7ae387a3fa2a..16b3aa519c76a 100644 --- a/components/epsy/actions/email-lookup/email-lookup.mjs +++ b/components/epsy/actions/email-lookup/email-lookup.mjs @@ -11,8 +11,8 @@ export default { value: { propDefinition: [ app, - "value" - ] + "value", + ], }, }, @@ -22,7 +22,7 @@ export default { data: { value: this.value, lookupId: 67, - } + }, }); $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); diff --git a/components/epsy/actions/name-lookup/name-lookup.mjs b/components/epsy/actions/name-lookup/name-lookup.mjs index 59a35141ea890..d9ee0a0605bac 100644 --- a/components/epsy/actions/name-lookup/name-lookup.mjs +++ b/components/epsy/actions/name-lookup/name-lookup.mjs @@ -11,8 +11,8 @@ export default { value: { propDefinition: [ app, - "value" - ] + "value", + ], }, }, @@ -22,7 +22,7 @@ export default { data: { value: this.value, lookupId: 149, - } + }, }); $.export("$summary", `Successfully sent request. Use the ID to get the results: '${response.id}'`); return response; diff --git a/components/epsy/epsy.app.mjs b/components/epsy/epsy.app.mjs index ce3881345d5ea..68d30e4d4f900 100644 --- a/components/epsy/epsy.app.mjs +++ b/components/epsy/epsy.app.mjs @@ -18,9 +18,9 @@ export default { const searchIds = response.list; return searchIds.map(({ id }) => ({ value: id, - })) - } - } + })); + }, + }, }, methods: { _baseUrl() { @@ -38,8 +38,8 @@ export default { url: this._baseUrl() + path, headers: { ...headers, - accept: `application/json`, - "content-type": `application/json`, + "accept": "application/json", + "content-type": "application/json", }, data: { ...data, @@ -52,30 +52,32 @@ export default { url: this._baseUrl() + path, headers: { ...headers, - "accept": `application/json`, - "content-type": `application/json`, + "accept": "application/json", + "content-type": "application/json", }, data: { ...data, key: `${this.$auth.api_key}`, - } + }, }); }, async emailLookup(args = {}) { return this._makeRequest({ - path: `/developer/combined_email`, + path: "/developer/combined_email", method: "post", ...args, }); }, async nameLookup(args = {}) { return this._makeRequest({ - path: `/developer/combined_name`, + path: "/developer/combined_name", method: "post", ...args, }); }, - async getLookupResults({ searchId, ...args }) { + async getLookupResults({ + searchId, ...args + }) { return this._makeRequest({ path: `/request-monitor/api-usage/${searchId}`, ...args, @@ -83,7 +85,7 @@ export default { }, async getSearchIds(args = {}) { return this._makeRequest({ - path: `/request-monitor/api-usage`, + path: "/request-monitor/api-usage", params: { key: `${this.$auth.api_key}`, },