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
31 32 33 |
# File 'lib/line/bot/httpclient.rb', line 31 def initialize( = {}) = end |
Instance Attribute Details
#http_options ⇒ Object
@return [Hash]
24 25 26 |
# File 'lib/line/bot/httpclient.rb', line 24 def end |
Instance Method Details
#delete(url, header = {}) ⇒ Object
61 62 63 64 |
# File 'lib/line/bot/httpclient.rb', line 61 def delete(url, header = {}) uri = URI(url) http(uri).delete(uri.request_uri, header) end |
#get(url, header = {}) ⇒ Object
51 52 53 54 |
# File 'lib/line/bot/httpclient.rb', line 51 def get(url, header = {}) uri = URI(url) http(uri).get(uri.request_uri, header) end |
#http(uri) ⇒ Net::HTTP
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/line/bot/httpclient.rb', line 36 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
56 57 58 59 |
# File 'lib/line/bot/httpclient.rb', line 56 def post(url, payload, header = {}) uri = URI(url) http(uri).post(uri.request_uri, payload, header) end |