Class: Line::Bot::Client
- Inherits:
-
Object
- Object
- Line::Bot::Client
- Defined in:
- lib/line/bot/client.rb
Instance Attribute Summary collapse
-
#certentials ⇒ Object
Returns the value of attribute certentials.
Instance Method Summary collapse
- #get_image(id, preview = false) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #send_image(to_mid, image_url, preview_url) ⇒ Object
- #send_message(to_mid, message) ⇒ Object
- #send_text(to_mid, message) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/line/bot/client.rb', line 6 def initialize( = {}) @certentials = if .is_a?(Certentials) @certentials = Certentials.new() if .is_a?(Hash) yield(self) if block_given? end |
Instance Attribute Details
#certentials ⇒ Object
Returns the value of attribute certentials.
4 5 6 |
# File 'lib/line/bot/client.rb', line 4 def certentials @certentials end |
Instance Method Details
#get_image(id, preview = false) ⇒ Object
12 13 14 15 16 |
# File 'lib/line/bot/client.rb', line 12 def get_image(id, preview = false) url = "#{API::ENDPOINT}/bot/message/#{id}/content" url = "#{url}/preview" if preview HTTP.get(url, @certentials.header) end |
#send_image(to_mid, image_url, preview_url) ⇒ Object
22 23 24 |
# File 'lib/line/bot/client.rb', line 22 def send_image(to_mid, image_url, preview_url) (to_mid, Message::Image.new( image_url: image_url, preview_url: preview_url) ) end |
#send_message(to_mid, message) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/line/bot/client.rb', line 26 def (to_mid, ) request = Request.new do |config| config.to_mid = to_mid config.certentials = @certentials config.endpoint = API::ENDPOINT config.endpoint_path = "/events" config. = config.event_type = Line::Bot::EventType::MESSAGE end request.post end |