-
Notifications
You must be signed in to change notification settings - Fork 8
/
media.go
74 lines (63 loc) · 2.56 KB
/
media.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package eventbrite
import (
"fmt"
"golang.org/x/net/context"
)
// https://www.eventbrite.com/developer/v3/resources/uploads/
type Media struct {
// the method (always POST)
Method string `json:"upload_method"`
// oauth token
Token string `json:"upload_token"`
// the URL that should be uploaded to
Url string `json:"url"`
// the POST data that should be included in the POST that uploads the file
UploadData UploadData `json:"upload_data"`
// Specifies the POST field that the file itself should be included in (handled using HTTP multipart upload)
FileParameterName string `json:"file_parameter_name"`
}
type UploadData struct {
AWSAccessKeyID string `json:"AWSAccessKeyId"`
Bucket string `json:"bucket"`
Acl string `json:"acl"`
Key string `json:"kcl"`
Signature string `json:"signature"`
Policy string `json:"policy"`
}
// https://www.eventbrite.com/developer/v3/endpoints/media/#ebapi-id1
type MediaGetUpload struct {
// The type of image to upload (Valid choices are: image-event-logo, image-event-logo-preserve-quality,
// image-event-view-from-seat, image-organizer-logo, image-user-photo, or image-structured-content)
Type string `json:"type" validate:"required"`
}
// https://www.eventbrite.com/developer/v3/endpoints/media/#ebapi-id3
type MediaCreateUpload struct {
// The upload_token from the GET portion of the upload
UploadToken string `json:"upload_token" validate:"required"`
// X coordinate for top-left corner of crop mask
TopLeftX int `json:"crop_mask.top_left.x"`
// Y coordinate for top-left corner of crop mask
TopLeftY int `json:"crop_mask.top_left.y"`
// Crop mask width
Width int `json:"crop_mask.width"`
// Crop mask height
Height int `json:"crop_mask.height"`
}
// https://www.eventbrite.com/developer/v3/endpoints/media/#ebapi-get-media-upload
// https://www.eventbrite.com/developer/v3/resources/uploads/
func (c *Client) MediaGet(ctx context.Context, req *MediaGetUpload) (*Media, error) {
m := new(Media)
return m, c.getJSON(ctx, "/media/upload/", req, m)
}
// Return an image for a given id
//
// https://www.eventbrite.com/developer/v3/endpoints/media/#ebapi-get-media-id
func (c *Client) MediaGetUpload(ctx context.Context, id string) (*Image, error) {
i := new(Image)
return i, c.getJSON(ctx, fmt.Sprintf("/media/%s/", id), nil, i)
}
// https://www.eventbrite.com/developer/v3/endpoints/media/#ebapi-post-media-upload
func (c *Client) MediaCreate(ctx context.Context, req *MediaCreateUpload) (*Image, error) {
i := new(Image)
return i, c.getJSON(ctx, fmt.Sprintf("/media/upload/"), req, i)
}