brazil-cep 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 846ef72872222fae21a466e025f9366f3194e03330c350f82a2e7241e95b2680
4
- data.tar.gz: 0a2df924f5d863cb398c027ec4b1c97686b3a966ca35a9e2202665f7e64a1133
3
+ metadata.gz: edf951cca19b548050bc06fa7e535be37dd2b9da172805a329401df5e621b609
4
+ data.tar.gz: d9311ce3cdf198acdd3daaef44fb80f0c7cbf0d318e08efc8445d18bb4adb00a
5
5
  SHA512:
6
- metadata.gz: 12722468d5c1e0187bee7d8c152239017f0c0e7ef256b3b34d46594028d5dbc84fb79db3d6402a8c677c1eacfeeb56ebfd47102e616108804b50f993a198bd4c
7
- data.tar.gz: 98492724593be83d12735da04a735722108f435b50219c60ad7616bb0aecea70c28e22a8cfe9fc32385e14a1bbf98ab138a26c43a5ea32f40a2ac19a57fc59e7
6
+ metadata.gz: 3d1cf60e8aeceefe738a7ca974deb8c00cf33226c3e54327a1b9a17169adf0ff7ed0576d35a45ae24c7a20b511c934cb97a97fd3c553b7727122ec6192b7be54
7
+ data.tar.gz: 623509c7060ee2699e107e8ee6d488e09eb25baa546abf6e6a00959c079b9be51ea371cc1b5ac91094f0f2481b71fbf7541d7e44dcc64effed435ea0401e4b25
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Brazil
4
+ module Cep
5
+ module Adapters
6
+ # Cep Aberto provider adapter class
7
+ # This class is responsible for fetching the address information from the Cep Aberto provider
8
+ class CepAberto < Base
9
+ provider base_url: "https://www.cepaberto.com/ceps/{{cep}}.json"
10
+
11
+ private
12
+
13
+ def transformation!
14
+ raise Brazil::Cep::ZipcodeNotFound, @response if @payload[:erro] == true
15
+
16
+ address_params = {
17
+ zipcode: @payload[:cep],
18
+ state: @payload[:estado][:sigla],
19
+ city: @payload[:cidade][:nome],
20
+ neighborhood: @payload[:bairro],
21
+ street: @payload[:logradouro],
22
+ complement: @payload[:complemento],
23
+ meta: @payload.update(provider: :cep_aberto)
24
+ }
25
+
26
+ Brazil::Cep::Address.new(**address_params)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -10,13 +10,15 @@ module Brazil
10
10
  autoload :Postmon, "brazil_cep/adapters/postmon"
11
11
  autoload :RepublicaVirtual, "brazil_cep/adapters/republica_virtual"
12
12
  autoload :CorreiosWeb, "brazil_cep/adapters/correios_web"
13
+ autoload :CepAberto, "brazil_cep/adapters/cep_aberto"
13
14
 
14
15
  # list of provider keys and classes
15
16
  PROVIDERS = {
16
17
  viacep: Viacep,
17
18
  postmon: Postmon,
18
19
  republica_virtual: RepublicaVirtual,
19
- correios_web: CorreiosWeb
20
+ correios_web: CorreiosWeb,
21
+ cep_aberto: CepAberto
20
22
  }
21
23
 
22
24
  private_constant :PROVIDERS
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Brazil
4
4
  module Cep
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brazil-cep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
@@ -28,6 +28,7 @@ files:
28
28
  - lib/brazil_cep.rb
29
29
  - lib/brazil_cep/adapters.rb
30
30
  - lib/brazil_cep/adapters/base.rb
31
+ - lib/brazil_cep/adapters/cep_aberto.rb
31
32
  - lib/brazil_cep/adapters/correios_web.rb
32
33
  - lib/brazil_cep/adapters/postmon.rb
33
34
  - lib/brazil_cep/adapters/republica_virtual.rb