workos 4.1.0 → 4.2.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +37 -0
  3. data/.github/workflows/release.yml +43 -0
  4. data/.rubocop.yml +8 -1
  5. data/Gemfile.lock +22 -69
  6. data/lib/workos/audit_log_export.rb +8 -31
  7. data/lib/workos/audit_logs.rb +0 -26
  8. data/lib/workos/authentication_factor_and_challenge.rb +0 -3
  9. data/lib/workos/authentication_response.rb +3 -6
  10. data/lib/workos/challenge.rb +9 -28
  11. data/lib/workos/client.rb +0 -41
  12. data/lib/workos/configuration.rb +0 -1
  13. data/lib/workos/connection.rb +11 -35
  14. data/lib/workos/directory.rb +10 -37
  15. data/lib/workos/directory_group.rb +9 -36
  16. data/lib/workos/directory_sync.rb +0 -21
  17. data/lib/workos/directory_user.rb +17 -51
  18. data/lib/workos/errors.rb +0 -16
  19. data/lib/workos/event.rb +5 -26
  20. data/lib/workos/events.rb +0 -7
  21. data/lib/workos/factor.rb +9 -28
  22. data/lib/workos/hash_provider.rb +0 -1
  23. data/lib/workos/impersonator.rb +0 -3
  24. data/lib/workos/invitation.rb +12 -37
  25. data/lib/workos/mfa.rb +0 -42
  26. data/lib/workos/organization.rb +8 -31
  27. data/lib/workos/organization_membership.rb +8 -27
  28. data/lib/workos/organizations.rb +0 -26
  29. data/lib/workos/passwordless.rb +0 -14
  30. data/lib/workos/portal.rb +1 -13
  31. data/lib/workos/profile.rb +12 -39
  32. data/lib/workos/profile_and_token.rb +1 -4
  33. data/lib/workos/refresh_authentication_response.rb +2 -5
  34. data/lib/workos/sso.rb +1 -43
  35. data/lib/workos/types/intent.rb +16 -0
  36. data/lib/workos/types/list_struct.rb +8 -5
  37. data/lib/workos/types/passwordless_session_struct.rb +10 -9
  38. data/lib/workos/types/provider.rb +15 -0
  39. data/lib/workos/types.rb +5 -23
  40. data/lib/workos/user.rb +10 -31
  41. data/lib/workos/user_and_token.rb +1 -4
  42. data/lib/workos/user_management.rb +32 -243
  43. data/lib/workos/user_response.rb +0 -3
  44. data/lib/workos/verify_challenge.rb +4 -18
  45. data/lib/workos/version.rb +1 -2
  46. data/lib/workos/webhook.rb +5 -26
  47. data/lib/workos/webhooks.rb +1 -38
  48. data/lib/workos.rb +0 -2
  49. data/spec/lib/workos/audit_logs_spec.rb +2 -3
  50. data/spec/lib/workos/configuration_spec.rb +0 -1
  51. data/spec/lib/workos/directory_sync_spec.rb +0 -1
  52. data/spec/lib/workos/directory_user_spec.rb +0 -1
  53. data/spec/lib/workos/event_spec.rb +0 -1
  54. data/spec/lib/workos/mfa_spec.rb +0 -1
  55. data/spec/lib/workos/organizations_spec.rb +0 -1
  56. data/spec/lib/workos/passwordless_spec.rb +0 -1
  57. data/spec/lib/workos/portal_spec.rb +0 -1
  58. data/spec/lib/workos/sso_spec.rb +0 -1
  59. data/spec/lib/workos/user_management_spec.rb +0 -1
  60. data/spec/lib/workos/webhooks_spec.rb +0 -1
  61. data/spec/spec_helper.rb +0 -9
  62. data/spec/support/shared_examples/client_spec.rb +0 -1
  63. data/workos.gemspec +1 -6
  64. metadata +11 -129
  65. data/.semaphore/rubygems.yml +0 -24
  66. data/.semaphore/semaphore.yml +0 -51
  67. data/bin/tapioca +0 -29
  68. data/codecov.yml +0 -12
  69. data/devbox.json +0 -18
  70. data/devbox.lock +0 -11
  71. data/lib/workos/types/audit_log_export_struct.rb +0 -17
  72. data/lib/workos/types/challenge_struct.rb +0 -18
  73. data/lib/workos/types/connection_struct.rb +0 -20
  74. data/lib/workos/types/directory_group_struct.rb +0 -19
  75. data/lib/workos/types/directory_struct.rb +0 -19
  76. data/lib/workos/types/directory_user_struct.rb +0 -26
  77. data/lib/workos/types/event_struct.rb +0 -15
  78. data/lib/workos/types/factor_struct.rb +0 -18
  79. data/lib/workos/types/intent_enum.rb +0 -17
  80. data/lib/workos/types/invitation_struct.rb +0 -20
  81. data/lib/workos/types/magic_auth_challenge_struct.rb +0 -12
  82. data/lib/workos/types/organization_membership_struct.rb +0 -16
  83. data/lib/workos/types/organization_struct.rb +0 -17
  84. data/lib/workos/types/profile_struct.rb +0 -21
  85. data/lib/workos/types/provider_enum.rb +0 -16
  86. data/lib/workos/types/user_struct.rb +0 -18
  87. data/lib/workos/types/verify_challenge_struct.rb +0 -13
  88. data/lib/workos/types/webhook_struct.rb +0 -15
  89. data/sorbet/config +0 -2
  90. data/sorbet/rbi/gems/addressable@2.8.0.rbi +0 -290
  91. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -54
  92. data/sorbet/rbi/gems/codecov@0.2.12.rbi +0 -55
  93. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -8
  94. data/sorbet/rbi/gems/crack@0.4.5.rbi +0 -57
  95. data/sorbet/rbi/gems/diff-lcs@1.4.4.rbi +0 -185
  96. data/sorbet/rbi/gems/docile@1.3.5.rbi +0 -54
  97. data/sorbet/rbi/gems/hashdiff@1.0.1.rbi +0 -82
  98. data/sorbet/rbi/gems/json@2.5.1.rbi +0 -109
  99. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -8
  100. data/sorbet/rbi/gems/parallel@1.20.1.rbi +0 -113
  101. data/sorbet/rbi/gems/parser@3.0.1.0.rbi +0 -1187
  102. data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -8
  103. data/sorbet/rbi/gems/public_suffix@4.0.6.rbi +0 -146
  104. data/sorbet/rbi/gems/rainbow@3.0.0.rbi +0 -153
  105. data/sorbet/rbi/gems/rake@13.0.3.rbi +0 -807
  106. data/sorbet/rbi/gems/rbi@0.0.16.rbi +0 -2118
  107. data/sorbet/rbi/gems/regexp_parser@2.1.1.rbi +0 -1117
  108. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -709
  109. data/sorbet/rbi/gems/rspec-core@3.9.3.rbi +0 -2467
  110. data/sorbet/rbi/gems/rspec-expectations@3.9.4.rbi +0 -1569
  111. data/sorbet/rbi/gems/rspec-mocks@3.9.1.rbi +0 -1493
  112. data/sorbet/rbi/gems/rspec-support@3.9.4.rbi +0 -511
  113. data/sorbet/rbi/gems/rspec@3.9.0.rbi +0 -38
  114. data/sorbet/rbi/gems/rubocop-ast@1.4.1.rbi +0 -1881
  115. data/sorbet/rbi/gems/rubocop@0.93.1.rbi +0 -11497
  116. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -405
  117. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -89
  118. data/sorbet/rbi/gems/simplecov@0.21.2.rbi +0 -577
  119. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.2.rbi +0 -8
  120. data/sorbet/rbi/gems/spoom@1.1.15.rbi +0 -1549
  121. data/sorbet/rbi/gems/tapioca@0.7.3.rbi +0 -1718
  122. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -844
  123. data/sorbet/rbi/gems/unicode-display_width@1.7.0.rbi +0 -22
  124. data/sorbet/rbi/gems/unparser@0.6.2.rbi +0 -8
  125. data/sorbet/rbi/gems/vcr@5.0.0.rbi +0 -699
  126. data/sorbet/rbi/gems/webmock@3.12.2.rbi +0 -662
  127. data/sorbet/rbi/gems/yard-sorbet@0.8.0.rbi +0 -268
  128. data/sorbet/rbi/gems/yard@0.9.26.rbi +0 -4048
  129. data/sorbet/tapioca/config.yml +0 -13
  130. data/sorbet/tapioca/require.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0828780b58051c7e4da7d76717a9eb71209803a508c71ca287a99dabcb0cc55a'
4
- data.tar.gz: 5da4147318e6c1f9947b50f69e8bf37dfbed7fd936deda7c46c9a072abfed99f
3
+ metadata.gz: 7010166c9732e20f33a78674e669c1f583fda9695ddbce0b998b666166cbb60b
4
+ data.tar.gz: 642d0e92afe77f1aec7404fffdfec5af386d05807ee43c6bfa3201c11fe45cd7
5
5
  SHA512:
6
- metadata.gz: '0916ae54fc3f1e30edf8f03dab9a75382062122a5b554aeefbaea26b39edc2e4d6415a9bdda25e53f19c5b82e6bb6e5e675c7c4ba1bc971a689346e6af997935'
7
- data.tar.gz: 232a18c18b3c58181dd3f3a16c8c8f16a9f7aa7d1dc5ac088dbda986b9fd86347fe41def6a27d3d19ca7ff2867f03353daefa611c6df175ad5b9464539cadfff
6
+ metadata.gz: b65ccc5817fc14633a235b12e2f3c25be1b04b6f1c07d9b781fd5d131cad89d7528dd0ab6326f100d542425261de9d1a81d28e89c1e30158a7e2a05291cdb8dd
7
+ data.tar.gz: 94b2b2d3e59882de00b1ff7c01d2a0c5284357d52fa4e8418f86eff9ea37b0c0d0ef2c197b88ad0497ca56b872f2ab3309a4598feab6a80aa6b1f55114bc57e4
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'main'
7
+ pull_request: {}
8
+
9
+ defaults:
10
+ run:
11
+ shell: bash
12
+
13
+ jobs:
14
+ test:
15
+ name: Test Ruby ${{ matrix.ruby }}
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ ruby:
20
+ - '2.7'
21
+ - '3.0'
22
+ - '3.1'
23
+ - '3.2'
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: Rubocop
32
+ run: |
33
+ bundle exec rubocop
34
+
35
+ - name: Spec
36
+ run: |
37
+ bundle exec rspec
@@ -0,0 +1,43 @@
1
+ name: Release
2
+
3
+ on:
4
+ # Support manually pushing a new release
5
+ workflow_dispatch: {}
6
+ # Trigger when a release is published
7
+ release:
8
+ types: [released]
9
+
10
+ defaults:
11
+ run:
12
+ shell: bash
13
+
14
+ jobs:
15
+ test:
16
+ name: Publish to RubyGems
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: '3.2'
23
+ bundler-cache: true
24
+
25
+ - name: Spec
26
+ run: |
27
+ bundle exec rspec
28
+
29
+ - name: Publish
30
+ env:
31
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
32
+ run: |
33
+ mkdir -p ~/.gem
34
+
35
+ cat << EOF > ~/.gem/credentials
36
+ ---
37
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
38
+ EOF
39
+
40
+ chmod 0600 ~/.gem/credentials
41
+
42
+ bundle exec gem build workos --output=release.gem
43
+ bundle exec gem push release.gem
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ # Disabling due to conflict with Ruby 2.7/3.1
2
+ Layout/BlockAlignment:
3
+ Enabled: false
1
4
  Layout/DotPosition:
