workos 4.8.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a59645d5489656e64892044220f777e2e1da74715f38e11f82c8bfad3ed905aa
4
- data.tar.gz: baa9a0fa487c51d3c3adf1f11635fb17bbd22effefc774ca40d1a09e537dfcc8
3
+ metadata.gz: 7d59f479bcadc439580843b8c8a608b41e4c0183d657241955ed3cfbc0f75a38
4
+ data.tar.gz: 48209d43a10edf6d5afa7b4ed5d92c69ee400afb660d23152706b46970602dcc
5
5
  SHA512:
6
- metadata.gz: ebb7b90352a85f433273cafd86e2ceecabd4d20451ce6e6c8122637beb509f55f82f19dc800f4028bdaf35f61a5a3d42dbe7d348db686dda129fff4fa0e034ce
7
- data.tar.gz: 9a6039a67909bfce3a5f42ba854d88da052d5a70d6208f9d60cc3a5d7c20c3ea596f6fba3b1263c6a00e435f772c77a6176d16011f4f3151246dafbd49e142c5
6
+ metadata.gz: 4457fcc8b132f5c7229d8ac5a480b0a3b86de5c1f5a8f28b688cca1e228a1d745fb906495708cf1466cc3a97aaead69fcb970f5fbffd457cdb8cf474ae72eda9
7
+ data.tar.gz: 778cebe2ed866d97858822ec755de7ebe105203450e1cc1de8858b863c1af21788582c74d86f249ea2c5561d5c330c669540d970e2769fadbed8f997e223daba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (4.8.0)
4
+ workos (5.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/workos/client.rb CHANGED
@@ -86,7 +86,7 @@ module WorkOS
86
86
  ].join('; ')
87
87
  end
88
88
 
89
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
89
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity:
90
90
  def handle_error_response(response:)
91
91
  http_status = response.code.to_i
92
92
  json = JSON.parse(response.body)
@@ -99,6 +99,9 @@ module WorkOS
99
99
  request_id: response['x-request-id'],
100
100
  code: json['code'],
101
101
  errors: json['errors'],
102
+ error: json['error'],
103
+ error_description: json['error_description'],
104
+ data: json,
102
105
  )
103
106
  when 401
104
107
  raise AuthenticationError.new(
@@ -107,7 +110,7 @@ module WorkOS
107
110
  request_id: response['x-request-id'],
108
111
  )
109
112
  when 404
