From 62ed77f1423780debc8f2c90835b66823edf15ec Mon Sep 17 00:00:00 2001 From: Philippe-Adrien Nousse Date: Mon, 30 Jul 2018 10:18:54 +0200 Subject: [PATCH] Added missing comments --- groups.go | 10 ++-------- types/app.go | 1 + types/capabilities.go | 1 + types/errors.go | 6 ++++++ types/responses.go | 9 +++++++++ types/user.go | 1 + 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/groups.go b/groups.go index 53b1a00..2ce3429 100644 --- a/groups.go +++ b/groups.go @@ -49,18 +49,12 @@ func (c *Client) GroupCreate(name string) error { "groupid": name, }, } - if err := c.groupBaseRequest("", "", ro, http.MethodPost); err != nil { - return err - } - return nil + return c.groupBaseRequest("", "", ro, http.MethodPost) } //GroupDelete deletes the group func (c *Client) GroupDelete(name string) error { - if err := c.groupBaseRequest(name, "", nil, http.MethodDelete); err != nil { - return err - } - return nil + return c.groupBaseRequest(name, "", nil, http.MethodDelete) } //GroupSubAdminList lists the group's subadmins diff --git a/types/app.go b/types/app.go index ef75b6c..514288f 100644 --- a/types/app.go +++ b/types/app.go @@ -1,5 +1,6 @@ package types +//App type App struct { ID string `json:"id"` Ocsid string `json:"ocsid"` diff --git a/types/capabilities.go b/types/capabilities.go index fba7d7b..a505fdc 100644 --- a/types/capabilities.go +++ b/types/capabilities.go @@ -1,5 +1,6 @@ package types +//Capabilities type Capabilities struct { Core struct { Pollinterval int `json:"pollinterval"` diff --git a/types/errors.go b/types/errors.go index 7e15103..be24610 100644 --- a/types/errors.go +++ b/types/errors.go @@ -5,11 +5,13 @@ import ( "strings" ) +//APIError contains the returned error code and message from the Nextcloud's API type APIError struct { Code int Message string } +//ErrorFromMeta return a types.APIError from the Response's types.Meta func ErrorFromMeta(meta Meta) *APIError { return &APIError{ meta.Statuscode, @@ -17,15 +19,18 @@ func ErrorFromMeta(meta Meta) *APIError { } } +//Error return the types.APIError string func (e *APIError) Error() string { return fmt.Sprintf("%d : %s", e.Code, e.Message) } +//UpdateError contains the user's field and corresponding error type UpdateError struct { Field string Error error } +//UpdateError contains the errors resulting from a UserUpdate or a UserCreateFull call type UserUpdateError struct { Errors map[string]error } @@ -38,6 +43,7 @@ func (e *UserUpdateError) Error() string { return strings.Join(errors, ",") } +//NewUpdateError returns an UpdateError based on an UpdateError channel func NewUpdateError(errors chan UpdateError) *UserUpdateError { empty := true var ue UserUpdateError diff --git a/types/responses.go b/types/responses.go index 15bd49b..0ad85a6 100644 --- a/types/responses.go +++ b/types/responses.go @@ -1,5 +1,6 @@ package types +//Meta type Meta struct { Status string `json:"status"` Statuscode int `json:"statuscode"` @@ -8,6 +9,7 @@ type Meta struct { Itemsperpage string `json:"itemsperpage"` } +//ErrorResponse type ErrorResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -15,6 +17,7 @@ type ErrorResponse struct { } `json:"ocs"` } +//UserListResponse type UserListResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -24,6 +27,7 @@ type UserListResponse struct { } `json:"ocs"` } +//UserResponse type UserResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -31,6 +35,7 @@ type UserResponse struct { } `json:"ocs"` } +//BaseResponse type BaseResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -38,6 +43,7 @@ type BaseResponse struct { } `json:"ocs"` } +//GroupListResponse type GroupListResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -47,6 +53,7 @@ type GroupListResponse struct { } `json:"ocs"` } +//AppListResponse type AppListResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -56,6 +63,7 @@ type AppListResponse struct { } `json:"ocs"` } +//AppResponse type AppResponse struct { Ocs struct { Meta Meta `json:"meta"` @@ -63,6 +71,7 @@ type AppResponse struct { } `json:"ocs"` } +//CapabilitiesResponse type CapabilitiesResponse struct { Ocs struct { Meta Meta `json:"meta"` diff --git a/types/user.go b/types/user.go index bae7fce..3af5a80 100644 --- a/types/user.go +++ b/types/user.go @@ -1,5 +1,6 @@ package types +//User type User struct { Enabled bool `json:"enabled"` ID string `json:"id"`