diff --git a/components/xverify/actions/verify-address/verify-address.mjs b/components/xverify/actions/verify-address/verify-address.mjs new file mode 100644 index 0000000000000..cd087458fa198 --- /dev/null +++ b/components/xverify/actions/verify-address/verify-address.mjs @@ -0,0 +1,119 @@ +import app from "../../xverify.app.mjs"; + +export default { + key: "xverify-verify-address", + name: "Verify Address", + description: "Sends an address verification request. [See the documentation](https://apidocs.xverify.com/#address-verification-api-endpoint).", + version: "0.0.1", + type: "action", + props: { + app, + // eslint-disable-next-line pipedream/props-label, pipedream/props-description + info: { + type: "alert", + alertType: "info", + content: "**Note**: The `city`, `state`, and `zip` fields are optional. However, you must provide at least one of these fields to verify an address. If you provide all three fields, the API will use the city and state to verify the address.", + }, + domain: { + propDefinition: [ + app, + "domain", + ], + }, + address1: { + type: "string", + label: "Street Address 1", + description: "The street address to be verified.", + }, + address2: { + type: "string", + label: "Street Address 2", + description: "The second line of the street address to be verified.", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "The city of the address to be verified.", + optional: true, + }, + state: { + type: "string", + label: "State", + description: "The state of the address to be verified.", + optional: true, + }, + zip: { + type: "string", + label: "Zip Code", + description: "The postal code of the address to be verified. **Required** if city and state are not provided.", + optional: true, + }, + urbanization: { + type: "string", + label: "Urbanization", + description: "A component of certain addresses in Puerto Rico.", + optional: true, + }, + parse: { + type: "boolean", + label: "Parse Address", + description: "Set to `true` if you want the street address to be parsed into individual elements in the response.", + optional: true, + }, + aff: { + propDefinition: [ + app, + "aff", + ], + }, + subaff: { + propDefinition: [ + app, + "subaff", + ], + }, + }, + methods: { + verifyAddress(args = {}) { + return this.app._makeRequest({ + path: "/av", + ...args, + }); + }, + }, + async run({ $ }) { + const { + verifyAddress, + domain, + address1, + address2, + city, + state, + zip, + urbanization, + parse, + aff, + subaff, + } = this; + + const response = await verifyAddress({ + $, + params: { + domain, + address1, + address2, + city, + state, + zip, + urbanization, + parse, + aff, + subaff, + }, + }); + + $.export("$summary", `Successfully sent address verification request with status \`${response.status}\`.`); + return response; + }, +}; diff --git a/components/xverify/actions/verify-email/verify-email.mjs b/components/xverify/actions/verify-email/verify-email.mjs new file mode 100644 index 0000000000000..f8992f5acf079 --- /dev/null +++ b/components/xverify/actions/verify-email/verify-email.mjs @@ -0,0 +1,82 @@ +import app from "../../xverify.app.mjs"; + +export default { + key: "xverify-verify-email", + name: "Verify Email", + description: "Sends an email verification request. [See the documentation](https://apidocs.xverify.com/#email-verification-api-endpoint).", + version: "0.0.1", + type: "action", + props: { + app, + domain: { + propDefinition: [ + app, + "domain", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + ip: { + type: "string", + label: "IP Address", + description: "IP address from which a user submitted an email address. Can be used to detect fraudulent or risky submissions.", + optional: true, + }, + ua: { + type: "string", + label: "User Agent", + description: "User Agent of the browser that submitted the email address. Can be used to detect fraudlent or risky data.", + optional: true, + }, + aff: { + propDefinition: [ + app, + "aff", + ], + }, + subaff: { + propDefinition: [ + app, + "subaff", + ], + }, + }, + methods: { + verifyEmail(args = {}) { + return this.app._makeRequest({ + path: "/ev", + ...args, + }); + }, + }, + async run({ $ }) { + const { + verifyEmail, + domain, + email, + ip, + ua, + aff, + subaff, + } = this; + + const response = await verifyEmail({ + $, + params: { + domain, + email, + ip, + ua, + aff, + subaff, + }, + }); + + $.export("$summary", `Successfully sent email verification with status \`${response.status}\`.`); + return response; + }, +}; diff --git a/components/xverify/actions/verify-phone/verify-phone.mjs b/components/xverify/actions/verify-phone/verify-phone.mjs new file mode 100644 index 0000000000000..75c68fe8a7c16 --- /dev/null +++ b/components/xverify/actions/verify-phone/verify-phone.mjs @@ -0,0 +1,66 @@ +import app from "../../xverify.app.mjs"; + +export default { + key: "xverify-verify-phone", + name: "Verify Phone", + description: "Sends a phone verification request. [See the documentation](https://apidocs.xverify.com/#phone-verification-api-endpoint).", + version: "0.0.1", + type: "action", + props: { + app, + domain: { + propDefinition: [ + app, + "domain", + ], + }, + phone: { + propDefinition: [ + app, + "phone", + ], + }, + aff: { + propDefinition: [ + app, + "aff", + ], + }, + subaff: { + propDefinition: [ + app, + "subaff", + ], + }, + }, + methods: { + verifyPhone(args = {}) { + return this.app._makeRequest({ + path: "/pv", + ...args, + }); + }, + }, + async run({ $ }) { + const { + verifyPhone, + domain, + phone, + aff, + subaff, + } = this; + + const response = await verifyPhone({ + $, + params: { + domain, + phone, + aff, + subaff, + }, + }); + + $.export("$summary", `Successfully sent verification with status \`${response.status}\`.`); + return response; + }, +}; diff --git a/components/xverify/package.json b/components/xverify/package.json index 223a7530b697d..2ec36fc931451 100644 --- a/components/xverify/package.json +++ b/components/xverify/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/xverify", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Xverify Components", "main": "xverify.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/components/xverify/xverify.app.mjs b/components/xverify/xverify.app.mjs index 8b26f4a7496d3..734fc0ebbc0d4 100644 --- a/components/xverify/xverify.app.mjs +++ b/components/xverify/xverify.app.mjs @@ -1,11 +1,60 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "xverify", - propDefinitions: {}, + propDefinitions: { + domain: { + type: "string", + label: "Domain", + description: "The domain you have configured in your Xverify settings under which this query should be processed. See below.", + options() { + return [ + this.$auth.domain, + ]; + }, + }, + email: { + type: "string", + label: "Email Address", + description: "The email address to be validated (and optionally corrected).", + }, + aff: { + type: "string", + label: "Affiliate ID", + description: "The ID you define to identify the affiliate or source of the email for reporting or potential blocking.", + optional: true, + }, + subaff: { + type: "string", + label: "Sub-Affiliate ID", + description: "The sub-identifier you define for the affiliate or source of the email for reporting or potential blocking.", + optional: true, + }, + phone: { + type: "string", + label: "Phone Number", + description: "The phone number to be verified.", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://api.xverify.com/v2${path}`; + }, + getParams(params) { + return { + ...params, + api_key: this.$auth.api_key, + }; + }, + _makeRequest({ + $ = this, path, params, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + params: this.getParams(params), + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8618199468a14..856e1e10e5720 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11981,7 +11981,11 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/xverify: {} + components/xverify: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/y_gy: dependencies: @@ -31054,8 +31058,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: