workos 0.10.3 → 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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.semaphore/semaphore.yml +8 -2
  4. data/Gemfile.lock +49 -36
  5. data/lib/workos.rb +3 -0
  6. data/lib/workos/client.rb +3 -3
  7. data/lib/workos/connection.rb +8 -1
  8. data/lib/workos/directory.rb +53 -0
  9. data/lib/workos/directory_group.rb +44 -0
  10. data/lib/workos/directory_sync.rb +63 -7
  11. data/lib/workos/directory_user.rb +60 -0
  12. data/lib/workos/profile.rb +1 -2
  13. data/lib/workos/sso.rb +10 -2
  14. data/lib/workos/types.rb +3 -0
  15. data/lib/workos/types/connection_struct.rb +2 -0
  16. data/lib/workos/types/directory_group_struct.rb +13 -0
  17. data/lib/workos/types/directory_struct.rb +16 -0
  18. data/lib/workos/types/directory_user_struct.rb +18 -0
  19. data/lib/workos/version.rb +1 -1
  20. data/sorbet/rbi/gems/addressable.rbi +199 -0
  21. data/sorbet/rbi/gems/ast.rbi +49 -0
  22. data/sorbet/rbi/gems/codecov.rbi +37 -0
  23. data/sorbet/rbi/gems/crack.rbi +62 -0
  24. data/sorbet/rbi/gems/docile.rbi +36 -0
  25. data/sorbet/rbi/gems/hashdiff.rbi +66 -0
  26. data/sorbet/rbi/gems/parallel.rbi +83 -0
  27. data/sorbet/rbi/gems/parser.rbi +1429 -0
  28. data/sorbet/rbi/gems/public_suffix.rbi +104 -0
  29. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  30. data/sorbet/rbi/gems/rake.rbi +644 -0
  31. data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
  32. data/sorbet/rbi/gems/rexml.rbi +628 -0
  33. data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
  34. data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
  35. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  36. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  37. data/sorbet/rbi/gems/rspec.rbi +15 -0
  38. data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
  39. data/sorbet/rbi/gems/rubocop.rbi +7253 -0
  40. data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
  41. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  42. data/sorbet/rbi/gems/simplecov.rbi +406 -0
  43. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  44. data/sorbet/rbi/gems/vcr.rbi +572 -0
  45. data/sorbet/rbi/gems/webmock.rbi +556 -0
  46. data/sorbet/rbi/gems/yard.rbi +1165 -0
  47. data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
  48. data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
  49. data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
  50. data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
  51. data/sorbet/rbi/todo.rbi +1 -3
  52. data/spec/lib/workos/directory_sync_spec.rb +347 -32
  53. data/spec/lib/workos/sso_spec.rb +106 -31
  54. data/spec/spec_helper.rb +1 -1
  55. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  56. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections.yml → directory_sync/list_directories/with_after.yml} +7 -7
  57. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_limit_param.yml → directory_sync/list_directories/with_before.yml} +8 -8
  58. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_connection_type_param.yml → directory_sync/list_directories/with_domain.yml} +11 -10
  59. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_after_param.yml → directory_sync/list_directories/with_limit.yml} +12 -10
  60. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  61. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_search.yml +73 -0
  62. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  63. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  64. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  65. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
  66. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  67. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  68. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  73. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  74. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
  75. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  76. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  77. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  78. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_domain_param.yml → list_connections/with_domain.yml} +6 -6
  79. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  80. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  81. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_organization_id_param.yml → list_connections/with_organization_id.yml} +6 -6
  82. data/workos.gemspec +2 -0
  83. metadata +97 -40
  84. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  85. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  86. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  87. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  88. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  89. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
  90. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +0 -63
  91. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +0 -62
  92. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +0 -62
  93. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_before_param.yml +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10533ea551520a47120ae8d73f4ff1399fd095eb893bd998ba200019262fc67a
4
- data.tar.gz: 1b3bdac8336b2ee2c24a09334aecd399a897e983c6693d73dbed5f196ec3eb18
3
+ metadata.gz: 40285726466960ebdf92e8c851d172bc9387a0941579c1f2e4fb9b1b262ea071
4
+ data.tar.gz: 3ceb76e02b50a129e077bc99822b0bc79615a2a8f4df1315c210766feb6333cb
5
5
  SHA512:
