Documentation
¶
Index ¶
- Variables
- func NewOAuth2Client(ctx context.Context, cfg Config) (*http.Client, error)
- type Client
- func (c *Client) DeleteComment(id string) error
- func (c *Client) DeletePost(id string) error
- func (c *Client) EditComment(id, body string) error
- func (c *Client) GetComments(username, after string) (*Listing[Comment], error)
- func (c *Client) GetPosts(username, after string) (*Listing[Post], error)
- func (c *Client) GetSavedComments(username, after string) (*Listing[Comment], error)
- func (c *Client) GetSavedPosts(username, after string) (*Listing[Comment], error)
- func (c *Client) UnsaveComment(id string) error
- func (c *Client) UnsavePost(id string) error
- type Comment
- type Config
- type EditResponse
- type Listing
- type Post
- type Time
Constants ¶
This section is empty.
Variables ¶
var (
ErrRateLimited = fmt.Errorf("rate limited")
)
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
TODO: doc -2024-10-22
func (*Client) DeleteComment ¶
TODO: doc -2024-10-25
func (*Client) EditComment ¶
TODO: doc -2024-10-25
func (*Client) GetComments ¶
TODO: doc -2024-10-22
func (*Client) GetSavedComments ¶
TODO: doc -2024-10-30
func (*Client) GetSavedPosts ¶
TODO: doc -2024-10-30
func (*Client) UnsaveComment ¶
TODO: doc -2024-10-30
type Comment ¶
type Comment struct { ID string `json:"id"` Body string `json:"body"` Permalink string `json:"permalink"` Subreddit string `json:"subreddit"` Score int `json:"score"` CreatedUTC Time `json:"created_utc"` }
TODO: doc -2024-10-22
type Config ¶
type Config struct { BaseURL string ClientID string ClientSecret string Username string Password string UserAgent string }
TODO: doc -2024-10-22
type EditResponse ¶
EditResponse is the response from the Reddit API when editing a comment. It has a weird structure - see the tests for examples.
func (*EditResponse) IsRateLimited ¶
func (resp *EditResponse) IsRateLimited() bool
IsRateLimited checks if the response indicates that the request was rate limited.
type Listing ¶
type Listing[T any] struct { Data struct { Before string `json:"before"` After string `json:"after"` Children []struct { Data T `json:"data"` } `json:"children"` } `json:"data"` }
TODO: doc -2024-10-22
type Post ¶
type Post struct { ID string `json:"id"` Title string `json:"title"` Permalink string `json:"permalink"` Subreddit string `json:"subreddit"` Score int `json:"score"` CreatedUTC Time `json:"created_utc"` }
TODO: doc -2024-10-30
type Time ¶
Time is a type used to unmarshal Reddit's weird floating point timestamps. Reddit's API returns timestamps as Unix epoch timestamps, but as floating point numbers (for some reason). This type is used to unmarshal those timestamps into Go's time.Time type.