-
Notifications
You must be signed in to change notification settings - Fork 0
/
assets.go
67 lines (54 loc) · 1.58 KB
/
assets.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
package appstore
import "fmt"
type AssetState string
const (
AssetStateReadyForUpload AssetState = "AWAITING_UPLOAD"
AssetStateUploadComplete AssetState = "UPLOAD_COMPLETE"
AssetStateComplete AssetState = "COMPLETE"
AssetStateFailed AssetState = "FAILED"
)
type AssetStateError struct {
Code string `json:"code"`
Description string `json:"description"`
}
type AssetDeliveryState struct {
State AssetState `json:"state"`
Errors []AssetStateError `json:"errors"`
Warnings []AssetStateError `json:"warnings"`
}
func (s AssetDeliveryState) IsComplete() bool {
return s.State == AssetStateComplete
}
func (s AssetDeliveryState) Error() error {
if s.State == AssetStateFailed {
return fmt.Errorf("asset failed: %v", s.Errors)
}
return nil
}
type ImageAsset struct {
TemplateURL string `json:"templateUrl"`
Width int `json:"width"`
Height int `json:"height"`
}
type HttpHeader struct {
Name string `json:"name"`
Value string `json:"value"`
}
type UploadOperation struct {
Method string `json:"method"`
URL string `json:"url"`
Offset int `json:"offset"`
Length int `json:"length"`
Headers []HttpHeader `json:"requestHeaders"`
}
type Asset struct {
Name string `json:"fileName"`
Size int `json:"fileSize"`
State AssetDeliveryState `json:"assetDeliveryState"`
Image ImageAsset `json:"imageAsset"`
Operations []UploadOperation `json:"uploadOperations"`
}
type createAsset struct {
Name string `json:"fileName"`
Size int `json:"fileSize"`
}