Class: ADNChannels::SearchMessages
- Inherits:
-
Object
- Object
- ADNChannels::SearchMessages
- Defined in:
- lib/TokiCLI/search_messages.rb
Instance Method Summary collapse
-
#initialize(token) ⇒ SearchMessages
constructor
A new instance of SearchMessages.
- #search_annotation(channel_id, query) ⇒ Object
Constructor Details
#initialize(token) ⇒ SearchMessages
Returns a new instance of SearchMessages.
5 6 7 8 |
# File 'lib/TokiCLI/search_messages.rb', line 5 def initialize(token) @base_url = 'http://api.app.net' @token = token end |
Instance Method Details
#search_annotation(channel_id, query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/TokiCLI/search_messages.rb', line 9 def search_annotation(channel_id, query) args = {:count => 200, :before_id => nil} = [] loop do @url = "#{@base_url}/channels/messages/search?query=#{query}&channel_ids=#{channel_id}&access_token=#{@token}&include_machine=1&include_message_annotations=1&include_deleted=0&count=#{args[:count]}&before_id=#{args[:before_id]}" resp = JSON.parse(RestClient.get(@url)) resp['data'].each { |m| << m } break unless resp['meta']['more'] args = {:count => 200, :before_id => resp['meta']['min_id']} end end |