Class: Line::Bot::Request
- Inherits:
-
Object
- Object
- Line::Bot::Request
- Defined in:
- lib/line/bot/request.rb
Constant Summary
- BASE_URL =
'https://trialbot-api.line.me'.freeze
Instance Method Summary (collapse)
-
- (Request) initialize(client, request_method, path, options = {})
constructor
A new instance of Request.
- - (Object) perform
Constructor Details
- (Request) initialize(client, request_method, path, options = {})
Returns a new instance of Request
11 12 13 14 15 16 17 |
# File 'lib/line/bot/request.rb', line 11 def initialize(client, request_method, path, = {}) @client = client @request_method = request_method @uri = URI(BASE_URL + path) @path = @uri.path @options = end |
Instance Method Details
- (Object) perform
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/line/bot/request.rb', line 19 def perform response = http_client.send(@request_method) do |req| req.url @path req.headers = Line::Bot::Headers.new(@client, @request_method, @uri).request_headers req.params = @options if @request_method == :get req.params = @options unless @options == {} else req.body = @options.to_json end end { status: response.status, body: response.body } end |