Class: OTX::Events
Overview
Besides receiving the pulse information, it is possible to return details of events that have occured in the OTX system and affect your account. This class provides a wrapper around this functionality.
Instance Method Summary collapse
-
#get_all(limit = 20) ⇒ Array
Get all events from the API, get all events in chunks defined by limit.
-
#get_events(limit = 10, page = 1, params = {}) ⇒ Object
Get subscribed events from the API.
-
#get_since(timestamp, limit = 20) ⇒ Array
Get all events from the API, get all events in chunks defined by limit and since timestamp.
Methods inherited from Base
#get, #initialize, #patch, #post
Constructor Details
This class inherits a constructor from OTX::Base
Instance Method Details
#get_all(limit = 20) ⇒ Array
Get all events from the API, get all events in chunks defined by limit
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/otx_ruby/events.rb', line 38 def get_all(limit = 20) uri = '/api/v1/pulses/events' params = {limit: limit} events = [] begin json_data = get(uri, params) page = json_data['next'] params = URI::decode_www_form(URI(page).query).to_h unless page.nil? events += json_data['results'] end while page && !json_data['results'].empty? results = [] events.each do |event| results << OTX::Event.new(event) end return results end |
#get_events(limit = 10, page = 1, params = {}) ⇒ Object
Get subscribed events from the API
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/otx_ruby/events.rb', line 15 def get_events(limit = 10, page = 1, params = {}) uri = '/api/v1/pulses/events' params['limit'] = limit params['page'] = page json_data = get(uri, params) events = json_data['results'] results = [] events.each do |event| results << OTX::Event.new(event) end return results end |
#get_since(timestamp, limit = 20) ⇒ Array
Get all events from the API, get all events in chunks defined by limit and since timestamp
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/otx_ruby/events.rb', line 67 def get_since(, limit = 20) uri = '/api/v1/pulses/events' params = {limit: limit, since: } events = [] begin json_data = get(uri, params) page = json_data['next'] params = URI::decode_www_form(URI(page).query).to_h unless page.nil? events += json_data['results'] end while page && !json_data['results'].empty? results = [] events.each do |event| results << OTX::Event.new(event) end return results end |