110
- raise APIError.new(
113
+ raise NotFoundError.new(
111
114
  message: json['message'],
112
115
  http_status: http_status,
113
116
  request_id: response['x-request-id'],
@@ -118,12 +121,21 @@ module WorkOS
118
121
  errors = extract_error(json['errors']) if json['errors']
119
122
  message += " (#{errors})" if errors
120
123
 
121
- raise InvalidRequestError.new(
124
+ raise UnprocessableEntityError.new(
122
125
  message: message,
123
126
  http_status: http_status,
124
127
  request_id: response['x-request-id'],
128
+ error: json['error'],
129
+ errors: errors,
125
130
  code: code,
126
131
  )
132
+ when 429
133
+ raise RateLimitExceededError.new(
134
+ message: json['message'],
135
+ http_status: http_status,
136
+ request_id: response['x-request-id'],
137
+ retry_after: response['Retry-After'],
138
+ )
127
139
  else
128
140
  raise APIError.new(
129
141
  message: json['message'],
@@ -132,7 +144,7 @@ module WorkOS
132
144
  )
133
145
  end
134
146
  end
135
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
147
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity:
136
148
 
137
149
  private
138
150
 
@@ -15,8 +15,6 @@ module WorkOS
15
15
  # Retrieve directories.
16
16
  #
17
17
  # @param [Hash] options An options hash
18
- # @option options [String] domain The domain of the directory to be
19
- # retrieved.
20
18
  # @option options [String] search A search term for direcory names.
21
19
  # @option options [String] limit Maximum number of records to return.
22
20
  # @option options [String] order The order in which to paginate records
data/lib/workos/errors.rb CHANGED
@@ -7,6 +7,10 @@ module WorkOS
7
7
  attr_reader :request_id
8
8
  attr_reader :code
9
9
  attr_reader :errors
10
+ attr_reader :error
11
+ attr_reader :error_description
12
+ attr_reader :data
13
+ attr_reader :retry_after
10
14
 
11
15
  # rubocop:disable Metrics/ParameterLists
12
16
  def initialize(
@@ -16,7 +20,9 @@ module WorkOS
16
20
  http_status: nil,
17
21
  request_id: nil,
18
22
  code: nil,
19
- errors: nil
23
+ errors: nil,
24
+ data: nil,
25
+ retry_after: nil
20
26
  )
21
27
  @message = message
22
28
  @error = error
@@ -25,6 +31,8 @@ module WorkOS
25
31
  @request_id = request_id
26
32
  @code = code
27
33
  @errors = errors
34
+ @data = data
35
+ @retry_after = retry_after
28
36
  end
29
37
  # rubocop:enable Metrics/ParameterLists
30
38
 
@@ -62,4 +70,13 @@ module WorkOS
62
70
 
63
71
  # TimeoutError is raised when the HTTP request to the API times out
64
72
  class TimeoutError < WorkOSError; end
73
+
74
+ # RateLimitExceededError is raised when the rate limit for the API has been hit
75
+ class RateLimitExceededError < WorkOSError; end
76
+
77
+ # NotFoundError is raised when a resource is not found
78
+ class NotFoundError < WorkOSError; end
79
+
80
+ # UnprocessableEntityError is raised when a request is made that cannot be processed
81
+ class UnprocessableEntityError < WorkOSError; end
65
82
  end
data/lib/workos/events.rb CHANGED
@@ -22,6 +22,8 @@ module WorkOS
22
22
  #
23
23
  # @return [Hash]
24
24
  def list_events(options = {})
25
+ raise ArgumentError, 'Events parameter is required.' if options[:events].nil?
26
+
25
27
  response = execute_request(
26
28
  request: get_request(
27
29
  path: '/events',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkOS
4
- VERSION = '4.8.0'
4
+ VERSION = '5.0.0'
5
5
  end
data/lib/workos.rb CHANGED
@@ -87,4 +87,7 @@ module WorkOS
87
87
  autoload :InvalidRequestError, 'workos/errors'
88
88
  autoload :SignatureVerificationError, 'workos/errors'
89
89
  autoload :TimeoutError, 'workos/errors'
90
+ autoload :NotFoundError, 'workos/errors'
91
+ autoload :UnprocessableEntityError, 'workos/errors'
92
+ autoload :RateLimitExceededError, 'workos/errors'
90
93
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/MultilineBlockChain
4
+ describe WorkOS::Client do
5
+ describe '.client' do
6
+ it 'returns a 400 error with appropriate fields' do
7
+ VCR.use_cassette('user_management/authenticate_with_code/invalid') do
8
+ expect do
9
+ WorkOS::UserManagement.authenticate_with_code(
10
+ code: 'invalid',
11
+ client_id: 'client_123',
12
+ ip_address: '200.240.210.16',
13
+ user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36',
14
+ )
15
+ end.to raise_error do |error|
16
+ expect(error).to be_a(WorkOS::InvalidRequestError)
17
+ expect(error.error).not_to be_nil
18
+ expect(error.error_description).not_to be_nil
19
+ expect(error.data).not_to be_nil
20
+ end
21
+ end
22
+ end
23
+
24
+ it 'returns a 401 error with appropriate fields' do
25
+ VCR.use_cassette('base/execute_request_unauthenticated') do
26
+ expect do
27
+ WorkOS::AuditLogs.create_event(
28
+ organization: 'org_123',
29
+ event: {},
30
+ )
31
+ end.to raise_error do |error|
32
+ expect(error).to be_a(WorkOS::AuthenticationError)
33
+ expect(error.message).not_to be_nil
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'returns a 404 error with appropriate fields' do
39
+ VCR.use_cassette('user_management/get_email_verification/invalid') do
40
+ expect do
41
+ WorkOS::UserManagement.get_email_verification(
42
+ id: 'invalid',
43
+ )
44
+ end.to raise_error do |error|
45
+ expect(error).to be_a(WorkOS::NotFoundError)
46
+ expect(error.message).not_to be_nil
47
+ end
48
+ end
49
+ end
50
+
51
+ it 'returns a 422 error with appropriate fields' do
52
+ VCR.use_cassette('user_management/create_user_invalid') do
53
+ expect do
54
+ WorkOS::UserManagement.create_user(
55
+ email: 'invalid',
56
+ )
57
+ end.to raise_error do |error|
58
+ expect(error).to be_a(WorkOS::UnprocessableEntityError)
59
+ expect(error.message).not_to be_nil
60
+ expect(error.errors).not_to be_nil
61
+ expect(error.code).not_to be_nil
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ # rubocop:enable Style/MultilineBlockChain
@@ -20,29 +20,6 @@ describe WorkOS::DirectorySync do
20
20
  end
21
21
  end
22
22
 
23
- context 'with domain option' do
24
- it 'forms the proper request to the API' do
25
- request_args = [
26
- '/directories?domain=foo-corp.com&'\
27
- 'order=desc',
28
- 'Content-Type' => 'application/json'
29
- ]
30
-
31
- expected_request = Net::HTTP::Get.new(*request_args)
32
-
33
- expect(Net::HTTP::Get).to receive(:new).with(*request_args).
34
- and_return(expected_request)
35
-
36
- VCR.use_cassette 'directory_sync/list_directories/with_domain' do
37
- directories = described_class.list_directories(
38
- domain: 'foo-corp.com',
39
- )
40
-
41
- expect(directories.data.size).to eq(1)
42
- end
43
- end
44
- end
45
-
46
23
  context 'with search option' do
47
24
  it 'forms the proper request to the API' do
48
25
  request_args = [
@@ -171,7 +148,7 @@ describe WorkOS::DirectorySync do
171
148
  expect do
172
149
  WorkOS::DirectorySync.get_directory(id: 'invalid')
173
150
  end.to raise_error(
174
- WorkOS::APIError,
151
+ WorkOS::NotFoundError,
175
152
  "Status 404, Directory not found: 'invalid'. - request ID: ",
176
153
  )
177
154
  end
@@ -185,7 +162,7 @@ describe WorkOS::DirectorySync do
185
162
  VCR.use_cassette('directory_sync/list_groups/with_no_options') do
186
163
  expect do
187
164
  WorkOS::DirectorySync.list_groups
188
- end.to raise_error(WorkOS::InvalidRequestError)
165
+ end.to raise_error(WorkOS::UnprocessableEntityError)
189
166
  end
190
167
  end
191
168
  end
@@ -319,7 +296,7 @@ describe WorkOS::DirectorySync do
319
296
  VCR.use_cassette('directory_sync/list_users/with_no_options') do
320
297
  expect do
321
298
  WorkOS::DirectorySync.list_users
322
- end.to raise_error(WorkOS::InvalidRequestError)
299
+ end.to raise_error(WorkOS::UnprocessableEntityError)
323
300
  end
324
301
  end
325
302
  end
@@ -471,7 +448,7 @@ describe WorkOS::DirectorySync do
471
448
  VCR.use_cassette('directory_sync/get_group_with_invalid_id') do
472
449
  expect do
473
450
  WorkOS::DirectorySync.get_group('invalid')
474
- end.to raise_error(WorkOS::APIError)
451
+ end.to raise_error(WorkOS:: NotFoundError)
475
452
  end
476
453
  end
477
454
  end
@@ -498,7 +475,7 @@ describe WorkOS::DirectorySync do
498
475
  VCR.use_cassette('directory_sync/get_user_with_invalid_id') do
499
476
  expect do
500
477
  WorkOS::DirectorySync.get_user('invalid')
501
- end.to raise_error(WorkOS::APIError)
478
+ end.to raise_error(WorkOS::NotFoundError)
502
479
  end
503
480
  end
504
481
  end
@@ -5,16 +5,11 @@ describe WorkOS::Events do
5
5
 
6
6
  describe '.list_events' do
7
7
  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
13
9
  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)
18
13
  end
19
14
  end
20
15
  end
@@ -44,7 +39,7 @@ describe WorkOS::Events do
44
39
  context 'with the after option' do
45
40
  it 'forms the proper request to the API' do
46
41
  request_args = [
47
- '/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1',
42
+ '/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1&events=dsync.user.created',
48
43
  'Content-Type' => 'application/json'
49
44
  ]
50
45
 
@@ -54,7 +49,10 @@ describe WorkOS::Events do
54
49
  and_return(expected_request)
55
50
 
56
51
  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
+ )
58
56
 
59
57
  expect(events.data.size).to eq(1)
60
58
  end
@@ -64,7 +62,7 @@ describe WorkOS::Events do
64
62
  context 'with the range_start and range_end options' do
65
63
  it 'forms the proper request to the API' do
66
64
  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',
68
66
  'Content-Type' => 'application/json'
69
67
  ]
70
68
 
@@ -75,6 +73,7 @@ describe WorkOS::Events do
75
73
 
76
74
  VCR.use_cassette 'events/list_events_with_range' do
77
75
  events = described_class.list_events(
76
+ events: ['dsync.user.created'],
78
77
  range_start: '2023-01-01T00:00:00Z',
79
78
  range_end: '2023-01-03T00:00:00Z',
80
79
  )
@@ -87,7 +86,7 @@ describe WorkOS::Events do
87
86
  context 'with the organization_id option' do
88
87
  it 'forms the proper request to the API' do
89
88
  request_args = [
90
- '/events?organization_id=org_1234',
89
+ '/events?events=dsync.user.created&organization_id=org_1234',
91
90
  'Content-Type' => 'application/json'
92
91
  ]
93
92
 
@@ -98,6 +97,7 @@ describe WorkOS::Events do
98
97
 
99
98
  VCR.use_cassette 'events/list_events_with_organization_id' do
100
99
  events = described_class.list_events(
100
+ events: ['dsync.user.created'],
101
101
  organization_id: 'org_1234',
102
102
  )
103
103
 
@@ -188,7 +188,7 @@ describe WorkOS::MFA do
188
188
  authentication_challenge_id: 'auth_challenge_01FZ4YVRBMXP5ZM0A7BP4AJ12J',
189
189
  code: '897792',
190
190
  )
191
- end.to raise_error(WorkOS::InvalidRequestError)
191
+ end.to raise_error(WorkOS::UnprocessableEntityError)
192
192
  end
193
193
  end
194
194
  end
@@ -201,7 +201,7 @@ describe WorkOS::MFA do
201
201
  authentication_challenge_id: 'auth_challenge_01FZ4YVRBMXP5ZM0A7BP4AJ12J',
202
202
  code: '897792',
203
203
  )
204
- end.to raise_error(WorkOS::InvalidRequestError)
204
+ end.to raise_error(WorkOS::UnprocessableEntityError)
205
205
  end
206
206
  end
207
207
  end
@@ -264,7 +264,7 @@ describe WorkOS::MFA do
264
264
  described_class.get_factor(
265
265
  id: 'auth_factor_invalid',
266
266
  )
267
- end.to raise_error(WorkOS::APIError)
267
+ end.to raise_error(WorkOS::NotFoundError)
268
268
  end
269
269
  end
270
270
  end
@@ -257,7 +257,7 @@ describe WorkOS::Organizations do
257
257
  expect do
258
258
  described_class.get_organization(id: 'invalid')
259
259
  end.to raise_error(
260
- WorkOS::APIError,
260
+ WorkOS::NotFoundError,
261
261
  'Status 404, Not Found - request ID: ',
262
262
  )
263
263
  end
@@ -302,7 +302,7 @@ describe WorkOS::Organizations do
302
302
  expect do
303
303
  described_class.delete_organization(id: 'invalid')
304
304
  end.to raise_error(
305
- WorkOS::APIError,
305
+ WorkOS::NotFoundError,
306
306
  'Status 404, Not Found - request ID: ',
307
307
  )
308
308
  end
@@ -32,7 +32,7 @@ describe WorkOS::Passwordless do
32
32
  expect do
33
33
  described_class.create_session(invalid_options)
34
34
  end.to raise_error(
35
- WorkOS::InvalidRequestError,
35
+ WorkOS::UnprocessableEntityError,
36
36
  /Status 422, Validation failed \(email: email must be a string; type: type must be a valid enum value\)/,
37
37
  )
38
38
  end
@@ -66,7 +66,7 @@ describe WorkOS::Passwordless do
66
66
  expect do
67
67
  described_class.send_session('session_123')
68
68
  end.to raise_error(
69
- WorkOS::InvalidRequestError,
69
+ WorkOS::UnprocessableEntityError,
70
70
  /Status 422, The passwordless session 'session_123' has expired or is invalid./,
71
71
  )
72
72
  end
@@ -618,7 +618,7 @@ describe WorkOS::SSO do
618
618
  expect do
619
619
  WorkOS::SSO.get_connection(id: 'invalid')
620
620
  end.to raise_error(
621
- WorkOS::APIError,
621
+ WorkOS::NotFoundError,
622
622
  'Status 404, Not Found - request ID: ',
623
623
  )
624
624
  end
@@ -645,7 +645,7 @@ describe WorkOS::SSO do
645
645
  expect do
646
646
  WorkOS::SSO.delete_connection(id: 'invalid')
647
647
  end.to raise_error(
648
- WorkOS::APIError,
648
+ WorkOS::NotFoundError,
649
649
  'Status 404, Not Found - request ID: ',
650
650
  )
651
651
  end
@@ -312,7 +312,7 @@ describe WorkOS::UserManagement do
312
312
  expect do
313
313
  described_class.create_user(email: '')
314
314
  end.to raise_error(
315
- WorkOS::InvalidRequestError,
315
+ WorkOS::UnprocessableEntityError,
316
316
  /email_string_required/,
317
317
  )
318
318
  end
@@ -342,7 +342,7 @@ describe WorkOS::UserManagement do
342
342
  VCR.use_cassette 'user_management/update_user/invalid' do
343
343
  expect do
344
344
  described_class.update_user(id: 'invalid')
345
- end.to raise_error(WorkOS::APIError, /User not found/)
345
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
346
346
  end
347
347
  end
348
348
  end
@@ -367,7 +367,7 @@ describe WorkOS::UserManagement do
367
367
  VCR.use_cassette('user_management/delete_user/invalid') do
368
368
  expect do
369
369
  WorkOS::UserManagement.delete_user(id: 'invalid')
370
- end.to raise_error(WorkOS::APIError, /User not found/)
370
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
371
371
  end
372
372
  end
373
373
  end
@@ -400,7 +400,7 @@ describe WorkOS::UserManagement do
400
400
  ip_address: '200.240.210.16',
401
401
  user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/108.0.0.0 Safari/537.36',
402
402
  )
