scrapbox

package module
v0.0.0-...-2ffa015 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-scrapbox License GoDoc Go Report Card

usage

import (
  "github.com/yellowglasses20/go-scrapbox"
  "fmt"
)

func main() {
  // Create scprapbox client
  // Please set the project name you want to get in "help-jp"
  client, _ := qiita.NewClient("help-jp")

  // Fetch pagelist and print them
  items, _, _ := client.PageList(&ListOptions{Skip: 0, Limit: 1})
  fmt.Println(items)

  // Fetch page title and print them
  items, _, _ := client.PageTitle("API")
  fmt.Println(items)

  // Fetch page text and print them
  body, _, _ := client.PageText("API")
  fmt.Printf("%s", body)

  // Fetch page icon
  bin, _, _ := client.PageIcon("API")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL     *url.URL
	ProjectName string
	UserAgent   string
	// contains filtered or unexported fields
}

Client is scrapbox API client

func NewClient

func NewClient(projectName string) (*Client, error)

NewClient returns a new scrapbox API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do http request

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest returns new http request

func (*Client) PageIcon

func (s *Client) PageIcon(title string) ([]byte, *http.Response, error)

PageIcon return text from scrapbox API

func (*Client) PageList

func (s *Client) PageList(lo *ListOptions) (*PageList, *http.Response, error)

PageList return pagelist from scrapbox API

func (*Client) PageText

func (s *Client) PageText(title string) ([]byte, *http.Response, error)

PageText return text from scrapbox API

func (*Client) PageTitle

func (s *Client) PageTitle(title string) (*PageText, *http.Response, error)

PageTitle return title from scrapbox API

func (*Client) Text

func (c *Client) Text(req *http.Request) (*http.Response, []byte, error)

Text http request

type Collaborator

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

Collaborator is a collection of pagelist elements

type Line

type Line struct {
	ID      string `json:"id"`
	Text    string `json:"text"`
	UserID  string `json:"userId"`
	Created int    `json:"created"`
	Updated int    `json:"updated"`
}

Line is a collection of pagelist elements

type Links1

type Links1 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"`
	Updated      int      `json:"updated"`
	Accessed     int      `json:"accessed"`
}

Links1 is a collection of pagelist elements

type ListOptions

type ListOptions struct {
	Skip  int `url:"skip,omitempty"`
	Limit int `url:"limit,omitempty"`
}

ListOptions is an option for getting PageList

type Page

type Page struct {
	ID              string   `json:"id"`
	Title           string   `json:"title"`
	Image           string   `json:"image"`
	Descriptions    []string `json:"descriptions"`
	User            UserID   `json:"user"`
	Pin             int      `json:"pin"`
	Views           int      `json:"views"`
	Linked          int      `json:"linked"`
	CommitID        string   `json:"commitId"`
	Created         int      `json:"created"`
	Updated         int      `json:"updated"`
	Accessed        int      `json:"accessed"`
	SnapshotCreated int      `json:"snapshotCreated"`
}

Page is a collection of pagelist elements

type PageList

type PageList struct {
	ProjectName string `json:"projectName"`
	Skip        int    `json:"skip"`
	Limit       int    `json:"limit"`
	Count       int    `json:"count"`
	Pages       []Page `json:"pages"`
}

PageList is a collection of pagelist elements

type PageText

type PageText struct {
	ID              string         `json:"id"`
	Title           string         `json:"title"`
	Image           string         `json:"image"`
	Descriptions    []string       `json:"descriptions"`
	User            UserID         `json:"user"`
	Pin             int            `json:"pin"`
	Views           int            `json:"views"`
	Linked          int            `json:"linked"`
	CommitID        string         `json:"commitId"`
	Created         int            `json:"created"`
	Updated         int            `json:"updated"`
	Accessed        int            `json:"accessed"`
	SnapshotCreated int            `json:"snapshotCreated"`
	Persistent      bool           `json:"persistent"`
	Lines           []Line         `json:"lines"`
	Links           []string       `json:"links"`
	Icons           struct{}       `json:"icons"`
	RelatedPages    RelatedPage    `json:"relatedPages"`
	Collaborators   []Collaborator `json:"collaborators"`
	LastAccessed    int            `json:"lastAccessed"`
}

PageText is a collection of pagelist elements

type RelatedPage

type RelatedPage struct {
	Links1hop []Links1 `json:"links1hop"`
	// TODO: not implement
	Links2hop []interface{} `json:"links2hop"`
	Icons1hop []interface{} `json:"icons1hop"`
}

RelatedPage is a collection of pagelist elements

type UserID

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

UserID is a collection of pagelist elements

Jump to

Keyboard shortcuts

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