sdk

package module
v0.0.0-...-a57ee08 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 10 Imported by: 1

README

Official SDK for NoteOf

CI Go Report Card GoDoc

development in progress

Documentation

Index

Constants

View Source
const NoteOfEndpoint = "https://api.noteof.app"

Variables

View Source
var (
	ErrInvalidCredentials       = errors.New("invalid username or password")
	ErrNotFound                 = errors.New("not found")
	ErrUnexpectedServerResponse = errors.New("invalid server response")
)

Functions

This section is empty.

Types

type AuthenticatedAPI

type AuthenticatedAPI struct {
	UnauthenticatedAPI
	// contains filtered or unexported fields
}

func NewAuthenticatedApi

func NewAuthenticatedApi(token string) *AuthenticatedAPI

func (*AuthenticatedAPI) DeleteNote

func (a *AuthenticatedAPI) DeleteNote(publicID string) (bool, error)

func (*AuthenticatedAPI) GetEndpoint

func (a *AuthenticatedAPI) GetEndpoint() string

func (*AuthenticatedAPI) GetNote

func (a *AuthenticatedAPI) GetNote(publicID string) (*Note, error)

func (*AuthenticatedAPI) GetNotes

func (a *AuthenticatedAPI) GetNotes() ([]*Note, error)

func (*AuthenticatedAPI) PostNewNote

func (a *AuthenticatedAPI) PostNewNote(n *Note) (*Note, error)

func (*AuthenticatedAPI) PutUpdateNote

func (a *AuthenticatedAPI) PutUpdateNote(n *Note) (*Note, error)

type Note

type Note struct {
	PublicID string `json:"public_id"`
	// UserID     int       `json:"-"`
	// NoteTextID int64     `json:"-"` // maybe get rid of?
	Archived bool      `json:"archived"`
	Starred  bool      `json:"starred"`
	Created  time.Time `json:"created"`

	Tags []NoteTag `json:"tags"`
	Meta NoteMeta  `json:"meta"`

	CurrentText *NoteText   `json:"current"`
	TextHistory []*NoteText `json:"history,omitempty"`
}

type NoteMeta

type NoteMeta map[string]string

NoteMeta is a map of string keys to string values that can be used to store arbitrary metadata about a note that is not part of the note itself and is useful for implementation specific values.

The server enforces a 255 character limit on both keys and values. The key is expected to be ascii only and the value is expected to be utf-8

type NoteTag

type NoteTag string

NoteTag is a string that includes methods for canonicalizing the tag as used by the server itself

func (NoteTag) C14n

func (nt NoteTag) C14n() string

C14n provides the standard method by which tags are canonicalized.

The process involves converting the string to NFD normalization and removing all Combining Diacritical Marks

There should be little need to call this directly other than perhaps comparing strings that have not yet been canonicalized by the server, it is provided here as a helper for such comparison but shall not be needed before a roundtrip to the server.

type NoteText

type NoteText struct {
	// NoteTextID int64     `json:"-"`
	// NoteID     int64     `json:"-"`
	NoteTextValue string    `json:"note_text"`
	Created       time.Time `json:"created"`
}

type Token

type Token struct {
	APIToken   string     `json:"token"`
	Created    time.Time  `json:"created"`
	Expiration *time.Time `json:"expiration,omitempty"`
}

type TokenRequest

type TokenRequest struct {
	Usage string `json:"usage"`
	TTL   *uint  `json:"ttl,omitempty"`
}

type TokenResponse

type TokenResponse struct {
	User   *User `json:"user"`
	*Token `json:",omitempty"`
}

type UnauthenticatedAPI

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

func (*UnauthenticatedAPI) DoAuth

func (u *UnauthenticatedAPI) DoAuth(username, password, usage string) (*TokenResponse, error)

func (*UnauthenticatedAPI) GetEndpoint

func (a *UnauthenticatedAPI) GetEndpoint() string

type User

type User struct {
	Username     string `json:"username"`
	EmailAddress string `json:"email"`
}

Jump to

Keyboard shortcuts

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