-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeviation_literature.go
109 lines (86 loc) · 3.26 KB
/
deviation_literature.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
package deviantart
import (
"fmt"
"github.com/google/uuid"
)
type CreateLiteratureParams struct {
// Literature title.
Title string `url:"title"`
// The `body` of the literature.
Body string `url:"body,omitempty"`
// Literature description.
Description string `url:"description,omitempty"`
// Literature tags.
Tags []string `url:"tags,brackets,omitempty"`
// UUIDs of gallery folders to publish this submission to.
GalleryIDs []uuid.UUID `url:"galleryids,omitempty"`
// 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"`
// Allow comments on the submission
AllowComments bool `url:"allow_comments,omitempty"`
// License options.
LicenseOptions []LicenseOptions `url:"license_options"`
// ID of the embeded deviation.
EmbeddedImageDeviationID string `url:"embedded_image_deviation_id,omitempty"`
}
// CreateLiterature creates literature.
//
// To connect to this endpoint OAuth2 Access Token from the Authorization Code
// Grant is required.
//
// The following scopes are required to access this resource:
//
// - user.manage
func (s *DeviationService) CreateLiterature(params *CreateLiteratureParams) (uuid.UUID, error) {
var (
success map[string]uuid.UUID
failure Error
)
_, err := s.sling.New().Post("literature/create/").BodyForm(params).Receive(&success, &failure)
if err := relevantError(err, failure); err != nil {
return uuid.UUID{}, fmt.Errorf("unable to create literature: %w", err)
}
return success["deviationid"], nil
}
type UpdateLiteratureParams struct {
// Literature title.
Title string `url:"title"`
// Literature tags.
Tags []string `url:"tags,brackets,omitempty"`
// UUIDs of gallery folders to publish this submission to.
GalleryIDs []uuid.UUID `url:"galleryids,omitempty"`
// 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"`
// Allow comments on the submission
AllowComments bool `url:"allow_comments,omitempty"`
// License options.
LicenseOptions []LicenseOptions `url:"license_options"`
}
// UpdateLiterature updates literature. Note: null/empty values will have the
// corresponding fields cleared. To keep a field value send the old one.
//
// To connect to this endpoint OAuth2 Access Token from the Authorization Code
// Grant is required.
//
// The following scopes are required to access this resource:
//
// - user.manage
func (s *DeviationService) UpdateLiterature(deviationID uuid.UUID, params *UpdateLiteratureParams) (DeviationUpdateResponse, error) {
var (
success DeviationUpdateResponse
failure Error
)
_, err := s.sling.New().Post("literature/update/").Path(deviationID.String()).BodyForm(params).Receive(&success, &failure)
if err := relevantError(err, failure); err != nil {
return DeviationUpdateResponse{}, fmt.Errorf("unable to update literature: %w", err)
}
return success, nil
}