Sha256: 8244f081629dad95fc3ddeb235e9b77f07cd5644beb8d1da99149ed667825fe2
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require 'cgi' require 'rest-client' module Roqua module Healthy module Oru class Client def self.execute(url, data, timeout:) Roqua::Healthy.convert_generic_errors_to_healthy_errors do deliver_data(url, data, timeout: timeout) end end def self.deliver_data(url, data, timeout:) xml = CGI.escape(data.to_xml) RestClient::Request.execute( method: :post, url: url.to_s, payload: xml, headers: {content_type: 'text/xml'}, timeout: timeout.to_i ) do |response, _request, _result| xml_response = Hash.from_xml(response.body) if response.code == 200 && xml_response['oru']['status'] == 'ACK' response.body else handle_error(response, xml_response) end end end def self.handle_error(response, xml_response) error = xml_response.dig('oru', 'error') raise ::Roqua::Healthy::ERRORS[error], error if ::Roqua::Healthy::ERRORS[error] raise ::Roqua::Healthy::NACK, error if error.present? raise ::Roqua::Healthy::UnknownFailure, response.body end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
roqua-healthy-1.6.0 | lib/roqua/healthy/oru/client.rb |
roqua-healthy-1.5.13 | lib/roqua/healthy/oru/client.rb |
roqua-healthy-1.5.12 | lib/roqua/healthy/oru/client.rb |