-
Notifications
You must be signed in to change notification settings - Fork 3
/
icons.go
59 lines (48 loc) · 1.4 KB
/
icons.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
package solus
import (
"context"
"fmt"
)
// IconsService handles all available methods with icons.
type IconsService service
// Icon represents an icon.
type Icon struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Type IconType `json:"type"`
}
// IconType represents available icon types.
type IconType string
const (
// IconTypeOS indicated OS specific icon.
// OSes like AlmaLinux, Ubuntu, and etc.
IconTypeOS IconType = "os"
// IconTypeApplication indicates application specific icon.
// Applications likes Plesk, Nginx, and etc.
IconTypeApplication IconType = "application"
// IconTypeFlags indicates countries flags.
IconTypeFlags IconType = "flags"
)
// IconsResponse represents paginated list of icons.
// This cursor can be used for iterating over all available icons.
type IconsResponse struct {
paginatedResponse
Data []Icon `json:"data"`
}
// List lists icons.
func (s *IconsService) List(ctx context.Context, filter *FilterIcons) (IconsResponse, error) {
resp := IconsResponse{
paginatedResponse: paginatedResponse{
service: (*service)(s),
},
}
return resp, s.client.list(ctx, "icons", &resp, withFilter(filter.data))
}
// Get gets specified icon.
func (s *IconsService) Get(ctx context.Context, id int) (Icon, error) {
var resp struct {
Data Icon `json:"data"`
}
return resp.Data, s.client.get(ctx, fmt.Sprintf("icons/%d", id), &resp)
}