Sha256: 0b0dd90456ae708a74c3ad867bca8502fc4a2a207e08ab11e0743e758bc7e15b
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require_relative "brazil_cep/version" require_relative "brazil_cep/address" require_relative "brazil_cep/adapters" module Brazil # Brazil::Cep providers a simple way to fetch address information from a Brazilian CEP # @public module Cep # generic error class class Error < StandardError; end # request error class class RequestError < Error attr_reader :status, :code, :response def initialize(response) @response = response @status = response.message || "Undefined" @code = response.code.to_i super("Request Error: #{code} #{status} - #{response.body[0..1000].inspect}") end end # zipcode not found error class class ZipcodeNotFound < RequestError; end # fetch address information from a Brazilian CEP # @param [String] cep the CEP to fetch # @return [Hash] the address information def self.fetch(cep, provider: :viacep) provider = Adapters.get(provider) provider.get(cep) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
brazil-cep-0.5.0 | lib/brazil_cep.rb |
brazil-cep-0.4.0 | lib/brazil_cep.rb |
brazil-cep-0.3.0 | lib/brazil_cep.rb |