workos 0.10.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +8 -2
  5. data/Gemfile.lock +49 -36
  6. data/README.md +13 -230
  7. data/lib/workos.rb +3 -0
  8. data/lib/workos/client.rb +21 -4
  9. data/lib/workos/connection.rb +12 -1
  10. data/lib/workos/directory.rb +53 -0
  11. data/lib/workos/directory_group.rb +44 -0
  12. data/lib/workos/directory_sync.rb +63 -7
  13. data/lib/workos/directory_user.rb +63 -0
  14. data/lib/workos/passwordless.rb +4 -0
  15. data/lib/workos/portal.rb +54 -1
  16. data/lib/workos/profile.rb +1 -2
  17. data/lib/workos/sso.rb +31 -6
  18. data/lib/workos/types.rb +3 -0
  19. data/lib/workos/types/connection_struct.rb +3 -0
  20. data/lib/workos/types/directory_group_struct.rb +13 -0
  21. data/lib/workos/types/directory_struct.rb +16 -0
  22. data/lib/workos/types/directory_user_struct.rb +19 -0
  23. data/lib/workos/types/intent_enum.rb +1 -0
  24. data/lib/workos/version.rb +1 -1
  25. data/sorbet/rbi/gems/addressable.rbi +199 -0
  26. data/sorbet/rbi/gems/ast.rbi +49 -0
  27. data/sorbet/rbi/gems/codecov.rbi +37 -0
  28. data/sorbet/rbi/gems/crack.rbi +62 -0
  29. data/sorbet/rbi/gems/docile.rbi +36 -0
  30. data/sorbet/rbi/gems/hashdiff.rbi +66 -0
  31. data/sorbet/rbi/gems/parallel.rbi +83 -0
  32. data/sorbet/rbi/gems/parser.rbi +1429 -0
  33. data/sorbet/rbi/gems/public_suffix.rbi +104 -0
  34. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  35. data/sorbet/rbi/gems/rake.rbi +644 -0
  36. data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
  37. data/sorbet/rbi/gems/rexml.rbi +628 -0
  38. data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
  39. data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
  40. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  41. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  42. data/sorbet/rbi/gems/rspec.rbi +15 -0
  43. data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
  44. data/sorbet/rbi/gems/rubocop.rbi +7253 -0
  45. data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
  46. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  47. data/sorbet/rbi/gems/simplecov.rbi +406 -0
  48. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  49. data/sorbet/rbi/gems/vcr.rbi +572 -0
  50. data/sorbet/rbi/gems/webmock.rbi +556 -0
  51. data/sorbet/rbi/gems/yard.rbi +1165 -0
  52. data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
  53. data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
  54. data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
  55. data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
  56. data/sorbet/rbi/todo.rbi +1 -3
  57. data/spec/lib/workos/audit_trail_spec.rb +0 -8
  58. data/spec/lib/workos/directory_sync_spec.rb +347 -40
  59. data/spec/lib/workos/passwordless_spec.rb +0 -8
  60. data/spec/lib/workos/portal_spec.rb +65 -11
  61. data/spec/lib/workos/sso_spec.rb +142 -76
  62. data/spec/spec_helper.rb +2 -1
  63. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  64. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections.yml → directory_sync/list_directories/with_after.yml} +7 -7
  65. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_limit_param.yml → directory_sync/list_directories/with_before.yml} +8 -8
  66. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_connection_type_param.yml → directory_sync/list_directories/with_domain.yml} +11 -10
  67. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_limit.yml +74 -0
  68. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_search.yml +73 -0
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  73. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_before_param.yml → directory_sync/list_groups/with_limit.yml} +12 -11
  74. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  75. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  76. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  77. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  78. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  79. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  80. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  81. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  82. data/spec/support/fixtures/vcr_cassettes/organization/get.yml +73 -0
  83. data/spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml +72 -0
  84. data/spec/support/fixtures/vcr_cassettes/organization/update.yml +73 -0
  85. data/spec/support/fixtures/vcr_cassettes/organization/update_invalid.yml +73 -0
  86. data/spec/support/fixtures/vcr_cassettes/portal/generate_link_dsync.yml +72 -0
  87. data/spec/support/fixtures/vcr_cassettes/portal/{generate_link.yml → generate_link_sso.yml} +1 -1
  88. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
  89. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  90. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  91. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  92. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_domain_param.yml → list_connections/with_domain.yml} +6 -6
  93. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  94. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  95. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_organization_id_param.yml → list_connections/with_organization_id.yml} +6 -6
  96. data/workos.gemspec +2 -0
  97. metadata +109 -42
  98. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  99. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  100. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  101. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  102. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  103. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
  104. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +0 -63
  105. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +0 -62
  106. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +0 -62
  107. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_after_param.yml +0 -72
