github.com/seeker-insurance/kit@v0.0.13/address/fromfactual.go (about) 1 package address 2 3 import "gopkg.in/mgo.v2/bson" 4 5 //FromFactualRecord builds an address from a serialized record from factual 6 func FromFactualRecord(factualRecord bson.M) Address { 7 getStr := func(key string) string { 8 val, _ := factualRecord[key] 9 str, _ := val.(string) 10 return str 11 } 12 return Address{ 13 Street: getStr("address"), 14 Extension: getStr("address_extended"), 15 POBox: getStr("po_box"), 16 Locality: getStr("locality"), 17 PostalCode: getStr("postcode"), 18 Region: getStr("region"), 19 Country: getStr("country"), 20 } 21 }