-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added method to list event log items (#97)
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "seatsio/exception" | ||
require "base64" | ||
require "seatsio/httpClient" | ||
require "seatsio/domain" | ||
require "json" | ||
require "cgi" | ||
|
||
module Seatsio | ||
class EventLogClient | ||
|
||
def initialize(http_client) | ||
@http_client = http_client | ||
end | ||
|
||
def list(filter: nil) | ||
extended_cursor = cursor | ||
extended_cursor.set_query_param('filter', filter) | ||
extended_cursor | ||
end | ||
|
||
private | ||
|
||
def cursor() | ||
Pagination::Cursor.new(EventLogItem, 'event-log', @http_client) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'test_helper' | ||
require 'util' | ||
|
||
class ListEventLogItemsTest < SeatsioTestClient | ||
def test_list_all_event_log_items | ||
chart = @seatsio.charts.create | ||
@seatsio.charts.update key: chart.key, new_name: 'a chart' | ||
|
||
sleep(2) | ||
|
||
event_log_items = @seatsio.event_log.list | ||
|
||
types = event_log_items.collect { |event_log_item| event_log_item.type } | ||
assert_equal(%w[chart.created chart.published], types) | ||
end | ||
|
||
def test_event_log_item_properties | ||
chart = @seatsio.charts.create | ||
|
||
sleep(2) | ||
|
||
event_log_items = @seatsio.event_log.list | ||
event_log_item = event_log_items.first_page.to_a[0] | ||
|
||
assert_equal('chart.created', event_log_item.type) | ||
assert_true(event_log_item.id > 0) | ||
assert_not_nil(event_log_item.date) | ||
assert_equal(@workspace.key, event_log_item.workspace_key) | ||
assert_equal({ "key" => chart.key }, event_log_item.data) | ||
end | ||
|
||
end |