403
- end.to raise_error(WorkOS::APIError, /User not found/)
403
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
404
404
  end
405
405
  end
406
406
  end
@@ -512,7 +512,7 @@ describe WorkOS::UserManagement do
512
512
  client_id: 'client_123',
513
513
  email: 'test@workos.com',
514
514
  )
515
- end.to raise_error(WorkOS::APIError, /User not found/)
515
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
516
516
  end
517
517
  end
518
518
  end
@@ -637,7 +637,7 @@ describe WorkOS::UserManagement do
637
637
  VCR.use_cassette('user_management/get_magic_auth/invalid') do
638
638
  expect do
639
639
  WorkOS::UserManagement.get_magic_auth(id: 'invalid')
640
- end.to raise_error(WorkOS::APIError, /MagicAuth not found/)
640
+ end.to raise_error(WorkOS::NotFoundError, /MagicAuth not found/)
641
641
  end
642
642
  end
643
643
  end
@@ -756,7 +756,7 @@ describe WorkOS::UserManagement do
756
756
  VCR.use_cassette('user_management/get_email_verification/invalid') do
757
757
  expect do
758
758
  WorkOS::UserManagement.get_email_verification(id: 'invalid')
759
- end.to raise_error(WorkOS::APIError, /Email Verification not found/)
759
+ end.to raise_error(WorkOS::NotFoundError, /Email Verification not found/)
760
760
  end
761
761
  end
762
762
  end
@@ -781,7 +781,7 @@ describe WorkOS::UserManagement do
781
781
  described_class.send_verification_email(
782
782
  user_id: 'bad_id',
783
783
  )
784
- end.to raise_error(WorkOS::APIError, /User not found/)
784
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
785
785
  end
786
786
  end
787
787
  end
@@ -810,7 +810,7 @@ describe WorkOS::UserManagement do
810
810
  code: '659770',
811
811
  user_id: 'bad_id',
812
812
  )
813
- end.to raise_error(WorkOS::APIError, /User not found/)
813
+ end.to raise_error(WorkOS::NotFoundError, /User not found/)
814
814
  end
815
815
  end
816
816
  end
@@ -849,7 +849,7 @@ describe WorkOS::UserManagement do
849
849
  VCR.use_cassette('user_management/get_password_reset/invalid') do
850
850
  expect do
851
851
  WorkOS::UserManagement.get_password_reset(id: 'invalid')
852
- end.to raise_error(WorkOS::APIError, /Password Reset not found/)
852
+ end.to raise_error(WorkOS::NotFoundError, /Password Reset not found/)
853
853
  end
854
854
  end
855
855
  end
@@ -893,7 +893,7 @@ describe WorkOS::UserManagement do
893
893
  password_reset_url: '',
