Class: WSDL::HTTP::Response

Inherits:
Data
  • Object
show all
Defined in:
lib/wsdl/http/response.rb

Overview

Represents an HTTP response returned by an HTTP client.

All HTTP client get and post methods must return an instance of this class (or a compatible object responding to status, headers, and body).

Examples:

Creating a response

WSDL::HTTP::Response.new(status: 200, headers: {}, body: '<xml/>')

From a custom client

class MyHTTPClient
  def post(url, headers, body)
    resp = Faraday.post(url, body, headers)
    WSDL::HTTP::Response.new(status: resp.status, headers: resp.headers, body: resp.body)
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, headers: {}, body: '') ⇒ Response

Creates a new Response.

Parameters:

  • status (Integer)

    HTTP status code

  • headers (Hash{String => String}) (defaults to: {})

    HTTP response headers

  • body (String) (defaults to: '')

    HTTP response body



28
29
30
# File 'lib/wsdl/http/response.rb', line 28

def initialize(status:, headers: {}, body: '')
  super
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



22
23
24
# File 'lib/wsdl/http/response.rb', line 22

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



22
23
24
# File 'lib/wsdl/http/response.rb', line 22

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



22
23
24
# File 'lib/wsdl/http/response.rb', line 22

def status
  @status
end