Skip to content

Commit e83247c

Browse files
committed
Remove the types package
1 parent 611be48 commit e83247c

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

api.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/rubiojr/omnivore-go/queries"
9-
"github.com/rubiojr/omnivore-go/types"
109
"github.com/shurcooL/graphql"
1110
)
1211

@@ -31,6 +30,17 @@ type Opts struct {
3130
Token string
3231
}
3332

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+
3444
type Subscription struct {
3545
AutoAddToLibrary bool
3646
Count int
@@ -73,7 +83,7 @@ type SearchItem struct {
7383
Words int
7484
FeedContent string
7585
Folder string
76-
Labels []types.Label
86+
Labels []Label
7787
}
7888

7989
type SearchOpts struct {
@@ -97,6 +107,10 @@ func NewClient(opts Opts) *Omnivore {
97107
}
98108

99109
func NewClientFor(url string, opts Opts) *Omnivore {
110+
if opts.Token == "" {
111+
panic("token is missing")
112+
}
113+
100114
httpClient := &http.Client{
101115
Transport: &headerTransport{
102116
Token: opts.Token,
@@ -146,9 +160,9 @@ func (c *Omnivore) Search(opts SearchOpts) ([]SearchItem, error) {
146160
FeedContent: edge.Node.FeedContent,
147161
Folder: edge.Node.Folder,
148162
}
149-
labels := []types.Label{}
163+
labels := []Label{}
150164
for _, label := range edge.Node.Labels {
151-
labels = append(labels, types.Label{
165+
labels = append(labels, Label{
152166
Name: label.Name,
153167
Color: label.Color,
154168
Description: label.Description,
@@ -250,8 +264,8 @@ func (a *ApiKey) HasExpiry() bool {
250264
return a.ExpiresAt != "+275760-09-13T00:00:00.000Z"
251265
}
252266

253-
func (c *Omnivore) Labels() ([]*types.Label, error) {
254-
a := []*types.Label{}
267+
func (c *Omnivore) Labels() ([]*Label, error) {
268+
a := []*Label{}
255269

256270
err := c.graphql.Query(context.Background(), &queries.Labels, nil)
257271
if err != nil {
@@ -260,7 +274,7 @@ func (c *Omnivore) Labels() ([]*types.Label, error) {
260274

261275
result := queries.Labels.Labels.LabelsSuccess
262276
for _, label := range result.Labels {
263-
a = append(a, &types.Label{
277+
a = append(a, &Label{
264278
ID: label.ID,
265279
Name: label.Name,
266280
Color: label.Color,

types/label.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)