core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServiceURL = "https://cdn-api.co-vin.in/api"

DefaultServiceURL the default URL of the CoWIN Production API server

View Source
const DefaultUserAgent = "" /* 158-byte string literal not displayed */

DefaultUserAgent the default user-agent

Variables

View Source
var Routes map[string]string = map[string]string{
	"request_otp":      "/v2/auth/public/generateOTP",
	"confirm_otp":      "/v2/auth/public/confirmOTP",
	"get_states":       "/v2/admin/location/states",
	"get_districts":    "/v2/admin/location/districts",
	"find_by_pin":      "/v2/appointment/sessions/public/findByPin",
	"find_by_district": "/v2/appointment/sessions/public/findByDistrict",
	"find_by_lat_lan":  "/v2/appointment/centers/public/findByLatLong",
	"cal_by_pin":       "/v2/appointment/sessions/public/calendarByPin",
	"cal_by_district":  "/v2/appointment/sessions/public/calendarByDistrict",
	"cal_by_center":    "/v2/appointment/sessions/public/calendarByCenter",
	"download_cert":    "/v2/registration/certificate/public/download",
}

Routes all the API routes that are available in this SDK

Functions

func SignOTP

func SignOTP(otp string) string

SignOTP signs OTP by hasing with SHA-256 algorithm

func ToJSONString

func ToJSONString(typedData *interface{}) (string, error)

ToJSONString returns JSON string given the type

Types

type CenterCalendar

type CenterCalendar struct {
	CenterID      int                 `json:"center_id"`
	Name          string              `json:"name"`
	NameL         string              `json:"name_l"`
	Address       string              `json:"address"`
	AddressL      string              `json:"address_l"`
	StateName     string              `json:"state_name"`
	StateNameL    string              `json:"state_name_l"`
	DistrictName  string              `json:"district_name"`
	DistrictNameL string              `json:"district_name_l"`
	BlockName     string              `json:"block_name"`
	BlockNameL    string              `json:"block_name_l"`
	Pincode       int                 `json:"pincode"`
	Lat           float64             `json:"lat"`
	Long          float64             `json:"long"`
	FromTime      string              `json:"from"`
	ToTime        string              `json:"to"`
	FeeType       string              `json:"fee_type"`
	Vaccines      VaccineFeeList      `json:"vaccine_fees"`
	Sessions      VaccinationSessions `json:"sessions"`
}

CenterCalendar the sessions of a center by calendar

type CentersCalendar

type CentersCalendar []CenterCalendar

CentersCalendar List of CenterCalendar

type CentersCalendarResponse

type CentersCalendarResponse struct {
	Centers CentersCalendar `json:"centers"`
}

CentersCalendarResponse The response returned by API

type CoWinAPI

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

CoWinAPI The main type that implements all the CoWIN APIs

func NewCoWinAPI

func NewCoWinAPI(language string, userAgent string) *CoWinAPI

NewCoWinAPI Creates and returns a new CoWinAPI given language and userAgent string

func (*CoWinAPI) ConfirmRawOTP

func (c *CoWinAPI) ConfirmRawOTP(otp string, txnID string) (*OTPConfirmResponse, error)

ConfirmRawOTP Confirm an OTP sent to given number by passing SHA-256 raw otp string

func (*CoWinAPI) ConfirmSignedOTP

func (c *CoWinAPI) ConfirmSignedOTP(otpSHA256 string, txnID string) (*OTPConfirmResponse, error)

ConfirmSignedOTP Confirm an OTP sent to given number by passing SHA-256 hashed otp string:

func (*CoWinAPI) GetCalendarByCenter

func (c *CoWinAPI) GetCalendarByCenter(centerID int, date string) (*CenterCalendar, error)

GetCalendarByCenter Get the calendar by center ID

func (*CoWinAPI) GetCalendarByDistrict

func (c *CoWinAPI) GetCalendarByDistrict(districtID int, date string) (*CentersCalendarResponse, error)

GetCalendarByDistrict Get the calendar by district ID

func (*CoWinAPI) GetCalendarByPIN

func (c *CoWinAPI) GetCalendarByPIN(pincode string, date string) (*CentersCalendarResponse, error)

GetCalendarByPIN Get the calendar by PIN

func (*CoWinAPI) GetCentersByLatLong

func (c *CoWinAPI) GetCentersByLatLong(lat float64, long float64) (*VaccinationCentersResp, error)

GetCentersByLatLong Get the vaccination sessions available by lat long

func (*CoWinAPI) GetCertificate

func (c *CoWinAPI) GetCertificate(beneficiaryID string, token string) ([]byte, error)

GetCertificate Get the certificate in binary blob format

func (*CoWinAPI) GetDistricts

func (c *CoWinAPI) GetDistricts(stateID int) (*DistrictResp, error)

GetDistricts Get all the districts under a state, pass stateID as the parameter

func (*CoWinAPI) GetSessionsByDistrict

func (c *CoWinAPI) GetSessionsByDistrict(districtID int, date string) (*VaccinationSessionResp, error)

GetSessionsByDistrict Get the vaccination sessions available by district ID

