Documentation
¶
Index ¶
- Constants
- type AccountType
- type Client
- func (c *Client) CreatePaste(req *CreatePasteRequest) (string, error)
- func (c *Client) DeletePaste(key string) error
- func (c *Client) GetRawPublicPasteContent(key string) (string, error)
- func (c *Client) GetRawUserPasteContent(key string) (string, error)
- func (c *Client) GetUserDetails() (*User, error)
- func (c *Client) GetUserPastes() ([]*Paste, error)
- type CreatePasteRequest
- type Expiration
- type Paste
- type User
- type Visibility
Constants ¶
const ( BaseUrl = "https://pastebin.com" LoginUrl = "https://pastebin.com/api/api_login.php" PostUrl = "https://pastebin.com/api/api_post.php" RawUrl = "https://pastebin.com/api/api_raw.php" RawPublicUrl = "https://pastebin.com/raw" )
Base URLs and API endpoints for Pastebin.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountType ¶
type AccountType int
AccountType represents a user account type on Pastebin. normal User = 0, pro User = 1
See https://pastebin.com/doc_api#12
const ( NormalUser AccountType = iota ProUser )
NormalUser is a free Pastebin account. ProUser is a paid Pastebin account.
func (AccountType) String ¶
func (acc AccountType) String() string
String returns the string representation of an AccountType.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Pastebin API client.
func NewClient ¶
NewClient creates a new Pastebin API client. If a username is provided, it logs the user in to obtain a user API key.
func (*Client) CreatePaste ¶
func (c *Client) CreatePaste(req *CreatePasteRequest) (string, error)
CreatePaste creates a new paste using the given request parameters.
func (*Client) DeletePaste ¶
DeletePaste deletes a paste by its unique key.
func (*Client) GetRawPublicPasteContent ¶
GetRawPublicPasteContent fetches the raw content of a public or unlisted paste.
func (*Client) GetRawUserPasteContent ¶
GetRawUserPasteContent retrieves the raw content of a user-owned paste.
func (*Client) GetUserDetails ¶
GetUserDetails retrieves account details of the authenticated user.
func (*Client) GetUserPastes ¶
GetUserPastes retrieves the list of pastes created by the authenticated user.
type CreatePasteRequest ¶
type CreatePasteRequest struct { // required. // this is the text that will be written inside your paste. Content string // optional. // this will be the name / title of your paste. Name string // optional. // this will be the syntax highlighting value. // // See https://pastebin.com/doc_api#5 Format string // optional. // this sets the key of the folder of your paste. // // See https://pastebin.com/doc_api#5 Folder string // optional. // this sets the expiration date of your paste. // default value: "N" (Never) // // See https://pastebin.com/doc_api#6 Expiration Expiration // optional. // this makes a paste public, unlisted or private. // Public = 0, Unlisted = 1, Private = 2 // // See https://pastebin.com/doc_api#7 Visibility Visibility // optional. // if true, this will create the paste as the currently logged in user. // otherwise it will create the paste as a guest. CreatePasteAsUser bool }
CreatePasteRequest holds the parameters to create a new paste.
type Expiration ¶
type Expiration string
Expiration defines the duration before a paste expires.
const ( Never Expiration = "N" TenMinutes Expiration = "10M" OneHour Expiration = "1H" OneDay Expiration = "1D" OneWeek Expiration = "1W" TwoWeeks Expiration = "2W" OneMonth Expiration = "1M" SixMonths Expiration = "6M" OneYear Expiration = "1Y" )
Predefined expiration times for pastes.
type Paste ¶
type Paste struct { Key string Title string URL string Hits int Size int CreatedAt time.Time ExpireDate time.Time Visibility Visibility FormatLong string FormatShort string }
Paste represents a Pastebin paste entry.
type User ¶
type User struct { UserName string `xml:"user_name"` Expiration Expiration `xml:"user_expiration"` Visibility Visibility `xml:"user_private"` Avatar string `xml:"user_avatar_url"` Website string `xml:"user_website"` Email string `xml:"user_email"` Location string `xml:"user_location"` AccountType AccountType `xml:"user_account_type"` }
User contains information about the logged in Pastebin user.
type Visibility ¶
type Visibility int
Visibility defines the visibility level of a paste. Public = 0, Unlisted = 1, Private = 2.
See https://pastebin.com/doc_api#7
const ( Public Visibility = iota Unlisted Private )
Public = 0, Unlisted = 1, Private = 2.
func (Visibility) String ¶
func (v Visibility) String() string
String returns the string representation of a Visibility.