Skip to content

Commit a2cabff

Browse files
authoredJun 6, 2024··
Make events parameter required for list_events (#282)
1 parent 519531a commit a2cabff

File tree

5 files changed

+41
-39
lines changed

5 files changed

+41
-39
lines changed
 

‎lib/workos/events.rb

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class << self
2222
#
2323
# @return [Hash]
2424
def list_events(options = {})
25+
raise ArgumentError, 'Events parameter is required.' if options[:events].nil?
26+
2527
response = execute_request(
2628
request: get_request(
2729
path: '/events',

‎spec/lib/workos/event_spec.rb

+11-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55

66
describe '.list_events' do
77
context 'with no options' do
8-
it 'returns events and metadata' do
9-
expected_metadata = {
10-
'after' => nil,
11-
}
12-
8+
it 'raises ArgumentError' do
139
VCR.use_cassette 'events/list_events_with_no_options' do
14-
events = described_class.list_events
15-
16-
expect(events.data.size).to eq(1)
17-
expect(events.list_metadata).to eq(expected_metadata)
10+
expect do
11+
described_class.list_events
12+
end.to raise_error(ArgumentError)
1813
end
1914
end
2015
end
@@ -44,7 +39,7 @@
4439
context 'with the after option' do
4540
it 'forms the proper request to the API' do
4641
request_args = [
47-
'/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1',
42+
'/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1&events=dsync.user.created',
4843
'Content-Type' => 'application/json'
4944
]
5045

@@ -54,7 +49,10 @@
5449
and_return(expected_request)
5550

5651
VCR.use_cassette 'events/list_events_with_after' do
57-
events = described_class.list_events(after: 'event_01FGCPNV312FHFRCX0BYWHVSE1')
52+
events = described_class.list_events(
53+
after: 'event_01FGCPNV312FHFRCX0BYWHVSE1',
54+
events: ['dsync.user.created'],
55+
)
5856

5957
expect(events.data.size).to eq(1)
6058
end
@@ -64,7 +62,7 @@
6462
context 'with the range_start and range_end options' do
6563
it 'forms the proper request to the API' do
6664
request_args = [
67-
'/events?range_start=2023-01-01T00%3A00%3A00Z&range_end=2023-01-03T00%3A00%3A00Z',
65+
'/events?events=dsync.user.created&range_start=2023-01-01T00%3A00%3A00Z&range_end=2023-01-03T00%3A00%3A00Z',
6866
'Content-Type' => 'application/json'
6967
]
7068

@@ -75,6 +73,7 @@
7573

7674
VCR.use_cassette 'events/list_events_with_range' do
7775
events = described_class.list_events(
76+
events: ['dsync.user.created'],
7877
range_start: '2023-01-01T00:00:00Z',
7978
range_end: '2023-01-03T00:00:00Z',
8079
)

‎spec/support/fixtures/vcr_cassettes/events/list_events_with_after.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎spec/support/fixtures/vcr_cassettes/events/list_events_with_no_options.yml

+26-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎spec/support/fixtures/vcr_cassettes/events/list_events_with_range.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.