workos 0.9.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +8 -2
  5. data/Gemfile.lock +49 -36
  6. data/README.md +15 -15
  7. data/docs/WorkOS/SSO.html +235 -235
  8. data/docs/file.README.html +20 -20
  9. data/lib/workos.rb +3 -0
  10. data/lib/workos/client.rb +25 -4
  11. data/lib/workos/connection.rb +8 -1
  12. data/lib/workos/directory.rb +53 -0
  13. data/lib/workos/directory_group.rb +44 -0
  14. data/lib/workos/directory_sync.rb +63 -7
  15. data/lib/workos/directory_user.rb +60 -0
  16. data/lib/workos/passwordless.rb +0 -2
  17. data/lib/workos/portal.rb +1 -7
  18. data/lib/workos/profile.rb +3 -4
  19. data/lib/workos/sso.rb +150 -17
  20. data/lib/workos/types.rb +3 -0
  21. data/lib/workos/types/connection_struct.rb +2 -0
  22. data/lib/workos/types/directory_group_struct.rb +13 -0
  23. data/lib/workos/types/directory_struct.rb +16 -0
  24. data/lib/workos/types/directory_user_struct.rb +18 -0
  25. data/lib/workos/types/intent_enum.rb +1 -0
  26. data/lib/workos/version.rb +1 -1
  27. data/sorbet/rbi/gems/addressable.rbi +199 -0
  28. data/sorbet/rbi/gems/ast.rbi +49 -0
  29. data/sorbet/rbi/gems/codecov.rbi +37 -0
  30. data/sorbet/rbi/gems/crack.rbi +62 -0
  31. data/sorbet/rbi/gems/docile.rbi +36 -0
  32. data/sorbet/rbi/gems/hashdiff.rbi +66 -0
  33. data/sorbet/rbi/gems/parallel.rbi +83 -0
  34. data/sorbet/rbi/gems/parser.rbi +1429 -0
  35. data/sorbet/rbi/gems/public_suffix.rbi +104 -0
  36. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  37. data/sorbet/rbi/gems/rake.rbi +644 -0
  38. data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
  39. data/sorbet/rbi/gems/rexml.rbi +628 -0
  40. data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
  41. data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
  42. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  43. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  44. data/sorbet/rbi/gems/rspec.rbi +15 -0
  45. data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
  46. data/sorbet/rbi/gems/rubocop.rbi +7253 -0
  47. data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
  48. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  49. data/sorbet/rbi/gems/simplecov.rbi +406 -0
  50. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  51. data/sorbet/rbi/gems/vcr.rbi +572 -0
  52. data/sorbet/rbi/gems/webmock.rbi +556 -0
  53. data/sorbet/rbi/gems/yard.rbi +1165 -0
  54. data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
  55. data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
  56. data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
  57. data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
  58. data/sorbet/rbi/todo.rbi +1 -3
  59. data/spec/lib/workos/audit_trail_spec.rb +0 -8
  60. data/spec/lib/workos/directory_sync_spec.rb +347 -40
  61. data/spec/lib/workos/passwordless_spec.rb +0 -8
  62. data/spec/lib/workos/portal_spec.rb +18 -11
  63. data/spec/lib/workos/sso_spec.rb +299 -29
  64. data/spec/spec_helper.rb +2 -1
  65. data/spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml +2 -2
  66. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  67. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_after.yml +72 -0
  68. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_before.yml +72 -0
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories_with_domain_param.yml → list_directories/with_domain.yml} +19 -9
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_limit.yml +74 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users_with_directory_param.yml → list_directories/with_search.yml} +22 -11
  73. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  74. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  75. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  76. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
  77. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  78. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  79. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  80. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  81. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  82. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  83. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  84. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  85. data/spec/support/fixtures/vcr_cassettes/portal/generate_link_dsync.yml +72 -0
  86. data/spec/support/fixtures/vcr_cassettes/portal/{generate_link.yml → generate_link_sso.yml} +1 -1
  87. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
  88. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_invalid_id.yml +72 -0
  89. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_valid_id.yml +70 -0
  90. data/spec/support/fixtures/vcr_cassettes/{directory_sync/list_groups_with_directory_param.yml → sso/get_connection_with_invalid_id.yml} +21 -11
  91. data/spec/support/fixtures/vcr_cassettes/sso/get_connection_with_valid_id.yml +74 -0
  92. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  93. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  94. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  95. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_domain.yml +72 -0
  96. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  97. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  98. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_organization_id.yml +72 -0
  99. data/workos.gemspec +2 -0
  100. metadata +109 -28
  101. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  102. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  103. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  104. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  105. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  106. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # The DirectoryUser class provides a lightweight wrapper around