894
894
  )
895
895
  end.to raise_error(
896
- WorkOS::InvalidRequestError,
896
+ WorkOS::UnprocessableEntityError,
897
897
  /password_reset_url_string_required/,
898
898
  )
899
899
  end
@@ -924,7 +924,7 @@ describe WorkOS::UserManagement do
924
924
  new_password: 'new_password',
925
925
  )
926
926
  end.to raise_error(
927
- WorkOS::APIError,
927
+ WorkOS::NotFoundError,
928
928
  /Could not locate user with provided token/,
929
929
  )
930
930
  end
@@ -1048,7 +1048,7 @@ describe WorkOS::UserManagement do
1048
1048
  expect do
1049
1049
  described_class.create_organization_membership(user_id: '', organization_id: '')
1050
1050
  end.to raise_error(
1051
- WorkOS::InvalidRequestError,
1051
+ WorkOS::UnprocessableEntityError,
1052
1052
  /user_id_string_required/,
1053
1053
  )
1054
1054
  end
@@ -1075,7 +1075,7 @@ describe WorkOS::UserManagement do
1075
1075
  VCR.use_cassette('user_management/delete_organization_membership/invalid') do
1076
1076
  expect do
1077
1077
  WorkOS::UserManagement.delete_organization_membership(id: 'invalid')
