Class: Chatbase::HttpService
- Inherits:
-
Object
- Object
- Chatbase::HttpService
- Defined in:
- lib/chatbase/http_service.rb
Instance Method Summary collapse
Instance Method Details
#connection ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/chatbase/http_service.rb', line 4 def connection @connection ||= begin Faraday.new(:url => 'https://chatbase.com/') do |faraday| faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end end |
#request_post(url, data) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/chatbase/http_service.rb', line 13 def request_post(url, data) connection.post do |req| req.url url req.headers['Content-Type'] = 'application/json' req.body = data.to_json end end |