lib/soapy_cake/client.rb in soapy_cake-1.18.1 vs lib/soapy_cake/client.rb in soapy_cake-1.19.0

- old
+ new

@@ -17,11 +17,11 @@ opts[:xml_response] == true end protected - attr_reader :domain, :api_key, :time_converter, :opts + attr_reader :domain, :api_key, :time_converter, :opts, :logger def run(request) request.api_key = api_key request.time_converter = time_converter @@ -29,14 +29,20 @@ xml_response? ? response.to_xml : response.to_enum end private + def logger + @logger ||= opts[:logger] || (defined?(::Rails) && ::Rails.logger) + end + def response_body(request) request.opts[:response].presence || http_response(request) end def http_response(request) + logger.info("soapy_cake:request #{request}") if logger + url = "https://#{domain}#{request.path}" http_response = HTTParty.post(url, headers: HEADERS, body: request.xml, timeout: NET_TIMEOUT) fail RequestFailed, "Request failed with HTTP #{http_response.code}: " \ "#{http_response.body}" unless http_response.success?