-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstash_publish.go
116 lines (92 loc) · 3.15 KB
/
stash_publish.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package deviantart
import (
"fmt"
"github.com/google/uuid"
)
// The mature level of the submission.
const (
MatureLevelStrict = "strict"
MatureLevelModerate = "moderate"
)
// The mature classification of the submission.
const (
MatureClassificationNudity = "nudity"
MatureClassificationSexual = "sexual"
MatureClassificationGore = "gore"
MatureClassificationLanguage = "language"
MatureClassificationIdeology = "ideology"
)
type DisplayResolution uint8
const (
DisplayResolutionOriginal DisplayResolution = iota
DisplayResolution400px
DisplayResolution600px
DisplayResolution800px
DisplayResolution900px
DisplayResolution1024px
DisplayResolution1280px
DisplayResolution1600px
DisplayResolution1920px
)
const (
SharingOptionsAllow = "allow"
SharingOptionsHideShareButtons = "hide_share_buttons"
SharingOptionsHideAndMembersOnly = "hide_and_members_only"
)
type StashPublishParams struct {
// The ID of the stash item to publish.
ItemID int64 `url:"itemid"`
// Submission is mature or not.
IsMature bool `url:"is_mature"`
// The mature level of the submission, required for mature submissions.
MatureLevel string `url:"mature_level,omitempty"`
// The mature classification of the submission.
MatureClassification []string `url:"mature_classification,brackets,omitempty"`
// Agree to submission policy.
AgreeSubmission bool `url:"agree_submission"`
// Agree to terms of service.
AgreeToS bool `url:"agree_tos"`
// Feature the submission. Default: true.
Feature bool `url:"feature,omitempty"`
// Allow comments on the submission. Default: true.
AllowComments bool `url:"allow_comments,omitempty"`
// Request a critique, only available to some users see `/publish/userdata`.
RequestCritique bool `url:"request_critique,omitempty"`
// Resize image to. Cannot be bigger than image and is ignored for non images.
DisplayResolution DisplayResolution `url:"display_resolution,omitempty"`
// Sharing options.
SharingOptions string `url:"sharing,omitempty"`
// License options.
LicenseOptions LicenseOptions `url:"license_options,omitempty"`
// UUIDs of gallery folders to publish this submission to.
GalleryIDs []string `url:"galleryids,omitempty"`
// Offer original file as a free download.
AllowFreeDownload bool `url:"allow_free_download,omitempty"`
// Add watermark. Available only if display_resolution is present.
AddWatermark bool `url:"add_watermark,omitempty"`
}
type StashPublishResponse struct {
StatusResponse
URL string `json:"url"`
DeviationID uuid.UUID `json:"deviationid"`
}
// Publish a Sta.sh item to deviantART.
//
// To connect to this endpoint OAuth2 Access Token from the Authorization Code
// Grant is required.
//
// The following scopes are required to access this resource:
//
// - stash
// - publish
func (s *StashService) Publish(params StashPublishParams) (StashPublishResponse, error) {
var (
success StashPublishResponse
failure Error
)
_, err := s.sling.New().Post("publish").QueryStruct(¶ms).Receive(&success, &failure)
if err := relevantError(err, failure); err != nil {
return StashPublishResponse{}, fmt.Errorf("unable to publish item: %w", err)
}
return success, nil
}