apiclient

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APICasesResponse added in v1.6.0

type APICasesResponse struct {
	TimeStamp TimeStamp `json:"DATE"`
	Province  string    `json:"PROVINCE"`
	Region    string    `json:"REGION"`
	AgeGroup  string    `json:"AGEGROUP"`
	Cases     int       `json:"CASES"`
}

APICasesResponse is the response of the Sciensano cases API

type APITestResultsResponse

type APITestResultsResponse struct {
	TimeStamp TimeStamp `json:"DATE"`
	Province  string    `json:"PROVINCE"`
	Region    string    `json:"REGION"`
	Total     int       `json:"TESTS_ALL"`
	Positive  int       `json:"TESTS_ALL_POS"`
}

APITestResultsResponse is the response of the Sciensano test results API

type APIVaccinationsResponse

type APIVaccinationsResponse struct {
	TimeStamp TimeStamp `json:"DATE"`
	Region    string    `json:"REGION"`
	AgeGroup  string    `json:"AGEGROUP"`
	Gender    string    `json:"SEX"`
	Dose      string    `json:"DOSE"`
	Count     int       `json:"Count"`
}

APIVaccinationsResponse is the response of the Sciensano vaccinations API

type Cache

type Cache struct {
	Getter
	Retention time.Duration
	// contains filtered or unexported fields
}

Cache implements a cache for the Sciensano API. It's meant to be API-compatible with Getter, so clients can replace their Getter with a Cache instead:

client := &Client{
	Getter: &apiclient.Client{HTTPClient: &http.Client{}},
}

becomes:

client := &Client{
	Getter: &apiclient.Cache{
		Getter: &apiclient.Client{HTTPClient: &http.Client{}},
		Retention: 15 * time.Minute,
	},
}

func (*Cache) GetCases added in v1.6.0

func (cache *Cache) GetCases(ctx context.Context) (results []*APICasesResponse, err error)

GetCases retrieves all COVID-19 cases. If a valid cached result exists, that is returned instead.

func (*Cache) GetTestResults

func (cache *Cache) GetTestResults(ctx context.Context) (results []*APITestResultsResponse, err error)

GetTestResults retrieves all COVID-19 test results. If a valid cached result exists, that is returned instead.

func (*Cache) GetVaccinations

func (cache *Cache) GetVaccinations(ctx context.Context) (results []*APIVaccinationsResponse, err error)

GetVaccinations retrieves all COVID-19 vaccinations. If a valid cached result exists, that is returned instead.

type Client

type Client struct {
	URL        string
	HTTPClient *http.Client
}

Client calls the different sciensano APIs

func (*Client) GetCases added in v1.6.0

func (client *Client) GetCases(ctx context.Context) (results []*APICasesResponse, err error)

GetCases retrieves all recorded COVID-19 cases

func (*Client) GetTestResults

func (client *Client) GetTestResults(ctx context.Context) (results []*APITestResultsResponse, err error)

GetTestResults retrieves all COVID-19 test results.

func (*Client) GetVaccinations

func (client *Client) GetVaccinations(ctx context.Context) (results []*APIVaccinationsResponse, err error)

GetVaccinations retrieves all COVID-19 vaccinations.

type Getter added in v1.6.0

type Getter interface {
	GetTestResults(ctx context.Context) (results []*APITestResultsResponse, err error)
	GetVaccinations(ctx context.Context) (results []*APIVaccinationsResponse, err error)
	GetCases(ctx context.Context) (results []*APICasesResponse, err error)
}

Getter interface exposes the different supported Sciensano APIs

type TimeStamp

type TimeStamp struct {
	time.Time
}

TimeStamp represents a timestamp in the API response. Needed for parsing purposes

func (*TimeStamp) UnmarshalJSON

func (ts *TimeStamp) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshalls a TimeStamp from the API response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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