From 19900b2e1d6a28715dfe98c3e317de2c9c2a932a Mon Sep 17 00:00:00 2001 From: Jaya Bharat Reddy Plivo Date: Mon, 30 Sep 2024 12:33:58 +0530 Subject: [PATCH] Added sdk changes for masking session. (#215) Added sdk changes for masking session. --- CHANGELOG.md | 4 + baseclient.go | 2 +- maskingsession.go | 161 ++++++++++++++++++++++------------------- maskingsession_test.go | 52 +++++++++++++ 4 files changed, 142 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4bec3b..8ef5f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Change Log +## [7.52.0](https://github.com/plivo/plivo-go/tree/v7.52.0) (2024-09-30) +**Feature - Adding new param support for Number Masking session with single party ** +- Added `create_session_with_single_party`, `virtual_number_cooloff_period` and `force_pin_authentication` attributes in Masking Session + ## [7.51.3](https://github.com/plivo/plivo-go/tree/v7.53.0) (2024-09-06) **Feature - Adding support for Locale param in Create, Get and List Session** - Enhance message object diff --git a/baseclient.go b/baseclient.go index 41901c4..b513ae4 100644 --- a/baseclient.go +++ b/baseclient.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-querystring/query" ) -const sdkVersion = "7.51.3" +const sdkVersion = "7.52.0" const lookupBaseUrl = "lookup.plivo.com" diff --git a/maskingsession.go b/maskingsession.go index 9d47a9b..b88e833 100644 --- a/maskingsession.go +++ b/maskingsession.go @@ -5,88 +5,97 @@ type MaskingSessionService struct { } type MaskingSession struct { - FirstParty string `json:"first_party,omitempty" url:"first_party,omitempty"` - SecondParty string `json:"second_party,omitempty" url:"second_party,omitempty"` - VirtualNumber string `json:"virtual_number,omitempty" url:"virtual_number,omitempty"` - Status string `json:"status,omitempty" url:"status,omitempty"` - InitiateCallToFirstParty bool `json:"initiate_call_to_first_party,omitempty" url:"initiate_call_to_first_party,omitempty"` - SessionUUID string `json:"session_uuid,omitempty" url:"session_uuid,omitempty"` - CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - CreatedAt string `json:"created_time,omitempty" url:"created_time,omitempty"` - UpdatedAt string `json:"modified_time,omitempty" url:"updated_at,omitempty"` - ExpiryAt string `json:"expiry_time,omitempty" url:"expiry_time,omitempty"` - Duration int64 `json:"duration,omitempty" url:"duration,omitempty"` - SessionCreationAmount int64 `json:"amount" url:"amount"` - CallTimeLimit int64 `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` - RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` - FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` - SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` - Record bool `json:"record,omitempty" url:"record,omitempty"` - RecordFileFormat string `json:"record_file_format,omitempty" url:"record_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"` - Interaction []VoiceInteractionResponse `json:"interaction" url:"interaction"` - TotalCallAmount float64 `json:"total_call_amount" url:"total_call_amount"` - TotalCallCount int `json:"total_call_count" url:"total_call_count"` - TotalCallBilledDuration int `json:"total_call_billed_duration" url:"total_call_billed_duration"` - TotalSessionAmount float64 `json:"total_session_amount" url:"total_session_amount"` - LastInteractionTime string `json:"last_interaction_time" url:"last_interaction_time"` - IsPinAuthenticationRequired bool `json:"is_pin_authentication_required" url:"is_pin_authentication_required"` - GeneratePin bool `json:"generate_pin" url:"generate_pin"` - GeneratePinLength int64 `json:"generate_pin_length" url:"generate_pin_length"` - FirstPartyPin string `json:"first_party_pin" url:"first_party_pin"` - SecondPartyPin string `json:"second_party_pin" url:"second_party_pin"` - PinPromptPlay string `json:"pin_prompt_play" url:"pin_prompt_play"` - PinRetry int64 `json:"pin_retry" url:"pin_retry"` - PinRetryWait int64 `json:"pin_retry_wait" url:"pin_retry_wait"` - IncorrectPinPlay string `json:"incorrect_pin_play" url:"incorrect_pin_play"` - UnknownCallerPlay string `json:"unknown_caller_play" url:"unknown_caller_play"` + FirstParty string `json:"first_party,omitempty" url:"first_party,omitempty"` + SecondParty string `json:"second_party,omitempty" url:"second_party,omitempty"` + VirtualNumber string `json:"virtual_number,omitempty" url:"virtual_number,omitempty"` + Status string `json:"status,omitempty" url:"status,omitempty"` + InitiateCallToFirstParty bool `json:"initiate_call_to_first_party,omitempty" url:"initiate_call_to_first_party,omitempty"` + SessionUUID string `json:"session_uuid,omitempty" url:"session_uuid,omitempty"` + CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` + CreatedAt string `json:"created_time,omitempty" url:"created_time,omitempty"` + UpdatedAt string `json:"modified_time,omitempty" url:"updated_at,omitempty"` + ExpiryAt string `json:"expiry_time,omitempty" url:"expiry_time,omitempty"` + Duration int64 `json:"duration,omitempty" url:"duration,omitempty"` + SessionCreationAmount int64 `json:"amount" url:"amount"` + CallTimeLimit int64 `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` + RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` + FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` + SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` + Record bool `json:"record,omitempty" url:"record,omitempty"` + RecordFileFormat string `json:"record_file_format,omitempty" url:"record_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"` + Interaction []VoiceInteractionResponse `json:"interaction" url:"interaction"` + TotalCallAmount float64 `json:"total_call_amount" url:"total_call_amount"` + TotalCallCount int `json:"total_call_count" url:"total_call_count"` + TotalCallBilledDuration int `json:"total_call_billed_duration" url:"total_call_billed_duration"` + TotalSessionAmount float64 `json:"total_session_amount" url:"total_session_amount"` + LastInteractionTime string `json:"last_interaction_time" url:"last_interaction_time"` + IsPinAuthenticationRequired bool `json:"is_pin_authentication_required" url:"is_pin_authentication_required"` + GeneratePin bool `json:"generate_pin" url:"generate_pin"` + GeneratePinLength int64 `json:"generate_pin_length" url:"generate_pin_length"` + FirstPartyPin string `json:"first_party_pin" url:"first_party_pin"` + SecondPartyPin string `json:"second_party_pin" url:"second_party_pin"` + PinPromptPlay string `json:"pin_prompt_play" url:"pin_prompt_play"` + PinRetry int64 `json:"pin_retry" url:"pin_retry"` + PinRetryWait int64 `json:"pin_retry_wait" url:"pin_retry_wait"` + IncorrectPinPlay string `json:"incorrect_pin_play" url:"incorrect_pin_play"` + UnknownCallerPlay string `json:"unknown_caller_play" url:"unknown_caller_play"` + VirtualNumberCooloffPeriod int `json:"virtual_number_cooloff_period,omitempty" url:"virtual_number_cooloff_period,omitempty"` + ForcePinAuthentication bool `json:"force_pin_authentication" url:"force_pin_authentication"` + CreateSessionWithSingleParty bool `json:"create_session_with_single_Party" url:"create_session_with_single_Party"` } type CreateMaskingSessionParams struct { - FirstParty string `json:"first_party,omitempty" url:"first_party,omitempty"` - SecondParty string `json:"second_party,omitempty" url:"second_party,omitempty"` - SessionExpiry int `json:"session_expiry" url:"session_expiry,omitempty"` - CallTimeLimit int `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` - Record bool `json:"record,omitempty" url:"record,omitempty"` - RecordFileFormat string `json:"record_file_format,omitempty" url:"record_file_format,omitempty"` - RecordingCallbackUrl string `json:"recording_callback_url,omitempty" url:"recording_callback_url,omitempty"` - InitiateCallToFirstParty bool `json:"initiate_call_to_first_party,omitempty" url:"initiate_call_to_first_party,omitempty"` - CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` - FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` - SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` - RecordingCallbackMethod string `json:"recording_callback_method,omitempty" url:"recording_callback_method,omitempty"` - IsPinAuthenticationRequired bool `json:"is_pin_authentication_required,omitempty" url:"is_pin_authentication_required,omitempty"` - GeneratePin bool `json:"generate_pin,omitempty" url:"generate_pin,omitempty"` - GeneratePinLength int64 `json:"generate_pin_length,omitempty" url:"generate_pin_length,omitempty"` - FirstPartyPin string `json:"first_party_pin,omitempty" url:"first_party_pin,omitempty"` - SecondPartyPin string `json:"second_party_pin,omitempty" url:"second_party_pin,omitempty"` - PinPromptPlay string `json:"pin_prompt_play,omitempty" url:"pin_prompt_play,omitempty"` - PinRetry int64 `json:"pin_retry,omitempty" url:"pin_retry,omitempty"` - PinRetryWait int64 `json:"pin_retry_wait,omitempty" url:"pin_retry_wait,omitempty"` - IncorrectPinPlay string `json:"incorrect_pin_play,omitempty" url:"incorrect_pin_play,omitempty"` - UnknownCallerPlay string `json:"unknown_caller_play,omitempty" url:"unknown_caller_play,omitempty"` - SubAccount string `json:"subaccount,omitempty" url:"subaccount,omitempty"` - GeoMatch *bool `json:"geomatch,omitempty" url:"geomatch,omitempty"` + FirstParty string `json:"first_party,omitempty" url:"first_party,omitempty"` + SecondParty string `json:"second_party,omitempty" url:"second_party,omitempty"` + SessionExpiry int `json:"session_expiry" url:"session_expiry,omitempty"` + CallTimeLimit int `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` + Record bool `json:"record,omitempty" url:"record,omitempty"` + RecordFileFormat string `json:"record_file_format,omitempty" url:"record_file_format,omitempty"` + RecordingCallbackUrl string `json:"recording_callback_url,omitempty" url:"recording_callback_url,omitempty"` + InitiateCallToFirstParty bool `json:"initiate_call_to_first_party,omitempty" url:"initiate_call_to_first_party,omitempty"` + CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` + RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` + FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` + SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` + RecordingCallbackMethod string `json:"recording_callback_method,omitempty" url:"recording_callback_method,omitempty"` + IsPinAuthenticationRequired bool `json:"is_pin_authentication_required,omitempty" url:"is_pin_authentication_required,omitempty"` + GeneratePin bool `json:"generate_pin,omitempty" url:"generate_pin,omitempty"` + GeneratePinLength int64 `json:"generate_pin_length,omitempty" url:"generate_pin_length,omitempty"` + FirstPartyPin string `json:"first_party_pin,omitempty" url:"first_party_pin,omitempty"` + SecondPartyPin string `json:"second_party_pin,omitempty" url:"second_party_pin,omitempty"` + PinPromptPlay string `json:"pin_prompt_play,omitempty" url:"pin_prompt_play,omitempty"` + PinRetry int64 `json:"pin_retry,omitempty" url:"pin_retry,omitempty"` + PinRetryWait int64 `json:"pin_retry_wait,omitempty" url:"pin_retry_wait,omitempty"` + IncorrectPinPlay string `json:"incorrect_pin_play,omitempty" url:"incorrect_pin_play,omitempty"` + UnknownCallerPlay string `json:"unknown_caller_play,omitempty" url:"unknown_caller_play,omitempty"` + SubAccount string `json:"subaccount,omitempty" url:"subaccount,omitempty"` + GeoMatch *bool `json:"geomatch,omitempty" url:"geomatch,omitempty"` + VirtualNumberCooloffPeriod int `json:"virtual_number_cooloff_period,omitempty" url:"virtual_number_cooloff_period,omitempty"` + ForcePinAuthentication bool `json:"force_pin_authentication,omitempty" url:"force_pin_authentication,omitempty"` + CreateSessionWithSingleParty bool `json:"create_session_with_single_Party,omitempty" url:"create_session_with_single_Party,omitempty"` } type UpdateMaskingSessionParams struct { - SessionExpiry int64 `json:"session_expiry,omitempty" url:"session_expiry,omitempty"` - CallTimeLimit int64 `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` - Record bool `json:"record,omitempty" url:"record,omitempty"` - RecordFileFormat string `json:"record_file_format,omitempty" url:"record_file_format,omitempty"` - RecordingCallbackUrl string `json:"recording_callback_url,omitempty" url:"recording_callback_url,omitempty"` - CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` - FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` - SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` - RecordingCallbackMethod string `json:"recording_callback_method,omitempty" url:"recording_callback_method,omitempty"` - SubAccount string `json:"subaccount,omitempty" url:"subaccount,omitempty"` - GeoMatch *bool `json:"geomatch,omitempty" url:"geomatch,omitempty"` + FirstParty string `json:"first_party,omitempty" url:"first_party,omitempty"` + SecondParty string `json:"second_party,omitempty" url:"second_party,omitempty"` + SessionExpiry int64 `json:"session_expiry,omitempty" url:"session_expiry,omitempty"` + CallTimeLimit int64 `json:"call_time_limit,omitempty" url:"call_time_limit,omitempty"` + Record bool `json:"record,omitempty" url:"record,omitempty"` + RecordFileFormat string `json:"record_file_format,omitempty" url:"record_file_format,omitempty"` + RecordingCallbackUrl string `json:"recording_callback_url,omitempty" url:"recording_callback_url,omitempty"` + CallbackUrl string `json:"callback_url,omitempty" url:"callback_url,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` + RingTimeout int64 `json:"ring_timeout,omitempty" url:"ring_timeout,omitempty"` + FirstPartyPlayUrl string `json:"first_party_play_url,omitempty" url:"first_party_play_url,omitempty"` + SecondPartyPlayUrl string `json:"second_party_play_url,omitempty" url:"second_party_play_url,omitempty"` + RecordingCallbackMethod string `json:"recording_callback_method,omitempty" url:"recording_callback_method,omitempty"` + SubAccount string `json:"subaccount,omitempty" url:"subaccount,omitempty"` + GeoMatch *bool `json:"geomatch,omitempty" url:"geomatch,omitempty"` + CreateSessionWithSingleParty bool `json:"create_session_with_single_Party,omitempty" url:"create_session_with_single_Party,omitempty"` } type ListSessionFilterParams struct { diff --git a/maskingsession_test.go b/maskingsession_test.go index 720bc8b..4e6cc09 100644 --- a/maskingsession_test.go +++ b/maskingsession_test.go @@ -42,6 +42,58 @@ func TestMaskingSessionService_CreateMaskingSession_GeoMatch(t *testing.T) { }) } +func TestMaskingSessionService_CreateMaskingSession_VirtualNumberCooloffPeriod(t *testing.T) { + t.Run("VirtualNumberCooloffPeriod::3500", func(t *testing.T) { + _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{ + FirstParty: "+919999323467", + SecondParty: "+919891865130", + VirtualNumberCooloffPeriod: 3500, + }) + if err != nil { + t.Logf("err :: %v", err) + } + }) + +} + +func TestMaskingSessionService_CreateMaskingSession_CreateSessionWithSingleParty(t *testing.T) { + t.Run("CreateSessionWithSingleParty::True", func(t *testing.T) { + _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{ + FirstParty: "+919999323467", + CreateSessionWithSingleParty: true, + }) + if err != nil { + t.Logf("err :: %v", err) + } + }) + +} + +func TestMaskingSessionService_CreateMaskingSession_ForcePinAuthentication(t *testing.T) { + t.Run("ForcePinAuthentication::True", func(t *testing.T) { + _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{ + FirstParty: "916303955746", + SecondParty: "916384880853", + CreateSessionWithSingleParty: true, + IsPinAuthenticationRequired: true, + GeneratePin: true, + GeneratePinLength: 4, + FirstPartyPin: "1234", + SecondPartyPin: "2435", + PinRetry: 2, + PinRetryWait: 5, + PinPromptPlay: "https://plivobin-prod-usw.plivops.com/api/v1/speak.mp3", + UnknownCallerPlay: "", + IncorrectPinPlay: "https://plivobin-prod-usw.plivops.com/api/v1/speak.mp3", + ForcePinAuthentication: true, + }) + if err != nil { + t.Logf("err :: %v", err) + } + }) + +} + func TestMaskingSessionService_CreateMaskingSession_SubAccount(t *testing.T) { t.Run("SubAccount::Empty", func(t *testing.T) { _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{