data/lib/workos/client.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ # typed: false
3
3
 
4
4
  module WorkOS
5
5
  # A Net::HTTP based API client for interacting with the WorkOS API
@@ -19,7 +19,7 @@ module WorkOS
19
19
 
20
20
  sig do
21
21
  params(
22
- request: T.any(Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Delete),
22
+ request: T.any(Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Delete, Net::HTTP::Put),
23
23
  ).returns(::T.untyped)
24
24
  end
25
25
  def execute_request(request:)
@@ -90,6 +90,23 @@ module WorkOS
90
90
  request
91
91
  end
92
92
 
93
+ sig do
94
+ params(
95
+ path: String,
96
+ auth: T.nilable(T::Boolean),
97
+ idempotency_key: T.nilable(String),
98
+ body: T.nilable(Hash),
99
+ ).returns(Net::HTTP::Put)
100
+ end
101
+ def put_request(path:, auth: false, idempotency_key: nil, body: nil)
102
+ request = Net::HTTP::Put.new(path, 'Content-Type' => 'application/json')
103
+ request.body = body.to_json if body
104
+ request['Authorization'] = "Bearer #{WorkOS.key!}" if auth
105
+ request['Idempotency-Key'] = idempotency_key if idempotency_key
106
+ request['User-Agent'] = user_agent
107
+ request
108
+ end
109
+
93
110
  sig { returns(String) }
94
111
  def user_agent
95
112
  engine = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : 'Ruby'
@@ -102,7 +119,7 @@ module WorkOS
102
119
  ].join('; ')
103
120
  end
104
121
 
105
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
122
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
106
123
  sig { params(response: ::T.untyped).void }
107
124
  def handle_error_response(response:)
108
125
  http_status = response.code.to_i
@@ -139,7 +156,7 @@ module WorkOS
139
156
  )
140
157
  end
141
158
  end
142
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
159
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
143
160
 
144
161
  private
145
162
 
@@ -5,10 +5,12 @@ module WorkOS
5
5
  # The Connection class provides a lightweight wrapper around
6
6
  # a WorkOS Connection resource. This class is not meant to be instantiated
7
7
  # in user space, and is instantiated internally but exposed.
8
+ # Note: status is deprecated - use state instead
8
9
  class Connection
9
10
  extend T::Sig
10
11
 
11
- attr_accessor :id, :name, :connection_type, :domains
12
+ attr_accessor :id, :name, :connection_type, :domains, :organization_id,
13
+ :state, :status
12
14
 
13
15
  sig { params(json: String).void }
14
16
  def initialize(json)
@@ -18,6 +20,9 @@ module WorkOS
18
20
  @name = T.let(raw.name, String)
19
21
  @connection_type = T.let(raw.connection_type, String)
20
22
  @domains = T.let(raw.domains, Array)
23
+ @organization_id = T.let(raw.organization_id, String)
24
+ @state = T.let(raw.state, String)
25
+ @status = T.let(raw.status, String)
21
26
  end
22
27
 
23
28
  def to_json(*)
@@ -26,6 +31,9 @@ module WorkOS
26
31
  name: name,
27
32
  connection_type: connection_type,
28
33
  domains: domains,
34
+ organization_id: organization_id,
35
+ state: state,
36
+ status: status,
29
37
  }
30
38
  end
31
39
 
@@ -40,6 +48,9 @@ module WorkOS
40
48
  name: hash[:name],
