Skip to content

EmergencyNumberAPI/emergency_number

 
 

Repository files navigation

Build Status Coverage Status Gem Version

EmergencyNumber

EmergencyNumber is a ruby gem for the Emergency Number API application.

  • Returns handy object to for any emergency numbers for any country in the world.
  • Takes in one argument - country code. Country can be an ISO3361-1_alpha-2 or ISO3361-1_numeric code.
  • Authentication is not required. Rate limit is the same as it is mentioned in Emergency Number API docs.

Requirements

  • Ruby 2.0.0 or higher

Installation

Add this line to your application's Gemfile:

gem 'emergency_number'

And then execute:

$ bundle

Or install it yourself as:

$ gem install emergency_number

Usage

require "emergency_number"

Examples

$ EmergencyNumber.get_country(:us) # or EmergencyNumber.get_country(840)
$ EmergencyNumber.get_country(:in) # or EmergencyNumber.get_country(356)
$ EmergencyNumber.get_country(:fr) # or EmergencyNumber.get_country(250)
$ EmergencyNumber.get_country(:au) # or EmergencyNumber.get_country(36)
$ @result = EmergencyNumber.get_country(:us)
{
    :disclaimer => "The data from this API is provided without any claims of accuracy, you should use this data as guidance, and do your own due diligence.",
         :error => "",
          :data => {
           :country => {
                  :name => "United States of America",
               :ISOCode => "US",
            :ISONumeric => "840"
        },
         :ambulance => {
              :all => [""],
              :gsm => nil,
            :fixed => nil
        },
              :fire => {
              :all => [""],
              :gsm => nil,
            :fixed => nil
        },
            :police => {
              :all => [""],
              :gsm => nil,
            :fixed => nil
        },
          :dispatch => {
              :all => ["911"],
              :gsm => nil,
            :fixed => nil
        },
        :member_112 => false,
         :localOnly => false,
            :nodata => false
    }
}

Retrieving Data

$ @result.data
{
       :country => {
              :name => "United States of America",
           :ISOCode => "US",
        :ISONumeric => "840"
    },
     :ambulance => {
          :all => [""],
          :gsm => nil,
        :fixed => nil
    },
          :fire => {
          :all => [""],
          :gsm => nil,
        :fixed => nil
    },
        :police => {
          :all => [""],
          :gsm => nil,
        :fixed => nil
    },
      :dispatch => {
          :all => ["911"],
          :gsm => nil,
        :fixed => nil
    },
    :member_112 => false,
     :localOnly => false,
        :nodata => false
}

Retrieving country name

$ @result.data.country.name
=> "United States of America"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/shayonj/emergency_number. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

GEM License

MIT License

Data License

Open Database License

About

Get any emergency numbers for any country in the world. Based on Emergency Number API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 98.1%
  • Shell 1.9%