6
+ # a WorkOS DirectoryUser resource. This class is not meant to be instantiated
7
+ # in DirectoryUser space, and is instantiated internally but exposed.
8
+ class DirectoryUser
9
+ extend T::Sig
10
+
11
+ attr_accessor :id, :emails, :first_name, :last_name, :username, :state,
12
+ :raw_attributes
13
+
14
+ sig { params(json: String).void }
15
+ def initialize(json)
16
+ raw = parse_json(json)
17
+
18
+ @id = T.let(raw.id, String)
19
+ @emails = T.let(raw.emails, Array)
20
+ @first_name = raw.first_name
21
+ @last_name = raw.last_name
22
+ @username = raw.username
23
+ @state = raw.state
24
+ @raw_attributes = raw.raw_attributes
25
+ end
26
+
27
+ def to_json(*)
28
+ {
29
+ id: id,
30
+ emails: emails,
31
+ first_name: first_name,
32
+ last_name: last_name,
33
+ username: username,
34
+ state: state,
35
+ raw_attributes: raw_attributes,
36
+ }
37
+ end
38
+
39
+ private
40
+
41
+ sig do
42
+ params(
43
+ json_string: String,
44
+ ).returns(WorkOS::Types::DirectoryUserStruct)
45
+ end
46
+ def parse_json(json_string)
47
+ hash = JSON.parse(json_string, symbolize_names: true)
48
+
49
+ WorkOS::Types::DirectoryUserStruct.new(
50
+ id: hash[:id],
51
+ emails: hash[:emails],
52
+ first_name: hash[:first_name],
53
+ last_name: hash[:last_name],
54
+ username: hash[:username],
55
+ state: hash[:state],
56
+ raw_attributes: hash[:raw_attributes],
57
+ )
58
+ end
59
+ end
60
+ end
@@ -36,7 +36,6 @@ module WorkOS
36
36
  ).returns(WorkOS::Types::PasswordlessSessionStruct)
37
37
  end
38
38
 
39
- # rubocop:disable Metrics/MethodLength
40
39
  def create_session(options)
41
40
  response = execute_request(
42
41
  request: post_request(
@@ -55,7 +54,6 @@ module WorkOS
55
54
  link: hash['link'],
56
55
  )
57
56
  end
58
- # rubocop:enable Metrics/MethodLength
59
57
 
60
58
  # Send a Passwordless Session via email.
61
59
  #
data/lib/workos/portal.rb CHANGED
@@ -42,7 +42,7 @@ module WorkOS
42
42
  # Generate a link to grant access to an organization's Admin Portal
43
43
  #
44
44
  # @param [String] intent The access scope for the generated Admin Portal
45
- # link. Valid values are: ["sso"]
45
+ # link. Valid values are: ["sso", "dsync"]
46
46
  # @param [String] organization The ID of the organization the Admin
47
47
  # Portal link will be generated for.
48
48
  # @param [String] The URL that the end user will be redirected to upon
@@ -55,7 +55,6 @@ module WorkOS
55
55
  return_url: T.nilable(String),
56
56
  ).returns(String)
57
57
  end
58
- # rubocop:disable Metrics/MethodLength
59
58
  def generate_link(intent:, organization:, return_url: nil)
60
59
  validate_intent(intent)
61
60
 
@@ -73,7 +72,6 @@ module WorkOS
73
72
 
74
73
  JSON.parse(response.body)['link']
75
74
  end
76
- # rubocop:enable Metrics/MethodLength
77
75
 
78
76
  # Retrieve a list of organizations that have connections configured
79
77
  # within your WorkOS dashboard.
@@ -91,7 +89,6 @@ module WorkOS
91
89
  options: T::Hash[Symbol, String],
92
90
  ).returns(WorkOS::Types::ListStruct)
93
91
  end
94
- # rubocop:disable Metrics/MethodLength
95
92
  def list_organizations(options = {})
96
93
  response = execute_request(
97
94
  request: get_request(
@@ -112,12 +109,10 @@ module WorkOS
112
109
  list_metadata: parsed_response['listMetadata'],
113
110
  )
114
111
  end
115
- # rubocop:enable Metrics/MethodLength
116
112
 
117
113
  private
118
114
 
119
115
  sig { params(response: Net::HTTPResponse).void }
120
- # rubocop:disable Metrics/MethodLength
121
116
  def check_and_raise_organization_error(response:)
122
117
  begin
123
118
  body = JSON.parse(response.body)
@@ -135,7 +130,6 @@ module WorkOS
135
130
  request_id: request_id,
136
131
  )
