Class: Bearychat::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/bearychat/http_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ HttpClient

Returns a new instance of HttpClient.



7
8
9
# File 'lib/bearychat/http_client.rb', line 7

def initialize(url)
  self.conn = build_conn(url)
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



5
6
7
# File 'lib/bearychat/http_client.rb', line 5

def conn
  @conn
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/bearychat/http_client.rb', line 5

def url
  @url
end

Instance Method Details

#post_json(body) ⇒ Object



11
12
13
14
15
16
# File 'lib/bearychat/http_client.rb', line 11

def post_json(body)
  conn.post do |req|
    req.headers['Content-Type'] = 'application/json'
    req.body = body
  end
end