Class: Pinnacle::Internal::Http::BaseRequest Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pinnacle/internal/http/base_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.

Direct Known Subclasses

JSON::Request, Multipart::Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, path:, method:, headers: {}, query: {}, request_options: {}) ⇒ BaseRequest

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 BaseRequest.

Parameters:

  • base_url (String)

    The base URL for the request

  • path (String)

    The path for the request

  • method (String)

    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)

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


16
17
18
19
20
21
22
23
# File 'lib/pinnacle/internal/http/base_request.rb', line 16

def initialize(base_url:, path:, method:, headers: {}, query: {}, request_options: {})
  @base_url = base_url
  @path = path
  @method = method
  @headers = headers
  @query = query
  @request_options = request_options
end

Instance Attribute Details

#base_urlObject (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/pinnacle/internal/http/base_request.rb', line 8

def base_url
  @base_url
end

#headersObject (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/pinnacle/internal/http/base_request.rb', line 8

def headers
  @headers
end

#methodObject (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/pinnacle/internal/http/base_request.rb', line 8

def method
  @method
end

#pathObject (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/pinnacle/internal/http/base_request.rb', line 8

def path
  @path
end

#queryObject (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/pinnacle/internal/http/base_request.rb', line 8

def query
  @query
end

#request_optionsObject (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/pinnacle/internal/http/base_request.rb', line 8

def request_options
  @request_options
end

Instance Method Details

#encode_queryHash

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 query parameters merged with additional query parameters from request options.

Returns:

  • (Hash)

    The query parameters merged with additional query parameters from request options.



26
27
28
29
# File 'lib/pinnacle/internal/http/base_request.rb', line 26

def encode_query
  additional_query = @request_options&.dig(:additional_query_parameters) || @request_options&.dig("additional_query_parameters") || {}
  @query.merge(additional_query)
end