workos 2.16.0 → 3.0.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +5 -14
- data/lib/workos/authentication_factor_and_challenge.rb +31 -0
- data/lib/workos/authentication_response.rb +27 -0
- data/lib/workos/client.rb +1 -1
- data/lib/workos/configuration.rb +1 -1
- data/lib/workos/invitation.rb +68 -0
- data/lib/workos/organization_membership.rb +50 -0
- data/lib/workos/sso.rb +1 -1
- data/lib/workos/types/invitation_struct.rb +20 -0
- data/lib/workos/types/magic_auth_challenge_struct.rb +12 -0
- data/lib/workos/types/organization_membership_struct.rb +15 -0
- data/lib/workos/types/provider_enum.rb +1 -0
- data/lib/workos/types/user_struct.rb +17 -0
- data/lib/workos/types.rb +9 -5
- data/lib/workos/user.rb +57 -0
- data/lib/workos/user_and_token.rb +29 -0
- data/lib/workos/user_management.rb +1008 -0
- data/lib/workos/user_response.rb +25 -0
- data/lib/workos/version.rb +1 -1
- data/lib/workos.rb +35 -28
- data/spec/lib/workos/sso_spec.rb +8 -8
- data/spec/lib/workos/user_management_spec.rb +1092 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/invalid.yml +84 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_code/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/invalid.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_email_verification/valid.yml +81 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_magic_auth/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_magic_auth/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/invalid.yml +81 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_organization_selection/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_password/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/invalid.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/authenticate_with_totp/valid.yml +81 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/confirm_password_reset/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/confirm_password_reset/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/invalid.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/create_organization_membership/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/create_user_invalid.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/create_user_valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/delete_organization_membership/valid.yml +78 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/delete_user/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/delete_user/valid.yml +78 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/enroll_auth_factor/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/get_invitation/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/get_invitation/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/get_organization_membership.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/get_user.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_auth_factors/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_auth_factors/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_after.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_before.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_limit.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_no_options.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_invitations/with_organization_id.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/no_options.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_organization_memberships/with_options.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_users/no_options.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/list_users/with_options.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/reset_password/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/reset_password/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/revoke_invitation/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/revoke_invitation/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_invitation/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_invitation/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_magic_auth_code/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_password_reset_email/invalid.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_password_reset_email/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/send_verification_email/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/update_user/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/update_user/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/update_user_password/invalid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/update_user_password/valid.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_code.yml +83 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/verify_email/invalid_magic_auth_challenge.yml +82 -0
- data/spec/support/fixtures/vcr_cassettes/user_management/verify_email/valid.yml +82 -0
- data/workos.gemspec +0 -2
- metadata +132 -55
- data/bin/docs +0 -5
- data/docs/WorkOS/APIError.html +0 -160
- data/docs/WorkOS/AuditLog.html +0 -235
- data/docs/WorkOS/AuditTrail.html +0 -235
- data/docs/WorkOS/AuthenticationError.html +0 -160
- data/docs/WorkOS/Base.html +0 -287
- data/docs/WorkOS/Client.html +0 -504
- data/docs/WorkOS/InvalidRequestError.html +0 -160
- data/docs/WorkOS/Profile.html +0 -788
- data/docs/WorkOS/RequestError.html +0 -135
- data/docs/WorkOS/SSO.html +0 -691
- data/docs/WorkOS/Types/ProfileStruct.html +0 -135
- data/docs/WorkOS/Types/Provider.html +0 -135
- data/docs/WorkOS/Types.html +0 -128
- data/docs/WorkOS/WorkOSError.html +0 -447
- data/docs/WorkOS.html +0 -324
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -496
- data/docs/file.README.html +0 -252
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -250
- data/docs/js/app.js +0 -314
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -267
- data/docs/top-level-namespace.html +0 -110
- data/lib/workos/audit_trail.rb +0 -111
- data/spec/lib/workos/audit_trail_spec.rb +0 -146
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a7377543b69e5754e2754e56bd4c43683ffe6177d678449150b41178cddc2b0
|
4
|
+
data.tar.gz: 8e0c5d4ee45c39f8084d4b5c31b0e8058ba52ba7d3a7ca56e0146491af723d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d987073ab5dfe9eac87cf279ac8b5e75aff23fd56faf2c4b16f0c6acb43054112042915f1662685af16ec80d172c11b8b6c0bf5a02f44440ac9bf2d973f036ea
|
7
|
+
data.tar.gz: 1627133ce7178bd72df4a6b0d710a842c9a66926d83ff05283836d3ff9afd958d10b8512c3f119621b4cc8ada2445e1854ae1d237f30e7430468b6dd2a90c6b1
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
workos (
|
4
|
+
workos (3.0.0)
|
5
5
|
sorbet-runtime (~> 0.5)
|
6
6
|
|
7
7
|
GEM
|
@@ -67,19 +67,11 @@ GEM
|
|
67
67
|
simplecov_json_formatter (~> 0.1)
|
68
68
|
simplecov-html (0.12.3)
|
69
69
|
simplecov_json_formatter (0.1.2)
|
70
|
-
sorbet (0.5.
|
71
|
-
sorbet-static (= 0.5.
|
70
|
+
sorbet (0.5.11132)
|
71
|
+
sorbet-static (= 0.5.11132)
|
72
72
|
sorbet-runtime (0.5.10484)
|
73
|
-
sorbet-static (0.5.
|
74
|
-
sorbet-static (0.5.
|
75
|
-
sorbet-static (0.5.10346-universal-darwin-16)
|
76
|
-
sorbet-static (0.5.10346-universal-darwin-17)
|
77
|
-
sorbet-static (0.5.10346-universal-darwin-18)
|
78
|
-
sorbet-static (0.5.10346-universal-darwin-19)
|
79
|
-
sorbet-static (0.5.10346-universal-darwin-20)
|
80
|
-
sorbet-static (0.5.10346-universal-darwin-21)
|
81
|
-
sorbet-static (0.5.10346-universal-darwin-22)
|
82
|
-
sorbet-static (0.5.10346-x86_64-linux)
|
73
|
+
sorbet-static (0.5.11132-universal-darwin)
|
74
|
+
sorbet-static (0.5.11132-x86_64-linux)
|
83
75
|
spoom (1.1.15)
|
84
76
|
sorbet (>= 0.5.10187)
|
85
77
|
sorbet-runtime (>= 0.5.9204)
|
@@ -121,7 +113,6 @@ DEPENDENCIES
|
|
121
113
|
vcr (~> 5.0.0)
|
122
114
|
webmock
|
123
115
|
workos!
|
124
|
-
yard
|
125
116
|
|
126
117
|
BUNDLED WITH
|
127
118
|
2.2.33
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The AuthenticationFactorAndChallenge class represents
|
6
|
+
# an authentication factor and challenge for a given user.
|
7
|
+
class AuthenticationFactorAndChallenge
|
8
|
+
include HashProvider
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
attr_accessor :authentication_factor, :authentication_challenge
|
12
|
+
|
13
|
+
sig { params(authentication_response_json: String).void }
|
14
|
+
def initialize(authentication_response_json)
|
15
|
+
json = JSON.parse(authentication_response_json, symbolize_names: true)
|
16
|
+
@authentication_factor = WorkOS::Factor.new(
|
17
|
+
json[:authentication_factor].to_json,
|
18
|
+
)
|
19
|
+
@authentication_challenge = WorkOS::Challenge.new(
|
20
|
+
json[:authentication_challenge].to_json,
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_json(*)
|
25
|
+
{
|
26
|
+
authentication_factor: authentication_factor.to_json,
|
27
|
+
authentication_challenge: authentication_challenge.to_json,
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The AuthenticationResponse class represents an Authentication Response as well as an corresponding
|
6
|
+
# response data that can later be appended on.
|
7
|
+
class AuthenticationResponse
|
8
|
+
include HashProvider
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
attr_accessor :user, :organization_id
|
12
|
+
|
13
|
+
sig { params(authentication_response_json: String).void }
|
14
|
+
def initialize(authentication_response_json)
|
15
|
+
json = JSON.parse(authentication_response_json, symbolize_names: true)
|
16
|
+
@user = WorkOS::User.new(json[:user].to_json)
|
17
|
+
@organization_id = T.let(json[:organization_id], T.nilable(String))
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json(*)
|
21
|
+
{
|
22
|
+
user: user.to_json,
|
23
|
+
organization_id: organization_id,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/workos/client.rb
CHANGED
@@ -9,7 +9,7 @@ module WorkOS
|
|
9
9
|
|
10
10
|
sig { returns(Net::HTTP) }
|
11
11
|
def client
|
12
|
-
Net::HTTP.new(WorkOS
|
12
|
+
Net::HTTP.new(WorkOS.config.api_hostname, 443).tap do |http_client|
|
13
13
|
http_client.use_ssl = true
|
14
14
|
http_client.open_timeout = WorkOS.config.timeout
|
15
15
|
http_client.read_timeout = WorkOS.config.timeout
|
data/lib/workos/configuration.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The Invitation class provides a lightweight wrapper around a WorkOS Invitation
|
6
|
+
# resource. This class is not meant to be instantiated in a user space,
|
7
|
+
# and is instantiated internally but exposed.
|
8
|
+
class Invitation
|
9
|
+
include HashProvider
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
attr_accessor :id, :email, :state, :accepted_at, :revoked_at,
|
13
|
+
:expires_at, :token, :organization_id, :created_at, :updated_at
|
14
|
+
|
15
|
+
# rubocop:disable Metrics/AbcSize
|
16
|
+
sig { params(json: String).void }
|
17
|
+
def initialize(json)
|
18
|
+
raw = parse_json(json)
|
19
|
+
|
20
|
+
@id = T.let(raw.id, String)
|
21
|
+
@email = T.let(raw.email, String)
|
22
|
+
@state = T.let(raw.state, String)
|
23
|
+
@token = T.let(raw.token, String)
|
24
|
+
@organization_id = T.let(raw.organization_id, T.nilable(String))
|
25
|
+
@accepted_at = T.let(raw.accepted_at, T.nilable(String))
|
26
|
+
@revoked_at = T.let(raw.revoked_at, T.nilable(String))
|
27
|
+
@expires_at = T.let(raw.expires_at, String)
|
28
|
+
@created_at = T.let(raw.created_at, String)
|
29
|
+
@updated_at = T.let(raw.updated_at, String)
|
30
|
+
end
|
31
|
+
# rubocop:enable Metrics/AbcSize
|
32
|
+
|
33
|
+
def to_json(*)
|
34
|
+
{
|
35
|
+
id: id,
|
36
|
+
email: email,
|
37
|
+
state: state,
|
38
|
+
token: token,
|
39
|
+
organization_id: organization_id,
|
40
|
+
accepted_at: accepted_at,
|
41
|
+
revoked_at: revoked_at,
|
42
|
+
expires_at: expires_at,
|
43
|
+
created_at: created_at,
|
44
|
+
updated_at: updated_at,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
sig { params(json_string: String).returns(WorkOS::Types::InvitationStruct) }
|
51
|
+
def parse_json(json_string)
|
52
|
+
hash = JSON.parse(json_string, symbolize_names: true)
|
53
|
+
|
54
|
+
WorkOS::Types::InvitationStruct.new(
|
55
|
+
id: hash[:id],
|
56
|
+
email: hash[:email],
|
57
|
+
state: hash[:state],
|
58
|
+
token: hash[:token],
|
59
|
+
organization_id: hash[:organization_id],
|
60
|
+
accepted_at: hash[:accepted_at],
|
61
|
+
revoked_at: hash[:revoked_at],
|
62
|
+
expires_at: hash[:expires_at],
|
63
|
+
created_at: hash[:created_at],
|
64
|
+
updated_at: hash[:updated_at],
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The OrganizationMembership class provides a lightweight wrapper around a WorkOS OrganizationMembership
|
6
|
+
# resource. This class is not meant to be instantiated in a user space,
|
7
|
+
# and is instantiated internally but exposed.
|
8
|
+
class OrganizationMembership
|
9
|
+
include HashProvider
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
attr_accessor :id, :user_id, :organization_id, :created_at, :updated_at
|
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
|
+
@user_id = T.let(raw.user_id, String)
|
20
|
+
@organization_id = raw.organization_id
|
21
|
+
@created_at = T.let(raw.created_at, String)
|
22
|
+
@updated_at = T.let(raw.updated_at, String)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json(*)
|
26
|
+
{
|
27
|
+
id: id,
|
28
|
+
user_id: user_id,
|
29
|
+
organization_id: organization_id,
|
30
|
+
created_at: created_at,
|
31
|
+
updated_at: updated_at,
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
sig { params(json_string: String).returns(WorkOS::Types::OrganizationMembershipStruct) }
|
38
|
+
def parse_json(json_string)
|
39
|
+
hash = JSON.parse(json_string, symbolize_names: true)
|
40
|
+
|
41
|
+
WorkOS::Types::OrganizationMembershipStruct.new(
|
42
|
+
id: hash[:id],
|
43
|
+
user_id: hash[:user_id],
|
44
|
+
organization_id: hash[:organization_id],
|
45
|
+
created_at: hash[:created_at],
|
46
|
+
updated_at: hash[:updated_at],
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/workos/sso.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
module Types
|
6
|
+
# This InvitationStruct acts as a typed interface for the Invitation class
|
7
|
+
class InvitationStruct < T::Struct
|
8
|
+
const :id, String
|
9
|
+
const :email, String
|
10
|
+
const :state, String
|
11
|
+
const :token, String
|
12
|
+
const :organization_id, T.nilable(String)
|
13
|
+
const :accepted_at, T.nilable(String)
|
14
|
+
const :revoked_at, T.nilable(String)
|
15
|
+
const :expires_at, String
|
16
|
+
const :created_at, String
|
17
|
+
const :updated_at, String
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
module Types
|
6
|
+
# This MagicAuthChallengeStruct acts as a typed interface for the
|
7
|
+
# MagicAuthChallenge class
|
8
|
+
class MagicAuthChallengeStruct < T::Struct
|
9
|
+
const :id, String
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
module Types
|
6
|
+
# This OrganizationMembershipStruct acts as a typed interface for the OrganizationMembership class
|
7
|
+
class OrganizationMembershipStruct < T::Struct
|
8
|
+
const :id, String
|
9
|
+
const :user_id, String
|
10
|
+
const :organization_id, String
|
11
|
+
const :created_at, String
|
12
|
+
const :updated_at, String
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
module Types
|
6
|
+
# This UserStruct acts as a typed interface for the User class
|
7
|
+
class UserStruct < T::Struct
|
8
|
+
const :id, String
|
9
|
+
const :email, String
|
10
|
+
const :first_name, T.nilable(String)
|
11
|
+
const :last_name, T.nilable(String)
|
12
|
+
const :email_verified, T::Boolean
|
13
|
+
const :created_at, String
|
14
|
+
const :updated_at, String
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/workos/types.rb
CHANGED
@@ -6,20 +6,24 @@ module WorkOS
|
|
6
6
|
# so we're using Sorbet throughout this Ruby gem.
|
7
7
|
module Types
|
8
8
|
require_relative 'types/audit_log_export_struct'
|
9
|
+
require_relative 'types/challenge_struct'
|
9
10
|
require_relative 'types/connection_struct'
|
10
|
-
require_relative 'types/directory_struct'
|
11
11
|
require_relative 'types/directory_group_struct'
|
12
|
+
require_relative 'types/directory_struct'
|
13
|
+
require_relative 'types/directory_user_struct'
|
12
14
|
require_relative 'types/event_struct'
|
15
|
+
require_relative 'types/factor_struct'
|
13
16
|
require_relative 'types/intent_enum'
|
17
|
+
require_relative 'types/invitation_struct'
|
14
18
|
require_relative 'types/list_struct'
|
19
|
+
require_relative 'types/magic_auth_challenge_struct'
|
15
20
|
require_relative 'types/organization_struct'
|
21
|
+
require_relative 'types/organization_membership_struct'
|
16
22
|
require_relative 'types/passwordless_session_struct'
|
17
23
|
require_relative 'types/profile_struct'
|
18
24
|
require_relative 'types/provider_enum'
|
19
|
-
require_relative 'types/
|
20
|
-
require_relative 'types/webhook_struct'
|
21
|
-
require_relative 'types/factor_struct'
|
22
|
-
require_relative 'types/challenge_struct'
|
25
|
+
require_relative 'types/user_struct'
|
23
26
|
require_relative 'types/verify_challenge_struct'
|
27
|
+
require_relative 'types/webhook_struct'
|
24
28
|
end
|
25
29
|
end
|
data/lib/workos/user.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The User class provides a lightweight wrapper around a WorkOS User
|
6
|
+
# resource. This class is not meant to be instantiated in a user space,
|
7
|
+
# and is instantiated internally but exposed.
|
8
|
+
class User
|
9
|
+
include HashProvider
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
attr_accessor :id, :email, :first_name, :last_name, :email_verified,
|
13
|
+
:created_at, :updated_at
|
14
|
+
|
15
|
+
sig { params(json: String).void }
|
16
|
+
def initialize(json)
|
17
|
+
raw = parse_json(json)
|
18
|
+
|
19
|
+
@id = T.let(raw.id, String)
|
20
|
+
@email = T.let(raw.email, String)
|
21
|
+
@first_name = raw.first_name
|
22
|
+
@last_name = raw.last_name
|
23
|
+
@email_verified = raw.email_verified
|
24
|
+
@created_at = T.let(raw.created_at, String)
|
25
|
+
@updated_at = T.let(raw.updated_at, String)
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_json(*)
|
29
|
+
{
|
30
|
+
id: id,
|
31
|
+
email: email,
|
32
|
+
first_name: first_name,
|
33
|
+
last_name: last_name,
|
34
|
+
email_verified: email_verified,
|
35
|
+
created_at: created_at,
|
36
|
+
updated_at: updated_at,
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
sig { params(json_string: String).returns(WorkOS::Types::UserStruct) }
|
43
|
+
def parse_json(json_string)
|
44
|
+
hash = JSON.parse(json_string, symbolize_names: true)
|
45
|
+
|
46
|
+
WorkOS::Types::UserStruct.new(
|
47
|
+
id: hash[:id],
|
48
|
+
email: hash[:email],
|
49
|
+
first_name: hash[:first_name],
|
50
|
+
last_name: hash[:last_name],
|
51
|
+
email_verified: hash[:email_verified],
|
52
|
+
created_at: hash[:created_at],
|
53
|
+
updated_at: hash[:updated_at],
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module WorkOS
|
5
|
+
# The UserAndToken class represents a User and a corresponding Token. This
|
6
|
+
# class is not meant to be instantiated in user space, and is instantiated
|
7
|
+
# internally but exposed.
|
8
|
+
class UserAndToken
|
9
|
+
include HashProvider
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
attr_accessor :token, :user
|
13
|
+
|
14
|
+
sig { params(user_and_token_json: String).void }
|
15
|
+
def initialize(user_and_token_json)
|
16
|
+
json = JSON.parse(user_and_token_json, symbolize_names: true)
|
17
|
+
|
18
|
+
@token = T.let(json[:token], String)
|
19
|
+
@user = WorkOS::User.new(json[:user].to_json)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*)
|
23
|
+
{
|
24
|
+
token: token,
|
25
|
+
user: user.to_json,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|