Documentation
¶
Overview ¶
Package client provides interfaces for interacting with the Dnote server and the data structures for responses
Index ¶
- Variables
- func Signout(ctx infra.DnoteCtx, sessionKey string) error
- type CreateBookPayload
- type CreateBookResp
- type CreateNotePayload
- type CreateNoteResp
- type DeleteBookResp
- type DeleteNoteResp
- type GetBooksResp
- type GetSyncFragmentResp
- type GetSyncStateResp
- type PresigninResponse
- type RespBook
- type RespNote
- type SigninPayload
- type SigninResponse
- type SyncFragBook
- type SyncFragNote
- type SyncFragment
- type UpdateBookResp
- type UpdateNoteResp
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidLogin = errors.New("wrong credentials")
ErrInvalidLogin is an error for invalid credentials for login
Functions ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetBooksResp is a response from get books endpoint
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
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
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 ¶
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