Help us shape the future of Go! Take the 2026 Go Developer Survey

pin

package module
v0.0.0-...-51cb10f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2016 License: MIT Imports: 9 Imported by: 1

README

Pin

Pin is a Go binding for the Pinboard API. Do note, some methods and field names have been renamed for sanity.

Docs: http://godoc.org/github.com/zachlatta/pin

NOTICE: Not complete, under active development.

License

The MIT License (MIT)

Copyright (c) 2014 Zach Latta

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthToken

type AuthToken struct {
	Username string
	Token    string
}

func (*AuthToken) String

func (t *AuthToken) String() string

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Posts *PostsService
	Tags  *TagsService
	User  *UserService
	Notes *NotesService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, authToken *AuthToken) *Client

NewClient returns a new Pinboard API client. If a nil httpClient client is provided, http.DefaultClient will be used. If you want to do authenticated requests using HTTP Auth, you need to pass in an authenticated client - this library does not handle authentication.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is XML decoded and stored in the value pointed to by v, or returned as an error if an API error has occured. If v implements the io.Writer interface, the raw response will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(urlStr string,
	urlParams *url.Values) (*http.Request, error)

NewRequest constructs a new request to the Pinboard API. A relative URL can be provided in urlStr, in which case it's resolved to the Client's BaseURL. Relative URLs should always be specified without a preceding slash. If the Client has an AuthToken set, then it is added to the urlParams.

type Date

type Date struct {
	Count int
	Date  *time.Time
}

type NotesService

type NotesService struct {
	// contains filtered or unexported fields
}

NotesService is the service for accessing Note-related calls from the Pinboard API.

func (*NotesService) Get

func (s *NotesService) Get()

TODO

https://pinboard.in/api#notes_get

func (*NotesService) List

func (s *NotesService) List()

TODO

https://pinboard.in/api#notes_list

type Post

type Post struct {
	Title       string
	Description string
	Hash        string
	URL         string
	Tags        []string
	ToRead      bool
	Time        *time.Time
}

Post represents a post stored in Pinboard. Fields are transformed from the actual response to be a bit more sane. For example, description from the response is renamed to Title and the extended field is renamed to Description.

type PostsService

type PostsService struct {
	// contains filtered or unexported fields
}

PostsService is the service for accessing Post-related calls from the Pinboard API.

func (*PostsService) Add

func (s *PostsService) Add(urlStr, title, description string, tags []string,
	creationTime *time.Time, replace, shared,
	toread bool) (*http.Response, error)

Add creates a new Post for the authenticated account. urlStr and title are required.

https://pinboard.in/api/#posts_add

func (*PostsService) All

func (s *PostsService) All(tags []string, start int, results int, fromdt, todt *time.Time) ([]*Post,
	*http.Response, error)

All fetches all bookmarks in the user's account.

https://pinboard.in/api#posts_all

func (*PostsService) Dates

func (s *PostsService) Dates(tags []string) ([]*Date, *http.Response, error)

Returns a list of dates with the number of posts at each date.

https://pinboard.in/api#posts_dates

func (*PostsService) Delete

func (s *PostsService) Delete(urlStr string) (*http.Response, error)

Delete deletes the specified Post from the authenticated account where urlStr is the URL of the Post to delete.

https://pinboard.in/api/#posts_delete

func (*PostsService) Get

func (s *PostsService) Get(tags []string, creationTime *time.Time, urlStr string) ([]*Post, *http.Response, error)

Get returns one or more posts on a single day matching the arguments. If no date or url is given, date of most recent bookmark will be used.

https://pinboard.in/api#posts_get

func (*PostsService) LastTimeUpdated

func (s *PostsService) LastTimeUpdated() (*time.Time, *http.Response, error)

Returns the most recent time a bookmark was added, updated or deleted. Use this before calling posts/all to see if the data has changed since the last fetch.

https://pinboard.in/api#posts_update

func (*PostsService) Recent

func (s *PostsService) Recent(tags []string, count int) ([]*Post,
	*http.Response, error)

Recent fetches the most recent Posts for the authenticated account, filtered by tag. Up to 3 tags can be specified to filter by. The max count is 100. If a negative count is passed, then the default number of posts (15) is returned.

https://pinboard.in/api/#posts_recent

func (*PostsService) Suggest

func (s *PostsService) Suggest(urlStr string) ([]string, []string, *http.Response, error)

Returns a list of popular tags and recommended tags for a given URL. Popular tags are tags used site-wide for the url; recommended tags are drawn from the user's own tags.

https://pinboard.in/api#posts_suggest

type Tag

type Tag struct {
	Count int    `xml:"count,attr"`
	Name  string `xml:"tag,attr"`
}

type TagsService

type TagsService struct {
	// contains filtered or unexported fields
}

TagsService is the service for accessing Tag-related calls from the Pinboard API.

func (*TagsService) Delete

func (s *TagsService) Delete(tag string) (*http.Response, error)

Delete an existing tag.

https://pinboard.in/api#tags_delete

func (*TagsService) Get

func (s *TagsService) Get() ([]*Tag, *http.Response, error)

Returns a full list of the user's tags along with the number of times they were used.

https://pinboard.in/api#tags_get

func (*TagsService) Rename

func (s *TagsService) Rename(newTag, oldTag string) (*http.Response, error)

Rename an tag, or fold it in to an existing tag

https://pinboard.in/api#tags_rename

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService provides methods for accessing user actions through the Pinboard API.

func (*UserService) APIToken

func (s *UserService) APIToken() (string, *http.Response, error)

APIToken returns the authenticated user's API token.

func (*UserService) SecretRSSKey

func (s *UserService) SecretRSSKey() (string, *http.Response, error)

SecretRSSKey returns the authenticated user's secret RSS key for viewing private RSS feeds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL