Class: Omniva::API::Client
- Inherits:
-
Object
- Object
- Omniva::API::Client
- Defined in:
- lib/omniva/api/client.rb
Class Method Summary collapse
- .call(data = nil) ⇒ Object
- .initial_request ⇒ Object
- .parsed_response(response) ⇒ Object
- .validate_config ⇒ Object
Class Method Details
.call(data = nil) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/omniva/api/client.rb', line 6 def self.call(data = nil) validate_config data ||= initial_request client = Savon.client(wsdl: Omniva::API.config[:wsdl]) auth = { authPhrase: Omniva::API.config[:key] } response = client.call :single_address1, attributes: auth, message: data parsed_response(response) end |
.initial_request ⇒ Object
35 36 37 |
# File 'lib/omniva/api/client.rb', line 35 def self.initial_request { nimetus: 'Eesti' } end |
.parsed_response(response) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/omniva/api/client.rb', line 26 def self.parsed_response(response) unwrapped = response .to_hash .fetch(:single_address_response) .fetch(:aadress_komponent_nimekiri) unwrapped ? unwrapped.fetch(:aadress_komponent) : nil end |
.validate_config ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/omniva/api/client.rb', line 15 def self.validate_config = { wsdl: 'WSDL is missing', key: 'Key is missing' } .each do |key, value| fail InvalidConfiguration, value if Omniva::API.config[key].blank? end end |