-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acf0f74
commit dcf5fdc
Showing
3 changed files
with
65 additions
and
0 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
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,40 @@ | ||
/** | ||
* Modules from the community: package.json | ||
*/ | ||
var check = require('check-types'); | ||
|
||
/** | ||
* Internal modules | ||
*/ | ||
var _makeRequest = require('./utils/makeRequest'); | ||
var _assignParams = require('./utils/assignParams'); | ||
var _jsonParser = require('./utils/jsonParser'); | ||
|
||
var _constants = require('./config/constants'); | ||
|
||
var ACCEPTED_PARAMS = _constants.ACCEPTED_PARAMS; | ||
var GOOGLEMAPS_ENDPOINTS = _constants.GOOGLEMAPS_ENDPOINTS; | ||
|
||
module.exports = function(params, callback) { | ||
|
||
if (typeof callback !== 'function') { | ||
throw new TypeError('callback must be present'); | ||
} | ||
|
||
if (this.config.key == null) { | ||
return callback(new Error('The placeSearch API requires a key. You can add it to the config.')); | ||
} | ||
|
||
if (!check.object(params)) { | ||
return callback(new TypeError('params must be an object')); | ||
} | ||
|
||
var args = _assignParams({}, params, ACCEPTED_PARAMS['place-text']); | ||
|
||
if (args.query == null) { | ||
return callback(new Error('params.query is required')); | ||
} | ||
|
||
return _makeRequest(this.request, this.config, GOOGLEMAPS_ENDPOINTS['place-text'], args, _jsonParser(callback)); | ||
|
||
}; |