From df063497a5a24506ecb377e4555a911c0aa80d60 Mon Sep 17 00:00:00 2001 From: Ajay Kumar Verma Plivo <96424204+ajay-plivo@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:38:51 +0530 Subject: [PATCH] VT-8376:mpcRecoringParamsAdded (#219) * VT-8376:mpcRecoringParamsAdded * VT-8376:GetRecordingTranscription * VT-8376 * VT-8376:unitTestCasesFuxed * dateChanged --- CHANGELOG.md | 6 ++++ baseclient.go | 2 +- fixtures/getRecordingTranscription.json | 9 +++++ multipartycall.go | 2 ++ plivoclient.go | 2 ++ transcription.go | 37 +++++++++++++++++++ transcription_test.go | 47 +++++++++++++++++++++++++ 7 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 fixtures/getRecordingTranscription.json create mode 100644 transcription.go create mode 100644 transcription_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 66c2f66..f5c1245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Change Log + +## [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 +- Support added for Transcription in MPC + ## [7.53.1](https://github.com/plivo/plivo-go/tree/v7.53.1) (2024-10-23) **Feature - FraudCheck param in Create, Get and List Session** - Support for the `fraud_check` parameter in sms verify session request diff --git a/baseclient.go b/baseclient.go index 0209eb9..8ec9cbc 100644 --- a/baseclient.go +++ b/baseclient.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-querystring/query" ) -const sdkVersion = "7.53.1" +const sdkVersion = "7.54.0" const lookupBaseUrl = "lookup.plivo.com" diff --git a/fixtures/getRecordingTranscription.json b/fixtures/getRecordingTranscription.json new file mode 100644 index 0000000..fe02673 --- /dev/null +++ b/fixtures/getRecordingTranscription.json @@ -0,0 +1,9 @@ +{ + "api_id": "e12d05fe-6979-485c-83dc-9276114dba3b", + "cost": 0.05, + "rate": 0.05, + "recording_duration_ms": 22780, + "recording_start_ms": 1729761222174, + "status": "success", + "transcription": "Okay. Recording has started. I'll tell something. Okay? HTTP, Plivo, Bin, Fraud, USWO, Plivo. You also speak. Yeah. You will prompt Now we can pass, I guess, and then resume on. If not, then we can check it. P a d 96 f d 9 f been on there now. I think we can disconnect the call before that. I think this one could be fine, I guess. Let's see, like, how we inside. Like, maybe we can disconnect the call and take 1. Sir, you you also disconnect. I also disconnect. Okay? Sure. Sure." +} \ No newline at end of file diff --git a/multipartycall.go b/multipartycall.go index e9a5d5f..17a1123 100644 --- a/multipartycall.go +++ b/multipartycall.go @@ -117,6 +117,8 @@ type MultiPartyCallStartRecordingParams struct { FileFormat string `json:"file_format,omitempty" url:"file_format,omitempty"` RecordingCallbackUrl string `json:"recording_callback_url,omitempty" url:"recording_callback_url,omitempty"` RecordingCallbackMethod string `json:"recording_callback_method,omitempty" url:"recording_callback_method,omitempty"` + TranscriptionUrl string `json:"transcription_url,omitempty" url:"transcription_url,omitempty"` + Transcript bool `json:"transcript,omitempty" url:"transcript,omitempty"` } type MultiPartyCallListResponse struct { diff --git a/plivoclient.go b/plivoclient.go index c6dc6c4..19fc0dc 100644 --- a/plivoclient.go +++ b/plivoclient.go @@ -29,6 +29,7 @@ type Client struct { PhoneNumbers *PhoneNumberService Pricing *PricingService // TODO Rename? Recordings *RecordingService + Transcription *TranscriptionService Calls *CallService Token *TokenService LiveCalls *LiveCallService @@ -102,6 +103,7 @@ func NewClient(authId, authToken string, options *ClientOptions) (client *Client client.PhoneNumbers = &PhoneNumberService{client: client} client.Pricing = &PricingService{client: client} client.Recordings = &RecordingService{client: client} + client.Transcription = &TranscriptionService{client: client} client.Calls = &CallService{client: client} client.Token = &TokenService{client: client} client.LiveCalls = &LiveCallService{client: client} diff --git a/transcription.go b/transcription.go new file mode 100644 index 0000000..bf81366 --- /dev/null +++ b/transcription.go @@ -0,0 +1,37 @@ +package plivo + +type TranscriptionService struct { + client *Client +} + +type GetRecordingTranscriptionRequest struct { + TranscriptionID string `json:"transcription_id"` + TranscriptionType string `json:"type"` +} + +type GetRecordingTranscriptionParams struct { + Type string `url:"type"` +} + +type GetRecordingTranscriptionResponse struct { + APIID string `json:"api_id"` + Cost float64 `json:"cost"` + Rate float64 `json:"rate"` + RecordingDurationMs float64 `json:"recording_duration_ms"` + RecordingStartMs float64 `json:"recording_start_ms"` + Status string `json:"status"` + Transcription interface{} `json:"transcription"` +} + +func (service *TranscriptionService) GetRecordingTranscription(request GetRecordingTranscriptionRequest) (response *GetRecordingTranscriptionResponse, err error) { + params := GetRecordingTranscriptionParams{ + Type: request.TranscriptionType, + } + req, err := service.client.NewRequest("GET", params, "Transcription/%s", request.TranscriptionID) + if err != nil { + return + } + response = &GetRecordingTranscriptionResponse{} + err = service.client.ExecuteRequest(req, response, isVoiceRequest()) + return +} diff --git a/transcription_test.go b/transcription_test.go new file mode 100644 index 0000000..6a7ddef --- /dev/null +++ b/transcription_test.go @@ -0,0 +1,47 @@ +package plivo + +import ( + "errors" + "testing" +) + +// without queryParam passed +func TestTranscriptionService_GetRecordingTranscription(t *testing.T) { + expectResponse("getRecordingTranscription.json", 200) + + if _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{ + TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b", + }); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl +} + +// with queryParam +func TestTranscriptionService_GetRecordingTranscriptionWithParam(t *testing.T) { + expectResponse("getRecordingTranscription.json", 200) + + if _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{ + TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b", + TranscriptionType: "raw", + }); err != nil { + panic(err) + } + + cl := client.httpClient + client.httpClient = nil + _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{}) + if err == nil { + client.httpClient = cl + panic(errors.New("error expected")) + } + client.httpClient = cl +}