# HG changeset patch # User Mikael Berthe # Date 1521579175 -3600 # Node ID 403ce36a94ab3d59a969fab39ffbc4361903631a # Parent 40ed4e2db3b9b8f48156205eab1cd67df170d14c Add UpdateMedia diff -r 40ed4e2db3b9 -r 403ce36a94ab media.go --- a/media.go Tue Mar 20 20:51:27 2018 +0100 +++ b/media.go Tue Mar 20 21:52:55 2018 +0100 @@ -13,6 +13,7 @@ "mime/multipart" "os" "path/filepath" + "strconv" "github.com/pkg/errors" "github.com/sendgrid/rest" @@ -86,3 +87,22 @@ } return &attachment, nil } + +// UpdateMedia updates the description and focal point of a media +// One of the description and focus arguments can be nil to not be updated. +func (mc *Client) UpdateMedia(mediaID int64, description, focus *string) (*Attachment, error) { + params := make(apiCallParams) + if description != nil { + params["description"] = *description + } + if focus != nil { + params["focus"] = *focus + } + + endPoint := "media/" + strconv.FormatInt(mediaID, 10) + var attachment Attachment + if err := mc.apiCall(endPoint, rest.Put, params, nil, nil, &attachment); err != nil { + return nil, err + } + return &attachment, nil +}