Class: Location::Services::Uni5
- Inherits:
-
Object
- Object
- Location::Services::Uni5
- Defined in:
- lib/location/services/uni5.rb
Constant Summary collapse
- FULL_ADDRESS =
'1'
- ONLY_CITY_AND_UF =
'2'
Instance Method Summary collapse
Instance Method Details
#fetch(postal_code, address) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/location/services/uni5.rb', line 10 def fetch(postal_code, address) @postal_code = postal_code http_request do |res| address.state = res['uf'] address.city = res['cidade'] address.district = res['bairro'] address.type = res['tipo_logradouro'] address.street = res['logradouro'] end end |
#options ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/location/services/uni5.rb', line 22 def required = { formato: 'json' } required[:cep] = @postal_code if defined?(@postal_code) Location.configuration..merge(required).tap do |o| raise OptionsError, 'Missing auth option' unless o.has_key? :auth end end |