Class: Twinkle::Client::Http
- Inherits:
-
Object
- Object
- Twinkle::Client::Http
- Defined in:
- lib/twinkle/client/http.rb
Instance Method Summary collapse
-
#initialize(endpoint, token) ⇒ Http
constructor
A new instance of Http.
- #post(path, params = {}) ⇒ Object
Constructor Details
#initialize(endpoint, token) ⇒ Http
Returns a new instance of Http.
7 8 9 10 11 12 13 14 15 |
# File 'lib/twinkle/client/http.rb', line 7 def initialize(endpoint, token) @token = token endpoint = ::URI.parse(endpoint).normalize @transport = ::Net::HTTP.new(endpoint.host, endpoint.port).tap do |http| http.open_timeout = 20 http.read_timeout = 20 end end |
Instance Method Details
#post(path, params = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/twinkle/client/http.rb', line 17 def post(path, params = {}) set_default_params(params) request = ::Net::HTTP::Post.new(path) request.set_form_data(params) @transport.request(request).kind_of?(::Net::HTTPSuccess) end |