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