Class: Line::Bot::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/httpclient.rb

Instance Method Summary collapse

Instance Method Details

#get(url, header = {}) ⇒ Object



20
21
22
23
# File 'lib/line/bot/httpclient.rb', line 20

def get(url, header = {})
  uri = URI(url)
  http(uri).get(uri.request_uri, header)
end

#http(uri) ⇒ Net::HTTP

Returns:

  • (Net::HTTP)


11
12
13
14
15
16
17
18
# File 'lib/line/bot/httpclient.rb', line 11

def http(uri)
  http = Net::HTTP.new(uri.host, uri.port)
  if uri.scheme == "https"
    http.use_ssl = true
  end

  http
end

#post(url, payload, header = {}) ⇒ Object



25
26
27
28
# File 'lib/line/bot/httpclient.rb', line 25

def post(url, payload, header = {})
  uri = URI(url)
  http(uri).post(uri.request_uri, payload, header)
end