Class: OTX::Activity

Inherits:
Base
  • Object
show all
Defined in:
lib/otx_ruby/activity.rb

Overview

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

Instance Method Summary collapse

Methods inherited from Base

#get, #initialize, #patch, #post

Constructor Details

This class inherits a constructor from OTX::Base

Instance Method Details

#get_activity(limit = 10, page = 1, params = {}) ⇒ Object

Get pulse activity from the API

Parameters:

  • limit (Integer) (defaults to: 10)

    Number of records returned

  • page (Integer) (defaults to: 1)

    page of records returned

  • params (Hash) (defaults to: {})

    Addtional parameters eg ‘modified_since: DateTime`



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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) ⇒ Array<OTX::Pulse>

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

Parameters:

  • limit (Integer) (defaults to: 20)

    Size of chunk of data to be Returned (default = 20)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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) ⇒ Array<OTX::Pulse>

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

ISO Format

Parameters:

  • timestamp (Time)

    Timestamp of point in time to get records since in

  • limit (Integer) (defaults to: 20)

    Size of chunk of data to be Returned (default = 20)

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 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