1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-06-30 06:45:24 +00:00
neonmodem/system/lobsters/api/tags.go
2023-01-05 14:57:01 -05:00

50 lines
999 B
Go

package api
import (
"context"
"net/http"
)
const TagsBaseURL = "/tags"
type TagModel struct {
ID int `json:"id"`
Tag string `json:"tag"`
Description string `json:"description"`
Privileged bool `json:"privileged"`
IsMedia bool `json:"is_media"`
Active bool `json:"active"`
HotnessMod float32 `json:"hotness_mod"`
PermitByNewUsers bool `json:"permit_by_new_users"`
CategoryID int `json:"category_id"`
}
type TagsService interface {
List(
ctx context.Context,
) (*[]TagModel, error)
}
type TagServiceHandler struct {
client *Client
}
// List
func (a *TagServiceHandler) List(
ctx context.Context,
) (*[]TagModel, error) {
uri := TagsBaseURL + ".json"
req, err := a.client.NewRequest(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}
response := new([]TagModel)
if err = a.client.Do(ctx, req, response); err != nil {
return nil, err
}
return response, nil
}