workos 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/workos/user_management.rb +34 -1
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/user_management_spec.rb +77 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/deactivate_organization_membership.yml +64 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_statuses_option.yml +64 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml +64 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332ad6b582c870d359c308f231c3a9aab661487177b5afb73f9eda7b8c42f3ba
|
4
|
+
data.tar.gz: e95ae8f206a0a365a96ecc849b7426c0fd5425b59ac3cb9fde6fae4db1bb3b87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b216f6e42eed12702ad449a0370aac224e7c946ea275b48170162a2eb43f4639ee2e7cdf5ef9a1be31edde3d120f3ae7f13d6531233d2974cf27c3af4c7a870a
|
7
|
+
data.tar.gz: e1597322a482e0c94fae260b11cc1225f831a80f5e916fbf8b52415df6972054b8eba8b973cb73336c6985396e518535197c9e3fccdc33cd17fd3871a5eff958
|
data/Gemfile.lock
CHANGED
@@ -748,7 +748,8 @@ module WorkOS
|
|
748
748
|
#
|
749
749
|
# @param [Hash] options
|
750
750
|
# @option options [String] user_id The ID of the User.
|
751
|
-
# @option options [String] organization_id Filter
|
751
|
+
# @option options [String] organization_id Filter memberships by the organization they are members of.
|
752
|
+
# @option options [Array<String>] statuses Filter memberships by status.
|
752
753
|
# @option options [String] limit Maximum number of records to return.
|
753
754
|
# @option options [String] order The order in which to paginate records
|
754
755
|
# @option options [String] before Pagination cursor to receive records
|
@@ -816,6 +817,38 @@ module WorkOS
|
|
816
817
|
response.is_a? Net::HTTPSuccess
|
817
818
|
end
|
818
819
|
|
820
|
+
# Deactivate an Organization Membership
|
821
|
+
#
|
822
|
+
# @param [String] id The unique ID of the Organization Membership.
|
823
|
+
#
|
824
|
+
# @return WorkOS::OrganizationMembership
|
825
|
+
def deactivate_organization_membership(id:)
|
826
|
+
response = execute_request(
|
827
|
+
request: put_request(
|
828
|
+
path: "/user_management/organization_memberships/#{id}/deactivate",
|
829
|
+
auth: true,
|
830
|
+
),
|
831
|
+
)
|
832
|
+
|
833
|
+
WorkOS::OrganizationMembership.new(response.body)
|
834
|
+
end
|
835
|
+
|
836
|
+
# Reactivate an Organization Membership
|
837
|
+
#
|
838
|
+
# @param [String] id The unique ID of the Organization Membership.
|
839
|
+
#
|
840
|
+
# @return WorkOS::OrganizationMembership
|
841
|
+
def reactivate_organization_membership(id:)
|
842
|
+
response = execute_request(
|
843
|
+
request: put_request(
|
844
|
+
path: "/user_management/organization_memberships/#{id}/reactivate",
|
845
|
+
auth: true,
|
846
|
+
),
|
847
|
+
)
|
848
|
+
|
849
|
+
WorkOS::OrganizationMembership.new(response.body)
|
850
|
+
end
|
851
|
+
|
819
852
|
# Gets an Invitation
|
820
853
|
#
|
821
854
|
# @param [String] id The unique ID of the Invitation.
|
data/lib/workos/version.rb
CHANGED
@@ -933,6 +933,33 @@ describe WorkOS::UserManagement do
|
|
933
933
|
end
|
934
934
|
end
|
935
935
|
end
|
936
|
+
|
937
|
+
context 'with statuses option' do
|
938
|
+
it 'returns a list of matching users' do
|
939
|
+
request_args = [
|
940
|
+
'/user_management/organization_memberships?user_id=user_01HXYSZBKQE2N3NHBKZHDP1X5X&'\
|
941
|
+
'statuses=active&statuses=inactive&order=desc&limit=5',
|
942
|
+
'Content-Type' => 'application/json'
|
943
|
+
]
|
944
|
+
|
945
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
946
|
+
|
947
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
948
|
+
and_return(expected_request)
|
949
|
+
|
950
|
+
VCR.use_cassette 'user_management/list_organization_memberships/with_statuses_option' do
|
951
|
+
organization_memberships = described_class.list_organization_memberships(
|
952
|
+
user_id: 'user_01HXYSZBKQE2N3NHBKZHDP1X5X',
|
953
|
+
statuses: %w[active inactive],
|
954
|
+
order: 'desc',
|
955
|
+
limit: '5',
|
956
|
+
)
|
957
|
+
|
958
|
+
expect(organization_memberships.data.size).to eq(1)
|
959
|
+
expect(organization_memberships.data[0].user_id).to eq('user_01HXYSZBKQE2N3NHBKZHDP1X5X')
|
960
|
+
end
|
961
|
+
end
|
962
|
+
end
|
936
963
|
end
|
937
964
|
|
938
965
|
describe '.create_organization_membership' do
|
@@ -988,6 +1015,56 @@ describe WorkOS::UserManagement do
|
|
988
1015
|
end
|
989
1016
|
end
|
990
1017
|
|
1018
|
+
describe '.deactivate_organization_membership' do
|
1019
|
+
context 'with a valid id' do
|
1020
|
+
it 'returns a organization membership' do
|
1021
|
+
VCR.use_cassette 'user_management/deactivate_organization_membership' do
|
1022
|
+
organization_membership = described_class.deactivate_organization_membership(
|
1023
|
+
id: 'om_01HXYT0G3H5QG9YTSHSHFZQE6D',
|
1024
|
+
)
|
1025
|
+
|
1026
|
+
expect(organization_membership.id.instance_of?(String))
|
1027
|
+
expect(organization_membership.instance_of?(WorkOS::OrganizationMembership))
|
1028
|
+
end
|
1029
|
+
end
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
context 'with an invalid id' do
|
1033
|
+
it 'returns an error' do
|
1034
|
+
expect do
|
1035
|
+
described_class.deactivate_organization_membership(
|
1036
|
+
id: 'invalid_organization_membership_id',
|
1037
|
+
).to raise_error(WorkOS::APIError)
|
1038
|
+
end
|
1039
|
+
end
|
1040
|
+
end
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
describe '.reactivate_organization_membership' do
|
1044
|
+
context 'with a valid id' do
|
1045
|
+
it 'returns a organization membership' do
|
1046
|
+
VCR.use_cassette 'user_management/reactivate_organization_membership' do
|
1047
|
+
organization_membership = described_class.reactivate_organization_membership(
|
1048
|
+
id: 'om_01HXYT0G3H5QG9YTSHSHFZQE6D',
|
1049
|
+
)
|
1050
|
+
|
1051
|
+
expect(organization_membership.id.instance_of?(String))
|
1052
|
+
expect(organization_membership.instance_of?(WorkOS::OrganizationMembership))
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
context 'with an invalid id' do
|
1058
|
+
it 'returns an error' do
|
1059
|
+
expect do
|
1060
|
+
described_class.reactivate_organization_membership(
|
1061
|
+
id: 'invalid_organization_membership_id',
|
1062
|
+
).to raise_error(WorkOS::APIError)
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
end
|
1066
|
+
end
|
1067
|
+
|
991
1068
|
describe '.get_invitation' do
|
992
1069
|
context 'with a valid id' do
|
993
1070
|
it 'returns an invitation' do
|
data/spec/support/fixtures/vcr_cassettes/user_management/deactivate_organization_membership.yml
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://api.workos.com/user_management/organization_memberships/om_01HXYT0G3H5QG9YTSHSHFZQE6D/deactivate
|
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/3.3.0; arm64-darwin23; v4.5.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Wed, 15 May 2024 19:13:06 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=15552000; includeSubDomains
|
35
|
+
Vary:
|
36
|
+
- Origin, Accept-Encoding
|
37
|
+
Access-Control-Allow-Credentials:
|
38
|
+
- "true"
|
39
|
+
Content-Security-Policy:
|
40
|
+
- "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self'
|
41
|
+
https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src
|
42
|
+
'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"
|
43
|
+
Expect-Ct:
|
44
|
+
- max-age=0
|
45
|
+
Referrer-Policy:
|
46
|
+
- no-referrer
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Dns-Prefetch-Control:
|
50
|
+
- "off"
|
51
|
+
X-Download-Options:
|
52
|
+
- noopen
|
53
|
+
X-Frame-Options:
|
54
|
+
- SAMEORIGIN
|
55
|
+
X-Permitted-Cross-Domain-Policies:
|
56
|
+
- none
|
57
|
+
X-Xss-Protection:
|
58
|
+
- "0"
|
59
|
+
body:
|
60
|
+
encoding: ASCII-8BIT
|
61
|
+
string: '{"object":"organization_membership","id":"om_01HXYT0G3H5QG9YTSHSHFZQE6D","organization_id":"org_01HRCVHACPY05V2FP0KEBQZYD3","user_id":"user_01HXYSZBKQE2N3NHBKZHDP1X5X","status":"inactive","role":{"slug":"member"},"created_at":"2024-05-15T19:00:05.359Z","updated_at":"2024-05-15T19:13:06.259Z"}'
|
62
|
+
http_version:
|
63
|
+
recorded_at: Wed, 15 May 2024 19:13:06 GMT
|
64
|
+
recorded_with: VCR 5.0.0
|
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.workos.com/user_management/organization_memberships?limit=5&order=desc&statuses=inactive&user_id=user_01HXYSZBKQE2N3NHBKZHDP1X5X
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
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/3.3.0; arm64-darwin23; v4.5.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Wed, 15 May 2024 19:14:44 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=15552000; includeSubDomains
|
35
|
+
Vary:
|
36
|
+
- Origin, Accept-Encoding
|
37
|
+
Access-Control-Allow-Credentials:
|
38
|
+
- "true"
|
39
|
+
Content-Security-Policy:
|
40
|
+
- "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self'
|
41
|
+
https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src
|
42
|
+
'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"
|
43
|
+
Expect-Ct:
|
44
|
+
- max-age=0
|
45
|
+
Referrer-Policy:
|
46
|
+
- no-referrer
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Dns-Prefetch-Control:
|
50
|
+
- "off"
|
51
|
+
X-Download-Options:
|
52
|
+
- noopen
|
53
|
+
X-Frame-Options:
|
54
|
+
- SAMEORIGIN
|
55
|
+
X-Permitted-Cross-Domain-Policies:
|
56
|
+
- none
|
57
|
+
X-Xss-Protection:
|
58
|
+
- "0"
|
59
|
+
body:
|
60
|
+
encoding: ASCII-8BIT
|
61
|
+
string: '{"object":"list","data":[{"object":"organization_membership","id":"om_01HXYT0G3H5QG9YTSHSHFZQE6D","organization_id":"org_01HRCVHACPY05V2FP0KEBQZYD3","user_id":"user_01HXYSZBKQE2N3NHBKZHDP1X5X","status":"active","role":{"slug":"member"},"created_at":"2024-05-15T19:00:05.359Z","updated_at":"2024-05-15T19:13:06.427Z"}],"list_metadata":{"before":null,"after":null}}'
|
62
|
+
http_version:
|
63
|
+
recorded_at: Wed, 15 May 2024 19:14:44 GMT
|
64
|
+
recorded_with: VCR 5.0.0
|
data/spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://api.workos.com/user_management/organization_memberships/om_01HXYT0G3H5QG9YTSHSHFZQE6D/reactivate
|
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/3.3.0; arm64-darwin23; v4.5.0
|
18
|
+
Authorization:
|
19
|
+
- Bearer <API_KEY>
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Wed, 15 May 2024 19:13:06 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=15552000; includeSubDomains
|
35
|
+
Vary:
|
36
|
+
- Origin, Accept-Encoding
|
37
|
+
Access-Control-Allow-Credentials:
|
38
|
+
- "true"
|
39
|
+
Content-Security-Policy:
|
40
|
+
- "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self'
|
41
|
+
https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src
|
42
|
+
'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"
|
43
|
+
Expect-Ct:
|
44
|
+
- max-age=0
|
45
|
+
Referrer-Policy:
|
46
|
+
- no-referrer
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Dns-Prefetch-Control:
|
50
|
+
- "off"
|
51
|
+
X-Download-Options:
|
52
|
+
- noopen
|
53
|
+
X-Frame-Options:
|
54
|
+
- SAMEORIGIN
|
55
|
+
X-Permitted-Cross-Domain-Policies:
|
56
|
+
- none
|
57
|
+
X-Xss-Protection:
|
58
|
+
- "0"
|
59
|
+
body:
|
60
|
+
encoding: ASCII-8BIT
|
61
|
+
string: '{"object":"organization_membership","id":"om_01HXYT0G3H5QG9YTSHSHFZQE6D","organization_id":"org_01HRCVHACPY05V2FP0KEBQZYD3","user_id":"user_01HXYSZBKQE2N3NHBKZHDP1X5X","status":"active","role":{"slug":"member"},"created_at":"2024-05-15T19:00:05.359Z","updated_at":"2024-05-15T19:13:06.427Z"}'
|
62
|
+
http_version:
|
63
|
+
recorded_at: Wed, 15 May 2024 19:13:06 GMT
|
64
|
+
recorded_with: VCR 5.0.0
|
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.
|
4
|
+
version: 4.6.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-05-
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid.yml
|
275
275
|
- spec/support/fixtures/vcr_cassettes/user_management/create_user_invalid.yml
|
276
276
|
- spec/support/fixtures/vcr_cassettes/user_management/create_user_valid.yml
|
277
|
+
- spec/support/fixtures/vcr_cassettes/user_management/deactivate_organization_membership.yml
|
277
278
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/invalid.yml
|
278
279
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/valid.yml
|
279
280
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_user/invalid.yml
|
@@ -295,8 +296,10 @@ files:
|
|
295
296
|
- spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_organization_id.yml
|
296
297
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/no_options.yml
|
297
298
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_options.yml
|
299
|
+
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_statuses_option.yml
|
298
300
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/no_options.yml
|
299
301
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/with_options.yml
|
302
|
+
- spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml
|
300
303
|
- spec/support/fixtures/vcr_cassettes/user_management/reset_password/invalid.yml
|
301
304
|
- spec/support/fixtures/vcr_cassettes/user_management/reset_password/valid.yml
|
302
305
|
- spec/support/fixtures/vcr_cassettes/user_management/revoke_invitation/invalid.yml
|
@@ -471,6 +474,7 @@ test_files:
|
|
471
474
|
- spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid.yml
|
472
475
|
- spec/support/fixtures/vcr_cassettes/user_management/create_user_invalid.yml
|
473
476
|
- spec/support/fixtures/vcr_cassettes/user_management/create_user_valid.yml
|
477
|
+
- spec/support/fixtures/vcr_cassettes/user_management/deactivate_organization_membership.yml
|
474
478
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/invalid.yml
|
475
479
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/valid.yml
|
476
480
|
- spec/support/fixtures/vcr_cassettes/user_management/delete_user/invalid.yml
|
@@ -492,8 +496,10 @@ test_files:
|
|
492
496
|
- spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_organization_id.yml
|
493
497
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/no_options.yml
|
494
498
|
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_options.yml
|
499
|
+
- spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_statuses_option.yml
|
495
500
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/no_options.yml
|
496
501
|
- spec/support/fixtures/vcr_cassettes/user_management/list_users/with_options.yml
|
502
|
+
- spec/support/fixtures/vcr_cassettes/user_management/reactivate_organization_membership.yml
|
497
503
|
- spec/support/fixtures/vcr_cassettes/user_management/reset_password/invalid.yml
|
498
504
|
- spec/support/fixtures/vcr_cassettes/user_management/reset_password/valid.yml
|
499
505
|
- spec/support/fixtures/vcr_cassettes/user_management/revoke_invitation/invalid.yml
|