workos 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fae212aa830d1b7de8522d9886fa3081ac578981a3fe352a7fd31b4a2e0ca02
4
- data.tar.gz: 189e54ee9cb6e86cae3f8754718a4c08034727a1f7ce9c6bcbcc272dd5e6b34e
3
+ metadata.gz: 25c285312ce05b78c1b7d98da7ca01681fadfa717e14c96c1594cbb87020c6a6
4
+ data.tar.gz: 59c465b46fda1b816b3a00b429912076f64b36f736d4b2fc778529cb56ec7a7b
5
5
  SHA512:
6
- metadata.gz: 816220f9a6b4dd3ba355ee7d94c343f5005b85cf91f7096f942e53cb2693fe8119981de1530269a04e456de16253f6d4205cf4410099723ff797b00caea724f9
7
- data.tar.gz: 04713ab0a225047a0f9fab79ece78a14a873eb6b4e5a2bfc5b96f4555568a7ec13a0ebe7e2c4127cb929ecc34be9c73056c066be9edb52045119eaa8144dd928
6
+ metadata.gz: ec7f4af257aa50426fd22ff3887ffde0da50310b7b53c412060a688069fec02eb2c151cb5a6c041ee5965a94c9ccef7605935425e5d97096a165040e254b44fc
7
+ data.tar.gz: 02ce83d0dd57f6e4b0994a4669a3a57ac8224cf71d2bd03d9236774eeea8ebbaf57f5d60244696533a98001d07e52b7b75cab61aeab73bfa0837881e40204d7e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.3.0)
4
+ workos (0.4.1)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -56,7 +56,7 @@ GEM
56
56
  simplecov-html (0.10.2)
57
57
  sorbet (0.5.5560)
58
58
  sorbet-static (= 0.5.5560)
59
- sorbet-runtime (0.5.5571)
59
+ sorbet-runtime (0.5.5862)
60
60
  sorbet-static (0.5.5560-universal-darwin-14)
61
61
  unicode-display_width (1.6.0)
62
62
  url (0.3.2)
@@ -57,6 +57,54 @@ module WorkOS
57
57
 
58
58
  execute_request(request: request)
59
59
  end
60
+
61
+ # Retrieve Audit Trail events.
62
+ #
63
+ # @param [Hash] options An options hash
64
+ # @option options [String] before Event ID to look before
65
+ # @option options [String] after Event ID to look after
66
+ # @option options [Integer] limit Number of Events to return
67
+ # @option options [Array<String>] group List of Groups to filter for
68
+ # @option options [Array<String>] action List of Actions to filter for
69
+ # @option options [Array<String>] action_type List of Action Types to
70
+ # filter for
71
+ # @option options [Array<String>] actor_name List of Actor Name to filter
72
+ # for
73
+ # @option options [Array<String>] actor_id List of Actor IDs to filter for
74
+ # @option options [Array<String>] target_name List of Target Names to
75
+ # filter for
76
+ # @option options [Array<String>] target_id List of Target IDs to filter
77
+ # for
78
+ # @option options [String] occurred_at ISO-8601 datetime of when an event
79
+ # occurred
80
+ # @option options [String] occurred_at_gt ISO-8601 datetime of when an
81
+ # event occurred after
82
+ # @option options [String] occurred_at_gte ISO-8601 datetime of when an
83
+ # event occurred at or after
84
+ # @option options [String] occurred_at_lt ISO-8601 datetime of when an
85
+ # event occurred before
86
+ # @option options [String] ISO-8601 datetime of when an event occured at
87
+ # or before
88
+ # @option options [String] search Keyword search
89
+ #
90
+ # @return [Array<Hash>]
91
+ sig do
92
+ params(
93
+ options: T::Hash[Symbol, String],
94
+ ).returns(T::Array[T::Hash[String, T.nilable(String)]])
95
+ end
96
+
97
+ def get_events(options = {})
98
+ response = execute_request(
99
+ request: get_request(
100
+ path: '/events',
101
+ auth: true,
102
+ params: options,
103
+ ),
104
+ )
105
+
106
+ JSON.parse(response.body)['data']
107
+ end
60
108
  end
