Class: ApiTester::Client
- Inherits:
-
Object
- Object
- ApiTester::Client
- Defined in:
- lib/api_tester/client.rb
Instance Method Summary collapse
-
#initialize(url, headers = {}, method = 'GET', body = nil, token = nil) ⇒ Client
constructor
A new instance of Client.
- #send_request ⇒ Object
Constructor Details
#initialize(url, headers = {}, method = 'GET', body = nil, token = nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/api_tester/client.rb', line 7 def initialize(url, headers = {}, method = 'GET', body = nil, token = nil) @uri = URI.parse(url) @headers = headers @method = method @body = body @token = token end |
Instance Method Details
#send_request ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/api_tester/client.rb', line 15 def send_request http = Net::HTTP.new(@uri.host, @uri.port) http.use_ssl = @uri.scheme == 'https' # Enable SSL for HTTPS request = build_request add_auth_token(request) if @token response = http.request(request) ApiTester::Response.new(response) end |