diff --git a/components/real_id/actions/create-id-check/create-id-check.mjs b/components/real_id/actions/create-id-check/create-id-check.mjs new file mode 100644 index 0000000000000..2f272c8eb78fb --- /dev/null +++ b/components/real_id/actions/create-id-check/create-id-check.mjs @@ -0,0 +1,123 @@ +import app from "../../real_id.app.mjs"; + +export default { + key: "real_id-create-id-check", + name: "Create ID Check", + description: "Create a new ID check for a user. [See the documentation](https://getverdict.com/help/docs/api/checks#create-an-id-check).", + version: "0.0.1", + type: "action", + props: { + app, + // eslint-disable-next-line pipedream/props-label, pipedream/props-description + info: { + type: "alert", + alertType: "info", + content: "Either the **Email** or the **Phone** number is required to create an ID check.", + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + phone: { + propDefinition: [ + app, + "phone", + ], + }, + firstName: { + type: "string", + label: "First Name", + description: "First name of the customer", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "Last name of the customer", + optional: true, + }, + wooCommerceCustomerId: { + type: "string", + label: "WooCommerce Customer ID", + description: "Unique identifier for the customer in WooCommerce", + optional: true, + }, + wooCommerceOrderId: { + type: "string", + label: "WooCommerce Order ID", + description: "Unique identifier for the order in WooCommerce", + optional: true, + }, + shopifyAdminGraphqlId: { + type: "string", + label: "Shopify Admin GraphQL ID", + description: "Unique identifier for the customer in Shopify", + optional: true, + }, + shopifyAdminGraphqlOrderId: { + type: "string", + label: "Shopify Admin GraphQL Order ID", + description: "Unique identifier for the order in Shopify", + optional: true, + }, + shopifyAdminGraphqlOrderName: { + type: "string", + label: "Shopify Admin GraphQL Order Name", + description: "Name of the order in Shopify", + optional: true, + }, + additionalParameters: { + type: "object", + label: "Additional Parameters", + description: "Additional parameters to include in the request", + optional: true, + }, + }, + methods: { + createIdCheck(args = {}) { + return this.app.post({ + path: "/checks", + ...args, + }); + }, + }, + async run({ $ }) { + const { + createIdCheck, + email, + phone, + firstName, + lastName, + wooCommerceCustomerId, + wooCommerceOrderId, + shopifyAdminGraphqlId, + shopifyAdminGraphqlOrderId, + shopifyAdminGraphqlOrderName, + additionalParameters, + } = this; + + const response = await createIdCheck({ + $, + data: { + customer: { + first_name: firstName, + last_name: lastName, + email, + phone, + wc_id: wooCommerceCustomerId, + shopify_admin_graphql_id: shopifyAdminGraphqlId, + }, + order: { + wc_id: wooCommerceOrderId, + shopify_admin_graphql_id: shopifyAdminGraphqlOrderId, + name: shopifyAdminGraphqlOrderName, + }, + ...additionalParameters, + }, + }); + $.export("$summary", "Successfully created ID check."); + return response; + }, +}; diff --git a/components/real_id/actions/delete-id-check/delete-id-check.mjs b/components/real_id/actions/delete-id-check/delete-id-check.mjs new file mode 100644 index 0000000000000..20ebe86e82426 --- /dev/null +++ b/components/real_id/actions/delete-id-check/delete-id-check.mjs @@ -0,0 +1,41 @@ +import app from "../../real_id.app.mjs"; + +export default { + key: "real_id-delete-id-check", + name: "Delete ID Check", + description: "Permanently delete all data associated with a specific ID check. [See the documentation](https://getverdict.com/help/docs/api/checks#delete-id-check-data).", + version: "0.0.1", + type: "action", + props: { + app, + checkId: { + propDefinition: [ + app, + "checkId", + ], + }, + }, + methods: { + deleteIdCheck({ + checkId, ...args + } = {}) { + return this.app.delete({ + path: `/checks/${checkId}`, + ...args, + }); + }, + }, + async run({ $ }) { + const { + deleteIdCheck, + checkId, + } = this; + + const response = await deleteIdCheck({ + $, + checkId, + }); + $.export("$summary", `Successfully deleted ID check \`${response.check.id}\`.`); + return response; + }, +}; diff --git a/components/real_id/actions/get-id-check/get-id-check.mjs b/components/real_id/actions/get-id-check/get-id-check.mjs new file mode 100644 index 0000000000000..ab863ae7bcba3 --- /dev/null +++ b/components/real_id/actions/get-id-check/get-id-check.mjs @@ -0,0 +1,52 @@ +import app from "../../real_id.app.mjs"; + +export default { + key: "real_id-get-id-check", + name: "Get ID Check", + description: "Retrieve an ID check. [See the documentation](https://getverdict.com/help/docs/api/checks#retrieve-an-id-check).", + version: "0.0.1", + type: "action", + props: { + app, + checkId: { + propDefinition: [ + app, + "checkId", + ], + }, + withPhotos: { + type: "boolean", + label: "Include Photos", + description: "All photos will be provided as short lived URLs in the API response under the `photos` key.", + optional: true, + }, + }, + methods: { + retrieveIdCheck({ + checkId, ...args + } = {}) { + return this.app._makeRequest({ + path: `/checks/${checkId}`, + ...args, + }); + }, + }, + async run({ $ }) { + const { + retrieveIdCheck, + checkId, + withPhotos, + } = this; + + const response = await retrieveIdCheck({ + $, + checkId, + params: { + withPhotos, + }, + }); + + $.export("$summary", "Successfully retrieved ID check."); + return response; + }, +}; diff --git a/components/real_id/package.json b/components/real_id/package.json index 1cfdffde352f9..9d65f5d460b56 100644 --- a/components/real_id/package.json +++ b/components/real_id/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/real_id", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Real ID Components", "main": "real_id.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/real_id/real_id.app.mjs b/components/real_id/real_id.app.mjs index 37e422174691a..ac1f236fbd1f9 100644 --- a/components/real_id/real_id.app.mjs +++ b/components/real_id/real_id.app.mjs @@ -1,11 +1,58 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "real_id", - propDefinitions: {}, + propDefinitions: { + email: { + type: "string", + label: "Email", + description: "Email address for initiating the ID check", + optional: true, + }, + phone: { + type: "string", + label: "Phone Number", + description: "Phone number for initiating the ID check", + optional: true, + }, + checkId: { + type: "string", + label: "ID Check Identifier", + description: "The unique identifier for the ID check", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://real-id.getverdict.com/api/v1${path}`; + }, + getHeaders(headers) { + return { + "Authorization": `Bearer ${this.$auth.api_key}`, + "Content-Type": "application/json", + ...headers, + }; + }, + _makeRequest({ + $ = this, path, headers, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + headers: this.getHeaders(headers), + }); + }, + post(args = {}) { + return this._makeRequest({ + method: "POST", + ...args, + }); + }, + delete(args = {}) { + return this._makeRequest({ + method: "DELETE", + ...args, + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5c25e482922d..9b25c85b37ff4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10087,7 +10087,11 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/real_id: {} + components/real_id: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/realgeeks: dependencies: @@ -33966,8 +33970,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: