From 69acb24f7676844f9e4ccf6dbbd31e912c40fc4f Mon Sep 17 00:00:00 2001 From: Ajay Kumar Verma Plivo <96424204+ajay-plivo@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:12:40 +0530 Subject: [PATCH] VT-8411:Add a participant to a multiparty call using API (#220) * VT-8411:Add a participant to a multiparty call using API * VT-8411:CreateRecordingTranscription and DeleteRecordingTranscription feature added * VT-8411:unitTestCaseAdded * VT-8411:record_participant_track_added * VT-8411 --- CHANGELOG.md | 5 +++ baseclient.go | 2 +- fixtures/createRecordingTranscription.json | 4 ++ fixtures/deleteRecordingTranscription.json | 4 ++ multipartycall.go | 3 ++ transcription.go | 34 ++++++++++++++++ transcription_test.go | 45 ++++++++++++++++++++++ 7 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 fixtures/createRecordingTranscription.json create mode 100644 fixtures/deleteRecordingTranscription.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f5c1245..362fc24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [7.55.0](https://github.com/plivo/plivo-go/tree/v7.55.0) (2024-11-12) +**Feature - CreateRecordingTranscription and DeleteRecordingTranscription feature added** +- This API would help in creating transcription for recorded calls for which transcription is not available and delete API to delete. +- Support for the `transcription_url`, `transcript` and `record_participant_track` parameter in MPC Add Participant. + ## [7.54.0](https://github.com/plivo/plivo-go/tree/v7.54.0) (2024-10-30) **Feature - GetRecordingTranscription feature to get transcription** - Support for the `type` filter parameter, supported filters are transcription, raw and diarized diff --git a/baseclient.go b/baseclient.go index 8ec9cbc..811b0a3 100644 --- a/baseclient.go +++ b/baseclient.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-querystring/query" ) -const sdkVersion = "7.54.0" +const sdkVersion = "7.55.0" const lookupBaseUrl = "lookup.plivo.com" diff --git a/fixtures/createRecordingTranscription.json b/fixtures/createRecordingTranscription.json new file mode 100644 index 0000000..eccd081 --- /dev/null +++ b/fixtures/createRecordingTranscription.json @@ -0,0 +1,4 @@ +{ + "api_id": "c9db3f38-55e8-4d97-93b2-1ece5a342528", + "message": "transcription in progress" +} \ No newline at end of file diff --git a/fixtures/deleteRecordingTranscription.json b/fixtures/deleteRecordingTranscription.json new file mode 100644 index 0000000..3b7a102 --- /dev/null +++ b/fixtures/deleteRecordingTranscription.json @@ -0,0 +1,4 @@ +{ +"api_id": "47ab0f0d-a7db-4f56-8200-6555cd3194e8", +"message": "request accepted" +} \ No newline at end of file diff --git a/multipartycall.go b/multipartycall.go index 17a1123..310cfb3 100644 --- a/multipartycall.go +++ b/multipartycall.go @@ -73,6 +73,9 @@ type MultiPartyCallAddParticipantParams struct { CreateMpcWithSingleParticipant *bool `json:"create_mpc_with_single_participant,omitempty" url:"create_mpc_with_single_participant,omitempty"` SendDigits string `json:"send_digits,omitempty" url:"send_digits,omitempty"` SendOnPreanswer bool `json:"send_on_preanswer,omitempty" url:"send_on_preanswer,omitempty"` + TranscriptionUrl string `json:"transcription_url,omitempty" url:"transcription_url,omitempty"` + Transcript bool `json:"transcript,omitempty" url:"transcript,omitempty"` + RecordParticipantTrack bool `json:"record_participant_track" url:"record_participant_track"` } type MultiPartyCallListParams struct { diff --git a/transcription.go b/transcription.go index bf81366..b854e7d 100644 --- a/transcription.go +++ b/transcription.go @@ -9,6 +9,19 @@ type GetRecordingTranscriptionRequest struct { TranscriptionType string `json:"type"` } +type CallBackUrlStruct struct { + CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` +} + +type RecordingTranscriptionRequest struct { + RecordingID string `json:"recording_id"` + CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` +} + +type DeleteRecordingTranscriptionRequest struct { + TranscriptionID string `json:"transcription_id"` +} + type GetRecordingTranscriptionParams struct { Type string `url:"type"` } @@ -23,6 +36,17 @@ type GetRecordingTranscriptionResponse struct { Transcription interface{} `json:"transcription"` } +func (service *TranscriptionService) CreateRecordingTranscription(request RecordingTranscriptionRequest) (response map[string]interface{}, err error) { + param := CallBackUrlStruct{CallbackUrl: request.CallbackUrl} + req, err := service.client.NewRequest("POST", param, "Transcription/%s", request.RecordingID) + if err != nil { + return + } + response = make(map[string]interface{}) + err = service.client.ExecuteRequest(req, &response, isVoiceRequest()) + return +} + func (service *TranscriptionService) GetRecordingTranscription(request GetRecordingTranscriptionRequest) (response *GetRecordingTranscriptionResponse, err error) { params := GetRecordingTranscriptionParams{ Type: request.TranscriptionType, @@ -35,3 +59,13 @@ func (service *TranscriptionService) GetRecordingTranscription(request GetRecord err = service.client.ExecuteRequest(req, response, isVoiceRequest()) return } + +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 + } + response = make(map[string]interface{}) + err = service.client.ExecuteRequest(req, &response, isVoiceRequest()) + return +} diff --git a/transcription_test.go b/transcription_test.go index 6a7ddef..31d7486 100644 --- a/transcription_test.go +++ b/transcription_test.go @@ -1,6 +1,7 @@ package plivo import ( + "encoding/json" "errors" "testing" ) @@ -45,3 +46,47 @@ 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 +} + +func TestTranscriptionService_DeleteRecordingTranscription(t *testing.T) { + expectResponse("deleteRecordingTranscription.json", 202) + 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.DeleteRecordingTranscription(DeleteRecordingTranscriptionRequest{ + TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b", + }); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.Transcription.DeleteRecordingTranscription(DeleteRecordingTranscriptionRequest{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl +}