Class: Slacking::HttpClient

Inherits:
Object
  • Object
show all
Includes:
Config, IO
Defined in:
lib/slacking/http_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ HttpClient

Returns a new instance of HttpClient.



12
13
14
# File 'lib/slacking/http_client.rb', line 12

def initialize(token)
  @token = token
end

Instance Method Details

#post_to_slack(profile) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/slacking/http_client.rb', line 16

def post_to_slack(profile)
  @profile = profile
  url = URI.parse(slack_url)

  request = Net::HTTP::Post.new("#{url.path}?#{url.query}")
  request.body = request_body
  request.add_field 'Content-Type', 'application/json'

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  handle_response http.request(request)
end