6
- metadata.gz: 0e36af027698d1887819dd51f93921eed30b47af78deabc99e34864374d5f6ff3569920cf1fdd15c26b488bdb9d7d22105e5ee89dfd40b8f0f2146e789c4b884
7
- data.tar.gz: fb776485526b8ace124319050a709fe044fd2a2cdbdaeb261b8b92fcfb7cafdc0f31b3f913d96839671d9fee9ed5151370868b4ccd02827523fb44d478f5b4d4
6
+ metadata.gz: 27d9e22ba5b80d6dcfdcdd68886c64b720d7f94ee0724007599a4d2410e56b778771978046930e24a480f1bac0de4823d2dd39c1669cdbc36a4629547a84e9f6
7
+ data.tar.gz: f750566f656fc734d9d112bb99285de9f371e64212fdfa404dae62f77473f97cc735990b157cc03e5f10032fe139a48d9a68533cd0f75b81f98d631408e17685
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.1
@@ -60,10 +60,16 @@ blocks:
60
60
  - sem-version ruby 2.6.5
61
61
  - bundle install
62
62
  - bundle exec rspec
63
- - name: Ruby 2.7.1
63
+ - name: Ruby 2.7.3
64
64
  commands:
65
65
  - checkout
66
- - sem-version ruby 2.7.1
66
+ - sem-version ruby 2.7.3
67
+ - bundle install
68
+ - bundle exec rspec
69
+ - name: Ruby 3.0.1
70
+ commands:
71
+ - checkout
72
+ - sem-version ruby 3.0.1
67
73
  - bundle install
68
74
  - bundle exec rspec
69
75
  promotions:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.10.3)
4
+ workos (0.11.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -9,60 +9,73 @@ GEM
9
9
  specs:
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.0)
13
- codecov (0.2.8)
12
+ ast (2.4.2)
13
+ codecov (0.2.12)
14
14
  json
15
15
  simplecov
16
- crack (0.4.3)
17
- safe_yaml (~> 1.0.0)
18
- diff-lcs (1.3)
19
- docile (1.3.2)
20
- hashdiff (1.0.0)
21
- jaro_winkler (1.5.4)
22
- json (2.3.1)
23
- parallel (1.19.1)
24
- parser (2.7.0.0)
25
- ast (~> 2.4.0)
26
- public_suffix (4.0.2)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.4.4)
19
+ docile (1.3.5)
20
+ hashdiff (1.0.1)
21
+ json (2.5.1)
22
+ parallel (1.20.1)
23
+ parser (3.0.1.0)
24
+ ast (~> 2.4.1)
25
+ public_suffix (4.0.6)
27
26
  rainbow (3.0.0)
28
- rake (13.0.1)
27
+ rake (13.0.3)
28
+ regexp_parser (2.1.1)
29
+ rexml (3.2.5)
29
30
  rspec (3.9.0)
30
31
  rspec-core (~> 3.9.0)
31
32
  rspec-expectations (~> 3.9.0)
32
33
  rspec-mocks (~> 3.9.0)
33
- rspec-core (3.9.0)
34
- rspec-support (~> 3.9.0)
35
- rspec-expectations (3.9.0)
34
+ rspec-core (3.9.3)
35
+ rspec-support (~> 3.9.3)
36
+ rspec-expectations (3.9.4)
36
37
  diff-lcs (>= 1.2.0, < 2.0)
37
38
  rspec-support (~> 3.9.0)
38
- rspec-mocks (3.9.0)
39
+ rspec-mocks (3.9.1)
39
40
  diff-lcs (>= 1.2.0, < 2.0)
40
41
  rspec-support (~> 3.9.0)
41
- rspec-support (3.9.0)
42
- rubocop (0.78.0)
43
- jaro_winkler (~> 1.5.1)
42
+ rspec-support (3.9.4)
43
+ rubocop (0.93.1)
44
44
  parallel (~> 1.10)
45
- parser (>= 2.6)
45
+ parser (>= 2.7.1.5)
46
46
  rainbow (>= 2.2.2, < 4.0)
47
+ regexp_parser (>= 1.8)
48
+ rexml
49
+ rubocop-ast (>= 0.6.0)
47
50
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 1.4.0, < 1.7)
49
- ruby-progressbar (1.10.1)
50
- safe_yaml (1.0.5)
51
- simplecov (0.19.0)
51
+ unicode-display_width (>= 1.4.0, < 2.0)
52
+ rubocop-ast (1.4.1)
53
+ parser (>= 2.7.1.5)
54
+ ruby-progressbar (1.11.0)
55
+ simplecov (0.21.2)
52
56
  docile (~> 1.1)
53
57
  simplecov-html (~> 0.11)
