Skip to content

Commit fd2581d

Browse files
authored
Modified the recording SDK to add a Delete function, and a test (#80)
1 parent 1d23ce0 commit fd2581d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

voice/recording.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ func (rec *Recording) Transcriptions(client *messagebird.Client, callID string)
109109
return newPaginator(client, path, reflect.TypeOf(Transcription{}))
110110
}
111111

112+
// Delete deletes a recording.
113+
func Delete(client *messagebird.Client, callID, legID, recordingID string) error {
114+
return client.Request(nil, http.MethodDelete, fmt.Sprintf("%s/v1/calls/%s/legs/%s/recordings/%s", apiRoot, callID, legID, recordingID), nil)
115+
}
116+
112117
// DownloadFile streams the recorded WAV file.
113118
func (rec *Recording) DownloadFile(client *messagebird.Client) (io.ReadCloser, error) {
114119
req, err := http.NewRequest(http.MethodGet, apiRoot+rec.Links["file"], nil)

voice/recording_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ func TestRecordingGetFile(t *testing.T) {
3434
}
3535
}
3636

37+
func TestDelete(t *testing.T) {
38+
mbtest.WillReturn([]byte(""), http.StatusNoContent)
39+
client := mbtest.Client(t)
40+
if err := Delete(client, "callid", "legid", "recid"); err != nil {
41+
t.Errorf("unexpected error while deleting recording: %s", err)
42+
}
43+
44+
mbtest.AssertEndpointCalled(t, http.MethodDelete, "/v1/calls/callid/legs/legid/recordings/recid")
45+
}
46+
47+
3748
func TestReadRecording(t *testing.T) {
3849
mbtest.WillReturnTestdata(t, "recordingObject.json", http.StatusOK)
3950
client := mbtest.Client(t)

0 commit comments

Comments
 (0)