6
6
"time"
7
7
8
8
"github.com/rubiojr/omnivore-go/queries"
9
- "github.com/rubiojr/omnivore-go/types"
10
9
"github.com/shurcooL/graphql"
11
10
)
12
11
@@ -31,6 +30,17 @@ type Opts struct {
31
30
Token string
32
31
}
33
32
33
+ type Label struct {
34
+ Name string
35
+ Color string
36
+ Description string
37
+ CreatedAt time.Time
38
+ ID graphql.ID
39
+ Source string
40
+ Internal bool
41
+ Position int
42
+ }
43
+
34
44
type Subscription struct {
35
45
AutoAddToLibrary bool
36
46
Count int
@@ -73,7 +83,7 @@ type SearchItem struct {
73
83
Words int
74
84
FeedContent string
75
85
Folder string
76
- Labels []types. Label
86
+ Labels []Label
77
87
}
78
88
79
89
type SearchOpts struct {
@@ -97,6 +107,10 @@ func NewClient(opts Opts) *Omnivore {
97
107
}
98
108
99
109
func NewClientFor (url string , opts Opts ) * Omnivore {
110
+ if opts .Token == "" {
111
+ panic ("token is missing" )
112
+ }
113
+
100
114
httpClient := & http.Client {
101
115
Transport : & headerTransport {
102
116
Token : opts .Token ,
@@ -146,9 +160,9 @@ func (c *Omnivore) Search(opts SearchOpts) ([]SearchItem, error) {
146
160
FeedContent : edge .Node .FeedContent ,
147
161
Folder : edge .Node .Folder ,
148
162
}
149
- labels := []types. Label {}
163
+ labels := []Label {}
150
164
for _ , label := range edge .Node .Labels {
151
- labels = append (labels , types. Label {
165
+ labels = append (labels , Label {
152
166
Name : label .Name ,
153
167
Color : label .Color ,
154
168
Description : label .Description ,
@@ -250,8 +264,8 @@ func (a *ApiKey) HasExpiry() bool {
250
264
return a .ExpiresAt != "+275760-09-13T00:00:00.000Z"
251
265
}
252
266
253
- func (c * Omnivore ) Labels () ([]* types. Label , error ) {
254
- a := []* types. Label {}
267
+ func (c * Omnivore ) Labels () ([]* Label , error ) {
268
+ a := []* Label {}
255
269
256
270
err := c .graphql .Query (context .Background (), & queries .Labels , nil )
257
271
if err != nil {
@@ -260,7 +274,7 @@ func (c *Omnivore) Labels() ([]*types.Label, error) {
260
274
261
275
result := queries .Labels .Labels .LabelsSuccess
262
276
for _ , label := range result .Labels {
263
- a = append (a , & types. Label {
277
+ a = append (a , & Label {
264
278
ID : label .ID ,
265
279
Name : label .Name ,
266
280
Color : label .Color ,
0 commit comments