Skip to content

Commit cec207b

Browse files
authored
New Components - callerapi (#15102)
* callerapi init * [Components] callerapi #14969 Actions - Get Phone Number Information - Get Phone Number Picture * pnpm update * pnpm update
1 parent d5341a6 commit cec207b

File tree

6 files changed

+124
-12
lines changed

6 files changed

+124
-12
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import callerapi from "../../callerapi.app.mjs";
2+
3+
export default {
4+
key: "callerapi-get-phone-number-information",
5+
name: "Get Phone Number Information",
6+
description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://callerapi.com/documentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
callerapi,
11+
phoneNumber: {
12+
propDefinition: [
13+
callerapi,
14+
"phoneNumber",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.callerapi.getPhoneInfo({
20+
$,
21+
phoneNumber: this.phoneNumber,
22+
});
23+
$.export("$summary", `Retrieved information for phone number ${this.phoneNumber}`);
24+
return response;
25+
},
26+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import fs from "fs";
3+
import callerapi from "../../callerapi.app.mjs";
4+
5+
export default {
6+
key: "callerapi-get-phone-number-picture",
7+
name: "Get Phone Number Picture",
8+
description: "Retrieve the profile picture associated with a phone number. [See the documentation](https://callerapi.com/documentation)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
callerapi,
13+
phoneNumber: {
14+
propDefinition: [
15+
callerapi,
16+
"phoneNumber",
17+
],
18+
description: "The phone number to retrieve the profile picture for, in E.164 format (e.g., +18006927753)",
19+
},
20+
},
21+
async run({ $ }) {
22+
try {
23+
const response = await this.callerapi.getPhonePicture({
24+
$,
25+
phoneNumber: this.phoneNumber,
26+
});
27+
const fileName = `CallerAPI-Pictgure-${Date.parse(new Date())}.png`;
28+
const buf = Buffer.from(response, "base64");
29+
fs.writeFileSync(`/tmp/${fileName}`, buf);
30+
31+
$.export("$summary", `The profile picture for ${this.phoneNumber} has been successfully retrieved and saved to the /tmp directory.`);
32+
return {
33+
path: `/tmp/${fileName}`,
34+
};
35+
} catch (e) {
36+
throw new ConfigurationError(e?.response?.data || e);
37+
}
38+
},
39+
};
Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "callerapi",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
phoneNumber: {
8+
type: "string",
9+
label: "Phone Number",
10+
description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)",
11+
},
12+
},
513
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
14+
_baseUrl() {
15+
return "https://callerapi.com/api/phone";
16+
},
17+
_headers() {
18+
return {
19+
"x-auth": this.$auth.api_key,
20+
};
21+
},
22+
_makeRequest({
23+
$ = this, method, path = "/", ...opts
24+
}) {
25+
return axios($, {
26+
...opts,
27+
method,
28+
url: this._baseUrl() + path,
29+
headers: this._headers(),
30+
});
31+
},
32+
getPhoneInfo({
33+
$, phoneNumber,
34+
}) {
35+
return this._makeRequest({
36+
$,
37+
path: `/info/${phoneNumber}`,
38+
});
39+
},
40+
getPhonePicture({
41+
$, phoneNumber,
42+
}) {
43+
return this._makeRequest({
44+
$,
45+
path: `/pic/${phoneNumber}`,
46+
});
947
},
1048
},
1149
};

components/callerapi/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/callerapi",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream CallerAPI Components",
55
"main": "callerapi.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

components/richpanel/richpanel.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

pnpm-lock.yaml

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)