41
49
  connection_type: hash[:connection_type],
42
50
  domains: hash[:domains],
51
+ organization_id: hash[:organization_id],
52
+ state: hash[:state],
53
+ status: hash[:status],
43
54
  )
44
55
  end
45
56
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # The Directory class provides a lightweight wrapper around
6
+ # a WorkOS Directory resource. This class is not meant to be instantiated
7
+ # in user space, and is instantiated internally but exposed.
8
+ class Directory
9
+ extend T::Sig
10
+
11
+ attr_accessor :id, :domain, :name, :type, :state
12
+
13
+ sig { params(json: String).void }
14
+ def initialize(json)
15
+ raw = parse_json(json)
16
+
17
+ @id = T.let(raw.id, String)
18
+ @name = T.let(raw.name, String)
19
+ @domain = T.let(raw.domain, String)
20
+ @type = T.let(raw.type, String)
21
+ @state = T.let(raw.state, String)
22
+ end
23
+
24
+ def to_json(*)
25
+ {
26
+ id: id,
27
+ name: name,
28
+ domain: domain,
29
+ type: type,
30
+ state: state,
31
+ }
32
+ end
33
+
34
+ private
35
+
36
+ sig do
37
+ params(
38
+ json_string: String,
39
+ ).returns(WorkOS::Types::DirectoryStruct)
40
+ end
41
+ def parse_json(json_string)
42
+ hash = JSON.parse(json_string, symbolize_names: true)
43
+
44
+ WorkOS::Types::DirectoryStruct.new(
45
+ id: hash[:id],
46
+ name: hash[:name],
47
+ domain: hash[:domain],
48
+ type: hash[:type],
49
+ state: hash[:state],
50
+ )
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # The DirectoryGroup class provides a lightweight wrapper around
6
+ # a WorkOS DirectoryGroup resource. This class is not meant to be instantiated
7
+ # in user space, and is instantiated internally but exposed.
8
+ class DirectoryGroup
9
+ extend T::Sig
10
+
11
+ attr_accessor :id, :name
12
+
13
+ sig { params(json: String).void }
14
+ def initialize(json)
15
+ raw = parse_json(json)
16
+
17
+ @id = T.let(raw.id, String)
18
+ @name = T.let(raw.name, String)
19
+ end
20
+
21
+ def to_json(*)
22
+ {
23
+ id: id,
24
+ name: name,
25
+ }
26
+ end
27
+
28
+ private
29
+
30
+ sig do
31
+ params(
32
+ json_string: String,
33
+ ).returns(WorkOS::Types::DirectoryGroupStruct)
34
+ end
35
+ def parse_json(json_string)
36
+ hash = JSON.parse(json_string, symbolize_names: true)
37
+
38
+ WorkOS::Types::DirectoryGroupStruct.new(
39
+ id: hash[:id],
40
+ name: hash[:name],
41
+ )
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
2
+ # typed: strict
3
3
 
4
4
  require 'net/http'
5
5
 
@@ -21,12 +21,17 @@ module WorkOS
21
21
  # @option options [String] domain The domain of the directory to be
22
22
  # retrieved.
23
23
  # @option options [String] search A search term for direcory names.
24
+ # @option options [String] limit Maximum number of records to return.
25
+ # @option options [String] before Pagination cursor to receive records
26
+ # before a provided Directory ID.
27
+ # @option options [String] after Pagination cursor to receive records
28
+ # before a provided Directory ID.
24
29
  #
25
30
  # @return [Hash]
26
31
  sig do
27
32
  params(
28
33
  options: T::Hash[Symbol, String],
29
- ).returns(T::Array[T::Hash[String, T.nilable(String)]])
34
+ ).returns(WorkOS::Types::ListStruct)
30
35
  end
31
36
  def list_directories(options = {})
32
37
  response = execute_request(
@@ -37,7 +42,15 @@ module WorkOS
37
42
  ),
38
43
  )
39
44
 
