Class: Candid::Internal::Multipart::Request Private

Inherits:
Http::BaseRequest show all
Defined in:
lib/candid/internal/multipart/multipart_request.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Attributes inherited from Http::BaseRequest

#base_url, #headers, #method, #path, #query, #request_options

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {}) ⇒ Request

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Request.

Parameters:

  • base_url (String)

    The base URL for the request

  • path (String)

    The path for the request

  • method (Symbol)

    The HTTP method for the request (:get, :post, etc.)

  • headers (Hash) (defaults to: {})

    Additional headers for the request (optional)

  • query (Hash) (defaults to: {})

    Query parameters for the request (optional)

  • body (MultipartFormData, nil) (defaults to: nil)

    The multipart form data for the request (optional)

  • request_options (Candid::RequestOptions, Hash{Symbol=>Object}, nil) (defaults to: {})


17
18
19
20
21
# File 'lib/candid/internal/multipart/multipart_request.rb', line 17

def initialize(base_url:, path:, method:, headers: {}, query: {}, body: nil, request_options: {})
  super(base_url:, path:, method:, headers:, query:, request_options:)

  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/candid/internal/multipart/multipart_request.rb', line 8

def body
  @body
end

Instance Method Details

#encode_bodyString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The encoded HTTP request body.

Returns:

  • (String, nil)

    The encoded HTTP request body.



31
32
33
# File 'lib/candid/internal/multipart/multipart_request.rb', line 31

def encode_body
  @body&.encode
end

#encode_headersHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The encoded HTTP request headers.

Returns:

  • (Hash)

    The encoded HTTP request headers.



24
25
26
27
28
# File 'lib/candid/internal/multipart/multipart_request.rb', line 24

def encode_headers
  {
    "Content-Type" => @body.content_type
  }.merge(@headers)
end