Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Host string // The host that the client is connecting to.
}
Represents the Spacebin API Client
func NewClient ¶
NewClient creates a new Spacebin API client. The only parameter is the host the client is connecting to. The return value of this method is the new *Client.
func (*Client) CreateDocument ¶
func (cli *Client) CreateDocument(opts *CreateDocumentOpts) (*HashDocument, error)
CreateDocument allows you to create a new document on the Spacebin. The only parameter is a *CreateDocumentOpts. The return value of this method is a *HashDocument.
type CreateDocumentOpts ¶
type CreateDocumentOpts struct {
Content string `json:"content"` // The content of the document
Extension string `json:"extension"` // The file extension of the document
}
Information needed to create a document
func NewCreateDocumentOpts ¶
func NewCreateDocumentOpts(content string) *CreateDocumentOpts
NewCreateDocumentOpts creates a new *CreateDocumentOpts for use in the CreateDocument method. The only parameter is the content for the *CreateDocumentOpts. It returns the new *CreateDocumentOpts.
func (*CreateDocumentOpts) Marshal ¶
func (opts *CreateDocumentOpts) Marshal() ([]byte, error)
Turn a CreateDocumentOpts into JSON
func (*CreateDocumentOpts) SetContent ¶
func (opts *CreateDocumentOpts) SetContent(content string) *CreateDocumentOpts
SetContent sets the content for the *CreateDocumentOpts. It returns the *CreateDocumentOpts
func (*CreateDocumentOpts) SetExtension ¶
func (opts *CreateDocumentOpts) SetExtension(extension string) *CreateDocumentOpts
SetExtension sets the extension for the *CreateDocumentOpts. It returns the *CreateDocumentOpts.
type Document ¶
type Document struct {
ID string // The document ID
Content string // The document content
Extension string // The file extension of the document
CreatedAt int // The time the document was created
UpdatedAt int // The time the document was last modified
}
Returned when GETting a document
type HashDocument ¶
type HashDocument struct {
ID string // The document ID
ContentHash string // The hash of the document content
}
Returned when POSTing a document
type Payload ¶
type Payload struct {
Content *string `json:"content,omitempty"` // The document content
ContentHash *string `json:"content_hash,omitempty"` // The hash of the document content
Extension *string `json:"extension,omitempty"` // The file extension of the document
ID *string `json:"id,omitempty"` // The document ID
CreatedAt *int `json:"created_at,omitempty"` // The time the document was created
UpdatedAt *int `json:"updated_at,omitempty"` // The time the document was last modified/updated
}
The main body of the response
type Response ¶
type Response struct {
Error string `json:"error,omitempty"` // The error, if one occurred
Payload Payload `json:"payload"` // The main body of the response
Status int64 `json:"status"` // The status code of the response
}
A Spacebin API response
func UnmarshalResponse ¶
Turn JSON into a response