40
- JSON.parse(response.body)['data']
45
+ parsed_response = JSON.parse(response.body)
46
+ directories = parsed_response['data'].map do |directory|
47
+ ::WorkOS::Directory.new(directory.to_json)
48
+ end
49
+
50
+ WorkOS::Types::ListStruct.new(
51
+ data: directories,
52
+ list_metadata: parsed_response['listMetadata'],
53
+ )
41
54
  end
42
55
 
43
56
  # Retrieve directory groups.
@@ -47,12 +60,17 @@ module WorkOS
47
60
  # directory groups will be retrieved.
48
61
  # @option options [String] user The ID of the directory user whose
49
62
  # directory groups will be retrieved.
63
+ # @option options [String] limit Maximum number of records to return.
64
+ # @option options [String] before Pagination cursor to receive records
65
+ # before a provided Directory Group ID.
66
+ # @option options [String] after Pagination cursor to receive records
67
+ # before a provided Directory Group ID.
50
68
  #
51
69
  # @return [Hash]
52
70
  sig do
53
71
  params(
54
72
  options: T::Hash[Symbol, String],
55
- ).returns(T::Array[T::Hash[String, T.nilable(String)]])
73
+ ).returns(WorkOS::Types::ListStruct)
56
74
  end
57
75
  def list_groups(options = {})
58
76
  response = execute_request(
@@ -63,7 +81,15 @@ module WorkOS
63
81
  ),
64
82
  )
65
83
 
66
- JSON.parse(response.body)['data']
84
+ parsed_response = JSON.parse(response.body)
85
+ groups = parsed_response['data'].map do |group|
86
+ ::WorkOS::DirectoryGroup.new(group.to_json)
87
+ end
88
+
89
+ WorkOS::Types::ListStruct.new(
90
+ data: groups,
91
+ list_metadata: parsed_response['listMetadata'],
92
+ )
67
93
  end
68
94
 
69
95
  # Retrieve directory users.
@@ -73,12 +99,17 @@ module WorkOS
73
99
  # directory users will be retrieved.
74
100
  # @option options [String] user The ID of the directory group whose
75
101
  # directory users will be retrieved.
102
+ # @option options [String] limit Maximum number of records to return.
103
+ # @option options [String] before Pagination cursor to receive records
104
+ # before a provided Directory User ID.
105
+ # @option options [String] after Pagination cursor to receive records
106
+ # before a provided Directory User ID.
76
107
  #
77
108
  # @return [Hash]
78
109
  sig do
79
110
  params(
80
111
  options: T::Hash[Symbol, String],
81
- ).returns(T::Array[T::Hash[String, T.untyped]])
112
+ ).returns(WorkOS::Types::ListStruct)
82
113
  end
83
114
  def list_users(options = {})
84
115
  response = execute_request(
@@ -89,7 +120,15 @@ module WorkOS
89
120
  ),
90
121
  )
91
122
 
92
- JSON.parse(response.body)['data']
123
+ parsed_response = JSON.parse(response.body)
124
+ users = parsed_response['data'].map do |user|
125
+ ::WorkOS::DirectoryUser.new(user.to_json)
126
+ end
127
+
128
+ WorkOS::Types::ListStruct.new(
129
+ data: users,
130
+ list_metadata: parsed_response['listMetadata'],
131
+ )
93
132
  end
94
133
 
95
134
  # Retrieve the directory group with the given ID.
@@ -125,6 +164,23 @@ module WorkOS
125
164
 
126
165
  JSON.parse(response.body)
127
166
  end
167
+
168
+ # Delete the directory with the given ID.
169
+ #
170
+ # @param [String] id The ID of the directory.
171
+ #
172
+ # @return Boolean
173
+ sig { params(id: String).returns(T::Boolean) }
174
+ def delete_directory(id)
175
+ request = delete_request(
176
+ auth: true,
177
+ path: "/directories/#{id}",
178
+ )
179
+
180
+ response = execute_request(request: request)
181
+
182
+ response.is_a? Net::HTTPSuccess
183
+ end
128
184
  end
129
185
  end
130
186
  end
@@ -0,0 +1,63 @@
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, :idp_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
+ @idp_id = T.let(raw.idp_id, String)
20
+ @emails = T.let(raw.emails, Array)
21
+ @first_name = raw.first_name
22
+ @last_name = raw.last_name
23
+ @username = raw.username
24
+ @state = raw.state
25
+ @raw_attributes = raw.raw_attributes
26
+ end
27
+
28
+ def to_json(*)
29
+ {
30
+ id: id,
31
+ idp_id: idp_id,
32
+ emails: emails,
33
+ first_name: first_name,
34
+ last_name: last_name,
35
+ username: username,
36
+ state: state,
37
+ raw_attributes: raw_attributes,
38
+ }
39
+ end
40
+
41
+ private
42
+
43
+ sig do
44
+ params(
45
+ json_string: String,
46
+ ).returns(WorkOS::Types::DirectoryUserStruct)
47
+ end
48
+ def parse_json(json_string)
49
+ hash = JSON.parse(json_string, symbolize_names: true)
50
+
51
+ WorkOS::Types::DirectoryUserStruct.new(
52
+ id: hash[:id],
53
+ idp_id: hash[:idp_id],
54
+ emails: hash[:emails],
55
+ first_name: hash[:first_name],
56
+ last_name: hash[:last_name],
57
+ username: hash[:username],
58
+ state: hash[:state],
59
+ raw_attributes: hash[:raw_attributes],
60
+ )
61
+ end
62
+ end
63
+ end
@@ -23,6 +23,10 @@ module WorkOS
23
23
  # received from WorkOS will contain. The state parameter can be used to
24
24
  # encode arbitrary information to help restore application state between
25
25
  # redirects.
26
+ # @option options [String] connection Optional parameter for the ID of a
27
+ # specific connection. This can be used to create a Passwordless Session
28
+ # for a specific connection rather than using the domain from the email
29
+ # to determine the Organization and Connection.
26
30
  # @option options [String] type The type of Passwordless Session to
27
31
  # create. Currently, the only supported value is 'MagicLink'.
28
32
  # @option options [String] redirect_uri The URI where users are directed
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
@@ -110,6 +110,59 @@ module WorkOS
110
110
  )
111
111
  end
112
112
 
113
+ # Get an Organization
114
+ #
115
+ # @param [String] id Organization unique identifier
116
+ #
117
+ # @example
118
+ # WorkOS::Portal.get_organization(id: 'org_02DRA1XNSJDZ19A31F183ECQW9')
119
+ # => #<WorkOS::Organization:0x00007fb6e4193d20
120
+ # @id="org_02DRA1XNSJDZ19A31F183ECQW9",
121
+ # @name="Foo Corp",
122
+ # @domains=
123
+ # [{:object=>"organization_domain",
124
+ # :id=>"org_domain_01E6PK9N3XMD8RHWF7S66380AR",
125
+ # :domain=>"foo-corp.com"}]>
126
+ #
127
+ # @return [WorkOS::Connection]
128
+ sig { params(id: String).returns(WorkOS::Organization) }
129
+ def get_organization(id:)
130
+ request = get_request(
131
+ auth: true,
132
+ path: "/organizations/#{id}",
133
+ )
134
+
135
+ response = execute_request(request: request)
136
+
137
+ WorkOS::Organization.new(response.body)
138
+ end
139
+
140
+ # Update an organization
141
+ #
142
+ # @param [String] organization Organization unique identifier
143
+ # @param [Array<String>] domains List of domains that belong to the
144
+ # organization
145
+ # @param [String] name A unique, descriptive name for the organization
146
+ sig do
147
+ params(
148
+ organization: String,
149
+ domains: T::Array[String],
150
+ name: String,
151
+ ).returns(WorkOS::Organization)
152
+ end
153
+ def update_organization(organization:, domains:, name:)
154
+ request = put_request(
155
+ auth: true,
156
+ body: { domains: domains, name: name },
157
+ path: "/organizations/#{organization}",
158
+ )
159
+
160
+ response = execute_request(request: request)
161
+ check_and_raise_organization_error(response: response)
162
+
163
+ WorkOS::Organization.new(response.body)
164
+ end
165
+
113
166
  private
114
167
 
115
168
  sig { params(response: Net::HTTPResponse).void }