Class: Dingding::Notifier::Util::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/dingding-notifier/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.



35
36
37
38
# File 'lib/dingding-notifier/util/http_client.rb', line 35

def initialize uri, params
  @uri          = uri
  @params       = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



33
34
35
# File 'lib/dingding-notifier/util/http_client.rb', line 33

def params
  @params
end

#uriObject (readonly)

Returns the value of attribute uri.



33
34
35
# File 'lib/dingding-notifier/util/http_client.rb', line 33

def uri
  @uri
end

Class Method Details

.post(uri, params) ⇒ Object



28
29
30
# File 'lib/dingding-notifier/util/http_client.rb', line 28

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

Instance Method Details

#callObject

rubocop:disable Layout/IndentHeredoc



41
42
43
44
45
46
47
48
# File 'lib/dingding-notifier/util/http_client.rb', line 41

def call
  response = Faraday.post(uri, params,{"Content-Type" => "application/json"})
  # http_obj.request(request_obj).tap do |response|
  #   unless response.is_a?(Net::HTTPSuccess)
  #     raise Dingding::Notifier::APIError.new(response)
  #   end
  # end
end