Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { ID int `json:"id"` Deleted string `json:"deleted"` Type ItemType `json:"type"` By string `json:"by"` Time int64 `json:"time"` Text string `json:"text"` Dead bool `json:"dead"` Parent int `json:"parent"` Poll int `json:"poll"` Kids []int `json:"kids"` URL string `json:"url"` Score int `json:"score"` Title string `json:"title"` Parts []int `json:"parts"` Descendants int `json:"descendants"` }
Item - GetItem() response struct. Items can be any of the ItemType options.
func GetItem ¶
GetItem - Get a single item and return as an Item struct. Items can be on of "job", "story", "comment", "poll", or "pollopt". They're identified by their ids, which are unique integers.
func HydrateItems ¶
HydrateItems concurrently hydrates a slice of item ids into Item structs. Requests that ask for multiple items such as GetStories() or GetUpdates() are returned only a slice of item ids. With this slice we need to pass each item id into GetItem() in order to get the full details. This HydrateItems function will fetch each ID in the slice of item ids concurrently to greatly improve execution time.
type ItemType ¶
type ItemType string
ItemType describes what type of object the Item struct represents
const ( // ItemTypeJob is a job item ItemTypeJob ItemType = "job" // ItemTypeStory is a story item ItemTypeStory ItemType = "story" // ItemTypeComment is a comment item ItemTypeComment ItemType = "comment" // ItemTypePoll is a poll item ItemTypePoll ItemType = "poll" // ItemTypePollOpt is a poll option item ItemTypePollOpt ItemType = "pollopt" )
type MaxItem ¶
type MaxItem int
MaxItem response struct. A single item ID.
func GetMaxItem ¶
GetMaxItem - The current largest item id.
type PaginatedStoriesResponse ¶
PaginatedStoriesResponse contains the story Items along with info regarding the page returned and the total possible results that can be accessed.
func GetPaginatedStories ¶
func GetPaginatedStories(storyType StoryType, limit int, pageNumber int) (PaginatedStoriesResponse, error)
GetPaginatedStories returns paginated responses of fully hydrated story Items. If the page requested is larger than the available data, the results will contain an empty slice of story Items.
func (*PaginatedStoriesResponse) HasNextpage ¶
func (p *PaginatedStoriesResponse) HasNextpage() bool
HasNextpage checks to see if there are more pages that can be returned. This will return false if requesting the next incremental page number will return 0 items.
type Stories ¶
type Stories []int
Stories - GetStories() response struct. An array of item ids.
func GetStories ¶
GetStories - Get a slice of all story ids of the type passed through the storyType argument.
StoryType can be one of the following:
- StoriesTop
- StoriesNew
- StoriesBest
- StoriesAsk
- StoriesShow
- StoriesJob
API DOCS:
type StoryType ¶
type StoryType int
StoryType - Enum value for types of stories available
Enum for types of stories
type Updates ¶
Updates - GetUpdates() response struct
func GetUpates ¶
GetUpates - Item and profile changes.
API DOC: https://github.com/HackerNews/API#changed-items-and-profiles