Class: Intelipost::ApiComponents::CepLocation
- Defined in:
- lib/intelipost/api/components/cep_location.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #address_complete(zipcode) ⇒ Object
-
#initialize(api_key) ⇒ CepLocation
constructor
A new instance of CepLocation.
Methods inherited from Component
Constructor Details
#initialize(api_key) ⇒ CepLocation
Returns a new instance of CepLocation.
5 6 7 |
# File 'lib/intelipost/api/components/cep_location.rb', line 5 def initialize(api_key) self.api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/intelipost/api/components/cep_location.rb', line 3 def api_key @api_key end |
Instance Method Details
#address_complete(zipcode) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/intelipost/api/components/cep_location.rb', line 9 def address_complete(zipcode) raw_data = Intelipost::Facade.get_with_log("/v1/cep_location/address_complete/#{zipcode}", api_key) if has_error?(raw_data) response = Intelipost::Models::ErrorResponse.new(raw_data) else response = Intelipost::Models::Address.new response.attributes = raw_data response.attributes = raw_data["content"] || {} end response end |