Sha256: 1c20fdd2f979c005adb943a7e5188bbdacb6ceb8c859d1818fe5ec9f1538e7d1

Contents?: true

Size: 885 Bytes

Versions: 4

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

module Brazil
  module Cep
    module Adapters
      # Republica Virtual provider adapter class
      # This class is responsible for fetching the address information from the Republica Virtual provider
      class RepublicaVirtual < Base
        provider base_url: "http://cep.republicavirtual.com.br/web_cep.php?cep={{cep}}&formato=json"

        private

        def transformation!
          address_params = {
            zipcode: @cep,
            state: @payload[:uf],
            city: @payload[:cidade],
            neighborhood: @payload[:bairro],
            street: "#{@payload[:tipo_logradouro]} #{@payload[:logradouro]}",
            complement: @payload[:complemento],
            meta: @payload.update(provider: :republica_virtual)
          }

          Brazil::Cep::Address.new(**address_params)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brazil-cep-0.5.0 lib/brazil_cep/adapters/republica_virtual.rb
brazil-cep-0.4.0 lib/brazil_cep/adapters/republica_virtual.rb
brazil-cep-0.3.0 lib/brazil_cep/adapters/republica_virtual.rb
brazil-cep-0.2.0 lib/brazil_cep/adapters/republica_virtual.rb