client

package module
Version: v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

README

coronavirusapi-go logo

coronavirusapi-go

COVID-19 API SDK for Golang. 🦠

Release Go Report Card Go Reference License


Getting Started

Import Covid-19 API Golang module:

import "github.com/moatsystems/coronavirusapi-go"

Dependence

Testing

Run the following command to test the package:

go test

Implementation

c: = client.New()
token,ok := c.Auth("<username>", "<password>")
...

// Call an endpoint such as US Death
usd := client.UsDeath()
  
// Retrieve all US Death data
j, err := usd.GetAll()

// Get API result (see simplejson)
j.Get("Code").String()
j.Get("Message").String()
j.Get("Document").Array()

// GetById
usd.GetById(1)

Below are all the available endpoints:

- UsDeath  
- UsConfirmed  
- GlobalDeath  
- GlobalConfirmed  
- GlobalRecovered  
- GlobalDailyReport 

All the endpoints listed above have five methods:

- GetAll()
- GetById(id int)
- Create(data map[string]interface{})
- UpdateById(id int, data map[string]interface{})
- DeleteById(id int)  

The COVID-19 API documentation is available here. If you need further assistance, don't hesitate to contact us.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the BSD 3-Clause License - see the file for details.

(c) 2020 - 2022 Moat Systems Limited.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New() *Client

func (*Client) Auth

func (c *Client) Auth(username, password string) (string, bool)

func (*Client) GlobalConfirmed

func (c *Client) GlobalConfirmed() *Resource

func (*Client) GlobalDailyReport

func (c *Client) GlobalDailyReport(month int, year int) *Resource

func (*Client) GlobalDeath

func (c *Client) GlobalDeath() *Resource

func (*Client) GlobalRecovered

func (c *Client) GlobalRecovered() *Resource

func (*Client) UsConfirmed

func (c *Client) UsConfirmed() *Resource

func (*Client) UsDeath

func (c *Client) UsDeath() *Resource

type HttpClient

type HttpClient struct {
	BaseURL *url.URL

	Token string
	// contains filtered or unexported fields
}

type Resource

type Resource struct {
	Name string
	Path string
}

func NewResource

func NewResource(name, path string) *Resource

func (*Resource) Create

func (r *Resource) Create(data map[string]interface{})

func (*Resource) DeleteById

func (r *Resource) DeleteById(id int)

func (*Resource) GetAll

func (r *Resource) GetAll() (*simplejson.Json, error)

func (*Resource) GetById

func (r *Resource) GetById(id int) (*simplejson.Json, error)

func (*Resource) UpdateById

func (r *Resource) UpdateById(id int, data map[string]interface{})

Jump to

Keyboard shortcuts

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