Sha256: 62f566d9940629627361f8de08dfdd254e923a36527b5105c40a93bb44a4db88
Contents?: true
Size: 788 Bytes
Versions: 12
Compression:
Stored size: 788 Bytes
Contents
require 'json' require 'rest_client' module ADNChannels class SearchMessages def initialize(token) @base_url = 'http://api.app.net' @token = token end def search_annotation(channel_id, query) args = {:count => 200, :before_id => nil} messages = [] 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| messages << m } break unless resp['meta']['more'] args = {:count => 200, :before_id => resp['meta']['min_id']} end messages end end end
Version data entries
12 entries across 12 versions & 1 rubygems