2
5
  EnforcedStyle: trailing
3
6
  Layout/EmptyLineAfterMagicComment:
@@ -16,9 +19,13 @@ Metrics/ModuleLength:
16
19
  Max: 200
17
20
  Metrics/ParameterLists:
18
21
  Max: 6
22
+ Naming/ConstantName:
23
+ Exclude:
24
+ - 'lib/workos/user_management.rb'
25
+ - 'lib/workos/types/*.rb'
19
26
  Style/TrailingCommaInArguments:
20
27
  EnforcedStyleForMultiline: 'consistent_comma'
21
28
  Style/TrailingCommaInHashLiteral:
22
29
  EnforcedStyleForMultiline: 'consistent_comma'
23
30
  AllCops:
24
- TargetRubyVersion: 2.5
31
+ TargetRubyVersion: 2.7
data/Gemfile.lock CHANGED
@@ -1,41 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (4.1.0)
5
- sorbet-runtime (~> 0.5)
4
+ workos (4.2.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
- addressable (2.8.0)
11
- public_suffix (>= 2.0.2, < 5.0)
9
+ addressable (2.8.6)
10
+ public_suffix (>= 2.0.2, < 6.0)
12
11
  ast (2.4.2)
13
- codecov (0.2.12)
14
- json
15
- simplecov
16
- coderay (1.1.3)
17
- crack (0.4.5)
12
+ bigdecimal (3.1.7)
13
+ crack (1.0.0)
14
+ bigdecimal
18
15
  rexml
19
- diff-lcs (1.4.4)
20
- docile (1.3.5)
21
- hashdiff (1.0.1)
22
- json (2.5.1)
23
- method_source (1.0.0)
24
- parallel (1.20.1)
25
- parser (3.0.1.0)
16
+ diff-lcs (1.5.1)
17
+ hashdiff (1.1.0)
18
+ parallel (1.24.0)
19
+ parser (3.3.0.5)
26
20
  ast (~> 2.4.1)
27
- pry (0.14.2)
28
- coderay (~> 1.1)
29
- method_source (~> 1.0)
30
- public_suffix (4.0.6)
31
- rainbow (3.0.0)
32
- rbi (0.0.16)
33
- ast
34
- parser (>= 2.6.4.0)
35
- sorbet-runtime (>= 0.5.9204)
36
- unparser
37
- regexp_parser (2.1.1)
38
- rexml (3.2.5)
21
+ racc
22
+ public_suffix (5.0.4)
23
+ racc (1.7.3)
24
+ rainbow (3.1.1)
25
+ regexp_parser (2.9.0)
26
+ rexml (3.2.6)
39
27
  rspec (3.9.0)
40
28
  rspec-core (~> 3.9.0)
41
29
  rspec-expectations (~> 3.9.0)
@@ -58,58 +46,23 @@ GEM
58
46
  rubocop-ast (>= 0.6.0)
59
47
  ruby-progressbar (~> 1.7)
60
48
  unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-ast (1.4.1)
62
- parser (>= 2.7.1.5)
63
- ruby-progressbar (1.11.0)
64
- simplecov (0.21.2)
65
- docile (~> 1.1)
66
- simplecov-html (~> 0.11)
67
- simplecov_json_formatter (~> 0.1)
68
- simplecov-html (0.12.3)
69
- simplecov_json_formatter (0.1.2)
70
- sorbet (0.5.11132)
71
- sorbet-static (= 0.5.11132)
72
- sorbet-runtime (0.5.10484)
73
- sorbet-static (0.5.11132-universal-darwin)
74
- sorbet-static (0.5.11132-x86_64-linux)
75
- spoom (1.1.15)
76
- sorbet (>= 0.5.10187)
77
- sorbet-runtime (>= 0.5.9204)
78
- thor (>= 0.19.2)
79
- tapioca (0.7.3)
80
- bundler (>= 1.17.3)
81
- pry (>= 0.12.2)
82
- rbi (~> 0.0.0, >= 0.0.14)
83
- sorbet-runtime (>= 0.5.9204)
84
- sorbet-static (>= 0.5.9204)
85
- spoom (~> 1.1.0, >= 1.1.11)
86
- thor (>= 1.2.0)
87
- yard-sorbet
88
- thor (1.2.1)
89
- unicode-display_width (1.7.0)
90
- unparser (0.6.2)
91
- diff-lcs (~> 1.3)
92
- parser (>= 3.0.0)
49
+ rubocop-ast (1.31.2)
50
+ parser (>= 3.3.0.4)
51
+ ruby-progressbar (1.13.0)
52
+ unicode-display_width (1.8.0)
93
53
  vcr (5.0.0)
94
- webmock (3.12.2)
95
- addressable (>= 2.3.6)
54
+ webmock (3.23.0)
55
+ addressable (>= 2.8.0)
96
56
  crack (>= 0.3.2)
97
57
  hashdiff (>= 0.4.0, < 2.0.0)
98
- yard (0.9.26)
99
- yard-sorbet (0.8.0)
100
- sorbet-runtime (>= 0.5)
101
- yard (>= 0.9)
102
58
 
103
59
  PLATFORMS
104
60
  ruby
105
61
 
106
62
  DEPENDENCIES
107
63
  bundler (>= 2.0.1)
108
- codecov (~> 0.2.8)
109
64
  rspec (~> 3.9.0)
110
65
  rubocop (~> 0.77)
111
- sorbet (~> 0.5)
112
- tapioca
113
66
  vcr (~> 5.0.0)
114
67
  webmock
115
68
  workos!
@@ -1,24 +1,21 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The AuditLogExport class represents the WorkOS entity created when exporting Audit Log Events.
6
5
  class AuditLogExport
7
6
  include HashProvider
8
- extend T::Sig
9
7
 
10
8
  attr_accessor :object, :id, :state, :url, :created_at, :updated_at
11
9
 
12
- sig { params(json: String).void }
13
10
  def initialize(json)
14
- raw = parse_json(json)
15
-
16
- @object = T.let(raw.object, String)
17
- @id = T.let(raw.id, String)
18
- @state = T.let(raw.state, String)
19
- @url = raw.url
20
- @created_at = T.let(raw.created_at, String)
21
- @updated_at = T.let(raw.updated_at, String)
11
+ hash = JSON.parse(json, symbolize_names: true)
12
+
13
+ @object = hash[:object]
14
+ @id = hash[:id]
15
+ @state = hash[:state]
16
+ @url = hash[:url]
17
+ @created_at = hash[:created_at]
18
+ @updated_at = hash[:updated_at]
22
19
  end
23
20
 
24
21
  def to_json(*)
@@ -31,25 +28,5 @@ module WorkOS
31
28
  updated_at: updated_at,
32
29
  }
