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..16b3aa519c76a --- /dev/null +++ b/components/epsy/actions/email-lookup/email-lookup.mjs @@ -0,0 +1,31 @@ +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({ + $, + data: { + 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..3e29201876a5b --- /dev/null +++ b/components/epsy/actions/get-lookup-results/get-lookup-results.mjs @@ -0,0 +1,39 @@ +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, + 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 new file mode 100644 index 0000000000000..d9ee0a0605bac --- /dev/null +++ b/components/epsy/actions/name-lookup/name-lookup.mjs @@ -0,0 +1,30 @@ +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({ + $, + 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 6f0c39b41e25f..68d30e4d4f900 100644 --- a/components/epsy/epsy.app.mjs +++ b/components/epsy/epsy.app.mjs @@ -1,11 +1,96 @@ +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 response = await this.getSearchIds(); + const searchIds = response.list; + return searchIds.map(({ id }) => ({ + 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, + 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", + }, + data: { + ...data, + 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", + params: { + key: `${this.$auth.api_key}`, + }, + ...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 8a4463fb5dd78..8d637d640c3d3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3179,7 +3179,11 @@ importers: components/eodhd_apis: {} - components/epsy: {} + components/epsy: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/equifax: {}