Class: Line::Bot::V2::HttpClient

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

Overview

This class is not intended for line-bot-sdk-ruby users. Breaking changes may occur; use at your own risk.

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, http_headers: {}, http_options: {}) ⇒ HttpClient

Initializes a new HttpClient instance.

docs.ruby-lang.org/en/3.4/Net/HTTP.html#method-i-options

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.

Parameters:

  • base_url (String)

    The base URL for requests.

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

    The default HTTP headers.

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

    The HTTP options (same as Net::HTTP options).



21
22
23
24
25
# File 'lib/line/bot/v2/http_client.rb', line 21

def initialize(base_url:, http_headers: {}, http_options: {})
  @base_url = base_url
  @http_headers = { 'User-Agent': "LINE-BotSDK-Ruby/#{Line::Bot::VERSION}" }.merge(normalize_headers(headers: http_headers))
  @http_options = http_options
end

Instance Method Details

#delete(path:, query_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



46
47
48
49
# File 'lib/line/bot/v2/http_client.rb', line 46

def delete(path:, query_params: nil, headers: nil)
  request = build_request(http_class: Net::HTTP::Delete, path: path, query_params: query_params, headers: headers)
  perform_request(request: request)
end

#get(path:, query_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



28
29
30
31
# File 'lib/line/bot/v2/http_client.rb', line 28

def get(path:, query_params: nil, headers: nil)
  request = build_request(http_class: Net::HTTP::Get, path: path, query_params: query_params, headers: headers)
  perform_request(request: request)
end

#post(path:, query_params: nil, body_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



34
35
36
37
# File 'lib/line/bot/v2/http_client.rb', line 34

def post(path:, query_params: nil, body_params: nil, headers: nil)
  request = build_request(http_class: Net::HTTP::Post, path: path, query_params: query_params, headers: headers, body_params: body_params)
  perform_request(request: request)
end

#post_form(path:, query_params: nil, form_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



52
53
54
55
# File 'lib/line/bot/v2/http_client.rb', line 52

def post_form(path:, query_params: nil, form_params: nil, headers: nil)
  request = build_form_request(http_class: Net::HTTP::Post, path: path, query_params: query_params, form_params: form_params, headers: headers)
  perform_request(request: request)
end

#post_form_multipart(path:, query_params: nil, form_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



58
59
60
61
# File 'lib/line/bot/v2/http_client.rb', line 58

def post_form_multipart(path:, query_params: nil, form_params: nil, headers: nil)
  request = build_multipart_request(http_class: Net::HTTP::Post::Multipart, path: path, query_params: query_params, form_params: form_params, headers: headers)
  perform_request(request: request)
end

#put(path:, query_params: nil, body_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



40
41
42
43
# File 'lib/line/bot/v2/http_client.rb', line 40

def put(path:, query_params: nil, body_params: nil, headers: nil)
  request = build_request(http_class: Net::HTTP::Put, path: path, query_params: query_params, headers: headers, body_params: body_params)
  perform_request(request: request)
end

#put_form_multipart(path:, query_params: nil, form_params: nil, headers: nil) ⇒ Object

NOTE: line-bot-sdk-ruby users should not use this. Breaking changes may occur, so use at your own risk.



64
65
66
67
# File 'lib/line/bot/v2/http_client.rb', line 64

def put_form_multipart(path:, query_params: nil, form_params: nil, headers: nil)
  request = build_multipart_request(http_class: Net::HTTP::Put::Multipart, path: path, query_params: query_params, form_params: form_params, headers: headers)
  perform_request(request: request)
end