Added missing comments

This commit is contained in:
Philippe-Adrien Nousse 2018-07-30 10:18:54 +02:00
parent 17ca4cbf14
commit 62ed77f142
6 changed files with 20 additions and 8 deletions

View File

@ -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

View File

@ -1,5 +1,6 @@
package types
//App
type App struct {
ID string `json:"id"`
Ocsid string `json:"ocsid"`

View File

@ -1,5 +1,6 @@
package types
//Capabilities
type Capabilities struct {
Core struct {
Pollinterval int `json:"pollinterval"`

View File

@ -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

View File

@ -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"`

View File

@ -1,5 +1,6 @@
package types
//User
type User struct {
Enabled bool `json:"enabled"`
ID string `json:"id"`