summaryrefslogtreecommitdiff
path: root/user-group.go
diff options
context:
space:
mode:
Diffstat (limited to 'user-group.go')
-rw-r--r--user-group.go78
1 files changed, 43 insertions, 35 deletions
diff --git a/user-group.go b/user-group.go
index 1592568..c6b53ee 100644
--- a/user-group.go
+++ b/user-group.go
@@ -1,44 +1,12 @@
package devianter
import (
+ "errors"
"strconv"
"strings"
)
// структура группы или пользователя
-type GroupAbout struct {
- FoundatedAt time `json:"foundationTs"`
- Description Text
-}
-type GroupAdmins struct {
- Results []struct {
- TypeId int
- User struct {
- Username string
- }
- }
-}
-
-type About struct {
- Country, Website, WebsiteLabel, Gender string
- RegDate int64 `json:"deviantFor"`
- Description Text `json:"textContent"`
-
- SocialLinks []struct {
- Value string
- }
- Interests []struct {
- Label, Value string
- }
-}
-
-type users struct {
- About About
- CoverDeviation struct {
- Deviation Deviation `json:"coverDeviation"`
- }
-}
-
type GRuser struct {
ErrorDescription string
Owner struct {
@@ -106,14 +74,21 @@ type Group struct {
}
// подходит как группа, так и пользователь
-func (s Group) GroupFunc() (g GRuser) {
+func (s Group) GetGroup() (g GRuser, err error) {
+ if s.Name == "" {
+ return g, errors.New("missing Name field")
+ }
ujson("dauserprofile/init/about?username="+s.Name, &g)
return
}
// гарелея пользователя или группы
-func (s Group) Gallery(page int, folderid ...int) (g Group) {
+func (s Group) GetGallery(page int, folderid ...int) (g Group, err error) {
+ if s.Name == "" {
+ return g, errors.New("missing Name field")
+ }
+
var url strings.Builder
if folderid[0] > 0 {
page--
@@ -137,3 +112,36 @@ func (s Group) Gallery(page int, folderid ...int) (g Group) {
ujson(url.String(), &g.Content)
return
}
+
+type GroupAbout struct {
+ FoundatedAt timeStamp `json:"foundationTs"`
+ Description Text
+}
+type GroupAdmins struct {
+ Results []struct {
+ TypeId int
+ User struct {
+ Username string
+ }
+ }
+}
+
+type About struct {
+ Country, Website, WebsiteLabel, Gender string
+ RegDate int64 `json:"deviantFor"`
+ Description Text `json:"textContent"`
+
+ SocialLinks []struct {
+ Value string
+ }
+ Interests []struct {
+ Label, Value string
+ }
+}
+
+type users struct {
+ About About
+ CoverDeviation struct {
+ Deviation Deviation `json:"coverDeviation"`
+ }
+}