func (*CoWinAPI) GetSessionsByPIN

func (c *CoWinAPI) GetSessionsByPIN(pincode string, date string) (*VaccinationSessionResp, error)

GetSessionsByPIN Get the vaccination sessions available by PIN

func (*CoWinAPI) GetStates

func (c *CoWinAPI) GetStates() (*StateResp, error)

GetStates get all the states and their IDs listed by CoWIN

func (*CoWinAPI) RequestOTP

func (c *CoWinAPI) RequestOTP(mobile string) (*OTPResponse, error)

RequestOTP Requests an OTP to be sent to given number:

type District

type District struct {
	StateID int    `json:"state_id"`
	ID      int    `json:"district_id"`
	Name    string `json:"district_name"`
	NameL   string `json:"district_name_l"`
}

District the district type

type DistrictResp

type DistrictResp struct {
	Districts []District `json:"districts"`
	TTL       int        `json:"ttl"`
}

DistrictResp the API response returned by /location/districts

type ErrorType

type ErrorType struct {
	ErrorCode string `json:"errorCode"`
	ErrString string `json:"error"`
}

ErrorType The error returned by API response

type OTPConfirmRequest

type OTPConfirmRequest struct {
	OTP   string `json:"otp"`
	TxnID string `json:"txnId"`
}

OTPConfirmRequest OTP Confirm request payload

type OTPConfirmResponse

type OTPConfirmResponse struct {
	Token string `json:"token"`
}

OTPConfirmResponse OTP Confirm response payload

type OTPRequest

type OTPRequest struct {
	Mobile string `json:"mobile"`
}

OTPRequest OTP request payload

type OTPResponse

type OTPResponse struct {
	TxnID string `json:"txnId"`
}

OTPResponse OTP response payload

type State

type State struct {
	ID    int    `json:"state_id"`
	Name  string `json:"state_name"`
	NameL string `json:"state_name_l"`
}

State the state type

type StateResp

type StateResp struct {
	States []State `json:"states"`
	TTL    int     `json:"ttl"`
}

StateResp the API response returned by /location/states

type VaccinationCenter

type VaccinationCenter struct {
	CenterID      int    `json:"center_id"`
	Name          string `json:"name"`
	NameL         string `json:"name_l"`
	Address       string `json:"address"`
	AddressL      string `json:"address_l"`
	StateName     string `json:"state_name"`
	StateNameL    string `json:"state_name_l"`
	DistrictName  string `json:"district_name"`
	DistrictNameL string `json:"district_name_l"`
	BlockName     string `json:"block_name"`
	BlockNameL    string `json:"block_name_l"`
	Pincode       string `json:"pincode"`
	Lat           string `json:"lat"`
	Long          string `json:"long"`
	FromTime      string `json:"from"`
	ToTime        string `json:"to"`
	FeeType       string `json:"fee_type"`
}

VaccinationCenter the type that represents a vaccination center

type VaccinationCentersResp

type VaccinationCentersResp struct {
	Centers []VaccinationCenter `json:"centers"`
	TTL     int                 `json:"ttl"`
}

VaccinationCentersResp the type that represents vaccination response

type VaccinationSession

type VaccinationSession struct {
	CenterID           int      `json:"center_id"`
	Name               string   `json:"name"`
	NameL              string   `json:"name_l"`
	Address            string   `json:"address"`
	AddressL           string   `json:"address_l"`
	StateName          string   `json:"state_name"`
	StateNameL         string   `json:"state_name_l"`
	DistrictName       string   `json:"district_name"`
	DistrictNameL      string   `json:"district_name_l"`
	BlockName          string   `json:"block_name"`
	BlockNameL         string   `json:"block_name_l"`
	Pincode            int      `json:"pincode"`
	Lat                float64  `json:"lat"`
	Long               float64  `json:"long"`
	FromTime           string   `json:"from"`
	ToTime             string   `json:"to"`
	FeeType            string   `json:"fee_type"`
	Fee                string   `json:"fee"`
	SessionID          string   `json:"session_id"`
	Date               string   `json:"date"`
	Capacity           int      `json:"available_capacity"`
	CapacityFirstDose  int      `json:"available_capacity_dose1"`
	CapacitySecondDose int      `json:"available_capacity_dose2"`
	MinimumAge         int      `json:"min_age_limit"`
	VaccineName        string   `json:"vaccine"`
	Slots              []string `json:"slots"`
}

VaccinationSession the Session type

type VaccinationSessionResp

type VaccinationSessionResp struct {
	Sessions []VaccinationSession `json:"sessions"`
}

VaccinationSessionResp the response returned by all find* APIs

type VaccinationSessions

type VaccinationSessions []VaccinationSession

VaccinationSessions list of VaccinationSession

type VaccineFee

type VaccineFee struct {
	Vaccine string `json:"vaccine"`
	Fee     string `json:"fee"`
}

VaccineFee the type that represents the fee of vaccine

type VaccineFeeList

type VaccineFeeList []VaccineFee

VaccineFeeList list of VaccineFee

Jump to

Keyboard shortcuts

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