Sha256: cde5eb8b9a1f735f608e783dbba137a9fd8afb49b0ab3fa7748922f14a4a6925

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

module Postcode
  # You're required to sign up for an api key at http://postcodeapi.nu
  class API
    include HTTParty

    base_uri "http://api.postcodeapi.nu"

    def initialize(api_key)
      @api_key = api_key
    end

    def postcode(postcode, options = {})
      options.merge!(:headers => { "Api-Key" => @api_key})
      response = self.class.get("/#{postcode}", options)
      Hashie::Mash.new(response.parsed_response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
postcodeapi-0.0.1 lib/postcodeapi/api.rb