-
Notifications
You must be signed in to change notification settings - Fork 33
add county_source to the sdk #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| const SmartySDK = require("smartystreets-javascript-sdk"); | ||
| const SmartySDK = require("../dist/cjs/index.cjs"); | ||
| const SmartyCore = SmartySDK.core; | ||
| const Lookup = SmartySDK.usStreet.Lookup; | ||
|
|
||
|
|
@@ -8,7 +8,8 @@ const Lookup = SmartySDK.usStreet.Lookup; | |
| // const credentials = new SmartyCore.StaticCredentials(authId, authToken); | ||
|
|
||
| // for client-side requests (browser/mobile), use this code: | ||
| let key = process.env.SMARTY_EMBEDDED_KEY; | ||
| // Note: key must be a string | ||
| let key = "your key"; | ||
| const credentials = new SmartyCore.SharedCredentials(key); | ||
|
|
||
| // The appropriate license values to be used for your subscriptions | ||
|
|
@@ -23,37 +24,17 @@ let client = clientBuilder.buildUsStreetApiClient(); | |
| // https://www.smarty.com/docs/us-street-api#input-fields | ||
|
|
||
| let lookup1 = new Lookup(); | ||
| lookup1.inputId = "24601"; // Optional ID from your system | ||
| lookup1.addressee = "John Doe"; | ||
| lookup1.street = "330 N 100 W"; | ||
| lookup1.street2 = "closet under the stairs"; | ||
| lookup1.secondary = "APT 2"; | ||
| lookup1.urbanization = ""; // Only applies to Puerto Rico addresses | ||
| lookup1.city = "Provo"; | ||
| lookup1.state = "Utah"; | ||
| lookup1.zipCode = "84601"; | ||
| lookup1.maxCandidates = 3; | ||
| lookup1.match = "invalid"; // "invalid" is the most permissive match, | ||
| // this will always return at least one result even if the address is invalid. | ||
| // Refer to the documentation for additional MatchStrategy options. | ||
|
|
||
| let lookup2 = new Lookup(); | ||
| lookup2.street = "1600 Amphitheater Pkwy"; | ||
| lookup2.lastLine = "Mountainview, CA"; | ||
| lookup2.maxCandidates = 5; | ||
|
|
||
| let lookup3 = new Lookup(); | ||
| lookup3.inputId = "8675309"; | ||
| lookup3.street = "1600 Amphitheatre Parkway Mountain View, CA 94043"; | ||
| lookup3.maxCandidates = 1; | ||
|
|
||
| // NOTE: batches are not supported when using SharedCredentials. | ||
| let batch = new SmartyCore.Batch(); | ||
| batch.add(lookup1); | ||
| batch.add(lookup2); | ||
| batch.add(lookup3); | ||
|
|
||
| await handleResponse(batch); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity... Is there a reason why we don't want to showcase batching in the example anymore? |
||
| lookup1.street = "805 Tye Crossing Ct"; | ||
| lookup1.city = "Burleson"; | ||
| lookup1.state = "TX"; | ||
| lookup1.zipCode = "76028"; | ||
| lookup1.candidates = 10; | ||
| lookup1.match = "enhanced"; | ||
| // lookup1.countySource = "geographic"; | ||
|
|
||
| (async () => { | ||
| await handleResponse(lookup1); | ||
| })(); | ||
|
|
||
| function handleSuccess(response) { | ||
| response.lookups.map(lookup => console.log(lookup.result)); | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it's important we keep this line as it adds context to the comment above. Maybe there could be a comment added after, such as...
let key = process.env.SMARTY_EMBEDDED_KEY // "your key".Also, is there any reason we couldn't freshen this up by changing
let -> const? I don't think this variable needs to be mutable, does it?