Created
January 4, 2017 17:26
-
-
Save travist/e4b955a9eff412d9ffcffa6745ae4893 to your computer and use it in GitHub Desktop.
Transform address
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
| var header = true; | |
| module.exports = function(record, next) { | |
| if (header) { | |
| // Ignore the header row. | |
| header = false; | |
| return next(); | |
| } | |
| next(null, { | |
| data: { | |
| propertyId: record[0], | |
| status: 'green', | |
| loanNumber: record[3], | |
| firstName: '', | |
| lastName: '', | |
| phoneNumber: '', | |
| email: '', | |
| address: { | |
| formatted_address: record[4], | |
| "partial_match": true, | |
| types: [ | |
| "street_address" | |
| ], | |
| geometry: { | |
| location: { | |
| lat: parseFloat(record[38]), | |
| lng: parseFloat(record[37]) | |
| } | |
| }, | |
| address_components: [ | |
| { | |
| "long_name": record[8], | |
| "short_name": record[8], | |
| "types": [ | |
| "street_number" | |
| ] | |
| }, | |
| { | |
| "long_name": record[9], | |
| "short_name": record[9], | |
| "types": [ | |
| "route" | |
| ] | |
| }, | |
| { | |
| "long_name": record[10], | |
| "short_name": record[10], | |
| "types": [ | |
| "locality", | |
| "political" | |
| ] | |
| }, | |
| { | |
| "long_name": "", | |
| "short_name": "", | |
| "types": [ | |
| "administrative_area_level_2", | |
| "political" | |
| ] | |
| }, | |
| { | |
| "long_name": "United States", | |
| "short_name": "US", | |
| "types": [ | |
| "country", | |
| "political" | |
| ] | |
| }, | |
| { | |
| "long_name": record[7], | |
| "short_name": record[7], | |
| "types": [ | |
| "administrative_area_level_1", | |
| "political" | |
| ] | |
| }, | |
| { | |
| "long_name": record[6], | |
| "short_name": record[6], | |
| "types": [ | |
| "postal_code" | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment