Class: Line::Bot::HTTPClient Deprecated

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

Overview

Deprecated.

This is deprecated. Please use V2::HttpClient instead.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_options = {}) ⇒ Line::Bot::HTTPClient

Deprecated.

This is deprecated. Please use V2::HttpClient#initialize instead.

Initialize a new HTTPClient

Parameters:

  • http_options (Hash) (defaults to: {})


37
38
39
# File 'lib/line/bot/v1/httpclient.rb', line 37

def initialize(http_options = {})
  @http_options = http_options
end

Instance Attribute Details

#http_optionsHash

Returns:

  • (Hash)


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

def http_options
  @http_options
end

Instance Method Details

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

Deprecated.

This is deprecated. Please use V2::HttpClient#delete instead.



85
86
87
88
# File 'lib/line/bot/v1/httpclient.rb', line 85

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

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

Deprecated.

This is deprecated. Please use V2::HttpClient#get instead.



61
62
63
64
# File 'lib/line/bot/v1/httpclient.rb', line 61

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

#http(uri) ⇒ Net::HTTP

Deprecated.

This is obsolete.

Returns:

  • (Net::HTTP)


45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/line/bot/v1/httpclient.rb', line 45

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

  http_options&.each do |key, value|
    http.send("#{key}=", value)
  end

  http
end

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

Deprecated.

This is deprecated. Please use V2::HttpClient#post instead.



69
70
71
72
# File 'lib/line/bot/v1/httpclient.rb', line 69

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

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

Deprecated.

This is deprecated. Please use V2::HttpClient#put instead.



77
78
79
80
# File 'lib/line/bot/v1/httpclient.rb', line 77

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