--- 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
+}