61
109
  end
62
110
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  # typed: true
3
3
 
4
+ require 'net/http'
5
+
4
6
  module WorkOS
5
7
  # The Directory Sync module provides convenience methods for working with the
6
8
  # WorkOS Directory Sync platform. You'll need a valid API key and to have
@@ -22,8 +22,8 @@ module WorkOS
22
22
 
23
23
  @id = T.let(raw.id, String)
24
24
  @email = T.let(raw.email, String)
25
- @first_name = T.let(raw.first_name, String)
26
- @last_name = T.let(raw.last_name, String)
25
+ @first_name = raw.first_name
26
+ @last_name = raw.last_name
27
27
  @connection_type = T.let(raw.connection_type, String)
28
28
  @idp_id = T.let(raw.idp_id, String)
29
29
  end
@@ -31,7 +31,7 @@ module WorkOS
31
31
  # @param [String] redirect_uri The URI where users are directed
32
32
  # after completing the authentication step. Must match a
33
33
  # configured redirect URI on your WorkOS dashboard.
34
- # @param [Hash] state An aribtrary state object
34
+ # @param [String] state An aribtrary state object
35
35
  # that is preserved and available to the client in the response.
36
36
  # @example
37
37
  # WorkOS::SSO.authorization_url(
@@ -40,7 +40,7 @@ module WorkOS
40
40
  # redirect_uri: 'https://workos.com/callback',
41
41
  # state: {
42
42
  # next_page: '/docs'
43
- # }
43
+ # }.to_s
44
44
  # )
45
45
  #
46
46
  # => "https://api.workos.com/sso/authorize?domain=acme.com" \
@@ -55,11 +55,11 @@ module WorkOS
55
55
  redirect_uri: String,
56
56
  domain: T.nilable(String),
57
57
  provider: T.nilable(String),
58
- state: Hash,
58
+ state: T.nilable(String),
59
59
  ).returns(String)
60
60
  end
61
61
  def authorization_url(
62
- project_id:, redirect_uri:, domain: nil, provider: nil, state: {}
62
+ project_id:, redirect_uri:, domain: nil, provider: nil, state: ''
63
63
  )
64
64
  validate_domain_and_provider(provider: provider, domain: domain)
65
65
 
@@ -8,8 +8,8 @@ module WorkOS
8
8
  class ProfileStruct < T::Struct
9
9
  const :id, String
10
10
  const :email, String
11
- const :first_name, String
12
- const :last_name, String
11
+ const :first_name, T.nilable(String)
12
+ const :last_name, T.nilable(String)
13
13
  const :connection_type, String
14
14
  const :idp_id, String
15
15
  end
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.1'
6
6
  end
@@ -137,4 +137,16 @@ describe WorkOS::AuditTrail do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe '.get_events' do
142
+ context 'with no options' do
143
+ it 'returns events' do
144
+ VCR.use_cassette('audit_trail/get_events') do
145
+ events = described_class.get_events
146
+
147
+ expect(events.size).to eq(2)
148
+ end
149
+ end
150
+ end
151
+ end
140
152
  end
@@ -13,7 +13,7 @@ describe WorkOS::SSO do
13
13
  redirect_uri: 'foo.com/auth/callback',
14
14
  state: {
15
15
  next_page: '/dashboard/edit',
16
- },
16
+ }.to_s,
17
17
  }
18
18
  end
19
19
  it 'returns a valid URL' do
@@ -47,7 +47,7 @@ describe WorkOS::SSO do
47
47
  redirect_uri: 'foo.com/auth/callback',
48
48
  state: {
49
49
  next_page: '/dashboard/edit',
50
- },
50
+ }.to_s,
51
51
  }
52
52
  end
53
53
  it 'returns a valid URL' do
@@ -80,7 +80,7 @@ describe WorkOS::SSO do
80
80
  redirect_uri: 'foo.com/auth/callback',
81
81
  state: {
82
82
  next_page: '/dashboard/edit',
83
- },
83
+ }.to_s,
84
84
  }
85
85
  end
