Skip to content

Commit

Permalink
VT-8411:Add a participant to a multiparty call using API (#220)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ajay-plivo authored Nov 12, 2024
1 parent df06349 commit 69acb24
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion baseclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 4 additions & 0 deletions fixtures/createRecordingTranscription.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"api_id": "c9db3f38-55e8-4d97-93b2-1ece5a342528",
"message": "transcription in progress"
}
4 changes: 4 additions & 0 deletions fixtures/deleteRecordingTranscription.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"api_id": "47ab0f0d-a7db-4f56-8200-6555cd3194e8",
"message": "request accepted"
}
3 changes: 3 additions & 0 deletions multipartycall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 34 additions & 0 deletions transcription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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,
Expand All @@ -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
}
45 changes: 45 additions & 0 deletions transcription_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package plivo

import (
"encoding/json"
"errors"
"testing"
)
Expand Down Expand Up @@ -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
}

0 comments on commit 69acb24

Please sign in to comment.