Remove feedbin code

Closes #31.
This commit is contained in:
Peter Stuifzand 2019-11-19 21:59:32 +01:00
parent c7a1e65b50
commit 5515416eb4
Signed by: peter
GPG Key ID: 374322D56E5209E8
3 changed files with 0 additions and 122 deletions

View File

@ -1,69 +0,0 @@
package feedbin
import (
"encoding/json"
"fmt"
)
// Feedbin is the main object for calling the Feedbin API
type Feedbin struct {
user string
password string
}
// New returns a new Feedbin object with the provided user and password
func New(user, password string) *Feedbin {
var fb Feedbin
fb.user = user
fb.password = password
return &fb
}
// Taggings returns taggings
func (fb *Feedbin) Taggings() ([]Tagging, error) {
resp, err := fb.get("/v2/taggings.json")
if err != nil {
return []Tagging{}, err
}
defer resp.Body.Close()
var taggings []Tagging
dec := json.NewDecoder(resp.Body)
dec.Decode(&taggings)
return taggings, nil
}
// Feed returns a Feed for id
func (fb *Feedbin) Feed(id int64) (Feed, error) {
resp, err := fb.get(fmt.Sprintf("/v2/feeds/%d.json", id))
if err != nil {
return Feed{}, err
}
defer resp.Body.Close()
var feed Feed
dec := json.NewDecoder(resp.Body)
dec.Decode(&feed)
return feed, nil
}
// Entries return a slice of entries
func (fb *Feedbin) Entries() ([]Entry, error) {
resp, err := fb.get("/v2/entries.json")
if err != nil {
return []Entry{}, err
}
defer resp.Body.Close()
var entries []Entry
dec := json.NewDecoder(resp.Body)
dec.Decode(&entries)
return entries, nil
}

View File

@ -1,20 +0,0 @@
package feedbin
import (
"fmt"
"net/http"
)
func (fb *Feedbin) get(u string) (*http.Response, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("https://api.feedbin.com%s", u), nil)
if err != nil {
return nil, err
}
req.SetBasicAuth(fb.user, fb.password)
client := http.Client{}
return client.Do(req)
}

View File

@ -1,33 +0,0 @@
package feedbin
import (
"time"
)
// Entry is a feedbin api entry
type Entry struct {
ID int64 `json:"id"`
FeedID int64 `json:"feed_id"`
Title string `json:"title"`
URL string `json:"url"`
Author string `json:"author"`
Content string `json:"content"`
Summary string `json:"summary"`
Published time.Time `json:"published"`
CreatedAt time.Time `json:"created_at"`
}
// Feed is a feedbin api feed
type Feed struct {
ID int64 `json:"id,omitempty"`
Title string `json:"title"`
FeedURL string `json:"feed_url"`
SiteURL string `json:"site_url"`
}
// Tagging is a feedbin api tagging
type Tagging struct {
ID int64 `json:"id,omitempty"`
FeedID int64 `json:"feed_id"`
Name string `json:"name"`
}