Class: PortaText::Client::HttpClient

Inherits:
BaseClient show all
Defined in:
lib/portatext/client/http_client.rb

Overview

This class implements the client using Net::HTTP

Author

Marcelo Gornstein ([email protected])

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Instance Attribute Summary

Attributes inherited from BaseClient

#api_key, #credentials, #endpoint, #executor, #logger

Instance Method Summary collapse

Methods inherited from BaseClient

#command_class_name, #initialize, #method_missing, #respond_to_missing?, #run

Constructor Details

This class inherits a constructor from PortaText::Client::BaseClient

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PortaText::Client::BaseClient

Instance Method Details

#execute(descriptor) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/portatext/client/http_client.rb', line 13

def execute(descriptor)
  uri = URI.parse descriptor.uri
  http = create_http uri
  request = create_request uri, descriptor.method, descriptor.body
  begin
    request! descriptor, http, request
  rescue => e
    raise ::PortaText::Exception::RequestError.new(
      descriptor, nil, e.message, e
    )
  end
end