86
86
  it 'raises an error' do
@@ -101,7 +101,7 @@ describe WorkOS::SSO do
101
101
  redirect_uri: 'foo.com/auth/callback',
102
102
  state: {
103
103
  next_page: '/dashboard/edit',
104
- },
104
+ }.to_s,
105
105
  }
106
106
  end
107
107
  it 'raises an error' do
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/events
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/2.7.1; x86_64-darwin19; v0.4.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Vary:
26
+ - Origin, Accept-Encoding
27
+ Access-Control-Allow-Credentials:
28
+ - "true"
29
+ X-Dns-Prefetch-Control:
30
+ - "off"
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ X-Download-Options:
36
+ - noopen
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ X-Request-Id:
42
+ - ""
43
+ Content-Type:
44
+ - application/json; charset=utf-8
45
+ Etag:
46
+ - W/"1784-HtVN7X+AT30Dlt9nZrirP0nnyV8"
47
+ Date:
48
+ - Fri, 31 Jul 2020 14:41:12 GMT
49
+ Connection:
50
+ - keep-alive
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string:
56
+ '{"data":[{"object":"event","id":"evt_01EEJM9Q9SMC3W2SZDKA5VJ8XQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPHAYX46BBZKGK3BGQXJ","metadata":{"description":"User
57
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.384Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}},{"object":"event","id":"evt_01EEJM9Q7GMR1VGT6VXN2N2JJQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPGM8KFT9VBQHJMV8YZB","metadata":{"description":"User
58
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.360Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}}],"listMetadata":{"before":"evt_01EEJKZDAR6G4JHFQT4R3KSZDQ","after":null}}'
59
+ http_version:
60
+ recorded_at: Fri, 31 Jul 2020 14:41:12 GMT
61
+ recorded_with: VCR 5.0.0
@@ -5,18 +5,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'workos/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'workos'
9
- spec.version = WorkOS::VERSION
10
- spec.authors = ['WorkOS']
11
- spec.email = ['support@workos.com']
12
- spec.description = 'API client for WorkOS'
13
- spec.summary = 'API client for WorkOS'
14
- spec.homepage = 'https://github.com/workos/workos-ruby'
15
- spec.license = 'MIT'
8
+ spec.name = 'workos'
9
+ spec.version = WorkOS::VERSION
10
+ spec.authors = ['WorkOS']
11
+ spec.email = ['support@workos.com']
12
+ spec.description = 'API client for WorkOS'
13
+ spec.summary = 'API client for WorkOS'
14
+ spec.homepage = 'https://github.com/workos-inc/workos-ruby'
15
+ spec.license = 'MIT'
16
+ spec.metadata = {
17
+ 'documentation_uri' => 'https://docs.workos.com/sdk/ruby',
18
+ }
16
19
 
17
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
23
  spec.require_paths = ['lib']
21
24
 
22
25
  spec.add_dependency 'sorbet-runtime', '~> 0.5'
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: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -239,6 +239,7 @@ files:
239
239
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
240
240
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
241
241
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
242
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
242
243
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
243
244
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
244
245
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
@@ -254,10 +255,11 @@ files:
254
255
  - spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml
255
256
  - spec/support/profile.txt
256
257
  - workos.gemspec
257
- homepage: https://github.com/workos/workos-ruby
258
+ homepage: https://github.com/workos-inc/workos-ruby
258
259
  licenses:
259
260
  - MIT
260
- metadata: {}
261
+ metadata:
262
+ documentation_uri: https://docs.workos.com/sdk/ruby
261
263
  post_install_message:
262
264
  rdoc_options: []
263
265
  require_paths:
@@ -273,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
275
  - !ruby/object:Gem::Version
274
276
  version: '0'
275
277
  requirements: []
276
- rubygems_version: 3.1.2
278
+ rubygems_version: 3.1.4
277
279
  signing_key:
278
280
  specification_version: 4
279
281
  summary: API client for WorkOS
@@ -288,6 +290,7 @@ test_files:
288
290
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
289
291
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
290
292
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
293
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
291
294
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
292
295
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
293
296
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml