Skip to content

Commit

Permalink
Remove the types package
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiojr committed Mar 23, 2024
1 parent 611be48 commit e83247c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
28 changes: 21 additions & 7 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/rubiojr/omnivore-go/queries"
"github.com/rubiojr/omnivore-go/types"
"github.com/shurcooL/graphql"
)

Expand All @@ -31,6 +30,17 @@ type Opts struct {
Token string
}

type Label struct {
Name string
Color string
Description string
CreatedAt time.Time
ID graphql.ID
Source string
Internal bool
Position int
}

type Subscription struct {
AutoAddToLibrary bool
Count int
Expand Down Expand Up @@ -73,7 +83,7 @@ type SearchItem struct {
Words int
FeedContent string
Folder string
Labels []types.Label
Labels []Label
}

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

func NewClientFor(url string, opts Opts) *Omnivore {
if opts.Token == "" {
panic("token is missing")
}

httpClient := &http.Client{
Transport: &headerTransport{
Token: opts.Token,
Expand Down Expand Up @@ -146,9 +160,9 @@ func (c *Omnivore) Search(opts SearchOpts) ([]SearchItem, error) {
FeedContent: edge.Node.FeedContent,
Folder: edge.Node.Folder,
}
labels := []types.Label{}
labels := []Label{}
for _, label := range edge.Node.Labels {
labels = append(labels, types.Label{
labels = append(labels, Label{
Name: label.Name,
Color: label.Color,
Description: label.Description,
Expand Down Expand Up @@ -250,8 +264,8 @@ func (a *ApiKey) HasExpiry() bool {
return a.ExpiresAt != "+275760-09-13T00:00:00.000Z"
}

func (c *Omnivore) Labels() ([]*types.Label, error) {
a := []*types.Label{}
func (c *Omnivore) Labels() ([]*Label, error) {
a := []*Label{}

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

result := queries.Labels.Labels.LabelsSuccess
for _, label := range result.Labels {
a = append(a, &types.Label{
a = append(a, &Label{
ID: label.ID,
Name: label.Name,
Color: label.Color,
Expand Down
18 changes: 0 additions & 18 deletions types/label.go

This file was deleted.

0 comments on commit e83247c

Please sign in to comment.