Skip to content

Commit 5403da4

Browse files
authored
Merging pull request #18175
* new components * pnpm-lock.yaml
1 parent 0839148 commit 5403da4

File tree

11 files changed

+395
-8
lines changed

11 files changed

+395
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import rinkel from "../../rinkel.app.mjs";
2+
3+
export default {
4+
key: "rinkel-add-note",
5+
name: "Add Note",
6+
description: "Add a note to a call. [See the documentation](https://developers.rinkel.com/docs/api/add-a-note-to-a-call-detail-record)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
rinkel,
11+
callId: {
12+
propDefinition: [
13+
rinkel,
14+
"callId",
15+
],
16+
},
17+
content: {
18+
type: "string",
19+
label: "Content",
20+
description: "The content of the note",
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.rinkel.addNote({
25+
$,
26+
id: this.callId,
27+
data: {
28+
content: this.content,
29+
},
30+
});
31+
$.export("$summary", `Note added to call ${this.callId}`);
32+
return response;
33+
},
34+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import rinkel from "../../rinkel.app.mjs";
2+
3+
export default {
4+
key: "rinkel-get-call-details",
5+
name: "Get Call Details",
6+
description: "Get details about a call. [See the documentation](https://developers.rinkel.com/docs/api/get-a-specific-call-detail-record)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
rinkel,
11+
callId: {
12+
propDefinition: [
13+
rinkel,
14+
"callId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.rinkel.getCallDetailRecord({
20+
$,
21+
id: this.callId,
22+
});
23+
$.export("$summary", `Call details for ${this.callId} retrieved`);
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 rinkel from "../../rinkel.app.mjs";
2+
3+
export default {
4+
key: "rinkel-get-call-recording",
5+
name: "Get Call Recording",
6+
description: "Get a call recording. [See the documentation](https://developers.rinkel.com/docs/api/get-a-recording)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
rinkel,
11+
recordingId: {
12+
propDefinition: [
13+
rinkel,
14+
"recordingId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.rinkel.getCallRecording({
20+
$,
21+
id: this.recordingId,
22+
});
23+
$.export("$summary", `Recording ${this.recordingId} retrieved`);
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 rinkel from "../../rinkel.app.mjs";
2+
3+
export default {
4+
key: "rinkel-get-voicemail",
5+
name: "Get Voicemail",
6+
description: "Returns a URL to stream or download a voicemail. [See the documentation](https://developers.rinkel.com/docs/api/get-a-temporary-url-to-stream-or-download-a-voicemail)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
rinkel,
11+
voicemailId: {
12+
propDefinition: [
13+
rinkel,
14+
"voicemailId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.rinkel.getVoicemail({
20+
$,
21+
id: this.voicemailId,
22+
});
23+
$.export("$summary", `Voicemail ${this.voicemailId} retrieved`);
24+
return response;
25+
},
26+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import rinkel from "../../rinkel.app.mjs";
2+
3+
export default {
4+
key: "rinkel-update-note",
5+
name: "Update Note",
6+
description: "Update a note on a call. [See the documentation](https://developers.rinkel.com/docs/api/update-a-note-in-a-call-detail-record)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
rinkel,
11+
callId: {
12+
propDefinition: [
13+
rinkel,
14+
"callId",
15+
],
16+
},
17+
noteId: {
18+
propDefinition: [
19+
rinkel,
20+
"noteId",
21+
(c) => ({
22+
callId: c.callId,
23+
}),
24+
],
25+
},
26+
content: {
27+
type: "string",
28+
label: "Content",
29+
description: "The content of the note",
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.rinkel.updateNote({
34+
$,
35+
callId: this.callId,
36+
noteId: this.noteId,
37+
data: {
38+
content: this.content,
39+
},
40+
});
41+
$.export("$summary", `Note updated for call ${this.callId}`);
42+
return response;
43+
},
44+
};

components/rinkel/package.json

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

components/rinkel/rinkel.app.mjs

Lines changed: 156 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,162 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "rinkel",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
callId: {
8+
type: "string",
9+
label: "Call ID",
10+
description: "The ID of the call to get the call detail records for",
11+
async options({ page }) {
12+
const response = await this.listCallDetailRecords({
13+
params: {
14+
page: page + 1,
15+
sort: "date",
16+
sortOrder: "DESC",
17+
},
18+
});
19+
return response.data.map((call) => call.id);
20+
},
21+
},
22+
recordingId: {
23+
type: "string",
24+
label: "Recording ID",
25+
description: "The ID of the recording to get the details for",
26+
async options({ page }) {
27+
const response = await this.listCallRecordings({
28+
params: {
29+
page: page + 1,
30+
sort: "date",
31+
sortOrder: "DESC",
32+
},
33+
});
34+
return response.data.map((recording) => recording.id);
35+
},
36+
},
37+
voicemailId: {
38+
type: "string",
39+
label: "Voicemail ID",
40+
description: "The ID of the voicemail to get the details for",
41+
async options({ page }) {
42+
const response = await this.listVoicemails({
43+
params: {
44+
page: page + 1,
45+
sort: "date",
46+
sortOrder: "DESC",
47+
},
48+
});
49+
return response.data.map((voicemail) => voicemail.id);
50+
},
51+
},
52+
noteId: {
53+
type: "string",
54+
label: "Note ID",
55+
description: "The ID of the note to update",
56+
async options({ callId }) {
57+
const response = await this.getCallDetailRecord({
58+
id: callId,
59+
});
60+
const notes = response.data.notes;
61+
return notes.map((note) => ({
62+
label: note.content,
63+
value: note.id,
64+
}));
65+
},
66+
},
67+
},
568
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
69+
_baseUrl() {
70+
return "https://api.rinkel.com/v1";
71+
},
72+
_makeRequest({
73+
$ = this, path, ...opts
74+
}) {
75+
return axios($, {
76+
url: `${this._baseUrl()}${path}`,
77+
headers: {
78+
"x-rinkel-api-key": this.$auth.api_key,
79+
},
80+
...opts,
81+
});
82+
},
83+
createWebhook({
84+
event, ...opts
85+
}) {
86+
return this._makeRequest({
87+
path: `/webhooks/${event}`,
88+
method: "POST",
89+
...opts,
90+
});
91+
},
92+
deleteWebhook({
93+
event, ...opts
94+
}) {
95+
return this._makeRequest({
96+
path: `/webhooks/${event}`,
97+
method: "DELETE",
98+
...opts,
99+
});
100+
},
101+
getCallDetailRecord({
102+
id, ...opts
103+
}) {
104+
return this._makeRequest({
105+
path: `/call-detail-records/${id}`,
106+
...opts,
107+
});
108+
},
109+
getCallRecording({
110+
id, ...opts
111+
}) {
112+
return this._makeRequest({
113+
path: `/recordings/${id}`,
114+
...opts,
115+
});
116+
},
117+
getVoicemail({
118+
id, ...opts
119+
}) {
120+
return this._makeRequest({
121+
path: `/voicemails/${id}/stream`,
122+
...opts,
123+
});
124+
},
125+
listCallDetailRecords(opts = {}) {
126+
return this._makeRequest({
127+
path: "/call-detail-records",
128+
...opts,
129+
});
130+
},
131+
listCallRecordings(opts = {}) {
132+
return this._makeRequest({
133+
path: "/recordings",
134+
...opts,
135+
});
136+
},
137+
listVoicemails(opts = {}) {
138+
return this._makeRequest({
139+
path: "/voicemails",
140+
...opts,
141+
});
142+
},
143+
addNote({
144+
id, ...opts
145+
}) {
146+
return this._makeRequest({
147+
path: `/call-detail-records/${id}/note`,
148+
method: "PUT",
149+
...opts,
150+
});
151+
},
152+
updateNote({
153+
callId, noteId, ...opts
154+
}) {
155+
return this._makeRequest({
156+
path: `/call-detail-records/${callId}/note/${noteId}`,
157+
method: "PATCH",
158+
...opts,
159+
});
9160
},
10161
},
11-
};
162+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import common from "../common/base-webhook.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "rinkel-call-ended",
7+
name: "Call Ended (Instant)",
8+
description: "Emit new event when a call ends. [See the documentation](https://developers.rinkel.com/docs/api/subscribe-to-a-webhook)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getEvent() {
15+
return "callEnd";
16+
},
17+
generateMeta(event) {
18+
return {
19+
id: event.id,
20+
summary: `Call ended: ${event.cause}`,
21+
ts: Date.parse(event.datetime),
22+
};
23+
},
24+
},
25+
sampleEmit,
26+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
id: '1c8b83a7c690084224ec3984515bc1a2',
3+
datetime: '2023-06-14T13:56:24.969Z',
4+
cause: 'ANSWERED'
5+
}

0 commit comments

Comments
 (0)