From fbaf8de0e81f57c685d362afc15f7a33be6c2c15 Mon Sep 17 00:00:00 2001 From: ajay-plivo Date: Thu, 7 Nov 2024 12:16:55 +0530 Subject: [PATCH] VT-8411:unitTestCaseAdded --- transcription.go | 10 +++++++--- transcription_test.go | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/transcription.go b/transcription.go index 81d123a..07fb61e 100644 --- a/transcription.go +++ b/transcription.go @@ -13,6 +13,10 @@ type RecordingTranscriptionRequest struct { RecordingID string `json:"recording_id"` } +type DeleteRecordingTranscriptionRequest struct { + TranscriptionID string `json:"transcription_id"` +} + type GetRecordingTranscriptionParams struct { Type string `url:"type"` } @@ -33,7 +37,7 @@ func (service *TranscriptionService) CreateRecordingTranscription(request Record return } response = make(map[string]interface{}) - err = service.client.ExecuteRequest(req, response, isVoiceRequest()) + err = service.client.ExecuteRequest(req, &response, isVoiceRequest()) return } @@ -50,8 +54,8 @@ func (service *TranscriptionService) GetRecordingTranscription(request GetRecord return } -func (service *TranscriptionService) DeleteRecordingTranscription(request RecordingTranscriptionRequest) (response map[string]interface{}, err error) { - req, err := service.client.NewRequest("DELETE", nil, "Transcription/%s", request.RecordingID) +func (service *TranscriptionService) DeleteRecordingTranscription(request DeleteRecordingTranscriptionRequest) (response map[string]interface{}, err error) { + req, err := service.client.NewRequest("DELETE", nil, "Transcription/%s", request.TranscriptionID) if err != nil { return } diff --git a/transcription_test.go b/transcription_test.go index 6a7ddef..d14cb64 100644 --- a/transcription_test.go +++ b/transcription_test.go @@ -1,6 +1,7 @@ package plivo import ( + "encoding/json" "errors" "testing" ) @@ -45,3 +46,25 @@ func TestTranscriptionService_GetRecordingTranscriptionWithParam(t *testing.T) { } client.httpClient = cl } + +func TestTranscriptionService_CreateRecordingTranscription(t *testing.T) { + expectResponse("createRecordingTranscription.json", 200) + var response map[string]interface{} + if err := json.Unmarshal([]byte(expectedResponse), &response); err != nil { + t.Fatalf("failed to unmarshal expected response: %v", err) + } + if _, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{ + RecordingID: "e12d05fe-6979-485c-83dc-9276114dba3b", + }); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl +}