From fae446f9a3944e74206ebbf6e39d5a22414681df Mon Sep 17 00:00:00 2001 From: Spencer Jorgensen Date: Thu, 29 Feb 2024 13:48:36 -0700 Subject: [PATCH] Update the us-enrichment-api to include geo-reference functionality. --- .../us-enrichment-api/geo-reference/main.go | 4 -- .../propertyFinancial/main.go | 56 +++++++++++++++++++ .../{property => propertyPrincipal}/main.go | 8 +-- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 examples/us-enrichment-api/propertyFinancial/main.go rename examples/us-enrichment-api/{property => propertyPrincipal}/main.go (85%) diff --git a/examples/us-enrichment-api/geo-reference/main.go b/examples/us-enrichment-api/geo-reference/main.go index cb27b56..11e8139 100644 --- a/examples/us-enrichment-api/geo-reference/main.go +++ b/examples/us-enrichment-api/geo-reference/main.go @@ -31,13 +31,9 @@ func main() { lookup := us_enrichment.Lookup{ SmartyKey: smartyKey, - Include: "", // optional: only include these attributes in the returned data - Exclude: "", // optional: exclude attributes from the returned data ETag: "", // optional: check if the record has been updated } - //For Financial - //err, results := client.SendPropertyFinancial(&lookup) err, results := client.SendPropertyGeoReference(&lookup) if err != nil { diff --git a/examples/us-enrichment-api/propertyFinancial/main.go b/examples/us-enrichment-api/propertyFinancial/main.go new file mode 100644 index 0000000..317283e --- /dev/null +++ b/examples/us-enrichment-api/propertyFinancial/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "os" + + us_enrichment "github.com/smartystreets/smartystreets-go-sdk/us-enrichment-api" + "github.com/smartystreets/smartystreets-go-sdk/wireup" +) + +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.CustomBaseURL("https://us-enrichment.api.rivendell.smartyops.net"), + // wireup.DebugHTTPOutput(), // uncomment this line to see detailed HTTP request/response information. + ) + + // Documentation for input fields can be found at: + // https://www.smarty.com/docs/cloud/us-address-enrichment-api#http-request-input-fields + + smartyKey := "1682393594" + + lookup := us_enrichment.Lookup{ + SmartyKey: smartyKey, + Include: "group_structural,sale_date", // optional: only include these attributes in the returned data + Exclude: "", // optional: exclude attributes from the returned data + ETag: "", // optional: check if the record has been updated + } + + err, results := client.SendPropertyFinancial(&lookup) + + if err != nil { + // If ETag was supplied in the lookup, this status will be returned if the ETag value for the record is current + if client.IsHTTPErrorCode(err, http.StatusNotModified) { + log.Printf("Record has not been modified since the last request") + return + } + 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/examples/us-enrichment-api/property/main.go b/examples/us-enrichment-api/propertyPrincipal/main.go similarity index 85% rename from examples/us-enrichment-api/property/main.go rename to examples/us-enrichment-api/propertyPrincipal/main.go index d0ee34b..2d2d37f 100644 --- a/examples/us-enrichment-api/property/main.go +++ b/examples/us-enrichment-api/propertyPrincipal/main.go @@ -31,13 +31,11 @@ func main() { lookup := us_enrichment.Lookup{ SmartyKey: smartyKey, - Include: "", // optional: only include these attributes in the returned data - Exclude: "", // optional: exclude attributes from the returned data - ETag: "", // optional: check if the record has been updated + Include: "group_structural,sale_date", // optional: only include these attributes in the returned data + Exclude: "", // optional: exclude attributes from the returned data + ETag: "", // optional: check if the record has been updated } - //For Financial - //err, results := client.SendPropertyFinancial(&lookup) err, results := client.SendPropertyPrincipal(&lookup) if err != nil {