diff --git a/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs new file mode 100644 index 0000000000000..d508482bc5d59 --- /dev/null +++ b/components/callerapi/actions/get-phone-number-information/get-phone-number-information.mjs @@ -0,0 +1,26 @@ +import callerapi from "../../callerapi.app.mjs"; + +export default { + key: "callerapi-get-phone-number-information", + name: "Get Phone Number Information", + description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://callerapi.com/documentation)", + version: "0.0.1", + type: "action", + props: { + callerapi, + phoneNumber: { + propDefinition: [ + callerapi, + "phoneNumber", + ], + }, + }, + async run({ $ }) { + const response = await this.callerapi.getPhoneInfo({ + $, + phoneNumber: this.phoneNumber, + }); + $.export("$summary", `Retrieved information for phone number ${this.phoneNumber}`); + return response; + }, +}; diff --git a/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs new file mode 100644 index 0000000000000..d46ec5b7c1d9d --- /dev/null +++ b/components/callerapi/actions/get-phone-number-picture/get-phone-number-picture.mjs @@ -0,0 +1,39 @@ +import { ConfigurationError } from "@pipedream/platform"; +import fs from "fs"; +import callerapi from "../../callerapi.app.mjs"; + +export default { + key: "callerapi-get-phone-number-picture", + name: "Get Phone Number Picture", + description: "Retrieve the profile picture associated with a phone number. [See the documentation](https://callerapi.com/documentation)", + version: "0.0.1", + type: "action", + props: { + callerapi, + phoneNumber: { + propDefinition: [ + callerapi, + "phoneNumber", + ], + description: "The phone number to retrieve the profile picture for, in E.164 format (e.g., +18006927753)", + }, + }, + async run({ $ }) { + try { + const response = await this.callerapi.getPhonePicture({ + $, + phoneNumber: this.phoneNumber, + }); + const fileName = `CallerAPI-Pictgure-${Date.parse(new Date())}.png`; + const buf = Buffer.from(response, "base64"); + fs.writeFileSync(`/tmp/${fileName}`, buf); + + $.export("$summary", `The profile picture for ${this.phoneNumber} has been successfully retrieved and saved to the /tmp directory.`); + return { + path: `/tmp/${fileName}`, + }; + } catch (e) { + throw new ConfigurationError(e?.response?.data || e); + } + }, +}; diff --git a/components/callerapi/callerapi.app.mjs b/components/callerapi/callerapi.app.mjs index 8fa151ce9331b..4820ef3912edc 100644 --- a/components/callerapi/callerapi.app.mjs +++ b/components/callerapi/callerapi.app.mjs @@ -1,11 +1,49 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "callerapi", - propDefinitions: {}, + propDefinitions: { + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://callerapi.com/api/phone"; + }, + _headers() { + return { + "x-auth": this.$auth.api_key, + }; + }, + _makeRequest({ + $ = this, method, path = "/", ...opts + }) { + return axios($, { + ...opts, + method, + url: this._baseUrl() + path, + headers: this._headers(), + }); + }, + getPhoneInfo({ + $, phoneNumber, + }) { + return this._makeRequest({ + $, + path: `/info/${phoneNumber}`, + }); + }, + getPhonePicture({ + $, phoneNumber, + }) { + return this._makeRequest({ + $, + path: `/pic/${phoneNumber}`, + }); }, }, }; diff --git a/components/callerapi/package.json b/components/callerapi/package.json index 6153acac036ca..8b4dcc7f8f74c 100644 --- a/components/callerapi/package.json +++ b/components/callerapi/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/callerapi", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream CallerAPI Components", "main": "callerapi.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/richpanel/richpanel.app.mjs b/components/richpanel/richpanel.app.mjs index 977736076b668..8b09379770ea3 100644 --- a/components/richpanel/richpanel.app.mjs +++ b/components/richpanel/richpanel.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35c70903974b6..21581c92b5adb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1511,7 +1511,11 @@ importers: components/call_fire: {} - components/callerapi: {} + components/callerapi: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/callhub: dependencies: @@ -24652,22 +24656,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} @@ -30859,6 +30863,8 @@ 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: