Skip to content
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

Support state_code in results from db-ip.com #1454

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Support state_code in results from db-ip.com #1454

merged 1 commit into from
Jun 8, 2020

Conversation

adamalbrecht
Copy link
Contributor

Currently, the state_code method on a result from db-ip.com returns the full state name. But the data returned from their API actually does include a 2 character state code, under stateProvCode.

Here is a sample query that I just performed:

irb(main):005:0> results = Geocoder.search("96.27.101.109")
irb(main):006:0> results[0].state_code
=> "Ohio"
irb(main):007:0> results[0].data['stateProvCode']
=> "OH"

Currently, the `state_code` method on a result from
db-ip.com returns the full state name. But the data
returned from their API actually does include
a 2 character state code, under `stateProvCode`.
@alexreisner
Copy link
Owner

Thanks for this! The weird thing is that I can't find any mention of stateProvCode in their documentation. I'm going to write to them to see if I can get an API key to try it out. Which plan are you using?

@adamalbrecht
Copy link
Contributor Author

I noticed the same lack of documentation, but it's definitely there.

Our account page says that we have a "Lite with Basic API" account.

@alexreisner alexreisner merged commit 466539a into alexreisner:master Jun 8, 2020
@alexreisner
Copy link
Owner

From customer support: "The stateProvCode response field is indeed a recent addition to our API services and it will be added to the documentation with our next website update. When available the field is populated with the state or province ISO 3166-2 code."

Thanks @adamalbrecht.

@adamalbrecht adamalbrecht deleted the fix_db_ip_com_state_code_mapping branch June 10, 2020 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants