news

package
v0.0.0-...-af9e3dd Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Source struct {
		ID   interface{} `json:"id"`
		Name string      `json:"name"`
	} `json:"source"`
	Author      string    `json:"author"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	URL         string    `json:"url"`
	URLToImage  string    `json:"urlToImage"`
	PublishedAt time.Time `json:"publishedAt"`
}

Article : Structure to store the json object

func (*Article) FormatPublishedDate

func (a *Article) FormatPublishedDate() string

FormatPublishedDate : Formatting published date

type Client

type Client struct {
	PageSize int
	// contains filtered or unexported fields
}

Client : Structure to store http client

func NewClient

func NewClient(httpClient *http.Client, key string, pageSize int) *Client

NewClient : <aking requests to the News api.

func (*Client) FetchByCategory

func (c *Client) FetchByCategory(category, page string) (*Results, error)

FetchByCategory : Fectch for Category

func (*Client) FetchBySearch

func (c *Client) FetchBySearch(query, page string) (*Results, error)

FetchBySearch : To fetch the queries

func (*Client) FetchBySource

func (c *Client) FetchBySource(query, page string) (*Results, error)

FetchBySource : To fetch by source

func (*Client) FetchHeadline

func (c *Client) FetchHeadline(page string) (*Results, error)

FetchHeadline : To fetch the headlines

type Results

type Results struct {
	Status       string    `json:"status"`
	TotalResults int       `json:"totalResults"`
	Articles     []Article `json:"articles"`
}

Results : Structure to store the results

Jump to

Keyboard shortcuts

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