54
- simplecov-html (0.12.2)
55
- sorbet (0.5.5560)
56
- sorbet-static (= 0.5.5560)
57
- sorbet-runtime (0.5.6366)
58
- sorbet-static (0.5.5560-universal-darwin-14)
59
- unicode-display_width (1.6.0)
58
+ simplecov_json_formatter (~> 0.1)
59
+ simplecov-html (0.12.3)
60
+ simplecov_json_formatter (0.1.2)
61
+ sorbet (0.5.6388)
62
+ sorbet-static (= 0.5.6388)
63
+ sorbet-runtime (0.5.6391)
64
+ sorbet-static (0.5.6388-universal-darwin-14)
65
+ sorbet-static (0.5.6388-universal-darwin-15)
66
+ sorbet-static (0.5.6388-universal-darwin-16)
67
+ sorbet-static (0.5.6388-universal-darwin-17)
68
+ sorbet-static (0.5.6388-universal-darwin-18)
69
+ sorbet-static (0.5.6388-universal-darwin-19)
70
+ sorbet-static (0.5.6388-universal-darwin-20)
71
+ sorbet-static (0.5.6388-x86_64-linux)
72
+ unicode-display_width (1.7.0)
60
73
  vcr (5.0.0)
61
- webmock (3.7.6)
74
+ webmock (3.12.2)
62
75
  addressable (>= 2.3.6)
63
76
  crack (>= 0.3.2)
64
77
  hashdiff (>= 0.4.0, < 2.0.0)
65
- yard (0.9.22)
78
+ yard (0.9.26)
66
79
 
67
80
  PLATFORMS
68
81
  ruby
@@ -80,4 +93,4 @@ DEPENDENCIES
80
93
  yard
81
94
 
82
95
  BUNDLED WITH
83
- 2.1.4
96
+ 2.2.16
data/lib/workos.rb CHANGED
@@ -32,11 +32,14 @@ module WorkOS
32
32
  autoload :AuditTrail, 'workos/audit_trail'
33
33
  autoload :Connection, 'workos/connection'
34
34
  autoload :DirectorySync, 'workos/directory_sync'
35
+ autoload :Directory, 'workos/directory'
36
+ autoload :DirectoryGroup, 'workos/directory_group'
35
37
  autoload :Organization, 'workos/organization'
36
38
  autoload :Passwordless, 'workos/passwordless'
37
39
  autoload :Portal, 'workos/portal'
38
40
  autoload :Profile, 'workos/profile'
39
41
  autoload :SSO, 'workos/sso'
42
+ autoload :DirectoryUser, 'workos/directory_user'
40
43
 
41
44
  # Errors
42
45
  autoload :APIError, 'workos/errors'
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
@@ -102,7 +102,7 @@ module WorkOS
102
102
  ].join('; ')
103
103
  end
104
104
 
105
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
105
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
106
106
  sig { params(response: ::T.untyped).void }
107
107
  def handle_error_response(response:)
108
108
  http_status = response.code.to_i
@@ -139,7 +139,7 @@ module WorkOS
139
139
  )
140
140
  end
141
141
  end
142
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
142
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
143
143
 
144
144
  private
145
145
 
@@ -8,7 +8,8 @@ module WorkOS
8
8
  class Connection
9
9
  extend T::Sig
10
10
 
11
- attr_accessor :id, :name, :connection_type, :domains
11
+ attr_accessor :id, :name, :connection_type, :domains, :organization_id,
12
+ :status
12
13
 
13
14
  sig { params(json: String).void }
14
15
  def initialize(json)
@@ -18,6 +19,8 @@ module WorkOS
18
19
  @name = T.let(raw.name, String)
19
20
  @connection_type = T.let(raw.connection_type, String)
20
21
  @domains = T.let(raw.domains, Array)
22
+ @organization_id = T.let(raw.organization_id, String)
23
+ @status = T.let(raw.status, String)
21
24
  end
22
25
 
23
26
  def to_json(*)
@@ -26,6 +29,8 @@ module WorkOS
26
29
  name: name,
27
30
  connection_type: connection_type,
28
31
  domains: domains,
32
+ organization_id: organization_id,
33
+ status: status,
29
34
  }
30
35
  end
31
36
 
@@ -40,6 +45,8 @@ module WorkOS
40
45
  name: hash[:name],
41
46
  connection_type: hash[:connection_type],
42
47
  domains: hash[:domains],
48
+ organization_id: hash[:organization_id],
49
+ status: hash[:status],
43
50
  )
44
51
  end
45
52
  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