class OTX::Activity

Within the OTX system you are able to subscribe to pulses from other users, this class allows the retreival of the currently subscribed pulse feeds and the associated pulses, as well as pulses from followed Users

Public Instance Methods

get_activity(limit = 10, page = 1, params = {}) click to toggle source

Get pulse activity from the API

@param limit [Integer] Number of records returned @param page [Integer] page of records returned @param params [Hash] Addtional parameters eg `modified_since: DateTime`

# File lib/otx_ruby/activity.rb, line 15
def get_activity(limit = 10, page = 1, params = {})
  uri = '/api/v1/pulses/activity'
  params['limit'] = limit
  params['page'] = page

  json_data = get(uri, params)

  pulses = json_data['results']

  results = []
  pulses.each do |pulse|
    results << OTX::Pulse.new(pulse)
  end

  return results
end
get_all(limit = 20) click to toggle source

Get all pulses activity from the API, get all events in chunks defined by limit

@param limit [Integer] Size of chunk of data to be Returned (default = 20) @return [Array<OTX::Pulse>] Parsed Pulses

# File lib/otx_ruby/activity.rb, line 39
def get_all(limit = 20)
  uri = '/api/v1/pulses/activity'
  params = {limit: limit}
  pulses = []
  begin
    json_data = get(uri, params)
    page = json_data['next']

    params = URI::decode_www_form(URI(page).query).to_h unless page.nil?

    pulses += json_data['results']
  end while page && !json_data['results'].empty?

  results = []
  pulses.each do |pulse|
    results << OTX::Pulse.new(pulse)
  end

  return results
end
get_since(timestamp, limit = 20) click to toggle source

Get all pulses activity from the API, get all events in chunks defined by limit and since timestamp

@param timestamp [Time] Timestamp of point in time to get records since in ISO Format @param limit [Integer] Size of chunk of data to be Returned (default = 20) @return [Array<OTX::Pulse>] Parsed Pulses

# File lib/otx_ruby/activity.rb, line 69
def get_since(timestamp, limit = 20)
  uri = '/api/v1/pulses/activity'
  params = {limit: limit, modified_since: timestamp}
  pulses = []
  begin
    json_data = get(uri, params)
    page = json_data['next']

    params = URI::decode_www_form(URI(page).query).to_h unless page.nil?

    pulses += json_data['results']
  end while page && !json_data['results'].empty?

  results = []
  pulses.each do |pulse|
    results << OTX::Pulse.new(pulse)
  end

  return results
end