Skip to content

Commit 31c13a7

Browse files
committed
callerapi init
1 parent 30a9f2c commit 31c13a7

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
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+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "callerapi-get-phone-number-information",
6+
name: "Get Phone Number Information",
7+
description: "Retrieve detailed information about a specific phone number, including name, location, and carrier. [See the documentation](https://github.com/dimondevceo/caller-id-api)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
callerapi: {
12+
type: "app",
13+
app: "callerapi",
14+
},
15+
phoneNumber: {
16+
type: "string",
17+
label: "Phone Number",
18+
description: "The phone number to retrieve information for (E.164 format, e.g., +18006927753)",
19+
},
20+
},
21+
async run({ $ }) {
22+
const response = await this.callerapi.getPhoneInfo(this.phoneNumber);
23+
$.export("$summary", `Retrieved information for phone number ${this.phoneNumber}`);
24+
return response;
25+
},
26+
};
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+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "callerapi-get-phone-number-picture",
6+
name: "Get Phone Number Picture",
7+
description: "Retrieve the profile picture associated with a phone number. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
callerapi: {
12+
type: "app",
13+
app: "callerapi",
14+
},
15+
phoneNumber: {
16+
type: "string",
17+
label: "Phone Number",
18+
description: "The phone number to retrieve the profile picture for, in E.164 format (e.g., +18006927753)",
19+
},
20+
},
21+
async run({ $ }) {
22+
const response = await this.callerapi.getPhonePicture(this.phoneNumber);
23+
$.export("$summary", `Retrieved profile picture for ${this.phoneNumber}`);
24+
return response;
25+
},
26+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "callerapi",
6+
version: "0.0.1",
47
propDefinitions: {},
58
methods: {
69
// this.$auth contains connected account data
710
authKeys() {
811
console.log(Object.keys(this.$auth));
912
},
13+
_baseUrl() {
14+
return "https://callerapi.com/api";
15+
},
16+
async _makeRequest(opts = {}) {
17+
const {
18+
$ = this, method = "GET", path = "/", headers, ...otherOpts
19+
} = opts;
20+
return axios($, {
21+
...otherOpts,
22+
method,
23+
url: this._baseUrl() + path,
24+
headers: {
25+
...headers,
26+
"X-Auth": this.$auth.api_key,
27+
},
28+
});
29+
},
30+
async getPhoneInfo(phoneNumber, opts = {}) {
31+
const phone = phoneNumber.replace(/^\+/, "");
32+
return this._makeRequest({
33+
method: "GET",
34+
path: `/phone/info/${phone}`,
35+
...opts,
36+
});
37+
},
38+
async getPhonePicture(phoneNumber, opts = {}) {
39+
const phone = phoneNumber.replace(/^\+/, "");
40+
return this._makeRequest({
41+
method: "GET",
42+
path: `/phone/pic/${phone}`,
43+
...opts,
44+
});
45+
},
1046
},
1147
};

components/callerapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)