Skip to content

Commit

Permalink
Add durations to the end calls endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
winston-stripe committed Sep 26, 2024
1 parent c198962 commit 240605c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"net/url"
"strconv"
"time"
)

type Call struct {
Expand Down Expand Up @@ -52,6 +53,11 @@ type UpdateCallParameters struct {
JoinURL string
}

type EndCallParameters struct {
// Duration is the duration of the call in seconds. Omitted if 0.
Duration time.Duration
}

type callResponse struct {
Call Call `json:"call"`
SlackResponse
Expand Down Expand Up @@ -148,17 +154,21 @@ func (api *Client) UpdateCallContext(ctx context.Context, callID string, params
}

// EndCall ends a Call.
func (api *Client) EndCall(callID string) error {
return api.EndCallContext(context.Background(), callID)
func (api *Client) EndCall(callID string, params EndCallParameters) error {
return api.EndCallContext(context.Background(), callID, params)
}

// EndCallContext ends a Call.
func (api *Client) EndCallContext(ctx context.Context, callID string) error {
func (api *Client) EndCallContext(ctx context.Context, callID string, params EndCallParameters) error {
values := url.Values{
"token": {api.token},
"id": {callID},
}

if params.Duration != 0 {
values.Set("duration", strconv.FormatInt(int64(params.Duration.Seconds()), 10))
}

response := &SlackResponse{}
if err := api.postMethod(ctx, "calls.end", values, response); err != nil {
return err
Expand Down

0 comments on commit 240605c

Please sign in to comment.