Class: X::RequestBuilder
- Inherits:
-
Object
- Object
- X::RequestBuilder
- Defined in:
- lib/x/request_builder.rb
Overview
Builds HTTP requests for the X API
Constant Summary collapse
- DEFAULT_HEADERS =
Default headers for API requests
{ "Content-Type" => "application/json; charset=utf-8", "User-Agent" => "X-Client/#{VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} (#{RUBY_PLATFORM})" }.freeze
- HTTP_METHODS =
Mapping of HTTP method symbols to Net::HTTP classes
{ get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }.freeze
Instance Method Summary collapse
-
#build(http_method:, uri:, body: nil, headers: {}, authenticator: Authenticator.new) ⇒ Net::HTTPRequest
Build an HTTP request.
Instance Method Details
#build(http_method:, uri:, body: nil, headers: {}, authenticator: Authenticator.new) ⇒ Net::HTTPRequest
Build an HTTP request
35 36 37 38 39 40 |
# File 'lib/x/request_builder.rb', line 35 def build(http_method:, uri:, body: nil, headers: {}, authenticator: Authenticator.new) request = create_request(http_method:, uri:, body:) add_headers(request:, headers:) add_authentication(request:, authenticator:) request end |