Sha256: 4c4b951c884f90e6eee49739fce53afab94e8f86e30cf2552dbf792ca32abeb9
Contents?: true
Size: 775 Bytes
Versions: 2
Compression:
Stored size: 775 Bytes
Contents
module Chatbase class HttpService attr_accessor :agent_key, :agent_name def initialize(agent_key: nil) @agent_key = agent_key || Chatbase.agent_key @agent_name = agent_name || Chatbase.agent_name end def connection @connection ||= begin Faraday.new(:url => 'https://chatbase-area120.appspot.com/api/message') do |faraday| faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end end def request_post(data) connection.post do |req| req.headers['Content-Type'] = 'application/json' req.body = {'api_key': agent_key, 'agent_name': agent_name}.merge(data).to_json end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chatbase-0.1.02 | lib/chatbase/http_service.rb |
chatbase-0.1.01 | lib/chatbase/http_service.rb |