scrapbox

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

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 11 Imported by: 0

README

go-scrapbox

go-scrapbox is a Go client library for accessing the scrapbox internal API.

Usage

TBD...

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Page *PageService
	// contains filtered or unexported fields
}

Client scrapbox client

func NewClient

func NewClient(token string) *Client

NewClient return a create Client

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(httpClient *http.Client) *Client

WithHTTPClient setup http.Client

type ErrorResponse

type ErrorResponse struct {
	Name       string `json:"name"`
	Message    string `json:"message"`
	StatusCode uint   `json:"statusCode"`
}

ErrorResponse api error response

type LinkHop

type LinkHop struct {
	ID               string   `json:"id"`
	Title            string   `json:"title"`
	TitleLc          string   `json:"titleLc"`
	Image            string   `json:"image"`
	Descriptions     []string `json:"descriptions"`
	LinksLc          []string `json:"linksLc"`
	UpdatedUnixTime  uint64   `json:"updated"`
	AccessedUnixTime uint64   `json:"accessed"`
}

LinkHop page link hop

type PageListResponse

type PageListResponse struct {
	ProjectName string `json:"projectName"`
	Skip        uint   `json:"skip"`
	Limit       uint   `json:"limit"`
	Count       uint   `json:"count"`
	Pages       []*struct {
		ID           string   `json:"id"`
		Title        string   `json:"title"`
		Image        string   `json:"image"`
		Descriptions []string `json:"descriptions"`
		User         struct {
			ID string `json:"id"`
		} `json:"user"`
		Pin                     uint64 `json:"pin"`
		Views                   uint   `json:"views"`
		Linked                  uint   `json:"linked"`
		CommitID                string `json:"commitId"`
		CreatedUnixTime         uint64 `json:"created"`
		UpdatedUnixTime         uint64 `json:"updated"`
		AccessedUnixTime        uint64 `json:"accessed"`
		SnapshotCreatedUnixTime uint64 `json:"snapshotCreated"`
	} `json:"pages"`
}

PageListResponse /api/pages/:projectName のresponse https://scrapbox.io/help-jp/API#58e676b197c29100006748f7

type PageResponse

type PageResponse struct {
	ID                      string   `json:"id"`
	Title                   string   `json:"title"`
	Image                   string   `json:"image"`
	Descriptions            []string `json:"descriptions"`
	User                    User     `json:"user"`
	Pin                     uint64   `json:"pin"`
	Views                   uint     `json:"views"`
	Linked                  uint     `json:"linked"`
	CommitID                string   `json:"commitId"`
	CreatedUnixTime         uint64   `json:"created"`
	UpdatedUnixTime         uint64   `json:"updated"`
	AccessedUnixTime        uint64   `json:"accessed"`
	SnapshotCreatedUnixTime uint64   `json:"snapshotCreated"`

	Persistent bool `json:"persistent"`
	Lines      []struct {
		ID      string `json:"id"`
		Text    string `json:"text"`
		UserID  string `json:"userId"`
		Created int    `json:"created"`
		Updated int    `json:"updated"`
	} `json:"lines"`
	Links        []string `json:"links"`
	Icons        struct{} `json:"icons"` // TODO: ?
	RelatedPages struct {
		Links1Hop []*LinkHop    `json:"links1hop"`
		Links2Hop []*LinkHop    `json:"links2hop"`
		Icons1Hop []interface{} `json:"icons1hop"` // TODO: ?
	} `json:"relatedPages"`
	Collaborators        []interface{} `json:"collaborators"` // TODO: ?
	LastAccessedUnixTime uint64        `json:"lastAccessed"`
}

PageResponse page response https://scrapbox.io/help-jp/API#58e6775897c29100006748fe

type PageService

type PageService struct {
	*Client
}

PageService page service

func (*PageService) Get

func (s *PageService) Get(ctx context.Context, projectName string, title string) (PageResponse, error)

Get get page

func (*PageService) IconURL

func (s *PageService) IconURL(ctx context.Context, projectName string, title string) (bool, *url.URL, error)

IconURL get page icon url

func (*PageService) List

func (s *PageService) List(ctx context.Context, projectName string, offset, limit uint) (PageListResponse, error)

List get page list

func (*PageService) ListAll

func (s *PageService) ListAll(ctx context.Context, projectName string) (PageListResponse, error)

List get page list

func (*PageService) Text

func (s *PageService) Text(ctx context.Context, projectName string, title string) (string, error)

Text get page text

type User

type User struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	Photo       string `json:"photo"`
}

User user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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