1078
- end.to raise_error(WorkOS::APIError, /Organization Membership not found/)
1078
+ end.to raise_error(WorkOS::NotFoundError, /Organization Membership not found/)
1079
1079
  end
1080
1080
  end
1081
1081
  end
@@ -1150,7 +1150,7 @@ describe WorkOS::UserManagement do
1150
1150
  VCR.use_cassette('user_management/get_invitation/invalid') do
1151
1151
  expect do
1152
1152
  WorkOS::UserManagement.get_invitation(id: 'invalid')
1153
- end.to raise_error(WorkOS::APIError, /Invitation not found/)
1153
+ end.to raise_error(WorkOS::NotFoundError, /Invitation not found/)
1154
1154
  end
1155
1155
  end
1156
1156
  end
@@ -1175,7 +1175,7 @@ describe WorkOS::UserManagement do
1175
1175
  VCR.use_cassette('user_management/find_invitation_by_token/invalid') do
1176
1176
  expect do
1177
1177
  WorkOS::UserManagement.find_invitation_by_token(token: 'invalid')
1178
- end.to raise_error(WorkOS::APIError, /Invitation not found/)
1178
+ end.to raise_error(WorkOS::NotFoundError, /Invitation not found/)
1179
1179
  end
1180
1180
  end
1181
1181
  end
@@ -1346,7 +1346,7 @@ describe WorkOS::UserManagement do
1346
1346
  id: 'invalid_id',
1347
1347
  )
1348
1348
  end.to raise_error(
1349
- WorkOS::APIError,
1349
+ WorkOS::NotFoundError,
1350
1350
  /Invitation not found/,
1351
1351
  )
1352
1352
  end
@@ -1375,7 +1375,7 @@ describe WorkOS::UserManagement do
1375
1375
  session_id: 'session_01H5JQDV7R7ATEYZDEG0W5PRYS',
1376
1376
  )
1377
1377
  end.to raise_error(
1378
- WorkOS::APIError,
1378
+ WorkOS::NotFoundError,
1379
1379
  /Session not found/,
1380
1380
  )
1381
1381
  end
