Class: Seibii::Http::Clients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/seibii/http/clients/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/seibii/http/clients/base.rb', line 7

def initialize(logger: nil)
  @logger = logger
end

Instance Method Details

#request(method:, uri:, read_timeout: 60, write_timeout: 60, request_body: nil, headers: {}, need_verify_cert: false) ⇒ Object

rubocop:disable Metrics/ParameterLists, Layout/LineLength



11
12
13
14
15
16
17
18
# File 'lib/seibii/http/clients/base.rb', line 11

def request(method:, uri:, read_timeout: 60, write_timeout: 60, request_body: nil, headers: {}, need_verify_cert: false) # rubocop:disable Metrics/ParameterLists, Layout/LineLength
  parsed_uri = URI.parse(uri)
  http = http(parsed_uri, need_verify_cert)
  http.read_timeout = read_timeout
  http.write_timeout = write_timeout
  with_logging(uri) { http.request(request_object(method, parsed_uri, request_body, headers)) }
    .yield_self { |response| handle_http_status(response) }
end