137
132
  end
138
- # rubocop:enable Metrics/MethodLength
139
133
 
140
134
  sig { params(intent: String).void }
141
135
  def validate_intent(intent)
@@ -13,7 +13,7 @@ module WorkOS
13
13
  sig { returns(String) }
14
14
  attr_accessor :id, :email, :first_name, :last_name, :connection_id,
15
15
  :connection_type, :idp_id, :raw_attributes
16
- # rubocop:disable Metrics/AbcSize
16
+
17
17
  sig { params(profile_json: String).void }
18
18
  def initialize(profile_json)
19
19
  raw = parse_json(profile_json)
@@ -27,7 +27,6 @@ module WorkOS
27
27
  @idp_id = raw.idp_id
28
28
  @raw_attributes = raw.raw_attributes
29
29
  end
30
- # rubocop:enable Metrics/AbcSize
31
30
 
32
31
  sig { returns(String) }
33
32
  def full_name
@@ -49,7 +48,7 @@ module WorkOS
49
48
 
50
49
  private
51
50
 
52
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
51
+ # rubocop:disable Metrics/AbcSize
53
52
  sig { params(json_string: String).returns(WorkOS::Types::ProfileStruct) }
54
53
  def parse_json(json_string)
55
54
  hash = JSON.parse(json_string, symbolize_names: true)
@@ -65,6 +64,6 @@ module WorkOS
65
64
  raw_attributes: hash[:profile][:raw_attributes],
66
65
  )
67
66
  end
68
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
67
+ # rubocop:enable Metrics/AbcSize
69
68
  end
70
69
  end
data/lib/workos/sso.rb CHANGED
@@ -6,7 +6,7 @@ require 'uri'
6
6
 
7
7
  module WorkOS
8
8
  # The SSO module provides convenience methods for working with the WorkOS
9
- # SSO platform. You'll need a valid API key, a project ID, and to have
9
+ # SSO platform. You'll need a valid API key, a client ID, and to have
10
10
  # created an SSO connection on your WorkOS dashboard.
11
11
  #
12
12
  # @see https://docs.workos.com/sso/overview
@@ -26,8 +26,12 @@ module WorkOS
26
26
  # required
27
27
  # @param [String] provider A provider name for an Identity Provider
28
28
  # configured on your WorkOS dashboard. Only 'Google' is supported.
29
- # @param [String] project_id The WorkOS project ID for the project
29
+ # @param [String] connection The ID for a Connection configured on
30
+ # WorkOS.
31
+ # @param [String] client_id The WorkOS client ID for the environment
30
32
  # where you've configured your SSO connection.
33
+ # @param [String] project_id The WorkOS project ID for the project.
34
+ # The project_id is deprecated in Dashboard2.
31
35
  # @param [String] redirect_uri The URI where users are directed
32
36
  # after completing the authentication step. Must match a
33
37
  # configured redirect URI on your WorkOS dashboard.
@@ -36,7 +40,7 @@ module WorkOS
36
40
  # @example
37
41
  # WorkOS::SSO.authorization_url(
38
42
  # domain: 'acme.com',
39
- # project_id: 'project_01DG5TGK363GRVXP3ZS40WNGEZ',
43
+ # client_id: 'project_01DG5TGK363GRVXP3ZS40WNGEZ',
40
44
  # redirect_uri: 'https://workos.com/callback',
41
45
  # state: {
42
46
  # next_page: '/docs'
@@ -51,40 +55,63 @@ module WorkOS
51
55
  # @return [String]
52
56
  sig do
53
57
  params(
54
- project_id: String,
55
58
  redirect_uri: String,
59
+ project_id: T.nilable(String),
60
+ client_id: T.nilable(String),
56
61
  domain: T.nilable(String),
57
62
  provider: T.nilable(String),
63
+ connection: T.nilable(String),
58
64
  state: T.nilable(String),
59
65
  ).returns(String)
60
66
  end
67
+ # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
61
68
  def authorization_url(
62
- project_id:, redirect_uri:, domain: nil, provider: nil, state: ''
69
+ redirect_uri:,
70
+ project_id: nil,
71
+ client_id: nil,
72
+ domain: nil,
73
+ provider: nil,
74
+ connection: nil,
75
+ state: ''
63
76
  )
64
- validate_domain_and_provider(provider: provider, domain: domain)
77
+ if project_id
78
+ warn '[DEPRECATION] `project_id` is deprecated.
79
+ Please use `client_id` instead.'
80
+ client_id = project_id
81
+ end
82
+
83
+ validate_authorization_url_arguments(
84
+ provider: provider,
85
+ domain: domain,
86
+ connection: connection,
87
+ )
65
88
 
66
89
  query = URI.encode_www_form({
67
- client_id: project_id,
90
+ client_id: client_id,
68
91
  redirect_uri: redirect_uri,
69
92
  response_type: 'code',
70
93
  state: state,
71
94
  domain: domain,
72
95
  provider: provider,
96
+ connection: connection,
73
97
  }.compact)
74
98
 
75
99
  "https://#{WorkOS::API_HOSTNAME}/sso/authorize?#{query}"
76
100
  end
101
+ # rubocop:enable Metrics/MethodLength, Metrics/ParameterLists
77
102
 
78
103
  # Fetch the profile details for the authenticated SSO user.
79
104
  #
80
105
  # @param [String] code The authorization code provided in the callback URL
81
- # @param [String] project_id The WorkOS project ID for the project
106
+ # @param [String] client_id The WorkOS client ID for the environment
82
107
  # where you've configured your SSO connection
108
+ # @param [String] project_id The WorkOS project ID for the project.
109
+ # The project_id is deprecated in Dashboard2.
83
110
  #
84
111
  # @example
85
112
  # WorkOS::SSO.profile(
86
113
  # code: 'acme.com',
87
- # project_id: 'project_01DG5TGK363GRVXP3ZS40WNGEZ'
114
+ # client_id: 'project_01DG5TGK363GRVXP3ZS40WNGEZ'
88
115
  # )
89
116
  # => #<WorkOS::Profile:0x00007fb6e4193d20
90
117
  # @id="prof_01DRA1XNSJDZ19A31F183ECQW5",
@@ -97,10 +124,22 @@ module WorkOS
97
124
  # >
98
125
  #
99
126
  # @return [WorkOS::Profile]
