Class: Request::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/request/resources/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

initialize

Class Method Details

.request(args) ⇒ Object



6
7
8
# File 'lib/request/resources/client.rb', line 6

def request(args)
  new.request(args)
end

Instance Method Details

#request(args) ⇒ Object

rubocop: disable Metrics/AbcSize, Style/CommentedKeyword



11
12
13
14
15
16
17
18
19
20
# File 'lib/request/resources/client.rb', line 11

def request(args) # rubocop: disable Metrics/AbcSize, Style/CommentedKeyword
  uri = URI.parse(args.url)
  uri.query = encode_www_form(args.params) if args.params

  body = process_params(headers: args.headers, data: args.data) if args.data
  Request::Auth::Authentication.apply(args.headers, args.auth) if args.auth

  response = send_request(uri, args, body)
  response.is_a?(Net::HTTPSuccess) ? build_response(response) : raise_error(response)
end