alexreisner / geocoder

Complete Ruby geocoding solution.
http://www.rubygeocoder.com
MIT License
6.35k stars 1.19k forks source link

Set license for API requests #1620

Open marco-gallardo opened 1 year ago

marco-gallardo commented 1 year ago

Context:

Smarty offers different licenses that determine a set of available services, usage details, etc. Not being able to specify this license limits our integration with Smarty and prevents taking full advantage of Smarty's features.

Expected behavior

It'd be great to be available to provide license argument that ends up being passed to Smarty API:

Geocoder.configure(..., license: '<license>')

I reviewed geocoder's code and apparently this will require only a few files to be changed:

Any thoughts about this?

alexreisner commented 1 year ago

Yes, thanks, this sounds great, and it's actually even easier than you think. You can pass arbitrary parameters to specific lookups like this:

Geocoder.configure(..., smarty_streets: {license: '<license>'})

So there's no need to modify options or set_defaults. Just add the license parameter in query_url_params, where you can access it via configuration[:license] (configuration returns all config for the current lookup, merged into a single hash). You might also want to mention this in a "Notes" item in the Smarty documentation.