Skip to content

Commit

Permalink
VT-8376:mpcRecoringParamsAdded (#219)
Browse files Browse the repository at this point in the history
* VT-8376:mpcRecoringParamsAdded

* VT-8376:GetRecordingTranscription

* VT-8376

* VT-8376:unitTestCasesFuxed

* dateChanged
  • Loading branch information
ajay-plivo authored Oct 30, 2024
1 parent 3581266 commit df06349
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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.53.1"
const sdkVersion = "7.54.0"

const lookupBaseUrl = "lookup.plivo.com"

Expand Down
9 changes: 9 additions & 0 deletions fixtures/getRecordingTranscription.json
Original file line number Diff line number Diff line change
@@ -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."
}
2 changes: 2 additions & 0 deletions multipartycall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions plivoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Client struct {
PhoneNumbers *PhoneNumberService
Pricing *PricingService // TODO Rename?
Recordings *RecordingService
Transcription *TranscriptionService
Calls *CallService
Token *TokenService
LiveCalls *LiveCallService
Expand Down Expand Up @@ -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}
Expand Down
37 changes: 37 additions & 0 deletions transcription.go
Original file line number Diff line number Diff line change
@@ -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
}
47 changes: 47 additions & 0 deletions transcription_test.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit df06349

Please sign in to comment.