-
Notifications
You must be signed in to change notification settings - Fork 0
/
appstore.go
49 lines (40 loc) · 845 Bytes
/
appstore.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
package appstore
import (
"net/http"
)
type Resource[T any] struct {
ID string `json:"id"`
Type string `json:"type"`
Attr T `json:"attributes"`
Links Links `json:"links"`
}
type Links struct {
Self string `json:"self"`
Next string `json:"next"`
First string `json:"first"`
}
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
type Client struct {
httpClient HTTPClient
tokenSource TokenSource
}
func NewClient(httpClient HTTPClient, tokenSource TokenSource) *Client {
return &Client{
httpClient: httpClient,
tokenSource: tokenSource,
}
}
type response[T any] struct {
Data T `json:"data"`
Links Links `json:"links"`
Meta meta `json:"meta"`
}
type meta struct {
Paging paging `json:"paging"`
}
type paging struct {
Total int `json:"total"`
Limit int `json:"limit"`
}