Skip to content

Commit

Permalink
VT-5275: Add support for agent_hold_nusic and customer_hold_music in …
Browse files Browse the repository at this point in the history
…the XML generation (#162)
  • Loading branch information
prashantp-plivo authored Feb 20, 2023
1 parent 73aa40f commit 1f3ac6a
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [7.20.0](https://github.com/plivo/plivo-go/tree/v7.20.0) (2023-02-20)
**Feature - MPC API**
- Added support for agent_hold_nusic and customer_hold_music in the XML generation

## [7.19.0](https://github.com/plivo/plivo-go/tree/v7.19.0) (2023-02-16)
**Feature - MPC AddParticipant API**
- Added two new param - agent_hold_music and customer_hold_music in AddParticipant API
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.19.0"
const sdkVersion = "7.20.0"

const lookupBaseUrl = "lookup.plivo.com"

Expand Down
99 changes: 62 additions & 37 deletions xml/plivoxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1160,42 +1160,42 @@ func TransformString(s string) string {
}

type MultiPartyCallElement struct {
Contents string `xml:",innerxml"`
Role *string `xml:"role,attr"`
MaxDuration *int64 `xml:"maxDuration,attr"`
MaxParticipants *int64 `xml:"maxParticipants,attr"`
RecordMinMemberCount *int64 `xml:"recordMinMemberCount,attr"`
WaitMusicUrl *string `xml:"waitMusicUrl,attr"`
WaitMusicMethod *string `xml:"waitMusicMethod,attr"`
AgentHoldMusicUrl *string `xml:"agentHoldMusicUrl,attr"`
AgentHoldMusicMethod *string `xml:"agentHoldMusicMethod,attr"`
CustomerHoldMusicUrl *string `xml:"customerHoldMusicUrl,attr"`
CustomerHoldMusicMethod *string `xml:"customerHoldMusicMethod,attr"`
Record *bool `xml:"record,attr"`
RecordFileFormat *string `xml:"recordFileFormat,attr"`
RecordingCallbackUrl *string `xml:"recordingCallbackUrl,attr"`
RecordingCallbackMethod *string `xml:"recordingCallbackMethod,attr"`
StatusCallbackEvents *string `xml:"statusCallbackEvents,attr"`
StatusCallbackUrl *string `xml:"statusCallbackUrl,attr"`
StatusCallbackMethod *string `xml:"statusCallbackMethod,attr"`
StayAlone *bool `xml:"stayAlone,attr"`
CoachMode *bool `xml:"coachMode,attr"`
Mute *bool `xml:"mute,attr"`
Hold *bool `xml:"hold,attr"`
StartMpcOnEnter *bool `xml:"startMpcOnEnter,attr"`
EndMpcOnExit *bool `xml:"endMpcOnExit,attr"`
EnterSound *string `xml:"enterSound,attr"`
EnterSoundMethod *string `xml:"enterSoundMethod,attr"`
ExitSound *string `xml:"exitSound,attr"`
ExitSoundMethod *string `xml:"exitSoundMethod,attr"`
OnExitActionUrl *string `xml:"onExitActionUrl,attr"`
OnExitActionMethod *string `xml:"onExitActionMethod,attr"`
RelayDtmfInputs *bool `xml:"relayDtmfInputs,attr"`
XMLName xml.Name `xml:"MultiPartyCall"`
StartRecordingAudio *string `xml:"StartRecordingAudio,attr"`
StartRecordingAudioMethod *string `xml:"StartRecordingAudioMethod,attr"`
StopRecordingAudio *string `xml:"StopRecordingAudio,attr"`
StopRecordingAudioMethod *string `xml:"StopRecordingAudioMethod,attr"`
Contents []interface{} `xml:",innerxml"`
Role *string `xml:"role,attr"`
MaxDuration *int64 `xml:"maxDuration,attr"`
MaxParticipants *int64 `xml:"maxParticipants,attr"`
RecordMinMemberCount *int64 `xml:"recordMinMemberCount,attr"`
WaitMusicUrl *string `xml:"waitMusicUrl,attr"`
WaitMusicMethod *string `xml:"waitMusicMethod,attr"`
AgentHoldMusicUrl *string `xml:"agentHoldMusicUrl,attr"`
AgentHoldMusicMethod *string `xml:"agentHoldMusicMethod,attr"`
CustomerHoldMusicUrl *string `xml:"customerHoldMusicUrl,attr"`
CustomerHoldMusicMethod *string `xml:"customerHoldMusicMethod,attr"`
Record *bool `xml:"record,attr"`
RecordFileFormat *string `xml:"recordFileFormat,attr"`
RecordingCallbackUrl *string `xml:"recordingCallbackUrl,attr"`
RecordingCallbackMethod *string `xml:"recordingCallbackMethod,attr"`
StatusCallbackEvents *string `xml:"statusCallbackEvents,attr"`
StatusCallbackUrl *string `xml:"statusCallbackUrl,attr"`
StatusCallbackMethod *string `xml:"statusCallbackMethod,attr"`
StayAlone *bool `xml:"stayAlone,attr"`
CoachMode *bool `xml:"coachMode,attr"`
Mute *bool `xml:"mute,attr"`
Hold *bool `xml:"hold,attr"`
StartMpcOnEnter *bool `xml:"startMpcOnEnter,attr"`
EndMpcOnExit *bool `xml:"endMpcOnExit,attr"`
EnterSound *string `xml:"enterSound,attr"`
EnterSoundMethod *string `xml:"enterSoundMethod,attr"`
ExitSound *string `xml:"exitSound,attr"`
ExitSoundMethod *string `xml:"exitSoundMethod,attr"`
OnExitActionUrl *string `xml:"onExitActionUrl,attr"`
OnExitActionMethod *string `xml:"onExitActionMethod,attr"`
RelayDtmfInputs *bool `xml:"relayDtmfInputs,attr"`
XMLName xml.Name `xml:"MultiPartyCall"`
StartRecordingAudio *string `xml:"StartRecordingAudio,attr"`
StartRecordingAudioMethod *string `xml:"StartRecordingAudioMethod,attr"`
StopRecordingAudio *string `xml:"StopRecordingAudio,attr"`
StopRecordingAudioMethod *string `xml:"StopRecordingAudioMethod,attr"`
}

func (e MultiPartyCallElement) SetRole(value string) MultiPartyCallElement {
Expand Down Expand Up @@ -1319,7 +1319,7 @@ func (e MultiPartyCallElement) SetExitSoundMethod(value string) MultiPartyCallEl
return e
}
func (e MultiPartyCallElement) SetContents(value string) MultiPartyCallElement {
e.Contents = value
e.Contents = append(e.Contents, value)
return e
}
func (e MultiPartyCallElement) SetStartRecordingAudio(value string) MultiPartyCallElement {
Expand All @@ -1339,6 +1339,31 @@ func (e MultiPartyCallElement) SetStopRecordingAudioMethod(value string) MultiPa
return e
}

func (e MultiPartyCallElement) AddContents(values ...interface{}) MultiPartyCallElement {
e.Contents = append(e.Contents, values)
return e
}

type AgentHoldMusicElement struct {
Contents []interface{} `xml:",innerxml"`
XMLName xml.Name `xml:"AgentHoldMusic"`
}

func (e AgentHoldMusicElement) SetContents(value []interface{}) AgentHoldMusicElement {
e.Contents = value
return e
}

type CustomerHoldMusicElement struct {
Contents []interface{} `xml:",innerxml"`
XMLName xml.Name `xml:"CustomerHoldMusic"`
}

func (e CustomerHoldMusicElement) SetContents(value []interface{}) CustomerHoldMusicElement {
e.Contents = value
return e
}

/*
wordTitle
Replacement of strings.Title as it is depreciated
Expand Down
11 changes: 11 additions & 0 deletions xml/plivoxml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ func TestMPCXML(t *testing.T) {
},
}.String())
}

func TestMPCXMLWithHold(t *testing.T) {
assert.Equal(t,
"<Response><MultiPartyCall role=\"Agent\">mpc_name<AgentHoldMusic><Play loop=\"1\">https://www.abc.com/speak.wav</Play><Wait length=\"5\"></Wait><Speak>Hi There</Speak></AgentHoldMusic><CustomerHoldMusic><Play loop=\"1\">https://www.abc.com/speak.wav</Play><Wait length=\"5\"></Wait><Speak>Hi There</Speak></CustomerHoldMusic></MultiPartyCall></Response>",
ResponseElement{Contents: []interface{}{new(MultiPartyCallElement).SetRole("Agent").SetContents("mpc_name").AddContents([]interface{}{
new(AgentHoldMusicElement).SetContents([]interface{}{new(PlayElement).SetLoop(1).SetContents("https://www.abc.com/speak.wav"), new(WaitElement).SetLength(5), new(SpeakElement).AddSpeak("Hi There")}),
new(CustomerHoldMusicElement).SetContents([]interface{}{new(PlayElement).SetLoop(1).SetContents("https://www.abc.com/speak.wav"), new(WaitElement).SetLength(5), new(SpeakElement).AddSpeak("Hi There")})},
),
},
}.String())
}

0 comments on commit 1f3ac6a

Please sign in to comment.