Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VT-8376:mpcRecoringParamsAdded #219

Merged
merged 5 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ajay-plivo marked this conversation as resolved.
Show resolved Hide resolved
- 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 @@ -5,7 +5,7 @@
"encoding/json"
"errors"
"fmt"
"io/ioutil"

Check failure on line 8 in baseclient.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
"net/http"
"net/url"
"reflect"
Expand All @@ -13,7 +13,7 @@
"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
}
Loading