gvaclient

package
v0.6.1-0...-4943b3d Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparator

type Comparator string

Comparator indicates how a value should be compared

const (
	// IsGreaterThan indicates the queried value should be greater than the given value
	IsGreaterThan Comparator = "is greater than"
	// IsLessThan indicates the queried value should be less than the given value
	IsLessThan Comparator = "is less than"
	// IsEqualTo indicates the queried value should be equal to the given value
	IsEqualTo Comparator = "is equal to"
	// IsNotEqualTo indicates the queried value should not be equal to the given value
	IsNotEqualTo Comparator = "is not equal to"
)

type Incident

type Incident struct {
	IncidentID   string    `csv:"Incident ID"`
	IncidentDate time.Time `csv:"Incident Date"`
	State        string    `csv:"State"`
	CityOrCounty string    `csv:"City Or County"`
	Address      string    `csv:"Address"`
	Killed       int       `csv:"# Killed"`
	Injured      int       `csv:"# Injured"`
	Operations   string    `csv:"Operations"`
	Longitude    *float64
	Latitude     *float64
}

Incident is a record of an incident of gun violence

type IncidentDateComparator

type IncidentDateComparator string

IncidentDateComparator indicates how a date range should be specified

const (
	// IsIn indicates the date must be between from and to
	IsIn IncidentDateComparator = "is in"
	// IsNotIn indicates the date must not be between from and to
	IsNotIn IncidentDateComparator = "is not in"
)

type QueryClient

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

QueryClient is a client to query the Gun Violence Archive

func NewQueryClient

func NewQueryClient(rootURL string, log *zap.SugaredLogger) (*QueryClient, error)

NewQueryClient creates a new QueryClient

func (*QueryClient) QueryIncidents

func (qc *QueryClient) QueryIncidents(opts ...QueryOption) ([]Incident, error)

QueryIncidents queries incidents from the Gun Violence Archive

type QueryID

type QueryID string

QueryID is a unique identifier of a query

type QueryOption

type QueryOption func(*QueryOptions)

QueryOption is a fluent crtierion for a query

func WithAllCriteriaMatching

func WithAllCriteriaMatching(all bool) QueryOption

WithAllCriteriaMatching indicates whether ALL crtieria must match or whether ANY criteria must match

func WithIncidentDate

func WithIncidentDate(comparator IncidentDateComparator, from, to time.Time) QueryOption

WithIncidentDate indicates the date range of an incident

func WithIncidentLocation

func WithIncidentLocation(state, city, county string) QueryOption

WithIncidentLocation indicates the state, city, and/or county of an incident

func WithParticipantsAge

func WithParticipantsAge(comparator Comparator, age int) QueryOption

WithParticipantsAge indicates the age of any participant of an incident

type QueryOptions

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

QueryOptions holds the form data to post in a query

Jump to

Keyboard shortcuts

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