Documentation ¶
Index ¶
- func MergeCommentChannels(channels ...<-chan models.Comment) chan models.Comment
- func MergeSubmissionChannels(channels ...<-chan models.Submission) chan models.Submission
- type AuthConfig
- type RedditClient
- func (c *RedditClient) GetComment(id string) (*models.Comment, error)
- func (c *RedditClient) GetCommentAnchor(subreddit string) (last *string, lastID *string, err error)
- func (c *RedditClient) GetSubmission(subreddit string, id string) (*models.Submission, error)
- func (c *RedditClient) GetSubmissionAnchor(subreddit string, sort string) (last *string, lastID *string, err error)
- func (c *RedditClient) GetSubredditComments(subreddit string, sort string, tdur string, limit int) ([]models.Comment, error)
- func (c *RedditClient) GetSubredditCommentsAfter(subreddit string, sort string, last string, limit int) ([]models.Comment, error)
- func (c *RedditClient) GetSubredditSubmissions(subreddit string, sort string, tdur string, limit int) ([]models.Submission, error)
- func (c *RedditClient) GetSubredditSubmissionsAfter(subreddit string, last string, limit int) ([]models.Submission, error)
- func (c *RedditClient) IsDeletedComment(id string) (bool, error)
- func (c *RedditClient) IsDeletedSubmission(subreddit string, id string) (bool, error)
- func (c RedditClient) Request(request Request) ([]byte, error)
- func (r *RedditClient) StreamSubredditComments(subreddit string, refresh int) (<-chan models.Comment, error)
- func (r *RedditClient) StreamSubredditSubmissions(subreddit string, sort string, refresh int) (<-chan models.Submission, error)
- type RedditErr
- type Request
- type Streaming
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeCommentChannels ¶
MergeCommentChannels merges multiple input comments channels and returns a single comment channel
func MergeSubmissionChannels ¶
func MergeSubmissionChannels(channels ...<-chan models.Submission) chan models.Submission
MergeSubmissionChannels merges multiple input submissions channels and returns a single submission channel
Types ¶
type AuthConfig ¶
type AuthConfig struct { ClientID string ClientSecret string UserAgent string Username string Password string }
AuthConfig is the struct storing the reddit credentials
func GetConfigByEnv ¶
func GetConfigByEnv() AuthConfig
GetConfigByEnv gets the reddit credentials from the env vars
func GetConfigByFile ¶
func GetConfigByFile(filePath string) AuthConfig
GetConfigByFile gets the reddit credentials from a config file
type RedditClient ¶
type RedditClient struct { Token string `json:"access_token"` Duration float64 `json:"expires_in"` ExpirationTicker *time.Ticker Config AuthConfig UserAgent string Stream Streaming Client *http.Client }
RedditClient is the client that makes requests to the api
func Authenticate ¶
func Authenticate(config *AuthConfig) (*RedditClient, error)
Authenticate creates a new RedditClient from the provided config credentials
func (*RedditClient) GetComment ¶
func (c *RedditClient) GetComment(id string) (*models.Comment, error)
GetComment sends a request to get a specific comment
func (*RedditClient) GetCommentAnchor ¶
func (c *RedditClient) GetCommentAnchor(subreddit string) (last *string, lastID *string, err error)
GetCommentAnchor gets latest comment in specified subreddit, returns its full Name (lastID), its id, and an error
func (*RedditClient) GetSubmission ¶
func (c *RedditClient) GetSubmission(subreddit string, id string) (*models.Submission, error)
GetSubmission sends a request to get a specific submission
func (*RedditClient) GetSubmissionAnchor ¶
func (c *RedditClient) GetSubmissionAnchor(subreddit string, sort string) (last *string, lastID *string, err error)
GetSubmissionAnchor gets latest submission in specified subreddit, returns its full Name (lastID), its id, and an error
func (*RedditClient) GetSubredditComments ¶
func (c *RedditClient) GetSubredditComments(subreddit string, sort string, tdur string, limit int) ([]models.Comment, error)
GetSubredditComments sends a request for comments in specified subreddit, sort and limit
func (*RedditClient) GetSubredditCommentsAfter ¶
func (c *RedditClient) GetSubredditCommentsAfter(subreddit string, sort string, last string, limit int) ([]models.Comment, error)
GetSubredditCommentsAfter sends a request for comments after last commment in specified subreddit, sort and limit
func (*RedditClient) GetSubredditSubmissions ¶
func (c *RedditClient) GetSubredditSubmissions(subreddit string, sort string, tdur string, limit int) ([]models.Submission, error)
GetSubredditSubmissions sends a request for submissions in specified subreddit, sort and limit (number of items)
func (*RedditClient) GetSubredditSubmissionsAfter ¶
func (c *RedditClient) GetSubredditSubmissionsAfter(subreddit string, last string, limit int) ([]models.Submission, error)
GetSubredditSubmissionsAfter sends a request for submissions after last submission (full name) in specified subreddit, sort and limit (number of items)
func (*RedditClient) IsDeletedComment ¶
func (c *RedditClient) IsDeletedComment(id string) (bool, error)
IsDeletedComment checks if comment is deleted
func (*RedditClient) IsDeletedSubmission ¶
func (c *RedditClient) IsDeletedSubmission(subreddit string, id string) (bool, error)
IsDeletedSubmission checks if submission is deleted
func (RedditClient) Request ¶
func (c RedditClient) Request(request Request) ([]byte, error)
Request makes a request to the reddit api returns the body of the response
func (*RedditClient) StreamSubredditComments ¶
func (r *RedditClient) StreamSubredditComments(subreddit string, refresh int) (<-chan models.Comment, error)
StreamSubredditComments streams comments from a specified subreddit Returns an output channel on which new comments are sent
func (*RedditClient) StreamSubredditSubmissions ¶
func (r *RedditClient) StreamSubredditSubmissions(subreddit string, sort string, refresh int) (<-chan models.Submission, error)
StreamSubredditSubmissions streams comments from a specified subreddit Returns an output channel on which new submissions are sent