lib/redfish_client/response.rb in redfish_client-0.5.1 vs lib/redfish_client/response.rb in redfish_client-0.5.2
- old
+ new
@@ -1,7 +1,9 @@
# frozen_string_literal: true
+require "uri"
+
module RedfishClient
# Response struct.
#
# This struct is returned from the methods that interact with the remote API.
class Response
@@ -18,14 +20,21 @@
def done?
status != 202
end
def monitor
- done? ? nil : headers["location"]
+ return nil if done?
+
+ uri = URI.parse(headers["location"])
+ [uri.path, uri.query].compact.join("?")
end
def to_h
{ "status" => status, "headers" => headers, "body" => body }
+ end
+
+ def to_s
+ "Response[status=#{status}, headers=#{headers}, body='#{body}']"
end
def self.from_hash(data)
new(*data.values_at("status", "headers", "body"))
end