Documentation ¶
Index ¶
- Constants
- Variables
- func GetAccessToken(developerKey string, developerSecret string) (*oauth.AccessToken, error)
- func WriteConfig(config *Config, path string) error
- type Arguments
- type Book
- type Client
- func (c *Client) AddToShelf(shelf string, bookID string) error
- func (c *Client) GetCurrentUserID() (*User, error)
- func (c *Client) ListShelfBooks(shelf string, userID string) ([]Book, error)
- func (c *Client) ListShelves(userID string) ([]UserShelf, error)
- func (c *Client) SearchBooks(query string) ([]Work, error)
- type Config
- type Response
- type Reviews
- type Search
- type Shelves
- type User
- type UserShelf
- type Work
Constants ¶
const ( // APIUri holds the Goodreads API uri. APIUri = "https://www.goodreads.com" // SearchEndpoint is the API endpoint for searching for books. SearchEndpoint = "/search/index.xml" // ShelfListEndpoint is the API endpoint for listing shelves ShelfListEndpoint = "/shelf/list.xml" // CurrentUserEndpoint is the API endpoint to get the current user CurrentUserEndpoint = "/api/auth_user" // ListShelfEndpoint is the API endpoint to list books on a shelf ListShelfEndpoint = "/review/list" // AddToShelfEndpoint is the API endpoint to add a book to a shelf AddToShelfEndpoint = "/shelf/add_to_shelf.xml" // RequestTokenURI holds the Goodreads request token uri RequestTokenURI = "https://www.goodreads.com/oauth/request_token" // AuthorizeTokenURI holds the Goodreads authorize token uri AuthorizeTokenURI = "https://www.goodreads.com/oauth/authorize" // AccessTokenURI holds the Goodreads access token uri AccessTokenURI = "https://www.goodreads.com/oauth/access_token" )
Variables ¶
var ( // ErrorEmptyResult defines the error when the result is empty. ErrorEmptyResult = errors.New("Empty result") )
Functions ¶
func GetAccessToken ¶
func GetAccessToken(developerKey string, developerSecret string) (*oauth.AccessToken, error)
GetAccessToken returns an oauth access token
func WriteConfig ¶
WriteConfig writes a Config object to the config file
Types ¶
type Arguments ¶
Arguments are a map of key/value query strings
func (Arguments) ToURLValues ¶
ToURLValues converts Arguments into query strings
type Book ¶
type Book struct { ID string `xml:"book>id,omitempty"` Title string `xml:"book>title,omitempty"` AvgRating string `xml:"book>average_rating,omitempty"` Link string `xml:"book>link,omitempty"` Pages string `xml:"book>num_pages,omitempty"` ReadAt string `xml:"read_at,omitempty"` }
Book defines the struct for the book object
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client contains information for authenticating with Goodreads API
func (*Client) AddToShelf ¶
AddToShelf adds a book to shelf.
func (*Client) GetCurrentUserID ¶
GetCurrentUserID returns id for oauth user
func (*Client) ListShelfBooks ¶
ListShelfBooks returns books by from a shelf.
func (*Client) ListShelves ¶
ListShelves for current user.
type Config ¶
type Config struct { DeveloperKey string `yaml:"DeveloperKey"` DeveloperSecret string `yaml:"DeveloperSecret"` AccessToken string `yaml:"AccessToken"` AccessSecret string `yaml:"AccessSecret"` }
Config contains configuration for authenticating with Goodreads API
func ReadConfig ¶
ReadConfig parses the config file into a Config object
type Response ¶
type Response struct { Search Search `xml:"search,omitempty"` Shelves Shelves `xml:"shelves,omitempty"` User User `xml:"user,omitempty"` Reviews Reviews `xml:"reviews,omitempty"` }
Response defines the data struct for an API response object.
type Reviews ¶
type Reviews struct { AttrEnd string `xml:"end,attr"` AttrStart string `xml:"start,attr"` AttrTotal string `xml:"total,attr"` Books []Book `xml:"review,omitempty"` }
Reviews defines the struct for the reviews object
type Search ¶
type Search struct {
Works []Work `xml:"results>work,omitempty" json:"work,omitempty"`
}
Search defines the struct for the search object
type Shelves ¶
type Shelves struct {
UserShelves []UserShelf `xml:"user_shelf,omitempty"`
}
Shelves defines the struct for the shelves object
type User ¶
type User struct {
ID string `xml:"id,attr"`
}
User defines the struct for the user object
type UserShelf ¶
type UserShelf struct { ID string `xml:"id,omitempty"` Name string `xml:"name,omitempty"` BookCount string `xml:"book_count,omitempty"` }
UserShelf defines the struct for the user shelf object
type Work ¶
type Work struct { ID string `xml:"best_book>id,omitempty"` Title string `xml:"best_book>title,omitempty"` Author string `xml:"best_book>author>name,omitempty"` RatingsCount string `xml:"ratings_count,omitempty"` AvgRating string `xml:"average_rating,omitempty"` }
Work defines the struct for the work object