$ go run cmd/server/main.go
$ go test -v ./...
Each task should be completed in order and with test coverage.
Add a new field ZipCode
to domain.User
that's persisted by memory.UserStore
and returned in the response of the /v1/users
route.
Example output of /v1/users
:
{
"users": [
{
"nameFirst": "John",
"nameLast": "Smith",
"email": "john.smith@gmail.com",
"zipcode": "02210"
}
]
}
You can make a POST request to /v1/users
to create a new user, but will need to modify it to support a zipcode.
Modify the /v1/user/{id}
route to incude a new field location
. This field should be populated with the city and state code of the user's zipcode.
Use the /search
endpoint from Zipcodebase API to get a city and state code for a zipcode. You will receive an API key for Zipcodebase from Eleanor Health.
Example output for the Zipcodebase /search
endpoint:
{"query":{"codes":["02210"],"country":"us"},"results":{"02210":[{"postal_code":"02210","country_code":"US","latitude":"42.34890000","longitude":"-71.04650000","city":"Boston","state":"Massachusetts","city_en":"Boston","state_en":"Massachusetts","state_code":"MA","province":"Suffolk","province_code":"025"}]}}
Example output of /v1/user/{id}
:
{
"nameFirst": "John",
"nameLast": "Smith",
"email": "john.smith@gmail.com",
"location": "Boston, MA"
}
Add a new route /v1/locations
to return a list of distinct locations. A location is an object made up of a distinct zip code, city, state code, and total count of users for the location.
Example output of /locations
given three users with the zipcode 02210
, two users with the zipcode 06040
, and one user with the zipcode 92648
:
{
"zipcode": "02210",
"location": "Boston, MA",
"userCount": 3
},
{
"zipcode": "06040",
"location": "Manchester, CT",
"userCount": 2
},
{
"zipcode": "92648",
"location": "Huntington Beach, CA",
"userCount": 1
}