Class: Line::Bot::HTTPClient
- Inherits:
-
Object
- Object
- Line::Bot::HTTPClient
- Defined in:
- lib/line/bot/httpclient.rb
Instance Attribute Summary collapse
-
#http_options ⇒ Object
@return [Hash].
Instance Method Summary collapse
- #delete(url, header = {}) ⇒ Object
- #get(url, header = {}) ⇒ Object
- #http(uri) ⇒ Net::HTTP
-
#initialize(http_options = {}) ⇒ Line::Bot::HTTPClient
constructor
Initialize a new HTTPClient.
- #post(url, payload, header = {}) ⇒ Object
Constructor Details
#initialize(http_options = {}) ⇒ Line::Bot::HTTPClient
Initialize a new HTTPClient
30 31 32 |
# File 'lib/line/bot/httpclient.rb', line 30 def initialize( = {}) = end |
Instance Attribute Details
#http_options ⇒ Object
@return [Hash]
23 24 25 |
# File 'lib/line/bot/httpclient.rb', line 23 def end |
Instance Method Details
#delete(url, header = {}) ⇒ Object
60 61 62 63 |
# File 'lib/line/bot/httpclient.rb', line 60 def delete(url, header = {}) uri = URI(url) http(uri).delete(uri.request_uri, header) end |
#get(url, header = {}) ⇒ Object
50 51 52 53 |
# File 'lib/line/bot/httpclient.rb', line 50 def get(url, header = {}) uri = URI(url) http(uri).get(uri.request_uri, header) end |
#http(uri) ⇒ Net::HTTP
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/line/bot/httpclient.rb', line 35 def http(uri) http = Net::HTTP.new(uri.host, uri.port) if uri.scheme == "https" http.use_ssl = true end if .each do |key, value| http.send("#{key}=", value) end end http end |
#post(url, payload, header = {}) ⇒ Object
55 56 57 58 |
# File 'lib/line/bot/httpclient.rb', line 55 def post(url, payload, header = {}) uri = URI(url) http(uri).post(uri.request_uri, payload, header) end |