vendor/github.com/McKael/madon/v3/media.go
changeset 270 df7e9dff1b66
parent 268 4dd196a4ee7c
equal deleted inserted replaced
269:c50e88700432 270:df7e9dff1b66
    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"
       
    17 
    16 
    18 	"github.com/pkg/errors"
    17 	"github.com/pkg/errors"
    19 	"github.com/sendgrid/rest"
    18 	"github.com/sendgrid/rest"
    20 )
    19 )
    21 
    20 
   104 	return &attachment, nil
   103 	return &attachment, nil
   105 }
   104 }
   106 
   105 
   107 // UpdateMedia updates the description and focal point of a media
   106 // UpdateMedia updates the description and focal point of a media
   108 // One of the description and focus arguments can be nil to not be updated.
   107 // One of the description and focus arguments can be nil to not be updated.
   109 func (mc *Client) UpdateMedia(mediaID int64, description, focus *string) (*Attachment, error) {
   108 func (mc *Client) UpdateMedia(mediaID ActivityID, description, focus *string) (*Attachment, error) {
   110 	params := make(apiCallParams)
   109 	params := make(apiCallParams)
   111 	if description != nil {
   110 	if description != nil {
   112 		params["description"] = *description
   111 		params["description"] = *description
   113 	}
   112 	}
   114 	if focus != nil {
   113 	if focus != nil {
   115 		params["focus"] = *focus
   114 		params["focus"] = *focus
   116 	}
   115 	}
   117 
   116 
   118 	endPoint := "media/" + strconv.FormatInt(mediaID, 10)
   117 	endPoint := "media/" + mediaID
   119 	var attachment Attachment
   118 	var attachment Attachment
   120 	if err := mc.apiCall("v1/"+endPoint, rest.Put, params, nil, nil, &attachment); err != nil {
   119 	if err := mc.apiCall("v1/"+endPoint, rest.Put, params, nil, nil, &attachment); err != nil {
   121 		return nil, err
   120 		return nil, err
   122 	}
   121 	}
   123 	return &attachment, nil
   122 	return &attachment, nil