Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions components/rinkel/actions/add-note/add-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import rinkel from "../../rinkel.app.mjs";

export default {
key: "rinkel-add-note",
name: "Add Note",
description: "Add a note to a call. [See the documentation](https://developers.rinkel.com/docs/api/add-a-note-to-a-call-detail-record)",
version: "0.0.1",
type: "action",
props: {
rinkel,
callId: {
propDefinition: [
rinkel,
"callId",
],
},
content: {
type: "string",
label: "Content",
description: "The content of the note",
},
},
async run({ $ }) {
const response = await this.rinkel.addNote({
$,
id: this.callId,
data: {
content: this.content,
},
});
$.export("$summary", `Note added to call ${this.callId}`);
return response;
},
};
26 changes: 26 additions & 0 deletions components/rinkel/actions/get-call-details/get-call-details.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import rinkel from "../../rinkel.app.mjs";

export default {
key: "rinkel-get-call-details",
name: "Get Call Details",
description: "Get details about a call. [See the documentation](https://developers.rinkel.com/docs/api/get-a-specific-call-detail-record)",
version: "0.0.1",
type: "action",
props: {
rinkel,
callId: {
propDefinition: [
rinkel,
"callId",
],
},
},
async run({ $ }) {
const response = await this.rinkel.getCallDetailRecord({
$,
id: this.callId,
});
$.export("$summary", `Call details for ${this.callId} retrieved`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import rinkel from "../../rinkel.app.mjs";

export default {
key: "rinkel-get-call-recording",
name: "Get Call Recording",
description: "Get a call recording. [See the documentation](https://developers.rinkel.com/docs/api/get-a-recording)",
version: "0.0.1",
type: "action",
props: {
rinkel,
recordingId: {
propDefinition: [
rinkel,
"recordingId",
],
},
},
async run({ $ }) {
const response = await this.rinkel.getCallRecording({
$,
id: this.recordingId,
});
$.export("$summary", `Recording ${this.recordingId} retrieved`);
return response;
},
};
26 changes: 26 additions & 0 deletions components/rinkel/actions/get-voicemail/get-voicemail.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import rinkel from "../../rinkel.app.mjs";

export default {
key: "rinkel-get-voicemail",
name: "Get Voicemail",
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)",
version: "0.0.1",
type: "action",
props: {
rinkel,
voicemailId: {
propDefinition: [
rinkel,
"voicemailId",
],
},
},
async run({ $ }) {
const response = await this.rinkel.getVoicemail({
$,
id: this.voicemailId,
});
$.export("$summary", `Voicemail ${this.voicemailId} retrieved`);
return response;
},
};
44 changes: 44 additions & 0 deletions components/rinkel/actions/update-note/update-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import rinkel from "../../rinkel.app.mjs";

export default {
key: "rinkel-update-note",
name: "Update Note",
description: "Update a note on a call. [See the documentation](https://developers.rinkel.com/docs/api/update-a-note-in-a-call-detail-record)",
version: "0.0.1",
type: "action",
props: {
rinkel,
callId: {
propDefinition: [
rinkel,
"callId",
],
},
noteId: {
propDefinition: [
rinkel,
"noteId",
(c) => ({
callId: c.callId,
}),
],
},
content: {
type: "string",
label: "Content",
description: "The content of the note",
},
},
async run({ $ }) {
const response = await this.rinkel.updateNote({
$,
callId: this.callId,
noteId: this.noteId,
data: {
content: this.content,
},
});
$.export("$summary", `Note updated for call ${this.callId}`);
return response;
},
};
7 changes: 5 additions & 2 deletions components/rinkel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/rinkel",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Rinkel Components",
"main": "rinkel.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
161 changes: 156 additions & 5 deletions components/rinkel/rinkel.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,162 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "rinkel",
propDefinitions: {},
propDefinitions: {
callId: {
type: "string",
label: "Call ID",
description: "The ID of the call to get the call detail records for",
async options({ page }) {
const response = await this.listCallDetailRecords({
params: {
page: page + 1,
sort: "date",
sortOrder: "DESC",
},
});
return response.data.map((call) => call.id);
},
},
recordingId: {
type: "string",
label: "Recording ID",
description: "The ID of the recording to get the details for",
async options({ page }) {
const response = await this.listCallRecordings({
params: {
page: page + 1,
sort: "date",
sortOrder: "DESC",
},
});
return response.data.map((recording) => recording.id);
},
},
voicemailId: {
type: "string",
label: "Voicemail ID",
description: "The ID of the voicemail to get the details for",
async options({ page }) {
const response = await this.listVoicemails({
params: {
page: page + 1,
sort: "date",
sortOrder: "DESC",
},
});
return response.data.map((voicemail) => voicemail.id);
},
},
noteId: {
type: "string",
label: "Note ID",
description: "The ID of the note to update",
async options({ callId }) {
const response = await this.getCallDetailRecord({
id: callId,
});
const notes = response.data.notes;
return notes.map((note) => ({
label: note.content,
value: note.id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.rinkel.com/v1";
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
"x-rinkel-api-key": this.$auth.api_key,
},
...opts,
});
},
createWebhook({
event, ...opts
}) {
return this._makeRequest({
path: `/webhooks/${event}`,
method: "POST",
...opts,
});
},
deleteWebhook({
event, ...opts
}) {
return this._makeRequest({
path: `/webhooks/${event}`,
method: "DELETE",
...opts,
});
},
getCallDetailRecord({
id, ...opts
}) {
return this._makeRequest({
path: `/call-detail-records/${id}`,
...opts,
});
},
getCallRecording({
id, ...opts
}) {
return this._makeRequest({
path: `/recordings/${id}`,
...opts,
});
},
getVoicemail({
id, ...opts
}) {
return this._makeRequest({
path: `/voicemails/${id}/stream`,
...opts,
});
},
listCallDetailRecords(opts = {}) {
return this._makeRequest({
path: "/call-detail-records",
...opts,
});
},
listCallRecordings(opts = {}) {
return this._makeRequest({
path: "/recordings",
...opts,
});
},
listVoicemails(opts = {}) {
return this._makeRequest({
path: "/voicemails",
...opts,
});
},
addNote({
id, ...opts
}) {
return this._makeRequest({
path: `/call-detail-records/${id}/note`,
method: "PUT",
...opts,
});
},
updateNote({
callId, noteId, ...opts
}) {
return this._makeRequest({
path: `/call-detail-records/${callId}/note/${noteId}`,
method: "PATCH",
...opts,
});
},
},
};
};
26 changes: 26 additions & 0 deletions components/rinkel/sources/call-ended/call-ended.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base-webhook.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "rinkel-call-ended",
name: "Call Ended (Instant)",

Check warning on line 7 in components/rinkel/sources/call-ended/call-ended.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a call ends. [See the documentation](https://developers.rinkel.com/docs/api/subscribe-to-a-webhook)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEvent() {
return "callEnd";
},
generateMeta(event) {
return {
id: event.id,
summary: `Call ended: ${event.cause}`,
ts: Date.parse(event.datetime),
};
},
},
sampleEmit,
};
5 changes: 5 additions & 0 deletions components/rinkel/sources/call-ended/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
id: '1c8b83a7c690084224ec3984515bc1a2',
datetime: '2023-06-14T13:56:24.969Z',
cause: 'ANSWERED'
}
Loading
Loading