100
- sig { params(code: String, project_id: String).returns(WorkOS::Profile) }
101
- def profile(code:, project_id:)
127
+ sig do
128
+ params(
129
+ code: String,
130
+ project_id: T.nilable(String),
131
+ client_id: T.nilable(String),
132
+ ).returns(WorkOS::Profile)
133
+ end
134
+ def profile(code:, project_id: nil, client_id: nil)
135
+ if project_id
136
+ warn '[DEPRECATION] `project_id` is deprecated.
137
+ Please use `client_id` instead.'
138
+ client_id = project_id
139
+ end
140
+
102
141
  body = {
103
- client_id: project_id,
142
+ client_id: client_id,
104
143
  client_secret: WorkOS.key!,
105
144
  grant_type: 'authorization_code',
106
145
  code: code,
@@ -168,17 +207,113 @@ module WorkOS
168
207
  WorkOS::Connection.new(response.body)
169
208
  end
170
209
 
210
+ # Retrieve connections.
211
+ #
212
+ # @param [Hash] options An options hash
213
+ # @option options [String] connection_type Authentication service
214
+ # provider descriptor.
215
+ # @option options [String] domain The domain of the connection to be
216
+ # retrieved.
217
+ # @option options [String] organization_id The id of the organization
218
+ # of the connections to be retrieved.
219
+ # @option options [String] limit Maximum number of records to return.
220
+ # @option options [String] before Pagination cursor to receive records
221
+ # before a provided Connection ID.
222
+ # @option options [String] after Pagination cursor to receive records
223
+ # before a provided Connection ID.
224
+ #
225
+ # @return [Hash]
226
+ sig do
227
+ params(
228
+ options: T::Hash[Symbol, String],
229
+ ).returns(WorkOS::Types::ListStruct)
230
+ end
231
+ def list_connections(options = {})
232
+ response = execute_request(
233
+ request: get_request(
234
+ path: '/connections',
235
+ auth: true,
236
+ params: options,
237
+ ),
238
+ )
239
+
240
+ parsed_response = JSON.parse(response.body)
241
+ connections = parsed_response['data'].map do |connection|
242
+ ::WorkOS::Connection.new(connection.to_json)
243
+ end
244
+
245
+ WorkOS::Types::ListStruct.new(
246
+ data: connections,
247
+ list_metadata: parsed_response['listMetadata'],
248
+ )
249
+ end
250
+
251
+ # Get a Connection
252
+ #
253
+ # @param [String] id Connection unique identifier
254
+ #
255
+ # @example
256
+ # WorkOS::SSO.get_connection(id: 'conn_02DRA1XNSJDZ19A31F183ECQW9')
257
+ # => #<WorkOS::Connection:0x00007fb6e4193d20
258
+ # @id="conn_02DRA1XNSJDZ19A31F183ECQW9",
259
+ # @name="Foo Corp",
260
+ # @connection_type="OktaSAML",
261
+ # @domains=
262
+ # [{:object=>"connection_domain",
263
+ # :id=>"domain_01E6PK9N3XMD8RHWF7S66380AR",
264
+ # :domain=>"example.com"}]>
265
+ #
266
+ # @return [WorkOS::Connection]
267
+ sig { params(id: String).returns(WorkOS::Connection) }
268
+ def get_connection(id:)
269
+ request = get_request(
270
+ auth: true,
271
+ path: "/connections/#{id}",
272
+ )
273
+
274
+ response = execute_request(request: request)
275
+
276
+ WorkOS::Connection.new(response.body)
277
+ end
278
+
279
+ # Delete a Connection
280
+ #
281
+ # @param [String] id Connection unique identifier
282
+ #
283
+ # @example
284
+ # WorkOS::SSO.delete_connection(id: 'conn_02DRA1XNSJDZ19A31F183ECQW9')
285
+ # => true
286
+ #
287
+ # @return [Bool] - returns `true` if successful
288
+ sig { params(id: String).returns(T::Boolean) }
289
+ def delete_connection(id:)
290
+ request = delete_request(
291
+ auth: true,
292
+ path: "/connections/#{id}",
293
+ )
294
+
295
+ response = execute_request(request: request)
296
+
297
+ response.is_a? Net::HTTPSuccess
298
+ end
299
+
171
300
  private
172
301
 
173
302
  sig do
174
303
  params(
175
304
  domain: T.nilable(String),
176
305
  provider: T.nilable(String),
306
+ connection: T.nilable(String),
177
307
  ).void
178
308
  end
179
- def validate_domain_and_provider(domain:, provider:)
180
- if [domain, provider].all?(&:nil?)
181
- raise ArgumentError, 'Either domain or provider is required.'
309
+ def validate_authorization_url_arguments(
310
+ domain:,
311
+ provider:,
312
+ connection:
313
+ )
314
+ if [domain, provider, connection].all?(&:nil?)
315
+ raise ArgumentError, 'Either connection, domain, or ' \
316
+ 'provider is required.'
182
317
  end
183
318
 
184
319
  return unless provider && !PROVIDERS.include?(provider)
@@ -187,7 +322,6 @@ module WorkOS
187
322
  " `provider` must be in #{PROVIDERS}"
188
323
  end
189
324
 
190
- # rubocop:disable Metrics/MethodLength
191
325
  sig { params(response: Net::HTTPResponse).void }
192
326
  def check_and_raise_profile_error(response:)
193
327
  begin
@@ -206,7 +340,6 @@ module WorkOS
206
340
  request_id: request_id,
207
341
  )
208
342
  end
209
- # rubocop:enable Metrics/MethodLength
210
343
  end
211
344
  end
212
345
  end
data/lib/workos/types.rb CHANGED
@@ -6,11 +6,14 @@ module WorkOS
6
6
  # so we're using Sorbet throughout this Ruby gem.
7
7
  module Types
8
8
  require_relative 'types/connection_struct'
9
+ require_relative 'types/directory_struct'
10
+ require_relative 'types/directory_group_struct'
9
11
  require_relative 'types/intent_enum'
10
12
  require_relative 'types/list_struct'
11
13
  require_relative 'types/organization_struct'
12
14
  require_relative 'types/passwordless_session_struct'
13
15
  require_relative 'types/profile_struct'
14
16
  require_relative 'types/provider_enum'
17
+ require_relative 'types/directory_user_struct'
15
18
  end
16
19
  end
@@ -10,6 +10,8 @@ module WorkOS
10
10
  const :name, String
11
11
  const :connection_type, String
12
12
  const :domains, T::Array[T.untyped]
13
+ const :organization_id, String
14
+ const :status, String
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ # typed: strict
3
+
4
+ module WorkOS
5
+ module Types
6
+ # This DirectoryGroupStruct acts as a typed interface
7
+ # for the DirectoryGroup class
8
+ class DirectoryGroupStruct < T::Struct
9
+ const :id, String
10
+ const :name, String
11
+ end
12
+ end
13
+ end