56 lines
857 B
Go
56 lines
857 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"git.bullercodeworks.com/brian/openstates"
|
|
"github.com/machinebox/graphql"
|
|
)
|
|
|
|
func main() {
|
|
req := graphql.NewRequest(`
|
|
query Reps($lat: Float, $long: Float) {
|
|
people(latitude: $lat, longitude: $long, first: 100) {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
sortName
|
|
familyName
|
|
givenName
|
|
image
|
|
birthDate
|
|
deathDate
|
|
createdAt
|
|
updatedAt
|
|
extras
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`)
|
|
req.Var("lat", 37.700824)
|
|
req.Var("long", -97.352906)
|
|
|
|
var res response
|
|
o := openstates.NewOpenStatesApi(ApiKey)
|
|
o.TurnOnLogging()
|
|
o.MakeRequest(req, &res)
|
|
j, _ := json.Marshal(res)
|
|
fmt.Println(string(j))
|
|
}
|
|
|
|
type response struct {
|
|
People people
|
|
}
|
|
type people struct {
|
|
Edges []edge
|
|
}
|
|
type edge struct {
|
|
Node node
|
|
}
|
|
type node struct {
|
|
Name string
|
|
}
|