Class: Line::Bot::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



6
7
8
9
10
# File 'lib/line/bot/client.rb', line 6

def initialize(options = {})
  @certentials = options if options.is_a?(Certentials)
  @certentials = Certentials.new(options) if options.is_a?(Hash)
  yield(self) if block_given?
end

Instance Attribute Details

#certentialsObject

Returns the value of attribute certentials.



4
5
6
# File 'lib/line/bot/client.rb', line 4

def certentials
  @certentials
end

Instance Method Details

#send_message(to_mid, message) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/line/bot/client.rb', line 16

def send_message(to_mid, message)
  request = Request.new do |config|
    config.to_mid = to_mid
    config.certentials = @certentials
    config.endpoint = API::ENDPOINT
    config.endpoint_path = "/events"
    config.message = message
    config.event_type = Line::Bot::EventType::MESSAGE
  end

  request.post
end

#send_text(to_mid, message) ⇒ Object



12
13
14
# File 'lib/line/bot/client.rb', line 12

def send_text(to_mid, message)
  send_message(to_mid, Message::Text.new(text: message))
end