Class: FDE::Slack::Util::HTTPClient

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, params) ⇒ HTTPClient

Returns a new instance of HTTPClient.



36
37
38
39
40
# File 'lib/slack/util/http_client.rb', line 36

def initialize uri, params
  @uri          = uri
  @http_options = params.delete(:http_options) || {}
  @params       = params
end

Instance Attribute Details

#http_optionsObject (readonly)

Returns the value of attribute http_options.



34
35
36
# File 'lib/slack/util/http_client.rb', line 34

def http_options
  @http_options
end

#paramsObject (readonly)

Returns the value of attribute params.



34
35
36
# File 'lib/slack/util/http_client.rb', line 34

def params
  @params
end

#uriObject (readonly)

Returns the value of attribute uri.



34
35
36
# File 'lib/slack/util/http_client.rb', line 34

def uri
  @uri
end

Class Method Details

.post(uri, params) ⇒ Object



29
30
31
# File 'lib/slack/util/http_client.rb', line 29

def post uri, params
  HTTPClient.new(uri, params).call
end

Instance Method Details

#callObject



42
43
44
45
46
47
48
# File 'lib/slack/util/http_client.rb', line 42

def call
  http_obj.request(request_obj).tap do |response|
    unless response.is_a?(Net::HTTPSuccess)
      raise FDE::Slack::APIError.new(response)
    end
  end
end