@@ -1,66 +1,66 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.workos.com/events
6
- body:
7
- encoding: UTF-8
8
- string: "{}"
9
- headers:
10
- Content-Type:
11
- - application/json
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - "*/*"
16
- User-Agent:
17
- - WorkOS; ruby/2.6.5; x86_64-darwin19; v0.1.0
18
- Authorization:
19
- - 'Bearer '
20
- response:
21
- status:
22
- code: 401
23
- message: Unauthorized
24
- headers:
25
- Server:
26
- - Cowboy
27
- Connection:
28
- - keep-alive
29
- Access-Control-Allow-Origin:
30
- - https://dashboard.workos-test.com
31
- Vary:
32
- - Origin, Accept-Encoding
33
- Access-Control-Allow-Credentials:
34
- - 'true'
35
- X-Dns-Prefetch-Control:
36
- - 'off'
37
- X-Frame-Options:
38
- - SAMEORIGIN
39
- Strict-Transport-Security:
40
- - max-age=15552000; includeSubDomains
41
- X-Download-Options:
42
- - noopen
43
- X-Content-Type-Options:
44
- - nosniff
45
- X-Xss-Protection:
46
- - 1; mode=block
47
- X-Request-Id:
48
- - 32a67a24-bfaf-4463-bf47-c407d54955d3
49
- Request-Id:
50
- - 32a67a24-bfaf-4463-bf47-c407d54955d3
51
- Content-Type:
52
- - application/json; charset=utf-8
53
- Content-Length:
54
- - '26'
55
- Etag:
56
- - W/"1a-pljHtlo127JYJR4E/RYOPb6ucbw"
57
- Date:
58
- - Sat, 11 Jan 2020 03:50:27 GMT
59
- Via:
60
- - 1.1 vegur
61
- body:
62
- encoding: UTF-8
63
- string: '{"message":"Unauthorized"}'
64
- http_version:
65
- recorded_at: Sat, 11 Jan 2020 03:50:27 GMT
3
+ - request:
4
+ method: post
5
+ uri: https://api.workos.com/audit_logs/events
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ User-Agent:
17
+ - WorkOS; ruby/2.6.5; x86_64-darwin19; v0.1.0
18
+ Authorization:
19
+ - 'Bearer '
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Access-Control-Allow-Origin:
30
+ - https://dashboard.workos-test.com
31
+ Vary:
32
+ - Origin, Accept-Encoding
33
+ Access-Control-Allow-Credentials:
34
+ - 'true'
35
+ X-Dns-Prefetch-Control:
36
+ - 'off'
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Strict-Transport-Security:
40
+ - max-age=15552000; includeSubDomains
41
+ X-Download-Options:
42
+ - noopen
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ X-Request-Id:
48
+ - 32a67a24-bfaf-4463-bf47-c407d54955d3
49
+ Request-Id:
50
+ - 32a67a24-bfaf-4463-bf47-c407d54955d3
51
+ Content-Type:
52
+ - application/json; charset=utf-8
53
+ Content-Length:
54
+ - '26'
55
+ Etag:
56
+ - W/"1a-pljHtlo127JYJR4E/RYOPb6ucbw"
57
+ Date:
58
+ - Sat, 11 Jan 2020 03:50:27 GMT
59
+ Via:
60
+ - 1.1 vegur
61
+ body:
62
+ encoding: UTF-8
63
+ string: '{"message":"Unauthorized"}'
64
+ http_version:
65
+ recorded_at: Sat, 11 Jan 2020 03:50:27 GMT
66
66
  recorded_with: VCR 5.0.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.workos.com/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1
5
+ uri: https://api.workos.com/events?after=event_01FGCPNV312FHFRCX0BYWHVSE1&events=dsync.user.created
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -14,40 +14,42 @@ http_interactions:
14
14
  Accept:
15
15
  - "*/*"
16
16
  User-Agent:
17
- - WorkOS; ruby/2.7.2; arm64-darwin21; v2.3.0
17
+ - WorkOS; ruby/3.3.0; arm64-darwin23; v4.1.0
18
18
  Authorization:
19
19
  - Bearer <API_KEY>
20
20
  response:
21
21
  status:
22
- code: 200
23
- message: OK
22
+ code: 400
23
+ message: Bad Request
24
24
  headers:
25
25
  Date:
26
- - Thu, 14 Jul 2022 16:46:23 GMT
26
+ - Thu, 11 Apr 2024 15:44:49 GMT
27
27
  Content-Type:
28
28
  - application/json; charset=utf-8
29
29
  Content-Length:
30
- - '616'
30
+ - '140'
31
31
  Connection:
32
32
  - keep-alive
33
+ Cf-Ray:
34
+ - 872c19a65dcb3af9-IAD
35
+ Cf-Cache-Status:
36
+ - DYNAMIC
37
+ Etag:
38
+ - W/"8c-3NPoweNh0oXUDzElVKxg5PG7PWk"
39
+ Strict-Transport-Security:
40
+ - max-age=15552000; includeSubDomains
41
+ Vary:
42
+ - Origin, Accept-Encoding
33
43
  Access-Control-Allow-Credentials:
34
44
  - 'true'
35
45
  Content-Security-Policy:
36
46
  - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
37
47
  https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
38
48
  ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
39
- Etag:
40
- - W/"680-NPvBik348v8xg6EE7iZMYwD5UXw"
41
49
  Expect-Ct:
42
50
  - max-age=0
43
51
  Referrer-Policy:
