client

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: GPL-3.0 Imports: 12 Imported by: 12

Documentation

Overview

Package client provides interfaces for interacting with the Dnote server and the data structures for responses

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLogin = errors.New("wrong credentials")

ErrInvalidLogin is an error for invalid credentials for login

Functions

func Signout added in v0.6.0

func Signout(ctx infra.DnoteCtx, sessionKey string) error

Signout deletes a user session on the server side

Types

type CreateBookPayload

type CreateBookPayload struct {
	Name string `json:"name"`
}

CreateBookPayload is a payload for creating a book

type CreateBookResp

type CreateBookResp struct {
	Book RespBook `json:"book"`
}

CreateBookResp is the response from create book api

func CreateBook

func CreateBook(ctx infra.DnoteCtx, label string) (CreateBookResp, error)

CreateBook creates a new book in the server

type CreateNotePayload

type CreateNotePayload struct {
	BookUUID string `json:"book_uuid"`
	Body     string `json:"content"`
}

CreateNotePayload is a payload for creating a note

type CreateNoteResp

type CreateNoteResp struct {
	Result RespNote `json:"result"`
}

CreateNoteResp is the response from create note endpoint

func CreateNote

func CreateNote(ctx infra.DnoteCtx, bookUUID, content string) (CreateNoteResp, error)

CreateNote creates a note in the server

type DeleteBookResp

type DeleteBookResp struct {
	Status int      `json:"status"`
	Book   RespBook `json:"book"`
}

DeleteBookResp is the response from create book api

func DeleteBook

func DeleteBook(ctx infra.DnoteCtx, uuid string) (DeleteBookResp, error)

DeleteBook deletes a book in the server

type DeleteNoteResp

type DeleteNoteResp struct {
	Status int      `json:"status"`
	Result RespNote `json:"result"`
}

DeleteNoteResp is the response from remove note api

func DeleteNote

func DeleteNote(ctx infra.DnoteCtx, uuid string) (DeleteNoteResp, error)

DeleteNote removes a note in the server

type GetBooksResp

type GetBooksResp []struct {
	UUID  string `json:"uuid"`
	Label string `json:"label"`
}

GetBooksResp is a response from get books endpoint

func GetBooks

func GetBooks(ctx infra.DnoteCtx, sessionKey string) (GetBooksResp, error)

GetBooks gets books from the server

type GetSyncFragmentResp

type GetSyncFragmentResp struct {
	Fragment SyncFragment `json:"fragment"`
}

GetSyncFragmentResp is the response from the get sync fragment endpoint

func GetSyncFragment

func GetSyncFragment(ctx infra.DnoteCtx, afterUSN int) (GetSyncFragmentResp, error)

GetSyncFragment gets a sync fragment response from the server

type GetSyncStateResp

type GetSyncStateResp struct {
	FullSyncBefore int   `json:"full_sync_before"`
	MaxUSN         int   `json:"max_usn"`
	CurrentTime    int64 `json:"current_time"`
}

GetSyncStateResp is the response get sync state endpoint

func GetSyncState

func GetSyncState(ctx infra.DnoteCtx) (GetSyncStateResp, error)

GetSyncState gets the sync state response from the server

type PresigninResponse added in v0.6.0

type PresigninResponse struct {
	Iteration int `json:"iteration"`
}

PresigninResponse is a reponse from /v1/presignin endpoint

func GetPresignin added in v0.6.0

func GetPresignin(ctx infra.DnoteCtx, email string) (PresigninResponse, error)

GetPresignin gets presignin credentials

type RespBook

type RespBook struct {
	ID        int       `json:"id"`
	UUID      string    `json:"uuid"`
	USN       int       `json:"usn"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Label     string    `json:"label"`
}

RespBook is the book in the response from the create book api

type RespNote

type RespNote struct {
	UUID      string       `json:"uuid"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"updated_at"`
	Body      string       `json:"content"`
	AddedOn   int64        `json:"added_on"`
	Public    bool         `json:"public"`
	USN       int          `json:"usn"`
	Book      respNoteBook `json:"book"`
	User      respNoteUser `json:"user"`
}

RespNote is a note in the response

type SigninPayload added in v0.6.0

type SigninPayload struct {
	Email   string `json:"email"`
	AuthKey string `json:"auth_key"`
}

SigninPayload is a payload for /v1/signin

type SigninResponse added in v0.6.0

type SigninResponse struct {
	Key          string `json:"key"`
	ExpiresAt    int64  `json:"expires_at"`
	CipherKeyEnc string `json:"cipher_key_enc"`
}

SigninResponse is a response from /v1/signin endpoint

func Signin added in v0.6.0

func Signin(ctx infra.DnoteCtx, email, authKey string) (SigninResponse, error)

Signin requests a session token

type SyncFragBook

type SyncFragBook struct {
	UUID      string    `json:"uuid"`
	USN       int       `json:"usn"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	AddedOn   int64     `json:"added_on"`
	Label     string    `json:"label"`
	Deleted   bool      `json:"deleted"`
}

SyncFragBook represents a book in a sync fragment and contains only the necessary information for the client to sync the note locally

type SyncFragNote

type SyncFragNote struct {
	UUID      string    `json:"uuid"`
	BookUUID  string    `json:"book_uuid"`
	USN       int       `json:"usn"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	AddedOn   int64     `json:"added_on"`
	EditedOn  int64     `json:"edited_on"`
	Body      string    `json:"content"`
	Public    bool      `json:"public"`
	Deleted   bool      `json:"deleted"`
}

SyncFragNote represents a note in a sync fragment and contains only the necessary information for the client to sync the note locally

type SyncFragment

type SyncFragment struct {
	FragMaxUSN    int            `json:"frag_max_usn"`
	UserMaxUSN    int            `json:"user_max_usn"`
	CurrentTime   int64          `json:"current_time"`
	Notes         []SyncFragNote `json:"notes"`
	Books         []SyncFragBook `json:"books"`
	ExpungedNotes []string       `json:"expunged_notes"`
	ExpungedBooks []string       `json:"expunged_books"`
}

SyncFragment contains a piece of information about the server's state.

type UpdateBookResp

type UpdateBookResp struct {
	Book RespBook `json:"book"`
}

UpdateBookResp is the response from create book api

func UpdateBook

func UpdateBook(ctx infra.DnoteCtx, label, uuid string) (UpdateBookResp, error)

UpdateBook updates a book in the server

type UpdateNoteResp

type UpdateNoteResp struct {
	Status int      `json:"status"`
	Result RespNote `json:"result"`
}

UpdateNoteResp is the response from create book api

func UpdateNote

func UpdateNote(ctx infra.DnoteCtx, uuid, bookUUID, content string, public bool) (UpdateNoteResp, error)

UpdateNote updates a note in the server

Jump to

Keyboard shortcuts

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