Class: MLB::RequestBuilder
- Inherits:
-
Object
- Object
- MLB::RequestBuilder
- Defined in:
- lib/mlb/request_builder.rb
Overview
Builds HTTP requests for the MLB Stats API
Constant Summary collapse
- DEFAULT_HEADERS =
Default HTTP headers for API requests
{ "Content-Type" => "application/json; charset=utf-8", "User-Agent" => "MLB-Client/#{VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} (#{RUBY_PLATFORM})" }.freeze
- HTTP_METHODS =
Mapping of HTTP method symbols to Net::HTTP request 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: {}) ⇒ Net::HTTPRequest
Builds an HTTP request.
Instance Method Details
#build(http_method:, uri:, body: nil, headers: {}) ⇒ Net::HTTPRequest
Builds an HTTP request
31 32 33 34 35 |
# File 'lib/mlb/request_builder.rb', line 31 def build(http_method:, uri:, body: nil, headers: {}) request = create_request(http_method:, uri:, body:) add_headers(request:, headers:) request end |