From 4222c103a964dc670ad2497a4a9a05b9015b270f Mon Sep 17 00:00:00 2001 From: Landon Fackrell <128620767+LandonSmarty@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:43:49 -0600 Subject: [PATCH] Us enrichment api (#33) * Initial code for us-enrichmemt-api. * Implement V1 enrichment sdk implemented full enrichment sdk functionality. --------- Co-authored-by: Bryan Amundson Co-authored-by: Michael Whatcott --- examples/us-enrichment-api/main.go | 40 +++ go.mod | 2 +- us-enrichment-api/client.go | 78 +++++ us-enrichment-api/client_test.go | 114 +++++++ us-enrichment-api/lookup.go | 61 ++++ us-enrichment-api/response.go | 502 +++++++++++++++++++++++++++++ wireup/builder.go | 7 + wireup/options.go | 6 + 8 files changed, 809 insertions(+), 1 deletion(-) create mode 100644 examples/us-enrichment-api/main.go create mode 100644 us-enrichment-api/client.go create mode 100644 us-enrichment-api/client_test.go create mode 100644 us-enrichment-api/lookup.go create mode 100644 us-enrichment-api/response.go diff --git a/examples/us-enrichment-api/main.go b/examples/us-enrichment-api/main.go new file mode 100644 index 0000000..68fffd7 --- /dev/null +++ b/examples/us-enrichment-api/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "fmt" + "github.com/smartystreets/smartystreets-go-sdk/wireup" + "log" + "os" +) + +func main() { + log.SetFlags(log.Ltime | log.Llongfile) + + client := wireup.BuildUSEnrichmentAPIClient( + //wireup.WebsiteKeyCredential(os.Getenv("SMARTY_AUTH_WEB"), os.Getenv("SMARTY_AUTH_REFERER")), + wireup.SecretKeyCredential(os.Getenv("SMARTY_AUTH_ID"), os.Getenv("SMARTY_AUTH_TOKEN")), + // The appropriate license values to be used for your subscriptions + // can be found on the Subscriptions page the account dashboard. + // https://www.smarty.com/docs/cloud/licensing + wireup.WithLicenses("us-property-data-principal-cloud"), + // wireup.DebugHTTPOutput(), // uncomment this line to see detailed HTTP request/response information. + ) + + // Documentation for input fields can be found at: + // https://smartystreets.com/docs/cloud/us-reverse-geo-api#http-request-input-fields + + smartyKey := "1682393594" + + err, results := client.SendPropertyPrincipalLookup(smartyKey) + + if err != nil { + log.Fatal("Error sending lookup:", err) + } + + fmt.Printf("Results for input: (%s, %s)\n", smartyKey, "principal") + for s, response := range results { + fmt.Printf("#%d: %+v\n", s, response) + } + + log.Println("OK") +} diff --git a/go.mod b/go.mod index db4c7a5..44f6edb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/smartystreets/smartystreets-go-sdk -go 1.13 +go 1.18 require ( github.com/smarty/assertions v1.15.1 diff --git a/us-enrichment-api/client.go b/us-enrichment-api/client.go new file mode 100644 index 0000000..97c3d9c --- /dev/null +++ b/us-enrichment-api/client.go @@ -0,0 +1,78 @@ +package us_enrichment + +import ( + "context" + "net/http" + "strings" + + "github.com/smartystreets/smartystreets-go-sdk" +) + +type Client struct { + sender sdk.RequestSender +} + +func NewClient(sender sdk.RequestSender) *Client { + return &Client{sender: sender} +} + +func (c *Client) SendPropertyFinancialLookup(smartyKey string) (error, []*FinancialResponse) { + l := &financialLookup{ + SmartyKey: smartyKey, + } + err := c.sendLookup(l) + + return err, l.Response +} + +func (c *Client) SendPropertyPrincipalLookup(smartyKey string) (error, []*PrincipalResponse) { + l := &principalLookup{ + SmartyKey: smartyKey, + } + err := c.sendLookup(l) + + return err, l.Response +} + +func (c *Client) sendLookup(lookup enrichmentLookup) error { + return c.sendLookupWithContext(context.Background(), lookup) +} + +func (c *Client) sendLookupWithContext(ctx context.Context, lookup enrichmentLookup) error { + if lookup == nil { + return nil + } + if len(lookup.GetSmartyKey()) == 0 { + return nil + } + + request := buildRequest(lookup) + request = request.WithContext(ctx) + + response, err := c.sender.Send(request) + if err != nil { + return err + } + + return lookup.UnmarshalResponse(response) +} + +func buildRequest(lookup enrichmentLookup) *http.Request { + request, _ := http.NewRequest("GET", buildLookupURL(lookup), nil) // We control the method and the URL. This is safe. + query := request.URL.Query() + request.URL.RawQuery = query.Encode() + return request +} + +func buildLookupURL(lookup enrichmentLookup) string { + newLookupURL := strings.Replace(lookupURL, lookupURLSmartyKey, lookup.GetSmartyKey(), 1) + newLookupURL = strings.Replace(newLookupURL, lookupURLDataSet, lookup.GetDataSet(), 1) + return strings.Replace(newLookupURL, lookupURLDataSubSet, lookup.GetDataSubset(), 1) +} + +const ( + lookupURLSmartyKey = ":smartykey" + lookupURLDataSet = ":dataset" + lookupURLDataSubSet = ":datasubset" + lookupURL = "/lookup/" + lookupURLSmartyKey + "/" + lookupURLDataSet + "/" + lookupURLDataSubSet // Remaining parts will be completed later by the sdk.BaseURLClient. +) diff --git a/us-enrichment-api/client_test.go b/us-enrichment-api/client_test.go new file mode 100644 index 0000000..8292f47 --- /dev/null +++ b/us-enrichment-api/client_test.go @@ -0,0 +1,114 @@ +package us_enrichment + +import ( + "context" + "errors" + "net/http" + "testing" + + "github.com/smarty/assertions/should" + "github.com/smarty/gunit" +) + +func TestClientFixture(t *testing.T) { + gunit.Run(new(ClientFixture), t) +} + +type ClientFixture struct { + *gunit.Fixture + + sender *FakeSender + client *Client + + input enrichmentLookup +} + +func (f *ClientFixture) Setup() { + f.sender = &FakeSender{} + f.client = NewClient(f.sender) + f.input = new(principalLookup) +} + +func (f *ClientFixture) TestLookupSerializedAndSentWithContext__ResponseSuggestionsIncorporatedIntoLookup() { + smartyKey := "123" + f.sender.response = validFinancialResponse + f.input = &financialLookup{ + SmartyKey: smartyKey, + } + + ctx := context.WithValue(context.Background(), "key", "value") + err := f.client.sendLookupWithContext(ctx, f.input) + + f.So(err, should.BeNil) + f.So(f.sender.request, should.NotBeNil) + f.So(f.sender.request.Method, should.Equal, "GET") + f.So(f.sender.request.URL.Path, should.Equal, "/lookup/"+smartyKey+"/"+f.input.GetDataSet()+"/"+f.input.GetDataSubset()) + f.So(f.sender.request.Context(), should.Resemble, ctx) + + response := f.input.(*financialLookup).Response + + f.So(response, should.Resemble, []*FinancialResponse{ + { + SmartyKey: "123", + DataSetName: "property", + DataSubsetName: "financial", + Attributes: FinancialAttributes{ + AssessedImprovementPercent: "Assessed_Improvement_Percent", + VeteranTaxExemption: "Veteran_Tax_Exemption", + WidowTaxExemption: "Widow_Tax_Exemption", + }, + }, + }) +} + +func (f *ClientFixture) TestNilLookupNOP() { + err := f.client.sendLookup(nil) + f.So(err, should.BeNil) + f.So(f.sender.request, should.BeNil) +} + +func (f *ClientFixture) TestEmptyLookup_NOP() { + err := f.client.sendLookup(new(principalLookup)) + f.So(err, should.BeNil) + f.So(f.sender.request, should.BeNil) +} + +func (f *ClientFixture) TestSenderErrorPreventsDeserialization() { + f.sender.err = errors.New("gophers") + f.sender.response = validPrincipalResponse // would be deserialized if not for the err (above) + f.input = &principalLookup{SmartyKey: "12345"} + + err := f.client.sendLookup(f.input) + + f.So(err, should.NotBeNil) + f.So(f.input.(*principalLookup).Response, should.BeEmpty) +} + +func (f *ClientFixture) TestDeserializationErrorPreventsDeserialization() { + f.sender.response = `I can't haz JSON` + f.input = &principalLookup{SmartyKey: "12345"} + + err := f.client.sendLookup(f.input) + + f.So(err, should.NotBeNil) + f.So(f.input.(*principalLookup).Response, should.BeEmpty) +} + +var validFinancialResponse = `[{"smarty_key":"123","data_set_name":"property","data_subset_name":"financial","attributes":{"assessed_improvement_percent":"Assessed_Improvement_Percent","veteran_tax_exemption":"Veteran_Tax_Exemption","widow_tax_exemption":"Widow_Tax_Exemption"}}]` +var validPrincipalResponse = `[{"smarty_key":"123","data_set_name":"property","data_subset_name":"principal","attributes":{"1st_floor_sqft":"1st_Floor_Sqft",lender_name_2":"Lender_Name_2","lender_seller_carry_back":"Lender_Seller_Carry_Back","year_built":"Year_Built","zoning":"Zoning"}}]` + +/**************************************************************************/ + +type FakeSender struct { + callCount int + request *http.Request + + response string + err error +} + +func (f *FakeSender) Send(request *http.Request) ([]byte, error) { + f.callCount++ + f.request = request + return []byte(f.response), f.err +} diff --git a/us-enrichment-api/lookup.go b/us-enrichment-api/lookup.go new file mode 100644 index 0000000..158a027 --- /dev/null +++ b/us-enrichment-api/lookup.go @@ -0,0 +1,61 @@ +package us_enrichment + +import ( + "encoding/json" +) + +type enrichmentLookup interface { + GetSmartyKey() string + GetDataSet() string + GetDataSubset() string + + UnmarshalResponse([]byte) error +} + +type financialLookup struct { + SmartyKey string + Response []*FinancialResponse +} + +func (f *financialLookup) GetSmartyKey() string { + return f.SmartyKey +} + +func (f *financialLookup) GetDataSet() string { + return propertyDataSet +} + +func (f *financialLookup) GetDataSubset() string { + return financialDataSubset +} + +func (f *financialLookup) UnmarshalResponse(bytes []byte) error { + return json.Unmarshal(bytes, &f.Response) +} + +type principalLookup struct { + SmartyKey string + Response []*PrincipalResponse +} + +func (p *principalLookup) GetSmartyKey() string { + return p.SmartyKey +} + +func (p *principalLookup) GetDataSet() string { + return propertyDataSet +} + +func (p *principalLookup) GetDataSubset() string { + return principalDataSubset +} + +func (p *principalLookup) UnmarshalResponse(bytes []byte) error { + return json.Unmarshal(bytes, &p.Response) +} + +const ( + financialDataSubset = "financial" + principalDataSubset = "principal" + propertyDataSet = "property" +) diff --git a/us-enrichment-api/response.go b/us-enrichment-api/response.go new file mode 100644 index 0000000..7888040 --- /dev/null +++ b/us-enrichment-api/response.go @@ -0,0 +1,502 @@ +package us_enrichment + +type PrincipalResponse struct { + SmartyKey string `json:"smarty_key"` + DataSetName string `json:"data_set_name"` + DataSubsetName string `json:"data_subset_name"` + Attributes PrincipalAttributes `json:"attributes"` +} + +type PrincipalAttributes struct { + StFloorSqft string `json:"1st_floor_sqft"` + NdFloorSqft string `json:"2nd_floor_sqft"` + Acres string `json:"acres"` + AddressInfoPrivacy string `json:"address_info_privacy"` + AirConditioner string `json:"air_conditioner"` + ArborPergola string `json:"arbor_pergola"` + AssessedImprovementPercent string `json:"assessed_improvement_percent"` + AssessedImprovementValue string `json:"assessed_improvement_value"` + AssessedLandValue string `json:"assessed_land_value"` + AssessedValue string `json:"assessed_value"` + AssessorLastUpdate string `json:"assessor_last_update"` + AssessorTaxrollUpdate string `json:"assessor_taxroll_update"` + AtticArea string `json:"attic_area"` + AtticFlag string `json:"attic_flag"` + Balcony string `json:"balcony"` + BalconyArea string `json:"balcony_area"` + BasementSqft string `json:"basement_sqft"` + BasementSqftFinished string `json:"basement_sqft_finished"` + BasementSqftUnfinished string `json:"basement_sqft_unfinished"` + BathHouse string `json:"bath_house"` + BathHouseSqft string `json:"bath_house_sqft"` + BathroomsPartial string `json:"bathrooms_partial"` + BathroomsTotal string `json:"bathrooms_total"` + Bedrooms string `json:"bedrooms"` + Block1 string `json:"block1"` + Block2 string `json:"block2"` + BoatAccess string `json:"boat_access"` + BoatHouse string `json:"boat_house"` + BoatHouseSqft string `json:"boat_house_sqft"` + BoatLift string `json:"boat_lift"` + BonusRoom string `json:"bonus_room"` + BreakfastNook string `json:"breakfast_nook"` + Breezeway string `json:"breezeway"` + BuildingDefinitionCode string `json:"building_definition_code"` + BuildingSqft string `json:"building_sqft"` + Cabin string `json:"cabin"` + CabinSqft string `json:"cabin_sqft"` + Canopy string `json:"canopy"` + CanopySqft string `json:"canopy_sqft"` + Carport string `json:"carport"` + CarportSqft string `json:"carport_sqft"` + CbsaCode string `json:"cbsa_code"` + CbsaName string `json:"cbsa_name"` + Cellar string `json:"cellar"` + CensusBlock string `json:"census_block"` + CensusBlockGroup string `json:"census_block_group"` + CensusFipsPlaceCode string `json:"census_fips_place_code"` + CensusTract string `json:"census_tract"` + CentralVacuum string `json:"central_vacuum"` + CodeTitleCompany string `json:"code_title_company"` + CombinedStatisticalArea string `json:"combined_statistical_area"` + CommunityRec string `json:"community_rec"` + CompanyFlag string `json:"company_flag"` + CongressionalDistrict string `json:"congressional_district"` + ConstructionType string `json:"construction_type"` + ContactCity string `json:"contact_city"` + ContactCrrt string `json:"contact_crrt"` + ContactFullAddress string `json:"contact_full_address"` + ContactHouseNumber string `json:"contact_house_number"` + ContactMailInfoFormat string `json:"contact_mail_info_format"` + ContactMailInfoPrivacy string `json:"contact_mail_info_privacy"` + ContactMailingCounty string `json:"contact_mailing_county"` + ContactMailingFips string `json:"contact_mailing_fips"` + ContactPostDirection string `json:"contact_post_direction"` + ContactPreDirection string `json:"contact_pre_direction"` + ContactState string `json:"contact_state"` + ContactStreetName string `json:"contact_street_name"` + ContactSuffix string `json:"contact_suffix"` + ContactUnitDesignator string `json:"contact_unit_designator"` + ContactValue string `json:"contact_value"` + ContactZip string `json:"contact_zip"` + ContactZip4 string `json:"contact_zip4"` + Courtyard string `json:"courtyard"` + CourtyardArea string `json:"courtyard_area"` + Deck string `json:"deck"` + DeckArea string `json:"deck_area"` + DeedDocumentPage string `json:"deed_ document_page"` + DeedDocumentBook string `json:"deed_document_book"` + DeedDocumentNumber string `json:"deed_document_number"` + DeedOwnerFirstName string `json:"deed_owner_first_name"` + DeedOwnerFirstName2 string `json:"deed_owner_first_name2"` + DeedOwnerFirstName3 string `json:"deed_owner_first_name3"` + DeedOwnerFirstName4 string `json:"deed_owner_first_name4"` + DeedOwnerFullName string `json:"deed_owner_full_name"` + DeedOwnerFullName2 string `json:"deed_owner_full_name2"` + DeedOwnerFullName3 string `json:"deed_owner_full_name3"` + DeedOwnerFullName4 string `json:"deed_owner_full_name4"` + DeedOwnerLastName string `json:"deed_owner_last_name"` + DeedOwnerLastName2 string `json:"deed_owner_last_name2"` + DeedOwnerLastName3 string `json:"deed_owner_last_name3"` + DeedOwnerLastName4 string `json:"deed_owner_last_name4"` + DeedOwnerMiddleName string `json:"deed_owner_middle_name"` + DeedOwnerMiddleName2 string `json:"deed_owner_middle_name2"` + DeedOwnerMiddleName3 string `json:"deed_owner_middle_name3"` + DeedOwnerMiddleName4 string `json:"deed_owner_middle_name4"` + DeedOwnerSuffix string `json:"deed_owner_suffix"` + DeedOwnerSuffix2 string `json:"deed_owner_suffix2"` + DeedOwnerSuffix3 string `json:"deed_owner_suffix3"` + DeedOwnerSuffix4 string `json:"deed_owner_suffix4"` + DeedSaleDate string `json:"deed_sale_date"` + DeedSalePrice string `json:"deed_sale_price"` + DeedTransactionId string `json:"deed_transaction_id"` + DepthLinearFootage string `json:"depth_linear_footage"` + DisabledTaxExemption string `json:"disabled_tax_exemption"` + DrivewaySqft string `json:"driveway_sqft"` + DrivewayType string `json:"driveway_type"` + EffectiveYearBuilt string `json:"effective_year_built"` + ElevationFeet string `json:"elevation_feet"` + Elevator string `json:"elevator"` + EquestrianArena string `json:"equestrian_arena"` + Escalator string `json:"escalator"` + ExerciseRoom string `json:"exercise_room"` + ExteriorWalls string `json:"exterior_walls"` + FamilyRoom string `json:"family_room"` + Fence string `json:"fence"` + FenceArea string `json:"fence_area"` + FipsCode string `json:"fips_code"` + FireResistanceCode string `json:"fire_resistance_code"` + FireSprinklersFlag string `json:"fire_sprinklers_flag"` + Fireplace string `json:"fireplace"` + FireplaceNumber string `json:"fireplace_number"` + FirstName string `json:"first_name"` + FirstName2 string `json:"first_name_2"` + FirstName3 string `json:"first_name_3"` + FirstName4 string `json:"first_name_4"` + Flooring string `json:"flooring"` + Foundation string `json:"foundation"` + GameRoom string `json:"game_room"` + Garage string `json:"garage"` + GarageSqft string `json:"garage_sqft"` + Gazebo string `json:"gazebo"` + GazeboSqft string `json:"gazebo_sqft"` + GolfCourse string `json:"golf_course"` + Grainery string `json:"grainery"` + GrainerySqft string `json:"grainery_sqft"` + GreatRoom string `json:"great_room"` + Greenhouse string `json:"greenhouse"` + GreenhouseSqft string `json:"greenhouse_sqft"` + GrossSqft string `json:"gross_sqft"` + Guesthouse string `json:"guesthouse"` + GuesthouseSqft string `json:"guesthouse_sqft"` + HandicapAccessibility string `json:"handicap_accessibility"` + Heat string `json:"heat"` + HeatFuelType string `json:"heat_fuel_type"` + HobbyRoom string `json:"hobby_room"` + HomeownerTaxExemption string `json:"homeowner_tax_exemption"` + InstrumentDate string `json:"instrument_date"` + IntercomSystem string `json:"intercom_system"` + InterestRateType2 string `json:"interest_rate_type_2"` + InteriorStructure string `json:"interior_structure"` + Kennel string `json:"kennel"` + KennelSqft string `json:"kennel_sqft"` + LandUseCode string `json:"land_use_code"` + LandUseGroup string `json:"land_use_group"` + LandUseStandard string `json:"land_use_standard"` + LastName string `json:"last_name"` + LastName2 string `json:"last_name_2"` + LastName3 string `json:"last_name_3"` + LastName4 string `json:"last_name_4"` + Latitude string `json:"latitude"` + Laundry string `json:"laundry"` + LeanTo string `json:"lean_to"` + LeanToSqft string `json:"lean_to_sqft"` + LegalDescription string `json:"legal_description"` + LegalUnit string `json:"legal_unit"` + LenderAddress string `json:"lender_address"` + LenderAddress2 string `json:"lender_address_2"` + LenderCity string `json:"lender_city"` + LenderCity2 string `json:"lender_city_2"` + LenderCode2 string `json:"lender_code_2"` + LenderFirstName string `json:"lender_first_name"` + LenderFirstName2 string `json:"lender_first_name_2"` + LenderLastName string `json:"lender_last_name"` + LenderLastName2 string `json:"lender_last_name_2"` + LenderName string `json:"lender_name"` + LenderName2 string `json:"lender_name_2"` + LenderSellerCarryBack string `json:"lender_seller_carry_back"` + LenderSellerCarryBack2 string `json:"lender_seller_carry_back_2"` + LenderState string `json:"lender_state"` + LenderState2 string `json:"lender_state_2"` + LenderZip string `json:"lender_zip"` + LenderZip2 string `json:"lender_zip_2"` + LenderZipExtended string `json:"lender_zip_extended"` + LenderZipExtended2 string `json:"lender_zip_extended_2"` + LoadingPlatform string `json:"loading_platform"` + LoadingPlatformSqft string `json:"loading_platform_sqft"` + Longitude string `json:"longitude"` + Lot1 string `json:"lot_1"` + Lot2 string `json:"lot_2"` + Lot3 string `json:"lot_3"` + LotSqft string `json:"lot_sqft"` + MarketImprovementPercent string `json:"market_improvement_percent"` + MarketImprovementValue string `json:"market_improvement_value"` + MarketLandValue string `json:"market_land_value"` + MarketValueYear string `json:"market_value_year"` + MatchType string `json:"match_type"` + MediaRoom string `json:"media_room"` + MetroDivision string `json:"metro_division"` + MiddleName string `json:"middle_name"` + MiddleName2 string `json:"middle_name_2"` + MiddleName3 string `json:"middle_name_3"` + MiddleName4 string `json:"middle_name_4"` + Milkhouse string `json:"milkhouse"` + MilkhouseSqft string `json:"milkhouse_sqft"` + MinorCivilDivisionCode string `json:"minor_civil_division_code"` + MinorCivilDivisionName string `json:"minor_civil_division_name"` + MobileHomeHookup string `json:"mobile_home_hookup"` + MortgageAmount string `json:"mortgage_amount"` + MortgageAmount2 string `json:"mortgage_amount_2"` + MortgageDueDate string `json:"mortgage_due_date"` + MortgageDueDate2 string `json:"mortgage_due_date_2"` + MortgageInterestRate string `json:"mortgage_interest_rate"` + MortgageInterestRateType string `json:"mortgage_interest_rate_type"` + MortgageLenderCode string `json:"mortgage_lender_code"` + MortgageRate2 string `json:"mortgage_rate_2"` + MortgageRecordingDate string `json:"mortgage_recording_date"` + MortgageRecordingDate2 string `json:"mortgage_recording_date_2"` + MortgageTerm string `json:"mortgage_term"` + MortgageTerm2 string `json:"mortgage_term_2"` + MortgageTermType string `json:"mortgage_term_type"` + MortgageTermType2 string `json:"mortgage_term_type_2"` + MortgageType string `json:"mortgage_type"` + MortgageType2 string `json:"mortgage_type_2"` + MsaCode string `json:"msa_code"` + MsaName string `json:"msa_name"` + MudRoom string `json:"mud_room"` + MultiParcelFlag string `json:"multi_parcel_flag"` + NameTitleCompany string `json:"name_title_company"` + NeighborhoodCode string `json:"neighborhood_code"` + NumberOfBuildings string `json:"number_of_buildings"` + Office string `json:"office"` + OfficeSqft string `json:"office_sqft"` + OtherTaxExemption string `json:"other_tax_exemption"` + OutdoorKitchenFireplace string `json:"outdoor_kitchen_fireplace"` + OverheadDoor string `json:"overhead_door"` + OwnerFullName string `json:"owner_full_name"` + OwnerFullName2 string `json:"owner_full_name_2"` + OwnerFullName3 string `json:"owner_full_name_3"` + OwnerFullName4 string `json:"owner_full_name_4"` + OwnerOccupancyStatus string `json:"owner_occupancy_status"` + OwnershipTransferDate string `json:"ownership_transfer_date"` + OwnershipTransferDocNumber string `json:"ownership_transfer_doc_number"` + OwnershipTransferTransactionId string `json:"ownership_transfer_transaction_id"` + OwnershipType string `json:"ownership_type"` + OwnershipType2 string `json:"ownership_type_2"` + OwnershipVestingRelationCode string `json:"ownership_vesting_relation_code"` + ParcelAccountNumber string `json:"parcel_account_number"` + ParcelMapBook string `json:"parcel_map_book"` + ParcelMapPage string `json:"parcel_map_page"` + ParcelNumberAlternate string `json:"parcel_number_alternate"` + ParcelNumberFormatted string `json:"parcel_number_formatted"` + ParcelNumberPrevious string `json:"parcel_number_previous"` + ParcelNumberYearAdded string `json:"parcel_number_year_added"` + ParcelNumberYearChange string `json:"parcel_number_year_change"` + ParcelRawNumber string `json:"parcel_raw_number"` + ParcelShellRecord string `json:"parcel_shell_record"` + ParkingSpaces string `json:"parking_spaces"` + PatioArea string `json:"patio_area"` + PhaseName string `json:"phase_name"` + PlumbingFixturesCount string `json:"plumbing_fixtures_count"` + PoleStruct string `json:"pole_struct"` + PoleStructSqft string `json:"pole_struct_sqft"` + Pond string `json:"pond"` + Pool string `json:"pool"` + PoolArea string `json:"pool_area"` + Poolhouse string `json:"poolhouse"` + PoolhouseSqft string `json:"poolhouse_sqft"` + Porch string `json:"porch"` + PorchArea string `json:"porch_area"` + PoultryHouse string `json:"poultry_house"` + PoultryHouseSqft string `json:"poultry_house_sqft"` + PreviousAssessedValue string `json:"previous_assessed_value"` + PriorSaleAmount string `json:"prior_sale_amount"` + PriorSaleDate string `json:"prior_sale_date"` + PropertyAddressCarrierRouteCode string `json:"property_address_carrier_route_code"` + PropertyAddressCity string `json:"property_address_city"` + PropertyAddressFull string `json:"property_address_full"` + PropertyAddressHouseNumber string `json:"property_address_house_number"` + PropertyAddressPostDirection string `json:"property_address_post_direction"` + PropertyAddressPreDirection string `json:"property_address_pre_direction"` + PropertyAddressState string `json:"property_address_state"` + PropertyAddressStreetName string `json:"property_address_street_name"` + PropertyAddressStreetSuffix string `json:"property_address_street_suffix"` + PropertyAddressUnitDesignator string `json:"property_address_unit_designator"` + PropertyAddressUnitValue string `json:"property_address_unit_value"` + PropertyAddressZip4 string `json:"property_address_zip_4"` + PropertyAddressZipcode string `json:"property_address_zipcode"` + PublicationDate string `json:"publication_date"` + Quarter string `json:"quarter"` + QuarterQuarter string `json:"quarter_quarter"` + Quonset string `json:"quonset"` + QuonsetSqft string `json:"quonset_sqft"` + Range string `json:"range"` + RecordingDate string `json:"recording_date"` + RoofCover string `json:"roof_cover"` + RoofFrame string `json:"roof_frame"` + Rooms string `json:"rooms"` + RvParking string `json:"rv_parking"` + SafeRoom string `json:"safe_room"` + SaleAmount string `json:"sale_amount"` + SaleDate string `json:"sale_date"` + Sauna string `json:"sauna"` + Section string `json:"section"` + SecurityAlarm string `json:"security_alarm"` + SeniorTaxExemption string `json:"senior_tax_exemption"` + SewerType string `json:"sewer_type"` + Shed string `json:"shed"` + ShedSqft string `json:"shed_sqft"` + Silo string `json:"silo"` + SiloSqft string `json:"silo_sqft"` + SittingRoom string `json:"sitting_room"` + SitusCounty string `json:"situs_county"` + SitusState string `json:"situs_state"` + SoundSystem string `json:"sound_system"` + SportsCourt string `json:"sports_court"` + Sprinklers string `json:"sprinklers"` + Stable string `json:"stable"` + StableSqft string `json:"stable_sqft"` + StorageBuilding string `json:"storage_building"` + StorageBuildingSqft string `json:"storage_building_sqft"` + StoriesNumber string `json:"stories_number"` + StormShelter string `json:"storm_shelter"` + StormShutter string `json:"storm_shutter"` + StructureStyle string `json:"structure_style"` + Study string `json:"study"` + Subdivision string `json:"subdivision"` + Suffix string `json:"suffix"` + Suffix2 string `json:"suffix_2"` + Suffix3 string `json:"suffix_3"` + Suffix4 string `json:"suffix_4"` + Sunroom string `json:"sunroom"` + TaxAssessYear string `json:"tax_assess_year"` + TaxBilledAmount string `json:"tax_billed_amount"` + TaxDelinquentYear string `json:"tax_delinquent_year"` + TaxFiscalYear string `json:"tax_fiscal_year"` + TaxJurisdiction string `json:"tax_jurisdiction"` + TaxRateArea string `json:"tax_rate_area"` + TennisCourt string `json:"tennis_court"` + TopographyCode string `json:"topography_code"` + TotalMarketValue string `json:"total_market_value"` + Township string `json:"township"` + TractNumber string `json:"tract_number"` + TransferAmount string `json:"transfer_amount"` + TrustDescription string `json:"trust_description"` + UnitCount string `json:"unit_count"` + UpperFloorsSqft string `json:"upper_floors_sqft"` + Utility string `json:"utility"` + UtilityBuilding string `json:"utility_building"` + UtilityBuildingSqft string `json:"utility_building_sqft"` + UtilitySqft string `json:"utility_sqft"` + VeteranTaxExemption string `json:"veteran_tax_exemption"` + ViewDescription string `json:"view_description"` + WaterFeature string `json:"water_feature"` + WaterServiceType string `json:"water_service_type"` + WetBar string `json:"wet_bar"` + WidowTaxExemption string `json:"widow_tax_exemption"` + WidthLinearFootage string `json:"width_linear_footage"` + WineCellar string `json:"wine_cellar"` + YearBuilt string `json:"year_built"` + Zoning string `json:"zoning"` +} + +type FinancialResponse struct { + SmartyKey string `json:"smarty_key"` + DataSetName string `json:"data_set_name"` + DataSubsetName string `json:"data_subset_name"` + Attributes FinancialAttributes `json:"attributes"` +} + +type FinancialAttributes struct { + AssessedImprovementPercent string `json:"assessed_improvement_percent"` + AssessedImprovementValue string `json:"assessed_improvement_value"` + AssessedLandValue string `json:"assessed_land_value"` + AssessedValue string `json:"assessed_value"` + AssessorLastUpdate string `json:"assessor_last_update"` + AssessorTaxrollUpdate string `json:"assessor_taxroll_update"` + ContactCity string `json:"contact_city"` + ContactCrrt string `json:"contact_crrt"` + ContactFullAddress string `json:"contact_full_address"` + ContactHouseNumber string `json:"contact_house_number"` + ContactMailInfoFormat string `json:"contact_mail_info_format"` + ContactMailInfoPrivacy string `json:"contact_mail_info_privacy"` + ContactMailingCounty string `json:"contact_mailing_county"` + ContactMailingFips string `json:"contact_mailing_fips"` + ContactPostDirection string `json:"contact_post_direction"` + ContactPreDirection string `json:"contact_pre_direction"` + ContactState string `json:"contact_state"` + ContactStreetName string `json:"contact_street_name"` + ContactSuffix string `json:"contact_suffix"` + ContactUnitDesignator string `json:"contact_unit_designator"` + ContactValue string `json:"contact_value"` + ContactZip string `json:"contact_zip"` + ContactZip4 string `json:"contact_zip4"` + DeedDocumentPage string `json:"deed_ document_page"` + DeedDocumentBook string `json:"deed_document_book"` + DeedDocumentNumber string `json:"deed_document_number"` + DeedOwnerFirstName string `json:"deed_owner_first_name"` + DeedOwnerFirstName2 string `json:"deed_owner_first_name2"` + DeedOwnerFirstName3 string `json:"deed_owner_first_name3"` + DeedOwnerFirstName4 string `json:"deed_owner_first_name4"` + DeedOwnerFullName string `json:"deed_owner_full_name"` + DeedOwnerFullName2 string `json:"deed_owner_full_name2"` + DeedOwnerFullName3 string `json:"deed_owner_full_name3"` + DeedOwnerFullName4 string `json:"deed_owner_full_name4"` + DeedOwnerLastName string `json:"deed_owner_last_name"` + DeedOwnerLastName2 string `json:"deed_owner_last_name2"` + DeedOwnerLastName3 string `json:"deed_owner_last_name3"` + DeedOwnerLastName4 string `json:"deed_owner_last_name4"` + DeedOwnerMiddleName string `json:"deed_owner_middle_name"` + DeedOwnerMiddleName2 string `json:"deed_owner_middle_name2"` + DeedOwnerMiddleName3 string `json:"deed_owner_middle_name3"` + DeedOwnerMiddleName4 string `json:"deed_owner_middle_name4"` + DeedOwnerSuffix string `json:"deed_owner_suffix"` + DeedOwnerSuffix2 string `json:"deed_owner_suffix2"` + DeedOwnerSuffix3 string `json:"deed_owner_suffix3"` + DeedOwnerSuffix4 string `json:"deed_owner_suffix4"` + DeedSaleDate string `json:"deed_sale_date"` + DeedSalePrice string `json:"deed_sale_price"` + DeedTransactionId string `json:"deed_transaction_id"` + DisabledTaxExemption string `json:"disabled_tax_exemption"` + FinancialHistory []struct { + CodeTitleCompany string `json:"code_title_company"` + InstrumentDate string `json:"instrument_date"` + InterestRateType2 string `json:"interest_rate_type_2"` + LenderAddress string `json:"lender_address"` + LenderAddress2 string `json:"lender_address_2"` + LenderCity string `json:"lender_city"` + LenderCity2 string `json:"lender_city_2"` + LenderCode2 string `json:"lender_code_2"` + LenderFirstName string `json:"lender_first_name"` + LenderFirstName2 string `json:"lender_first_name_2"` + LenderLastName string `json:"lender_last_name"` + LenderLastName2 string `json:"lender_last_name_2"` + LenderName string `json:"lender_name"` + LenderName2 string `json:"lender_name_2"` + LenderSellerCarryBack string `json:"lender_seller_carry_back"` + LenderSellerCarryBack2 string `json:"lender_seller_carry_back_2"` + LenderState string `json:"lender_state"` + LenderState2 string `json:"lender_state_2"` + LenderZip string `json:"lender_zip"` + LenderZip2 string `json:"lender_zip_2"` + LenderZipExtended string `json:"lender_zip_extended"` + LenderZipExtended2 string `json:"lender_zip_extended_2"` + MortgageAmount string `json:"mortgage_amount"` + MortgageAmount2 string `json:"mortgage_amount_2"` + MortgageDueDate string `json:"mortgage_due_date"` + MortgageDueDate2 string `json:"mortgage_due_date_2"` + MortgageInterestRate string `json:"mortgage_interest_rate"` + MortgageInterestRateType string `json:"mortgage_interest_rate_type"` + MortgageLenderCode string `json:"mortgage_lender_code"` + MortgageRate2 string `json:"mortgage_rate_2"` + MortgageRecordingDate string `json:"mortgage_recording_date"` + MortgageRecordingDate2 string `json:"mortgage_recording_date_2"` + MortgageTerm string `json:"mortgage_term"` + MortgageTerm2 string `json:"mortgage_term_2"` + MortgageTermType string `json:"mortgage_term_type"` + MortgageTermType2 string `json:"mortgage_term_type_2"` + MortgageType string `json:"mortgage_type"` + MortgageType2 string `json:"mortgage_type_2"` + MultiParcelFlag string `json:"multi_parcel_flag"` + NameTitleCompany string `json:"name_title_company"` + RecordingDate string `json:"recording_date"` + TransferAmount string `json:"transfer_amount"` + } `json:"financial_history"` + HomeownerTaxExemption string `json:"homeowner_tax_exemption"` + MarketImprovementPercent string `json:"market_improvement_percent"` + MarketImprovementValue string `json:"market_improvement_value"` + MarketLandValue string `json:"market_land_value"` + MarketValueYear string `json:"market_value_year"` + MatchType string `json:"match_type"` + OtherTaxExemption string `json:"other_tax_exemption"` + OwnershipTransferDate string `json:"ownership_transfer_date"` + OwnershipTransferDocNumber string `json:"ownership_transfer_doc_number"` + OwnershipTransferTransactionId string `json:"ownership_transfer_transaction_id"` + OwnershipType string `json:"ownership_type"` + OwnershipType2 string `json:"ownership_type_2"` + PreviousAssessedValue string `json:"previous_assessed_value"` + PriorSaleAmount string `json:"prior_sale_amount"` + PriorSaleDate string `json:"prior_sale_date"` + SaleAmount string `json:"sale_amount"` + SaleDate string `json:"sale_date"` + SeniorTaxExemption string `json:"senior_tax_exemption"` + TaxAssessYear string `json:"tax_assess_year"` + TaxBilledAmount string `json:"tax_billed_amount"` + TaxDelinquentYear string `json:"tax_delinquent_year"` + TaxFiscalYear string `json:"tax_fiscal_year"` + TaxRateArea string `json:"tax_rate_area"` + TotalMarketValue string `json:"total_market_value"` + TrustDescription string `json:"trust_description"` + VeteranTaxExemption string `json:"veteran_tax_exemption"` + WidowTaxExemption string `json:"widow_tax_exemption"` +} diff --git a/wireup/builder.go b/wireup/builder.go index a01be03..cd54364 100644 --- a/wireup/builder.go +++ b/wireup/builder.go @@ -15,6 +15,7 @@ import ( international_street "github.com/smartystreets/smartystreets-go-sdk/international-street-api" "github.com/smartystreets/smartystreets-go-sdk/us-autocomplete-api" autocomplete_pro "github.com/smartystreets/smartystreets-go-sdk/us-autocomplete-pro-api" + us_enrichment "github.com/smartystreets/smartystreets-go-sdk/us-enrichment-api" "github.com/smartystreets/smartystreets-go-sdk/us-extract-api" us_reverse_geo "github.com/smartystreets/smartystreets-go-sdk/us-reverse-geo-api" "github.com/smartystreets/smartystreets-go-sdk/us-street-api" @@ -148,6 +149,11 @@ func (b *clientBuilder) buildUSAutocompleteProAPIClient() *autocomplete_pro.Clie return autocomplete_pro.NewClient(b.buildHTTPSender()) } +func (b *clientBuilder) buildUSEnrichmentAPIClient() *us_enrichment.Client { + b.ensureBaseURLNotNil(defaultBaseURL_USEnrichmentAPI) + return us_enrichment.NewClient(b.buildHTTPSender()) +} + func (b *clientBuilder) buildUSExtractAPIClient() *extract.Client { b.ensureBaseURLNotNil(defaultBaseURL_USExtractAPI) return extract.NewClient(b.buildHTTPSender()) @@ -227,6 +233,7 @@ var ( defaultBaseURL_USStreetAPI = &url.URL{Scheme: "https", Host: "us-street.api.smarty.com"} defaultBaseURL_USZIPCodeAPI = &url.URL{Scheme: "https", Host: "us-zipcode.api.smarty.com"} defaultBaseURL_USAutocompleteAPI = &url.URL{Scheme: "https", Host: "us-autocomplete.api.smarty.com"} + defaultBaseURL_USEnrichmentAPI = &url.URL{Scheme: "https", Host: "us-enrichment.api.smarty.com"} defaultBaseURL_USExtractAPI = &url.URL{Scheme: "https", Host: "us-extract.api.smarty.com"} defaultBaseURL_USReverseGeocodingAPI = &url.URL{Scheme: "https", Host: "us-reverse-geo.api.smarty.com"} defaultBaseURL_USAutocompleteProAPI = &url.URL{Scheme: "https", Host: "us-autocomplete-pro.api.smarty.com"} diff --git a/wireup/options.go b/wireup/options.go index ac00ca7..ce09375 100644 --- a/wireup/options.go +++ b/wireup/options.go @@ -8,6 +8,7 @@ import ( international_street "github.com/smartystreets/smartystreets-go-sdk/international-street-api" "github.com/smartystreets/smartystreets-go-sdk/us-autocomplete-api" autocomplete_pro "github.com/smartystreets/smartystreets-go-sdk/us-autocomplete-pro-api" + us_enrichment "github.com/smartystreets/smartystreets-go-sdk/us-enrichment-api" "github.com/smartystreets/smartystreets-go-sdk/us-extract-api" us_reverse_geo "github.com/smartystreets/smartystreets-go-sdk/us-reverse-geo-api" "github.com/smartystreets/smartystreets-go-sdk/us-street-api" @@ -34,6 +35,11 @@ func BuildUSAutocompleteProAPIClient(options ...Option) *autocomplete_pro.Client return configure(options...).buildUSAutocompleteProAPIClient() } +// BuildUSEnrichmentAPIClient builds a client for the US Enrichment API using the provided options. +func BuildUSEnrichmentAPIClient(options ...Option) *us_enrichment.Client { + return configure(options...).buildUSEnrichmentAPIClient() +} + // BuildUSExtractAPIClient builds a client for the US Extract API using the provided options. func BuildUSExtractAPIClient(options ...Option) *extract.Client { return configure(options...).buildUSExtractAPIClient()