33
30
  end
34
-
35
- private
36
-
37
- sig do
38
- params(
39
- json_string: String,
40
- ).returns(WorkOS::Types::AuditLogExportStruct)
41
- end
42
- def parse_json(json_string)
43
- hash = JSON.parse(json_string, symbolize_names: true)
44
-
45
- WorkOS::Types::AuditLogExportStruct.new(
46
- object: hash[:object],
47
- id: hash[:id],
48
- state: hash[:state],
49
- url: hash[:url],
50
- created_at: hash[:created_at],
51
- updated_at: hash[:updated_at],
52
- )
53
- end
54
31
  end
55
32
  end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  require 'net/http'
5
4
  require 'uri'
@@ -9,7 +8,6 @@ module WorkOS
9
8
  # WorkOS Audit Logs platform. You'll need a valid API key.
10
9
  module AuditLogs
11
10
  class << self
12
- extend T::Sig
13
11
  include Client
14
12
 
15
13
  # Create an Audit Log Event.
@@ -19,13 +17,6 @@ module WorkOS
19
17
  # @param [String] idempotency_key An idempotency key
20
18
  #
21
19
  # @return [nil]
22
- sig do
23
- params(
24
- organization: String,
25
- event: Hash,
26
- idempotency_key: T.nilable(String),
27
- ).void
28
- end
29
20
  def create_event(organization:, event:, idempotency_key: nil)
