Documentation ¶
Index ¶
- Constants
- Variables
- func AddUseRawContentToContext(ctx context.Context, val bool) context.Context
- func ChangeTitle(client APIClient, old, new string) error
- func CreateNotebook(client APIClient, notebook *Notebook, defaultNotebook bool) error
- func DeleteNote(client APIClient, title, notebook string) error
- func GetUseRawContentFromContext(ctx context.Context) bool
- func Login(client APIClient) error
- func Logout(cfg config.Configuration) error
- func MoveNote(client APIClient, noteTitle, notebookName string) error
- func SaveChanges(client APIClient, n *Note, useRawContent bool) error
- func SaveNewNote(client APIClient, n *Note, raw bool) error
- func UpdateNotebook(client APIClient, name string, notebook *Notebook) error
- type APIClient
- type Client
- func (c Client) GetAPIToken() string
- func (c *Client) GetAuthorizedToken(tmpToken *oauth.RequestToken, verifier string) (string, error)
- func (c *Client) GetConfig() config.Configuration
- func (c *Client) GetNoteStore() (NotestoreClient, error)
- func (c *Client) GetRequestToken(callback string) (*oauth.RequestToken, string, error)
- type Note
- type NoteFilter
- type Notebook
- type Notestore
- func (s *Notestore) CreateNote(n *Note) error
- func (s *Notestore) CreateNotebook(b *Notebook, defaultNotebook bool) error
- func (s *Notestore) DeleteNote(guid string) error
- func (s *Notestore) FindNotes(filter *NoteFilter, offset, count int) ([]*Note, error)
- func (s *Notestore) GetAllNotebooks() ([]*Notebook, error)
- func (s *Notestore) GetClient() APIClient
- func (s *Notestore) GetNoteContent(guid string) (string, error)
- func (s *Notestore) GetNotebook(guid string) (*Notebook, error)
- func (s *Notestore) UpdateNote(note *Note) error
- func (s *Notestore) UpdateNotebook(b *Notebook) error
- type NotestoreClient
Constants ¶
const ( // XMLHeader is the header that needs to added to the note content. XMLHeader string = `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">` )
Variables ¶
var ( // ErrNotLoggedIn is returned when the user is trying to perform // authenticated actions without being authenticated. ErrNotLoggedIn = errors.New("your are not logged in") // ErrAlreadyLoggedIn is returned if the user is trying to authenticate // but is already authenticated. ErrAlreadyLoggedIn = errors.New("you are already logged in") // ErrTempTokenMismatch is returned if the callback doesn't match the // expected token. ErrTempTokenMismatch = errors.New("temporary token mismatch") // ErrAccessRevoked is returned if the user decline access. ErrAccessRevoked = errors.New("access revoked") // ErrNoGUIDSet is returned if the note does not have a GUID. ErrNoGUIDSet = errors.New("no GUID set.") // ErrNoTitleSet is returned if the not does not have a title. ErrNoTitleSet = errors.New("no title set") )
var ( // NoteFilterOrderCreated sorts the notes by create time. NoteFilterOrderCreated = int32(1) // NoteFilterOrderUpdated sorts the notes by update time. NoteFilterOrderUpdated = int32(2) // NoteFilterOrderRelevance sorts the notes by relevance. NoteFilterOrderRelevance = int32(3) // NoteFilterOrderSequenceNumber sorts the notes by sequence number. NoteFilterOrderSequenceNumber = int32(4) // NoteFilterOrderTitle sorts the notes by title. NoteFilterOrderTitle = int32(5) )
var ( // ErrNoNotebookFound is returned if no matching notebook was found. ErrNoNotebookFound = errors.New("no notebook found") // ErrNoNotebookCached is returned when trying to update a notebook // that hasn't been pulled from the server. ErrNoNotebookCached = errors.New("no notebook found") )
var ErrNoCachedNote = errors.New("no cache note found")
ErrNoCachedNote is return if the note wasn't cached and can't be updated.
var ( // ErrNoNoteFound is returned if search resulted in no notes found. ErrNoNoteFound = errors.New("no note found") )
Functions ¶
func AddUseRawContentToContext ¶ added in v0.3.0
AddUseRawContentToContext adds the value to the context.
func ChangeTitle ¶
ChangeTitle changes the note's title.
func CreateNotebook ¶ added in v0.3.0
CreateNotebook creates a new notebook.
func DeleteNote ¶
DeleteNote moves a note from the notebook to the trash can.
func GetUseRawContentFromContext ¶ added in v0.3.0
GetUseRawContentFromContext get's the useRawContent from the context.
func Logout ¶ added in v0.3.0
func Logout(cfg config.Configuration) error
Logout removes the session stored.
func SaveChanges ¶
SaveChanges updates the changes to the note on the server.
func SaveNewNote ¶
SaveNewNote pushes the new note to the server.
Types ¶
type APIClient ¶ added in v0.3.0
type APIClient interface { // GetNoteStore returns the note store for the user. GetNoteStore() (NotestoreClient, error) // GetAuthorizedToken gets the authorized token from the server. GetAuthorizedToken(tmpToken *oauth.RequestToken, verifier string) (token string, err error) // GetRequestToken requests a request token from the server. GetRequestToken(callbackURL string) (token *oauth.RequestToken, url string, err error) // GetConfig returns the client's configuration. GetConfig() config.Configuration // GetAPIToken returns the user's token. GetAPIToken() string }
APIClient is the interface for the api client.
type Client ¶ added in v0.3.0
type Client struct { // Config holds all the configurations. Config config.Configuration // contains filtered or unexported fields }
Client is an implementation of the client interface for Evernote.
func NewClient ¶ added in v0.3.0
func NewClient(cfg config.Configuration) *Client
NewClient creates a new Evernote client.
func (Client) GetAPIToken ¶ added in v0.3.0
GetAPIToken is the access token for the user's account.
func (*Client) GetAuthorizedToken ¶ added in v0.3.0
GetAuthorizedToken gets the authorized token from the server.
func (*Client) GetConfig ¶ added in v0.3.0
func (c *Client) GetConfig() config.Configuration
GetConfig returns the configuration.
func (*Client) GetNoteStore ¶ added in v0.3.0
func (c *Client) GetNoteStore() (NotestoreClient, error)
GetNoteStore returns a notestore client for the user.
func (*Client) GetRequestToken ¶ added in v0.3.0
GetRequestToken requests a request token from the server.
type Note ¶
type Note struct { // Title is the note tile. Title string // GUID is the unique identifier. GUID string // Body contains the body of the note. Body string `xml:",innerxml"` // MD is a Markdown representation of the note body. MD string // MDHash is the MD5 hash of the MD body. MDHash [16]byte // Deleted is set true if the note is marked for deletion. Deleted bool // Notebook the note belongs to. Notebook *Notebook // Created Created int64 // Updated Updated int64 }
Note is the structure of an Evernote note.
type NoteFilter ¶ added in v0.3.0
type NoteFilter struct { // NotebookGUID is the GUID for the notebook to limit the search to. NotebookGUID string // Words can be a search string or note title. Words string // Order Order int32 }
NoteFilter is the search filter for notes.
type Notebook ¶
type Notebook struct { // Name is the notebook's name Name string // GUID is the notebook's GUID. GUID string // Stack is the stack that the notebook belongs too. Stack string }
Notebook is a struct for the notebook.
func FindNotebook ¶
FindNotebook gets the notebook matching with the name. If no notebook is found, nil is returned.
func GetNotebook ¶ added in v0.3.0
GetNotebook returns a notebook from the user's notestore.
func GetNotebooks ¶
GetNotebooks returns all the user's notebooks.
type Notestore ¶ added in v0.3.0
type Notestore struct {
// contains filtered or unexported fields
}
Notestore is an implementation of the NotestoreClient.
func (*Notestore) CreateNote ¶ added in v0.3.0
CreateNote creates a new note and saves it to the server.
func (*Notestore) CreateNotebook ¶ added in v0.3.0
CreateNotebook creates a new notebook for the user.
func (*Notestore) DeleteNote ¶ added in v0.3.0
DeleteNote removes a note from the user's notebook.
func (*Notestore) FindNotes ¶ added in v0.3.0
func (s *Notestore) FindNotes(filter *NoteFilter, offset, count int) ([]*Note, error)
FindNotes searches for the notes based on the filter.
func (*Notestore) GetAllNotebooks ¶ added in v0.3.0
GetAllNotebooks returns all the of users notebooks.
func (*Notestore) GetNoteContent ¶ added in v0.3.0
GetNoteContent gets the note's content from the notestore.
func (*Notestore) GetNotebook ¶ added in v0.3.0
func (*Notestore) UpdateNote ¶ added in v0.3.0
UpdateNote update's the note.
func (*Notestore) UpdateNotebook ¶ added in v0.3.0
UpdateNotebook updates the notebook on the server.
type NotestoreClient ¶ added in v0.3.0
type NotestoreClient interface { // GetClient returns the client for the notestore. GetClient() APIClient // FindNotes searches for the notes based on the filter. FindNotes(filter *NoteFilter, offset, count int) ([]*Note, error) // GetAllNotebooks returns all the of users notebooks. GetAllNotebooks() ([]*Notebook, error) // GetNotebook GetNotebook(guid string) (*Notebook, error) // CreateNotebook CreateNotebook(b *Notebook, defaultNotebook bool) error // GetNoteContent gets the note's content from the notestore. GetNoteContent(guid string) (string, error) // UpdateNote update's the note. UpdateNote(note *Note) error // DeleteNote removes a note from the user's notebook. DeleteNote(guid string) error // CreateNote creates a new note on the server. CreateNote(note *Note) error // UpdateNotebook updates the notebook on the server. UpdateNotebook(book *Notebook) error }
NotestoreClient is the interface for the notestore.