Skip to content

Commit 35e7b07

Browse files
committed
Add support for the optional webhook when placing a call
1 parent 25c6114 commit 35e7b07

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

voice/call.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,24 @@ func Calls(client *messagebird.Client) *Paginator {
121121
// When placing a call, you pass the source (the caller ID), the destination
122122
// (the number/address that will be called), and the callFlow (the call flow to
123123
// execute when the call is answered).
124-
func InitiateCall(client *messagebird.Client, source, destination string, callflow CallFlow) (*Call, error) {
124+
func InitiateCall(client *messagebird.Client, source, destination string, callflow CallFlow, webhook *Webhook) (*Call, error) {
125125
body := struct {
126126
Source string `json:"source"`
127127
Destination string `json:"destination"`
128128
Callflow CallFlow `json:"callflow"`
129-
// TODO: Optional webhook
129+
Webhook struct {
130+
URL string `json:"url,omitempty"`
131+
Token string `json:"token,omitempty"`
132+
}
130133
}{
131134
Source: source,
132135
Destination: destination,
133136
Callflow: callflow,
134137
}
138+
if webhook != nil {
139+
body.Webhook.URL = webhook.URL
140+
body.Webhook.Token = webhook.Token
141+
}
135142
call := &Call{}
136143
err := client.Request(call, "POST", "calls/", body)
137144
return call, err

0 commit comments

Comments
 (0)