data

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTwitterImageUrlFromPage added in v1.0.6

func GetTwitterImageUrlFromPage(ctx context.Context, page string) (string, error)

GetTwitterImageUrlFromPage gets the twitter:image meta content tag contents for the given page url by fetching and parsing the page

Types

type NewsItem

type NewsItem struct {
	ID         string `json:"id"`
	CreateTime int64  `json:"createtime"`
	Text       string `json:"text"`
	MediaURL   string `json:"mediaurl"`
	MediaData  string `json:"mediadata"`
	StoryURL   string `json:"storyurl"`
}

NewsItem represents a single news item

type NewsItems added in v1.0.15

type NewsItems []NewsItem

func (NewsItems) Len added in v1.0.15

func (n NewsItems) Len() int

Let NewsItems know how to sort by implementing the sort interface (https://pkg.go.dev/sort#Interface):

func (NewsItems) Less added in v1.0.15

func (n NewsItems) Less(i, j int) bool

func (NewsItems) Swap added in v1.0.15

func (n NewsItems) Swap(i, j int)

type NewsReport

type NewsReport struct {
	Items   NewsItems `json:"items"`
	Version string    `json:"version"`
}

NewsReport defines a news report

func GetNewsReport

func GetNewsReport(ctx context.Context, services []NewsService) NewsReport

GetNewsReport calls all services in parallel and returns the first result

type NewsService

type NewsService interface {
	// GetNewsReport gets the news report
	GetNewsReport(ctx context.Context) (NewsReport, error)
}

NewsService is the interface for all services that can fetch news data

type Tweet added in v1.0.10

type Tweet struct {
	Text      string    `json:"text"`
	CreatedAt time.Time `json:"created_at"`
	Entities  struct {
		Annotations []struct {
			Start          int     `json:"start"`
			End            int     `json:"end"`
			Probability    float64 `json:"probability"`
			Type           string  `json:"type"`
			NormalizedText string  `json:"normalized_text"`
		} `json:"annotations"`
		Urls []struct {
			Start       int    `json:"start"`
			End         int    `json:"end"`
			URL         string `json:"url"`
			ExpandedURL string `json:"expanded_url"`
			DisplayURL  string `json:"display_url"`
		} `json:"urls"`
	} `json:"entities"`
	ID string `json:"id"`
}

Tweet represents an individual tweet

type TwitterCNNService added in v1.0.6

type TwitterCNNService struct{}

TwitterCNNService represents the CNN news service

func (TwitterCNNService) GetNewsReport added in v1.0.6

func (s TwitterCNNService) GetNewsReport(ctx context.Context) (NewsReport, error)

GetNewsReport gets breaking news from CNN

type TwitterTimelineResponse added in v1.0.10

type TwitterTimelineResponse struct {
	Tweets []Tweet `json:"data"`
	Meta   struct {
		OldestID    string `json:"oldest_id"`
		NewestID    string `json:"newest_id"`
		ResultCount int    `json:"result_count"`
		NextToken   string `json:"next_token"`
	} `json:"meta"`
}

TwitterTimelineResponse represents the response to a timeline request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL