Documentation ¶
Index ¶
- Constants
- Variables
- type APIResponse
- type APIResponseAccount
- type APIResponsePage
- type APIResponsePageList
- type APIResponsePageViews
- type Account
- type Client
- func (c *Client) CreateAccount(shortName, authorName, authorURL string) (acc Account, err error)
- func (c *Client) CreatePage(title, authorName, authorURL string, content []Node, returnContent bool) (page Page, err error)
- func (c *Client) CreatePageWithHTML(title, authorName, authorURL, htmlContent string, returnContent bool) (page Page, err error)
- func (c *Client) EditAccountInfo(shortName, authorName, authorURL string) (acc Account, err error)
- func (c *Client) EditPage(path, title string, content []Node, authorName, authorURL string, ...) (page Page, err error)
- func (c *Client) GetAccountInfo(fields []string) (acc Account, err error)
- func (c *Client) GetPage(path string, returnContent bool) (page Page, err error)
- func (c *Client) GetPageList(offset, limit int) (list PageList, err error)
- func (c *Client) GetViews(path string, year, month, day, hour int) (views PageViews, err error)
- func (c *Client) RevokeAccessToken() (acc Account, err error)
- type Node
- type NodeElement
- type Page
- type PageList
- type PageViews
Constants ¶
const (
APIBaseURL = "https://api.telegra.ph"
)
constants
Variables ¶
var Verbose bool // default: false
Verbose flag for logging
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
APIResponse struct
type APIResponseAccount ¶
type APIResponseAccount struct { APIResponse Result Account `json:"result,omitempty"` }
APIResponseAccount struct
type APIResponsePage ¶
type APIResponsePage struct { APIResponse Result Page `json:"result,omitempty"` }
APIResponsePage struct
type APIResponsePageList ¶
type APIResponsePageList struct { APIResponse Result PageList `json:"result,omitempty"` }
APIResponsePageList struct
type APIResponsePageViews ¶
type APIResponsePageViews struct { APIResponse Result PageViews `json:"result,omitempty"` }
APIResponsePageViews struct
type Account ¶
type Account struct { ShortName string `json:"short_name"` AuthorName string `json:"author_name"` AuthorURL string `json:"author_url"` AccessToken string `json:"access_token,omitempty"` AuthURL string `json:"auth_url,omitempty"` PageCount int `json:"page_count,omitempty"` }
Account type
type Client ¶
Client struct
func (*Client) CreateAccount ¶
CreateAccount creates a new Telegraph account.
shortName: 1-32 characters authorName: 0-128 characters (optional) authorURL: 0-512 characters (optional)
func (*Client) CreatePage ¶
func (c *Client) CreatePage(title, authorName, authorURL string, content []Node, returnContent bool) (page Page, err error)
CreatePage creates a new Telegraph page.
title: 1-256 characters authorName: 0-128 characters (optional) authorURL: 0-512 characters (optional) content: Array of Node returnContent: return created Page object or not
func (*Client) CreatePageWithHTML ¶
func (c *Client) CreatePageWithHTML(title, authorName, authorURL, htmlContent string, returnContent bool) (page Page, err error)
CreatePageWithHTML creates a new page with HTML.
func (*Client) EditAccountInfo ¶
EditAccountInfo updates information about a Telegraph account.
shortName: 1-32 characters authorName: 0-128 characters (optional) authorURL: 0-512 characters (optional)
func (*Client) EditPage ¶
func (c *Client) EditPage(path, title string, content []Node, authorName, authorURL string, returnContent bool) (page Page, err error)
EditPage edits an existing Telegraph page.
path: Path to the page title: 1-256 characters content: Array of Node authorName: 0-128 characters (optional) authorURL: 0-512 characters (optional) returnContent: return edited Page object or not
func (*Client) GetAccountInfo ¶
GetAccountInfo fetches information about a Telegraph account.
fields: Available fields: "short_name", "author_name", "author_url", "auth_url", and "page_count" (default = ["short_name", "author_name", "author_url"])
func (*Client) GetPage ¶
GetPage fetches a Telegraph page.
path: Path to the Telegraph page returnContent: return the Page object or not
func (*Client) GetPageList ¶
GetPageList fetches a list of pages belonging to a Telegraph account.
offset: Sequential number of the first page (default = 0) limit: Number of pages to be returned (0-200, default = 50)
func (*Client) GetViews ¶
GetViews fetches the number of views for a Telegraph page.
path: Path to the Telegraph page year: 2000-2100 (required when 'month' is passed) month: 1-12 (required when 'day' is passed) day: 1-31 (required when 'hour' is passed) hour: 0-24 (pass -1 if none)
func (*Client) RevokeAccessToken ¶
RevokeAccessToken revokes access token and generate a new one.
type Node ¶
type Node interface{} // XXX - can be a string, or NodeElement
Node type
func NewNodeWithElement ¶
NewNodeWithElement creates a new node with given element.
func NewNodeWithString ¶
NewNodeWithString creates a new node with given string.
func NewNodesWithHTML ¶
NewNodesWithHTML creates new nodes with given HTML string.
type NodeElement ¶
type NodeElement struct { Tag string `json:"tag"` Attrs map[string]string `json:"attrs,omitempty"` Children []Node `json:"children,omitempty"` }
NodeElement type
type Page ¶
type Page struct { Path string `json:"path"` URL string `json:"url"` Title string `json:"title"` Description string `json:"description"` AuthorName string `json:"author_name,omitempty"` AuthorURL string `json:"author_url,omitempty"` ImageURL string `json:"image_url,omitempty"` Content []Node `json:"content,omitempty"` Views int `json:"views"` CanEdit bool `json:"can_edit,omitempty"` }
Page type