Module: Falconz::APIs::Feed
- Included in:
- Client
- Defined in:
- lib/falconz/apis/feed.rb
Overview
A module consisting of the method associated with the Feed section of the API.
Instance Method Summary collapse
-
#latest_feed ⇒ Object
access a feed of last 250 reports over 24h.
-
#latest_feed_count ⇒ Integer
A little wrapper method to #latest_feed that returns the count of the amount of data found in the feed.
Instance Method Details
#latest_feed ⇒ Object
access a feed of last 250 reports over 24h
Example
# create a new client
client = Falconz.client.new
client.latest_feed do |data|
# do something with the data
puts data.to_json
end
# or, if you'd like, you can be a fancy shamncy pants
client.latest_feed { |data| puts data.to_json }
feed = client.latest_feed
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/falconz/apis/feed.rb', line 27 def latest_feed # return response unless block was given ( like the in-line example ) return get_request('/feed/latest') unless block_given? # capture response response = get_request('/feed/latest') # raise error (built out of the response) unless everything is ok raise "response not ok: #{response}" unless Falconz.response_is_ok?(response) # raise error unless there is any data raise "no data to iterate through in response #{response}" unless response['data'] or !response['data'].zero? response['data'].each do |data| yield data end end |
#latest_feed_count ⇒ Integer
A little wrapper method to #latest_feed that returns the count of the amount of data found in the feed.
Example
# create a new client
client = Falconz.client.new
# print latest feed found to the screen
puts client.latest_feed_count
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/falconz/apis/feed.rb', line 53 def latest_feed_count # capture response response = latest_feed # raise error (built out of the response) unless everything is ok raise response unless Falconz.response_is_ok?(response) # raise error unless there is any count in the response raise "no count found in response #{response}" unless response['count'] # return the count response["count"] end |