evernote

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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")
)
View Source
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)
)
View Source
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")
)
View Source
var ErrNoCachedNote = errors.New("no cache note found")

ErrNoCachedNote is return if the note wasn't cached and can't be updated.

View Source
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

func AddUseRawContentToContext(ctx context.Context, val bool) context.Context

AddUseRawContentToContext adds the value to the context.

func ChangeTitle

func ChangeTitle(client APIClient, old, new string) error

ChangeTitle changes the note's title.

func CreateNotebook added in v0.3.0

func CreateNotebook(client APIClient, notebook *Notebook, defaultNotebook bool) error

CreateNotebook creates a new notebook.

func DeleteNote

func DeleteNote(client APIClient, title, notebook string) error

DeleteNote moves a note from the notebook to the trash can.

func GetUseRawContentFromContext added in v0.3.0

func GetUseRawContentFromContext(ctx context.Context) bool

GetUseRawContentFromContext get's the useRawContent from the context.

func Login added in v0.3.0

func Login(client APIClient) error

Login logs the user in to the server.

func Logout added in v0.3.0

func Logout(cfg config.Configuration) error

Logout removes the session stored.

func MoveNote

func MoveNote(client APIClient, noteTitle, notebookName string) error

MoveNote moves the note to a new notebook.

func SaveChanges

func SaveChanges(client APIClient, n *Note, useRawContent bool) error

SaveChanges updates the changes to the note on the server.

func SaveNewNote

func SaveNewNote(client APIClient, n *Note, raw bool) error

SaveNewNote pushes the new note to the server.

func UpdateNotebook

func UpdateNotebook(client APIClient, name string, notebook *Notebook) error

UpdateNotebook updates the notebook.

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

func (c Client) GetAPIToken() string

GetAPIToken is the access token for the user's account.

func (*Client) GetAuthorizedToken added in v0.3.0

func (c *Client) GetAuthorizedToken(tmpToken *oauth.RequestToken, verifier string) (string, error)

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

func (c *Client) GetRequestToken(callback string) (*oauth.RequestToken, string, error)

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.

func FindNotes added in v0.3.0

func FindNotes(client APIClient, filter *NoteFilter, offset int, count int) ([]*Note, error)

FindNotes searches for notes.

func GetNote

func GetNote(client APIClient, title, notebook string) (*Note, error)

GetNote gets the note metadata in the notebook from the server. If the notebook is an empty string, the first matching note will be returned.

func GetNoteWithContent

func GetNoteWithContent(client APIClient, title string) (*Note, error)

GetNoteWithContent returns the note with content from the user's notestore.

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

func FindNotebook(client APIClient, name string) (*Notebook, error)

FindNotebook gets the notebook matching with the name. If no notebook is found, nil is returned.

func GetNotebook added in v0.3.0

func GetNotebook(client APIClient, guid string) (*Notebook, error)

GetNotebook returns a notebook from the user's notestore.

func GetNotebooks

func GetNotebooks(client APIClient) ([]*Notebook, error)

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

func (s *Notestore) CreateNote(n *Note) error

CreateNote creates a new note and saves it to the server.

func (*Notestore) CreateNotebook added in v0.3.0

func (s *Notestore) CreateNotebook(b *Notebook, defaultNotebook bool) error

CreateNotebook creates a new notebook for the user.

func (*Notestore) DeleteNote added in v0.3.0

func (s *Notestore) DeleteNote(guid string) error

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

func (s *Notestore) GetAllNotebooks() ([]*Notebook, error)

GetAllNotebooks returns all the of users notebooks.

func (*Notestore) GetClient added in v0.3.0

func (s *Notestore) GetClient() APIClient

GetClient returns the client for the notestore.

func (*Notestore) GetNoteContent added in v0.3.0

func (s *Notestore) GetNoteContent(guid string) (string, error)

GetNoteContent gets the note's content from the notestore.

func (*Notestore) GetNotebook added in v0.3.0

func (s *Notestore) GetNotebook(guid string) (*Notebook, error)

func (*Notestore) UpdateNote added in v0.3.0

func (s *Notestore) UpdateNote(note *Note) error

UpdateNote update's the note.

func (*Notestore) UpdateNotebook added in v0.3.0

func (s *Notestore) UpdateNotebook(b *Notebook) error

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.

Directories

Path Synopsis
Package api provides interface for the Evernote API.
Package api provides interface for the Evernote API.

Jump to

Keyboard shortcuts

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