From 69b8dd5c0864899f51e66f8e9bd987d66649e38a Mon Sep 17 00:00:00 2001 From: Ken Michie Date: Fri, 9 Feb 2024 16:27:35 -0700 Subject: [PATCH 1/3] Moving test JSON into a file --- fc/person_test.go | 6 +- fc/person_test.json | 338 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 fc/person_test.json diff --git a/fc/person_test.go b/fc/person_test.go index c050012..9b23fdb 100644 --- a/fc/person_test.go +++ b/fc/person_test.go @@ -1,6 +1,7 @@ package fullcontact import ( + "os" "strings" "testing" @@ -9,8 +10,9 @@ import ( func TestPersonEnrich(t *testing.T) { ch := make(chan *APIResponse) - respJson := "{\"fullName\":\"Marquita H Ross\",\"ageRange\":\"37-47\",\"gender\":\"Female\",\"location\":\"San Francisco, California, United States\",\"title\":\"Senior Petroleum Manager\",\"organization\":\"Mostow Co.\",\"twitter\":\"https://twitter.com/marqross91\",\"linkedin\":\"https://www.linkedin.com/in/marquita-ross-5b6b72192\",\"facebook\":null,\"bio\":\"Senior Petroleum Manager at Mostow Co.\",\"avatar\":\"https://img.fullcontact.com/sandbox/1gagrO2K67_oc5DLG_siVCpYVE5UvCu2Z.png\",\"website\":\"http://marquitaas8.com/\",\"details\":{\"name\":{\"given\":\"Marquita\",\"family\":\"Ross\",\"full\":\"Marquita H Ross\"},\"age\":{\"range\":\"35-44\",\"value\":42},\"gender\":\"Female\",\"household\":{\"familyInfo\":{\"totalAdults\":2,\"totalChildren\":1,\"totalPeopleInHousehold\":3},\"homeInfo\":{\"dwellingType\":\"Multi Family Dwelling/Apartment\",\"homeValueEstimate\":513,\"loanToValueEstimate\":4},\"locationInfo\":{\"seasonalAddress\":true,\"carrierRoute\":\"PO Box\",\"designatedMarketArea\":\"807\",\"coreBasedStatisticalArea\":\"41860 - San Francisco-Oakland-Hayward, CA Metropolitan Statistical Area\",\"nielsenCountySize\":\"B - All counties in the next largest set of metropolitan areas which toher account for 30% of U.S. households according to the 2000 Census. No non-metropolitan counties qualify as A or B counties.\",\"congressionalDistrict\":\"14\",\"numericCountyCode\":222},\"presence\":{\"multigenerationalResident\":\"PRESENT\",\"children\":\"PRESENT\"},\"finance\":{\"discretionaryIncomeEstimate\":45,\"financialDebtRangeEstimate\":\"$0\",\"income\":\"$150,000 - $199,999\",\"netWorthRange\":\"$50,000 - $74,999\",\"cashValueBalanceHouseholdEstimate\":\"$25,000 - $49,999\"}},\"demographics\":{\"gender\":\"Female\",\"age\":{\"range\":\"35-44\",\"value\":42},\"livingStatus\":\"Probable Homeowner\",\"maritalStatus\":\"MARRIED\",\"occupation\":\"Professional - Engineer/Industrial\"},\"survey\":{\"own\":{\"ownDigitalCamera\":true,\"ownDog\":true,\"ownSwimmingPool\":true,\"ownRv\":true},\"collectibles\":{\"general\":true,\"coins\":true,\"stamps\":true},\"creditCards\":{\"premium\":{\"amex\":true,\"store\":true,\"visaOrMasterCard\":true},\"regular\":{\"amex\":true,\"other\":true,\"visaOrMasterCard\":true},\"debit\":true},\"dietConcerns\":{\"general\":true,\"loseWeight\":true,\"vitaminSupplements\":true,\"healthy\":true},\"hobby\":{\"general\":true,\"baking\":true,\"cigarSmoking\":true,\"gourmetCooking\":true,\"cooking\":true,\"gardening\":{\"general\":true,\"flowers\":true},\"homeImprovement\":true,\"exercise3xPerWeek\":true,\"lowFatCooking\":true,\"diy\":true,\"spirituality\":true},\"onlinePurchaser\":true,\"investments\":true,\"music\":{\"general\":true,\"christianOrGospel\":true,\"classical\":true,\"other\":true,\"rhythmAndBlues\":true},\"reading\":{\"likesToRead\":true,\"bibleOrDevotional\":true,\"bestSellingFiction\":true,\"childrens\":true,\"history\":true,\"health\":true,\"naturalHealthRemedies\":true,\"entertainment\":true,\"worldNewsOrPolitics\":true,\"bestSellers\":true,\"magazines\":true},\"sporting\":{\"fitness\":true,\"walking\":true,\"running\":true},\"travel\":{\"general\":true,\"usBusiness\":true,\"casinoVacations\":true,\"frequentFlyer\":true},\"religious\":true,\"electronics\":{\"appleDevice\":true,\"cableTv\":true,\"highSpeedInternet\":true,\"dvdPlayer\":true,\"hdtv\":true,\"homeTheater\":true,\"other\":true},\"purchase\":{\"homeDecorating\":true,\"beautyProducts\":true,\"clubStores\":true,\"usesCoupons\":true}},\"finance\":{\"bankCard\":\"Multiple Bank Card\",\"activeLineOfCredit\":true,\"retailCard\":\"Multiple Retail Card\"},\"census\":{\"basicTractNumber\":145,\"basicBlockGroup\":2,\"year2010\":{\"educationLevel\":\"High School Diploma\",\"average\":{\"numberOfCarsInHousehold\":2.3000000000000003},\"percent\":{\"abovePovertyLevel\":74,\"belowPovertyLevel\":28,\"black\":17,\"blueCollarEmployed\":35,\"divorcedOrSeparated\":14,\"hispanic\":43,\"homesBuiltSince2000\":52,\"homeowner\":90,\"householdsWithChildren\":38,\"married\":36,\"mobileHome\":45,\"movedToAreaSince2000\":21,\"salariedProfessional\":35,\"singleFamilyHome\":43,\"vehicleOwnership\":84,\"white\":35},\"median\":{\"ageOfHouseholder\":23,\"effectiveBuyingIncome\":18,\"homeValue\":35,\"householdIncome\":18,\"householdIncomeByState\":69},\"populationDensity\":{\"centileInState\":67,\"centileInUs\":17},\"socioEconomicScore\":29}},\"buyer\":{\"catalog\":{\"payment\":{\"amx\":true,\"creditCard\":true,\"houseCharge\":true,\"masterCard\":true,\"retailCard\":true,\"visa\":true},\"apparel\":{\"general\":true,\"children\":true,\"men\":true,\"mensBigTall\":true,\"nonGenderSpecific\":true,\"womenPetiteSize\":true,\"womenPlusSize\":true},\"beauty\":true,\"books\":true,\"childrenProducts\":true,\"electronics\":true,\"furniture\":true,\"health\":true,\"jewelry\":true,\"music\":true,\"stationery\":true,\"travel\":true,\"videoEntertainment\":true},\"retail\":{\"apparel\":{\"general\":true,\"children\":true,\"women\":true},\"beauty\":true,\"books\":true,\"childrenProducts\":true,\"collectibles\":true,\"foodBeverages\":true,\"gift\":true,\"health\":true,\"homeFurnishings\":true,\"jewelry\":true,\"music\":true,\"stationery\":true,\"travel\":true}},\"emails\":[],\"phones\":[],\"profiles\":{\"twitter\":{\"username\":\"marqross91\",\"url\":\"https://twitter.com/marqross91\",\"bio\":\"Senior Petroleum Manager at Mostow Co.\",\"service\":\"twitter\"},\"pinterest\":{\"username\":\"marquitaross006\",\"url\":\"http://www.pinterest.com/marquitaross006/\",\"bio\":\"Senior Petroleum Manager at Mostow Co.\",\"service\":\"pinterest\"},\"linkedin\":{\"username\":\"marquita-ross-5b6b72192\",\"userid\":\"761326554\",\"url\":\"https://www.linkedin.com/in/marquita-ross-5b6b72192\",\"bio\":\"Senior Petroleum Manager at Mostow Co.\",\"service\":\"linkedin\"}},\"locations\":[{\"city\":\"San Francisco\",\"region\":\"California\",\"regionCode\":\"CA\",\"country\":\"United States\",\"countryCode\":\"US\",\"formatted\":\"San Francisco, California, United States\"}],\"employment\":[{\"name\":\"Mostow Co.\",\"current\":true,\"title\":\"Senior Petroleum Manager\",\"start\":{\"year\":2019,\"month\":9}}],\"photos\":[{\"label\":\"avatar\",\"value\":\"https://img.fullcontact.com/sandbox/1gagrO2K67_oc5DLG_siVCpYVE5UvCu2Z.png\"}],\"education\":[{\"name\":\"University of California, Berkeley\",\"degree\":\"Bachelors\",\"end\":{\"year\":1998}}],\"urls\":[{\"value\":\"http://marquitaas8.com/\"}],\"interests\":[]},\"extended\":{\"epsilon_key_1\": \"9\",\"epsilon_key_2\": \"H\",\"epsilon_key_3\": \"Q\",\"epsilon_key_4\": \"0\",\"epsilon_key_5\": \"11\"},\"isSandboxProfile\":true,\"updated\":\"1970-01-01\"}" - fcTestClient, testServer := getTestServerAndClient(personEnrichUrl, respJson, 200) + respJson, _ := os.ReadFile("person_test.json") + + fcTestClient, testServer := getTestServerAndClient(personEnrichUrl, string(respJson), 200) defer testServer.Close() go fcTestClient.do(testServer.URL, nil, ch) resp := <-ch diff --git a/fc/person_test.json b/fc/person_test.json new file mode 100644 index 0000000..40bbf44 --- /dev/null +++ b/fc/person_test.json @@ -0,0 +1,338 @@ +{ + "fullName": "Marquita H Ross", + "ageRange": "37-47", + "gender": "Female", + "location": "San Francisco, California, United States", + "title": "Senior Petroleum Manager", + "organization": "Mostow Co.", + "twitter": "https://twitter.com/marqross91", + "linkedin": "https://www.linkedin.com/in/marquita-ross-5b6b72192", + "facebook": null, + "bio": "Senior Petroleum Manager at Mostow Co.", + "avatar": "https://img.fullcontact.com/sandbox/1gagrO2K67_oc5DLG_siVCpYVE5UvCu2Z.png", + "website": "http://marquitaas8.com/", + "details": { + "name": { + "given": "Marquita", + "family": "Ross", + "full": "Marquita H Ross" + }, + "age": { + "range": "35-44", + "value": 42 + }, + "gender": "Female", + "household": { + "familyInfo": { + "totalAdults": 2, + "totalChildren": 1, + "totalPeopleInHousehold": 3 + }, + "homeInfo": { + "dwellingType": "Multi Family Dwelling/Apartment", + "homeValueEstimate": 513, + "loanToValueEstimate": 4 + }, + "locationInfo": { + "seasonalAddress": true, + "carrierRoute": "PO Box", + "designatedMarketArea": "807", + "coreBasedStatisticalArea": "41860 - San Francisco-Oakland-Hayward, CA Metropolitan Statistical Area", + "nielsenCountySize": "B - All counties in the next largest set of metropolitan areas which toher account for 30% of U.S. households according to the 2000 Census. No non-metropolitan counties qualify as A or B counties.", + "congressionalDistrict": "14", + "numericCountyCode": 222 + }, + "presence": { + "multigenerationalResident": "PRESENT", + "children": "PRESENT" + }, + "finance" : { + "income" : "$30,000 - $39,999", + "discretionarySpendingIncome" : "$65,000 - $74,999", + "firstMortgageAmountInThousands" : "5147", + "homeMarketValueTaxRecord" : "453", + "shortTermLiability" : "$50,000 or more", + "netWorth" : "$150,000 - $249,999", + "wealthResources" : "$250,000 - $499,999", + "paymentMethodCreditCard" : "Y" + } + }, + "demographics": { + "gender": "Female", + "age": { + "range": "35-44", + "value": 42 + }, + "livingStatus": "Probable Homeowner", + "maritalStatus": "MARRIED", + "occupation": "Professional - Engineer/Industrial" + }, + "survey": { + "own": { + "ownDigitalCamera": true, + "ownDog": true, + "ownSwimmingPool": true, + "ownRv": true + }, + "collectibles": { + "general": true, + "coins": true, + "stamps": true + }, + "creditCards": { + "premium": { + "amex": true, + "store": true, + "visaOrMasterCard": true + }, + "regular": { + "amex": true, + "other": true, + "visaOrMasterCard": true + }, + "debit": true + }, + "dietConcerns": { + "general": true, + "loseWeight": true, + "vitaminSupplements": true, + "healthy": true + }, + "hobby": { + "general": true, + "baking": true, + "cigarSmoking": true, + "gourmetCooking": true, + "cooking": true, + "gardening": { + "general": true, + "flowers": true + }, + "homeImprovement": true, + "exercise3xPerWeek": true, + "lowFatCooking": true, + "diy": true, + "spirituality": true + }, + "onlinePurchaser": true, + "investments": true, + "music": { + "general": true, + "christianOrGospel": true, + "classical": true, + "other": true, + "rhythmAndBlues": true + }, + "reading": { + "likesToRead": true, + "bibleOrDevotional": true, + "bestSellingFiction": true, + "childrens": true, + "history": true, + "health": true, + "naturalHealthRemedies": true, + "entertainment": true, + "worldNewsOrPolitics": true, + "bestSellers": true, + "magazines": true + }, + "sporting": { + "fitness": true, + "walking": true, + "running": true + }, + "travel": { + "general": true, + "usBusiness": true, + "casinoVacations": true, + "frequentFlyer": true + }, + "religious": true, + "electronics": { + "appleDevice": true, + "cableTv": true, + "highSpeedInternet": true, + "dvdPlayer": true, + "hdtv": true, + "homeTheater": true, + "other": true + }, + "purchase": { + "homeDecorating": true, + "beautyProducts": true, + "clubStores": true, + "usesCoupons": true + } + }, + "finance": { + "bankCard": "Multiple Bank Card", + "activeLineOfCredit": true, + "retailCard": "Multiple Retail Card" + }, + "census": { + "basicTractNumber": 145, + "basicBlockGroup": 2, + "year2010": { + "educationLevel": "High School Diploma", + "average": { + "numberOfCarsInHousehold": 2.3000000000000003 + }, + "percent": { + "abovePovertyLevel": 74, + "belowPovertyLevel": 28, + "black": 17, + "blueCollarEmployed": 35, + "divorcedOrSeparated": 14, + "hispanic": 43, + "homesBuiltSince2000": 52, + "homeowner": 90, + "householdsWithChildren": 38, + "married": 36, + "mobileHome": 45, + "movedToAreaSince2000": 21, + "salariedProfessional": 35, + "singleFamilyHome": 43, + "vehicleOwnership": 84, + "white": 35 + }, + "median": { + "ageOfHouseholder": 23, + "effectiveBuyingIncome": 18, + "homeValue": 35, + "householdIncome": 18, + "householdIncomeByState": 69 + }, + "populationDensity": { + "centileInState": 67, + "centileInUs": 17 + }, + "socioEconomicScore": 29 + } + }, + "buyer": { + "catalog": { + "payment": { + "amx": true, + "creditCard": true, + "houseCharge": true, + "masterCard": true, + "retailCard": true, + "visa": true + }, + "apparel": { + "general": true, + "children": true, + "men": true, + "mensBigTall": true, + "nonGenderSpecific": true, + "womenPetiteSize": true, + "womenPlusSize": true + }, + "beauty": true, + "books": true, + "childrenProducts": true, + "electronics": true, + "furniture": true, + "health": true, + "jewelry": true, + "music": true, + "stationery": true, + "travel": true, + "videoEntertainment": true + }, + "retail": { + "apparel": { + "general": true, + "children": true, + "women": true + }, + "beauty": true, + "books": true, + "childrenProducts": true, + "collectibles": true, + "foodBeverages": true, + "gift": true, + "health": true, + "homeFurnishings": true, + "jewelry": true, + "music": true, + "stationery": true, + "travel": true + } + }, + "emails": [], + "phones": [], + "profiles": { + "twitter": { + "username": "marqross91", + "url": "https://twitter.com/marqross91", + "bio": "Senior Petroleum Manager at Mostow Co.", + "service": "twitter" + }, + "pinterest": { + "username": "marquitaross006", + "url": "http://www.pinterest.com/marquitaross006/", + "bio": "Senior Petroleum Manager at Mostow Co.", + "service": "pinterest" + }, + "linkedin": { + "username": "marquita-ross-5b6b72192", + "userid": "761326554", + "url": "https://www.linkedin.com/in/marquita-ross-5b6b72192", + "bio": "Senior Petroleum Manager at Mostow Co.", + "service": "linkedin" + } + }, + "locations": [ + { + "city": "San Francisco", + "region": "California", + "regionCode": "CA", + "country": "United States", + "countryCode": "US", + "formatted": "San Francisco, California, United States" + } + ], + "employment": [ + { + "name": "Mostow Co.", + "current": true, + "title": "Senior Petroleum Manager", + "start": { + "year": 2019, + "month": 9 + } + } + ], + "photos": [ + { + "label": "avatar", + "value": "https://img.fullcontact.com/sandbox/1gagrO2K67_oc5DLG_siVCpYVE5UvCu2Z.png" + } + ], + "education": [ + { + "name": "University of California, Berkeley", + "degree": "Bachelors", + "end": { + "year": 1998 + } + } + ], + "urls": [ + { + "value": "http://marquitaas8.com/" + } + ], + "interests": [] + }, + "extended": { + "epsilon_key_1": "9", + "epsilon_key_2": "H", + "epsilon_key_3": "Q", + "epsilon_key_4": "0", + "epsilon_key_5": "11" + }, + "isSandboxProfile": true, + "updated": "1970-01-01" +} From f76a18e82f39c795938af378c496143e4a6c8774 Mon Sep 17 00:00:00 2001 From: Ken Michie Date: Fri, 9 Feb 2024 16:28:09 -0700 Subject: [PATCH 2/3] Properly supporting Household::Finance object --- fc/household.go | 17 ++++++++--------- fc/person_test.go | 17 +++++++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/fc/household.go b/fc/household.go index 8eaf617..d34b1fe 100644 --- a/fc/household.go +++ b/fc/household.go @@ -21,15 +21,14 @@ type Presence struct { } type Finance struct { - CashValueBalanceHouseholdEstimate string `json:"cashValueBalanceHouseholdEstimate"` - FinancialDebtRangeEstimate string `json:"financialDebtRangeEstimate"` - HouseholdIncomeEstimate string `json:"income"` - NetWorthRange string `json:"netWorthRange"` - BankCard string `json:"bankCard"` - RetailCard string `json:"retailCard"` - ActiveLineOfCredit bool `json:"activeLineOfCredit"` - Bankruptcy bool `json:"bankruptcy"` - DiscretionaryIncomeEstimate int `json:"discretionaryIncomeEstimate"` + Income string `json:"income"` + DiscretionarySpendingIncome string `json:"discretionarySpendingIncome"` + FirstMortgageAmountInThousands string `json:"firstMortgageAmountInThousands"` + HomeMarketValueTaxRecord string `json:"homeMarketValueTaxRecord"` + ShortTermLiability string `json:"shortTermLiability"` + NetWorth string `json:"netWorth"` + WealthResources string `json:"wealthResources"` + PaymentMethodCreditCard string `json:"paymentMethodCreditCard"` } type LocationInfo struct { diff --git a/fc/person_test.go b/fc/person_test.go index 9b23fdb..d96312a 100644 --- a/fc/person_test.go +++ b/fc/person_test.go @@ -53,14 +53,19 @@ func TestPersonEnrich(t *testing.T) { assert.Equal(t, 222, response.Details.Household.LocationInfo.NumericCountyCode) assert.Equal(t, "PRESENT", response.Details.Household.Presence.MultigenerationalResident) assert.Equal(t, "PRESENT", response.Details.Household.Presence.Children) - assert.Equal(t, 45, response.Details.Household.Finance.DiscretionaryIncomeEstimate) - assert.Equal(t, "$150,000 - $199,999", response.Details.Household.Finance.HouseholdIncomeEstimate) - assert.Equal(t, "$25,000 - $49,999", response.Details.Household.Finance.CashValueBalanceHouseholdEstimate) + + // Finance + assert.Equal(t, "$30,000 - $39,999", response.Details.Household.Finance.Income) + assert.Equal(t, "$65,000 - $74,999", response.Details.Household.Finance.DiscretionarySpendingIncome) + assert.Equal(t, "5147", response.Details.Household.Finance.FirstMortgageAmountInThousands) + assert.Equal(t, "453", response.Details.Household.Finance.HomeMarketValueTaxRecord) + assert.Equal(t, "$50,000 or more", response.Details.Household.Finance.ShortTermLiability) + assert.Equal(t, "$150,000 - $249,999", response.Details.Household.Finance.NetWorth) + assert.Equal(t, "$250,000 - $499,999", response.Details.Household.Finance.WealthResources) + assert.Equal(t, "Y", response.Details.Household.Finance.PaymentMethodCreditCard) + assert.Equal(t, "Probable Homeowner", response.Details.Demographics.LivingStatus) assert.Equal(t, "Professional - Engineer/Industrial", response.Details.Demographics.Occupation) - assert.Equal(t, "Multiple Bank Card", response.Details.Finance.BankCard) - assert.Equal(t, "Multiple Retail Card", response.Details.Finance.RetailCard) - assert.True(t, response.Details.Finance.ActiveLineOfCredit) assert.Equal(t, 145, response.Details.Census.BasicTractNumber) assert.Equal(t, 2, response.Details.Census.BasicBlockGroup) assert.Equal(t, "High School Diploma", response.Details.Census.Year2010.EducationLevel) From da600d207d74a976b7af1e548bb29d801dd7c84c Mon Sep 17 00:00:00 2001 From: Ken Michie Date: Fri, 9 Feb 2024 16:31:02 -0700 Subject: [PATCH 3/3] .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ee4c98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +../.idea/