-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Secondary Data lookup and count.
- Loading branch information
Showing
8 changed files
with
266 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
usenrich "github.com/smartystreets/smartystreets-go-sdk/us-enrichment-api" | ||
"github.com/smartystreets/smartystreets-go-sdk/wireup" | ||
"log" | ||
"net/http" | ||
"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")), | ||
) | ||
|
||
// Documentation for input fields can be found at: | ||
// https://www.smarty.com/docs/cloud/us-address-enrichment-api#http-request-input-fields | ||
|
||
smartyKey := "1270119982" | ||
|
||
lookup := usenrich.Lookup{ | ||
SmartyKey: smartyKey, | ||
ETag: "", // optional: check if the record has been updated | ||
} | ||
|
||
err, results := client.SendSecondaryCountLookup(&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, "secondary") | ||
for s, response := range results { | ||
fmt.Printf("#%d: %+v\n", s, response) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
usenrich "github.com/smartystreets/smartystreets-go-sdk/us-enrichment-api" | ||
"github.com/smartystreets/smartystreets-go-sdk/wireup" | ||
"log" | ||
"net/http" | ||
"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")), | ||
) | ||
|
||
// Documentation for input fields can be found at: | ||
// https://www.smarty.com/docs/cloud/us-address-enrichment-api#http-request-input-fields | ||
|
||
smartyKey := "1270119982" | ||
|
||
lookup := usenrich.Lookup{ | ||
SmartyKey: smartyKey, | ||
ETag: "", // optional: check if the record has been updated | ||
} | ||
|
||
err, results := client.SendSecondaryLookup(&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, "secondary") | ||
for s, response := range results { | ||
fmt.Printf("#%d: %+v\n", s, response) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
github.com/smarty/assertions v1.15.1 h1:812oFiXI+G55vxsFf+8bIZ1ux30qtkdqzKbEFwyX3Tk= | ||
github.com/smarty/assertions v1.15.1/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= | ||
github.com/smarty/assertions v1.16.0 h1:EvHNkdRA4QHMrn75NZSoUQ/mAUXAYWfatfB01yTCzfY= | ||
github.com/smarty/assertions v1.16.0/go.mod h1:duaaFdCS0K9dnoM50iyek/eYINOZ64gbh1Xlf6LG7AI= | ||
github.com/smarty/gunit v1.5.0 h1:OmG6a/rgi7qCjlQis6VjXbvx/WqZ8I6xSlbfN4YB5MY= | ||
github.com/smarty/gunit v1.5.0/go.mod h1:uAeNibUD292KZRcg5OTy7lb6WR5++UC0BQOzNuiRzpU= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters