Documentation
¶
Overview ¶
Package goRant implements a API-wrapper for the public API of http://www.devrant.io
Index ¶
- Constants
- type Avatar
- type Client
- func (c *Client) Collabs() ([]Rant, error)
- func (c *Client) GetRant(id int) (Rant, []Comment, error)
- func (c *Client) Profile(username string) (User, error)
- func (c *Client) Rants(sort string, limit int, skip int) ([]Rant, error)
- func (c *Client) Search(query string) ([]Rant, error)
- func (c *Client) Stories() ([]Rant, error)
- func (c *Client) Surprise() (Rant, []Comment, error)
- func (c *Client) WeeklyRant() ([]Rant, error)
- type Comment
- type Content
- type Counts
- type Image
- type News
- type Rant
- type RantRes
- type Rants
- type SearchRes
- type User
- type UserIDRes
- type UserRes
Constants ¶
const ( API = "https://www.devrant.io/api" VERSION = 3 RANTS = "%s/devrant/rants?sort=%s&limit=%d&skip=%d&app=%d" RANT = "%s/devrant/rants/%d?app=%d" USERID = "%s/get-user-id?username=%s&app=%d" USER = "%s/users/%d?app=%d" SEARCH = "%s/devrant/search?term=%s&app=%d" SURPRISE = "%s/devrant/rants/surprise?app=%d" WEEKLY = "%s/devrant/weekly-rants?app=%d" COLLABS = "%s/devrant/collabs?app=%d" STORIES = "%s/devrant/story-rants?app=%d" )
All Constants are written in uppercase, and have no need to be exported
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Avatar ¶
Avatar is a struct to save avatar information of a user profile B stands for background color I is the actual image of the profile
type Client ¶
type Client struct {
}
Client in an empty interface It is has all functionalitios of goRant Wrapper
func (*Client) Profile ¶
Profile returns a User profile info It takes a username of type string as input
func (*Client) Rants ¶
Rants return an array of Rants from devRant.io
It has 3 parameters: Sort, Limit, Skip Sort can take 3 values, "algo", "recent", "top" Limit is an int value, used to specify number of rants to get Skip is an int value, used to specify number of rants to skip Example: If you eant the recent 20 rants: Rants("recent",20,0) If you want the next 20 rants: Rants("recent",20,20)
func (*Client) WeeklyRant ¶
WeeklyRant return an array of Rants from weekly rants tab of devRant
type Comment ¶
type Comment struct {
ID int `json:"id"`
RantID int `json:"rant_id"`
Body string `json:"body"`
Score int `json:"score"`
CreatedTime int `json:"created_time"`
UserID int `json:"user_id"`
Username string `json:"user_username"`
UserScore int `json:"user_score"`
}
Comment is a struct to store comment data
type Content ¶
type Content struct {
Rants []Rant `json:"rants"`
Upvoted []Rant `json:"upvoted"`
Comments []Comment `json:"comments"`
Favorites []Rant `json:"favorites"`
}
Content is a struct to save Content of a User It has rants,upvotes,comments,favoutites of a user
type Counts ¶
type Counts struct {
Rants int `json:"rants"`
Upvotes int `json:"upvoted"`
Comments int `json:"comments"`
Favourites int `json:"favourites"`
Collabs int `json:"collabs"`
}
Counts is a struct to save Counts of a User It has count(int values) of Rants, Upvotes, Comments, Favourites, and Colabs of a user
type Image ¶
Image struct is used to store info about Images Any attached images in rants, and/or comments It has Height, Width, and URl of the image
type News ¶
type News struct {
ID int `json:"id"`
Type string `json:"type"`
Headline string `json:"headline"`
Body string `json:"body"`
Height int `json:"height"`
Action string `json:"action"`
}
News struct is used to store info about any News from devRant
type Rant ¶
type Rant struct {
ID int `json:"id"`
Text string `json:"text"`
Score int `json:"score"`
CreatedTime int `json:"created_time"`
AttachedImage Image `json:"attached_image"`
NumComments int `json:"num_comments"`
Tags []string `json:"tags"`
VoteState int `json:"vote_state"`
Edited bool `json:"edited"`
UserID int `json:"user_id"`
Username string `json:"user_username"`
UserScore int `json:"user_score"`
}
Rant is a struct to save Rant data
type RantRes ¶
type RantRes struct {
Success bool `json:"success"`
Error string `json:"error"`
Rant Rant `json:"rant"`
Comments []Comment `json:"comments"`
}
RantRes is a struct to receive Rant response
type Rants ¶
type Rants struct {
Success bool `json:"success"`
Error string `json:"error"`
Rants []Rant `json:"rants"`
Settings string `json:"settings"`
Set string `json:"set"`
Wrw int `json:"wrw"`
News News `json:"news"`
}
Rants is struct for receiving Rants response
type SearchRes ¶
type SearchRes struct {
Success bool `json:"success"`
Error string `json:"error"`
Rants []Rant `json:"results"`
}
SearchRes is a struct to receive Search response
type User ¶
type User struct {
Username string `json:"username"`
Score int `json:"score"`
About string `json:"about"`
Location string `json:"location"`
CreatedTime int `json:"created_time"`
Skills string `json:"skills"`
Github string `json:"github"`
Website string `json:"website"`
Content struct {
Content Content `json:"content"`
Counts Counts `json:"counts"`
} `json:"content"`
Avatar Avatar `json:"avatar"`
DPP int `json:"dpp"`
}
User is a struct to store User data