44
52
  - no-referrer
45
- Strict-Transport-Security:
46
- - max-age=15552000; includeSubDomains
47
- Vary:
48
- - Origin, Accept-Encoding
49
- Via:
50
- - 1.1 spaces-router (b642bf20b975)
51
53
  X-Content-Type-Options:
52
54
  - nosniff
53
55
  X-Dns-Prefetch-Control:
@@ -59,22 +61,21 @@ http_interactions:
59
61
  X-Permitted-Cross-Domain-Policies:
60
62
  - none
61
63
  X-Request-Id:
62
- - 51a82273-b413-cead-b968-c07ba4d6fd08
64
+ - 660c0035-b70d-4939-a0d3-2b0917535e7f
63
65
  X-Xss-Protection:
64
66
  - '0'
65
- Cf-Cache-Status:
66
- - DYNAMIC
67
- Report-To:
68
- - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=OS7ELJ3A8tkzMafvaIThD%2B5JlYmul1puZlAXTxEKYBLlq%2B6DCtqDqAi4dtr4yRP3khNmg6MwPiuLqtdOXRmPOtag9Ti%2FGK8ra%2BJOlpwkFjD965CNBfzao4EJtExDkbS3"}],"group":"cf-nel","max_age":604800}'
69
- Nel:
70
- - '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
67
+ Set-Cookie:
68
+ - __cf_bm=UpBr7jsatrWLaunHA8NhaflwkUco6FBxeXhgwz2bAoM-1712850289-1.0.1.1-KJCKaoohiG088DieTdV2V91AtW1fbs7ec.x7gsal9xsVzA2OPf67b0R__57KFvEsEZ97obgydtH.VEwyYhpGTw;
69
+ path=/; expires=Thu, 11-Apr-24 16:14:49 GMT; domain=.workos.com; HttpOnly;
70
+ Secure; SameSite=None
71
+ - __cfruid=bbad8ba60df9a023f0ba77749b5c0b92162e6ed3-1712850289; path=/; domain=.workos.com;
72
+ HttpOnly; Secure; SameSite=None
71
73
  Server:
72
74
  - cloudflare
73
- Cf-Ray:
74
- - 72abbbf2b93e8ca5-EWR
75
75
  body:
76
- encoding: ASCII-8BIT
77
- string: '{"object":"list","data":[{"object":"event","id":"event_01FK3HFFGMC2WF32RR8SKWC8KA","event":"dsync.user.created","created_at":"2021-10-28T13:29:54.451Z","data":{"email":"foo@foocorp.com"}}], "list_metadata":{"after":null}}'
76
+ encoding: UTF-8
77
+ string: '{"message":"One or more event names (e.g. dsync.user.created) must
78
+ be provided using the events parameter.","code":"invalid_events_request"}'
78
79
  http_version:
79
- recorded_at: Thu, 14 Jul 2022 16:46:23 GMT
80
+ recorded_at: Thu, 11 Apr 2024 15:44:49 GMT
80
81
  recorded_with: VCR 5.0.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.workos.com/events?organization_id=org_1234
5
+ uri: https://api.workos.com/events?events=dsync.user.created&organization_id=org_1234
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.workos.com/events?range_end=2023-01-03T00:00:00Z&range_start=2023-01-01T00:00:00Z
5
+ uri: https://api.workos.com/events?events=dsync.user.created&range_end=2023-01-03T00:00:00Z&range_start=2023-01-01T00:00:00Z
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-04 00:00:00.000000000 Z
11
+ date: 2024-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -152,6 +152,7 @@ files:
152
152
  - lib/workos/webhook.rb
153
153
  - lib/workos/webhooks.rb
154
154
  - spec/lib/workos/audit_logs_spec.rb
155
+ - spec/lib/workos/client.rb
155
156
  - spec/lib/workos/configuration_spec.rb
156
157
  - spec/lib/workos/directory_sync_spec.rb
157
158
  - spec/lib/workos/directory_user_spec.rb
@@ -359,6 +360,7 @@ specification_version: 4
359
360
  summary: API client for WorkOS
360
361
  test_files:
361
362
  - spec/lib/workos/audit_logs_spec.rb
363
+ - spec/lib/workos/client.rb
362
364
  - spec/lib/workos/configuration_spec.rb
363
365
  - spec/lib/workos/directory_sync_spec.rb
364
366
  - spec/lib/workos/directory_user_spec.rb