Sha256: b329ba77a029b570f11cc0172286b7091ac183f59229569cebaa58aa1d03f430

Contents?: true

Size: 727 Bytes

Versions: 12

Compression:

Stored size: 727 Bytes

Contents

require 'json'
require 'rest_client'
module ADNChannels
  class GetChannels
    def initialize(token)
      @base_url = 'http://api.app.net'
      @token = token
    end
    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
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
TokiCLI-0.2.1 lib/TokiCLI/get_channels.rb
TokiCLI-0.2.0 lib/TokiCLI/get_channels.rb
TokiCLI-0.1.1 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.9 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.8 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.7 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.6 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.5 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.4 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.3 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.2 lib/TokiCLI/get_channels.rb
TokiCLI-0.0.1 lib/TokiCLI/get_channels.rb