Sha256: 706c0151e1356f6f6d7802cafc4c124bd73bdb6830c79b15bb68aa8571e93065

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

module RedfishClient
  # Response struct.
  #
  # This struct is returned from the methods that interact with the remote API.
  class Response
    attr_reader :status
    attr_reader :headers
    attr_reader :body

    def initialize(status, headers, body)
      @status = status
      @headers = headers
      @body = body
    end

    def done?
      status != 202
    end

    def monitor
      done? ? nil : headers["location"]
    end

    def to_h
      { "status" => status, "headers" => headers, "body" => body }
    end

    def self.from_hash(data)
      new(*data.values_at("status", "headers", "body"))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redfish_client-0.5.1 lib/redfish_client/response.rb
redfish_client-0.5.0 lib/redfish_client/response.rb