equal
deleted
inserted
replaced
11 "encoding/json" |
11 "encoding/json" |
12 "io" |
12 "io" |
13 "mime/multipart" |
13 "mime/multipart" |
14 "os" |
14 "os" |
15 "path/filepath" |
15 "path/filepath" |
|
16 "strconv" |
16 |
17 |
17 "github.com/pkg/errors" |
18 "github.com/pkg/errors" |
18 "github.com/sendgrid/rest" |
19 "github.com/sendgrid/rest" |
19 ) |
20 ) |
20 |
21 |
84 if err != nil { |
85 if err != nil { |
85 return nil, errors.Wrap(err, "cannot decode API response (media)") |
86 return nil, errors.Wrap(err, "cannot decode API response (media)") |
86 } |
87 } |
87 return &attachment, nil |
88 return &attachment, nil |
88 } |
89 } |
|
90 |
|
91 // UpdateMedia updates the description and focal point of a media |
|
92 // One of the description and focus arguments can be nil to not be updated. |
|
93 func (mc *Client) UpdateMedia(mediaID int64, description, focus *string) (*Attachment, error) { |
|
94 params := make(apiCallParams) |
|
95 if description != nil { |
|
96 params["description"] = *description |
|
97 } |
|
98 if focus != nil { |
|
99 params["focus"] = *focus |
|
100 } |
|
101 |
|
102 endPoint := "media/" + strconv.FormatInt(mediaID, 10) |
|
103 var attachment Attachment |
|
104 if err := mc.apiCall(endPoint, rest.Put, params, nil, nil, &attachment); err != nil { |
|
105 return nil, err |
|
106 } |
|
107 return &attachment, nil |
|
108 } |