30
21
  request = post_request(
31
22
  path: '/audit_logs/events',
@@ -52,18 +43,6 @@ module WorkOS
52
43
  # @param [Array<String>] targets A list of target types to filter by
53
44
  #
54
45
  # @return [WorkOS::AuditLogExport]
55
- sig do
56
- params(
57
- organization: String,
58
- range_start: String,
59
- range_end: String,
60
- actions: T.nilable(T::Array[String]),
61
- actors: T.nilable(T::Array[String]),
62
- targets: T.nilable(T::Array[String]),
63
- actor_names: T.nilable(T::Array[String]),
64
- actor_ids: T.nilable(T::Array[String]),
65
- ).returns(WorkOS::AuditLogExport)
66
- end
67
46
  def create_export(organization:, range_start:, range_end:, actions: nil, # rubocop:disable Metrics/ParameterLists
68
47
  actors: nil, targets: nil, actor_names: nil, actor_ids: nil)
69
48
  body = {
@@ -94,11 +73,6 @@ module WorkOS
94
73
  # @param [String] id An Audit Log Export ID
95
74
  #
96
75
  # @return [WorkOS::AuditLogExport]
97
- sig do
98
- params(
99
- id: String,
100
- ).returns(WorkOS::AuditLogExport)
101
- end
102
76
  def get_export(id:)
103
77
  request = get_request(
104
78
  auth: true,
@@ -1,16 +1,13 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The AuthenticationFactorAndChallenge class represents
6
5
  # an authentication factor and challenge for a given user.
7
6
  class AuthenticationFactorAndChallenge
8
7
  include HashProvider
9
- extend T::Sig
10
8
 
11
9
  attr_accessor :authentication_factor, :authentication_challenge
12
10
 
13
- sig { params(authentication_response_json: String).void }
14
11
  def initialize(authentication_response_json)
15
12
  json = JSON.parse(authentication_response_json, symbolize_names: true)
16
13
  @authentication_factor = WorkOS::Factor.new(
@@ -1,27 +1,24 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The AuthenticationResponse class represents an Authentication Response as well as an corresponding
6
5
  # response data that can later be appended on.
7
6
  class AuthenticationResponse
8
7
  include HashProvider
9
- extend T::Sig
10
8
 
11
9
  attr_accessor :user, :organization_id, :impersonator, :access_token, :refresh_token
12
10
 
13
- sig { params(authentication_response_json: String).void }
14
11
  def initialize(authentication_response_json)
15
12
  json = JSON.parse(authentication_response_json, symbolize_names: true)
16
13
  @user = WorkOS::User.new(json[:user].to_json)
17
- @organization_id = T.let(json[:organization_id], T.nilable(String))
14
+ @organization_id = json[:organization_id]
18
15
  @impersonator =
19
16
  if (impersonator_json = json[:impersonator])
20
17
  Impersonator.new(email: impersonator_json[:email],
21
18
  reason: impersonator_json[:reason],)
22
19
  end
23
- @access_token = T.let(json[:access_token], String)
24
- @refresh_token = T.let(json[:refresh_token], String)
20
+ @access_token = json[:access_token]
21
+ @refresh_token = json[:refresh_token]
25
22
  end
26
23
 
27
24
  def to_json(*)
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: false
3
2
 
4
3
  module WorkOS
5
4
  # The Challnge class provides a lightweight wrapper around
@@ -7,20 +6,19 @@ module WorkOS
7
6
  # in DirectoryUser space, and is instantiated internally but exposed.
8
7
  class Challenge
9
8
  include HashProvider
10
- extend T::Sig
11
9
 
12
10
  attr_accessor :id, :object, :expires_at, :code, :authentication_factor_id, :updated_at, :created_at
13
11
 
14
- sig { params(json: String).void }
15
12
  def initialize(json)
16
- raw = parse_json(json)
17
- @id = T.let(raw.id, String)
18
- @object = T.let(raw.object, String)
19
- @expires_at = T.let(raw.expires_at, String)
20
- @code = raw.code
21
- @authentication_factor_id = T.let(raw.authentication_factor_id, String)
22
- @created_at = T.let(raw.created_at, String)
23
- @updated_at = T.let(raw.updated_at, String)
13
+ hash = JSON.parse(json, symbolize_names: true)
14
+
15
+ @id = hash[:id]
16
+ @object = hash[:object]
17
+ @expires_at = hash[:expires_at]
18
+ @code = hash[:code]
19
+ @authentication_factor_id = hash[:authentication_factor_id]
20
+ @created_at = hash[:created_at]
21
+ @updated_at = hash[:updated_at]
24
22
  end
25
23
 
26
24
  def to_json(*)
@@ -34,22 +32,5 @@ module WorkOS
34
32
  updated_at: updated_at,
35
33
  }
36
34
  end
37
-
38
- private
39
-
40
- sig { params(json_string: String).returns(WorkOS::Types::ChallengeStruct) }
41
- def parse_json(json_string)
42
- hash = JSON.parse(json_string, symbolize_names: true)
43
-
44
- WorkOS::Types::ChallengeStruct.new(
45
- id: hash[:id],
46
- object: hash[:object],
47
- expires_at: hash[:expires_at],
48
- code: hash[:code],
49
- authentication_factor_id: hash[:authentication_factor_id],
50
- created_at: hash[:created_at],
51
- updated_at: hash[:updated_at],
52
- )
53
- end
54
35
  end
55
36
  end
data/lib/workos/client.rb CHANGED
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
- # typed: false
3
2
 
4
3
  module WorkOS
5
4
  # A Net::HTTP based API client for interacting with the WorkOS API
6
5
  module Client
7
- extend T::Sig
8
6
  include Kernel
9
7
 
10
- sig { returns(Net::HTTP) }
11
8
  def client
12
9
  Net::HTTP.new(WorkOS.config.api_hostname, 443).tap do |http_client|
13
10
  http_client.use_ssl = true
@@ -17,11 +14,6 @@ module WorkOS
17
14
  end
18
15
  end
19
16
 
20
- sig do
21
- params(
22
- request: T.any(Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Delete, Net::HTTP::Put),
23
- ).returns(::T.untyped)
24
- end
25
17
  def execute_request(request:)
26
18
  begin
27
19
  response = client.request(request)
@@ -37,14 +29,6 @@ module WorkOS
37
29
  response
38
30
  end
39
31
 
40
- sig do
41
- params(
42
- path: String,
43
- auth: T.nilable(T::Boolean),
44
- params: T.nilable(Hash),
45
- access_token: T.nilable(String),
46
- ).returns(Net::HTTP::Get)
47
- end
48
32
  def get_request(path:, auth: false, params: {}, access_token: nil)
49
33
  uri = URI(path)
50
34
  uri.query = URI.encode_www_form(params) if params
@@ -59,14 +43,6 @@ module WorkOS
59
43
  request
60
44
  end
61
45
 
62
- sig do
63
- params(
64
- path: String,
65
- auth: T.nilable(T::Boolean),
66
- idempotency_key: T.nilable(String),
67
- body: T.nilable(Hash),
68
- ).returns(Net::HTTP::Post)
69
- end
70
46
  def post_request(path:, auth: false, idempotency_key: nil, body: nil)
71
47
  request = Net::HTTP::Post.new(path, 'Content-Type' => 'application/json')
72
48
  request.body = body.to_json if body
@@ -76,13 +52,6 @@ module WorkOS
76
52
  request
77
53
  end
78
54
 
79
- sig do
80
- params(
81
- path: String,
82
- auth: T.nilable(T::Boolean),
83
- params: T.nilable(Hash),
84
- ).returns(Net::HTTP::Delete)
85
- end
86
55
  def delete_request(path:, auth: false, params: {})
87
56
  uri = URI(path)
88
57
  uri.query = URI.encode_www_form(params) if params
@@ -97,14 +66,6 @@ module WorkOS
97
66
  request
98
67
  end
99
68
 
100
- sig do
101
- params(
102
- path: String,
103
- auth: T.nilable(T::Boolean),
104
- idempotency_key: T.nilable(String),
105
- body: T.nilable(Hash),
106
- ).returns(Net::HTTP::Put)
107
- end
108
69
  def put_request(path:, auth: false, idempotency_key: nil, body: nil)
109
70
  request = Net::HTTP::Put.new(path, 'Content-Type' => 'application/json')
110
71
  request.body = body.to_json if body
@@ -114,7 +75,6 @@ module WorkOS
114
75
  request
115
76
  end
116
77
 
117
- sig { returns(String) }
118
78
  def user_agent
119
79
  engine = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : 'Ruby'
120
80
 
@@ -127,7 +87,6 @@ module WorkOS
127
87
  end
128
88
 
129
89
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
130
- sig { params(response: ::T.untyped).void }
131
90
  def handle_error_response(response:)
132
91
  http_status = response.code.to_i
133
92
  json = JSON.parse(response.body)
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # Configuration class sets config initializer
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # typed: true
3
2
 
4
3
  module WorkOS
5
4
  # The Connection class provides a lightweight wrapper around
@@ -8,27 +7,23 @@ module WorkOS
8
7
  # Note: status is deprecated - use state instead
9
8
  class Connection
10
9
  include HashProvider
11
- extend T::Sig
12
10
 
13
11
  attr_accessor :id, :name, :connection_type, :domains, :organization_id,
14
12
  :state, :status, :created_at, :updated_at
15
13
 
16
- # rubocop:disable Metrics/AbcSize
17
- sig { params(json: String).void }
18
14
  def initialize(json)
19
- raw = parse_json(json)
20
-
21
- @id = T.let(raw.id, String)
22
- @name = T.let(raw.name, String)
23
- @connection_type = T.let(raw.connection_type, String)
24
- @domains = T.let(raw.domains, Array)
25
- @organization_id = raw.organization_id
26
- @state = T.let(raw.state, String)
27
- @status = T.let(raw.status, String)
28
- @created_at = T.let(raw.created_at, String)
29
- @updated_at = T.let(raw.updated_at, String)
15
+ hash = JSON.parse(json, symbolize_names: true)
16
+
17
+ @id = hash[:id]
18
+ @name = hash[:name]
19
+ @connection_type = hash[:connection_type]
20
+ @domains = hash[:domains]
21
+ @organization_id = hash[:organization_id]
22
+ @state = hash[:state]
23
+ @status = hash[:status]
24
+ @created_at = hash[:created_at]
25
+ @updated_at = hash[:updated_at]
30
26
  end
31
- # rubocop:enable Metrics/AbcSize
32
27
 
33
28
  def to_json(*)
34
29
  {
@@ -43,24 +38,5 @@ module WorkOS
43
38
  updated_at: updated_at,
44
39
  }
45
40
  end
46
-
47
- private
48
-
49
- sig { params(json_string: String).returns(WorkOS::Types::ConnectionStruct) }
50
- def parse_json(json_string)
51
- hash = JSON.parse(json_string, symbolize_names: true)
52
-
53
- WorkOS::Types::ConnectionStruct.new(
54
- id: hash[:id],
55
- name: hash[:name],
56
- connection_type: hash[:connection_type],
57
- domains: hash[:domains],
58
- organization_id: hash[:organization_id],
59
- state: hash[:state],
60
- status: hash[:status],
61
- created_at: hash[:created_at],
62
- updated_at: hash[:updated_at],
63
- )
64
- end
65
41
  end
66
42
  end