workos 5.24.0 → 5.25.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7f42db282e0cd23cad458937055c17ec9fa9e82672b9aa1b888ce2200aa8891
4
- data.tar.gz: 1e05a96b056eba6bef1e8f89d7ad6b2cabba616b3911c2afccee6133e8749b9f
3
+ metadata.gz: 86d12c42e6f45139b343d1f519807176eca7a9ac77dbd2d3de0287a9406c50c4
4
+ data.tar.gz: 3addd0959c8b7b8c2caae994b694bfda1eabe41499f540d76e71865e9ae9b35f
5
5
  SHA512:
6
- metadata.gz: 1f3282f8a5c632f2f03a98ce2c43824cfe2fbbb57b575ee51def000a5b03073b1ab284368f55543a79e3281223b6409854fdb98a45457b17268f9768a7717957
7
- data.tar.gz: dbf3dd84bc9758fd141649e1dbb5c7d41fc06b6d5e8e64d1ae597e8188a87369783ecdae026c7b6a6f947afbc28c25fd475aa8f927cb422feb6766c6ddfa0804
6
+ metadata.gz: e286d3aa2d010bbab396d9267795c9eee35cac00f7d3c4c95fb35d70b08df133d32b0081a5f83a1ecf1fe28d663f660947b27756b7225a22ed7b345d4e5d5898
7
+ data.tar.gz: 9571637a3bda0ce330a54ea0a8a09076905fdece0b2e85565a3dd9510d5c3f27d52021cca7a51372d7bc0c3de00a7aeaacb521e0522b9a849df8081d5c316828
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (5.24.0)
4
+ workos (5.25.0)
5
5
  encryptor (~> 3.0)
6
6
  jwt (~> 2.8)
7
7
 
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WorkOS
4
+ # The FeatureFlag class provides a lightweight wrapper around
5
+ # a WorkOS Feature Flag resource. This class is not meant to be instantiated
6
+ # in user space, and is instantiated internally but exposed.
7
+ class FeatureFlag
8
+ include HashProvider
9
+
10
+ attr_accessor :id, :name, :slug, :description, :created_at, :updated_at
11
+
12
+ def initialize(json)
13
+ hash = JSON.parse(json, symbolize_names: true)
14
+
15
+ @id = hash[:id]
16
+ @name = hash[:name]
17
+ @slug = hash[:slug]
18
+ @description = hash[:description]
19
+ @created_at = hash[:created_at]
20
+ @updated_at = hash[:updated_at]
21
+ end
22
+
23
+ def to_json(*)
24
+ {
25
+ id: id,
26
+ name: name,
27
+ slug: slug,
28
+ description: description,
29
+ created_at: created_at,
30
+ updated_at: updated_at,
31
+ }
32
+ end
33
+ end
34
+ end
@@ -224,6 +224,46 @@ module WorkOS
224
224
  )
225
225
  end
226
226
 
227
+ # Retrieve a list of feature flags for the given organization.
228
+ #
229
+ # @param [String] organization_id The ID of the organization to fetch feature flags for.
230
+ # @param [Hash] options
231
+ # @option options [String] before A pagination argument used to request
232
+ # feature flags before the provided FeatureFlag ID.
233
+ # @option options [String] after A pagination argument used to request
234
+ # feature flags after the provided FeatureFlag ID.
235
+ # @option options [Integer] limit A pagination argument used to limit the number
236
+ # of listed FeatureFlags that are returned.
237
+ # @option options [String] order The order in which to paginate records
238
+ #
239
+ # @example
240
+ # WorkOS::Organizations.list_organization_feature_flags(organization_id: 'org_01EHZNVPK3SFK441A1RGBFSHRT')
241
+ # => #<WorkOS::Types::ListStruct data=[#<WorkOS::FeatureFlag id="flag_123" slug="new-feature"
242
+ # enabled=true ...>] ...>
243
+ #
244
+ # @return [WorkOS::Types::ListStruct] - Collection of FeatureFlag objects
245
+ def list_organization_feature_flags(organization_id:, options: {})
246
+ options[:order] ||= 'desc'
247
+ response = execute_request(
248
+ request: get_request(
249
+ path: "/organizations/#{organization_id}/feature-flags",
250
+ auth: true,
251
+ params: options,
252
+ ),
253
+ )
254
+
255
+ parsed_response = JSON.parse(response.body)
256
+
257
+ feature_flags = parsed_response['data'].map do |feature_flag|
258
+ WorkOS::FeatureFlag.new(feature_flag.to_json)
259
+ end
260
+
261
+ WorkOS::Types::ListStruct.new(
262
+ data: feature_flags,
263
+ list_metadata: parsed_response['list_metadata']&.transform_keys(&:to_sym),
264
+ )
265
+ end
266
+
227
267
  private
228
268
 
229
269
  def check_and_raise_organization_error(response:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkOS
4
- VERSION = '5.24.0'
4
+ VERSION = '5.25.0'
5
5
  end
data/lib/workos.rb CHANGED
@@ -59,6 +59,7 @@ module WorkOS
59
59
  autoload :Event, 'workos/event'
60
60
  autoload :Events, 'workos/events'
61
61
  autoload :Factor, 'workos/factor'
62
+ autoload :FeatureFlag, 'workos/feature_flag'
62
63
  autoload :Impersonator, 'workos/impersonator'
63
64
  autoload :Invitation, 'workos/invitation'
64
65
  autoload :MagicAuth, 'workos/magic_auth'
@@ -450,4 +450,120 @@ describe WorkOS::Organizations do
450
450
  end
451
451
  end
452
452
  end
453
+
454
+ describe '.list_organization_feature_flags' do
455
+ context 'with no options' do
456
+ it 'returns feature flags for organization' do
457
+ expected_metadata = {
458
+ after: nil,
459
+ before: nil,
460
+ }
461
+
462
+ VCR.use_cassette 'organization/list_organization_feature_flags' do
463
+ feature_flags = described_class.list_organization_feature_flags(
464
+ organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529',
465
+ )
466
+
467
+ expect(feature_flags.data.size).to eq(2)
468
+ expect(feature_flags.list_metadata).to eq(expected_metadata)
469
+ end
470
+ end
471
+ end
472
+
473
+ context 'with the before option' do
474
+ it 'forms the proper request to the API' do
475
+ request_args = [
476
+ '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?before=before-id&'\
477
+ 'order=desc',
478
+ 'Content-Type' => 'application/json'
479
+ ]
480
+
481
+ expected_request = Net::HTTP::Get.new(*request_args)
482
+
483
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
484
+ and_return(expected_request)
485
+
486
+ VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do
487
+ feature_flags = described_class.list_organization_feature_flags(
488
+ organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529',
489
+ options: { before: 'before-id' },
490
+ )
491
+
492
+ expect(feature_flags.data.size).to eq(2)
493
+ end
494
+ end
495
+ end
496
+
497
+ context 'with the after option' do
498
+ it 'forms the proper request to the API' do
499
+ request_args = [
500
+ '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?after=after-id&'\
501
+ 'order=desc',
502
+ 'Content-Type' => 'application/json'
503
+ ]
504
+
505
+ expected_request = Net::HTTP::Get.new(*request_args)
506
+
507
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
508
+ and_return(expected_request)
509
+
510
+ VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do
511
+ feature_flags = described_class.list_organization_feature_flags(
512
+ organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529',
513
+ options: { after: 'after-id' },
514
+ )
515
+
516
+ expect(feature_flags.data.size).to eq(2)
517
+ end
518
+ end
519
+ end
520
+
521
+ context 'with the limit option' do
522
+ it 'forms the proper request to the API' do
523
+ request_args = [
524
+ '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?limit=10&'\
525
+ 'order=desc',
526
+ 'Content-Type' => 'application/json'
527
+ ]
528
+
529
+ expected_request = Net::HTTP::Get.new(*request_args)
530
+
531
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
532
+ and_return(expected_request)
533
+
534
+ VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do
535
+ feature_flags = described_class.list_organization_feature_flags(
536
+ organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529',
537
+ options: { limit: 10 },
538
+ )
539
+
540
+ expect(feature_flags.data.size).to eq(2)
541
+ end
542
+ end
543
+ end
544
+
545
+ context 'with multiple pagination options' do
546
+ it 'forms the proper request to the API' do
547
+ request_args = [
548
+ '/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?after=after-id&'\
549
+ 'limit=5&order=asc',
550
+ 'Content-Type' => 'application/json'
551
+ ]
552
+
553
+ expected_request = Net::HTTP::Get.new(*request_args)
554
+
555
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
556
+ and_return(expected_request)
557
+
558
+ VCR.use_cassette 'organization/list_organization_feature_flags', match_requests_on: [:path] do
559
+ feature_flags = described_class.list_organization_feature_flags(
560
+ organization_id: 'org_01HX7Q7R12H1JMAKN75SH2G529',
561
+ options: { after: 'after-id', limit: 5, order: 'asc' },
562
+ )
563
+
564
+ expect(feature_flags.data.size).to eq(2)
565
+ end
566
+ end
567
+ end
568
+ end
453
569
  end
@@ -0,0 +1,78 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/organizations/org_01HX7Q7R12H1JMAKN75SH2G529/feature-flags?order=desc
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.1.4; arm64-darwin24; v5.24.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Mon, 04 Aug 2025 18:37:04 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Cf-Ray:
34
+ - 96a029f4191e2f57-LAX
35
+ Cf-Cache-Status:
36
+ - DYNAMIC
37
+ Etag:
38
+ - W/"1f7-g5rU0vT2OhGT9sAPsywR3YS8ePw"
39
+ Strict-Transport-Security:
40
+ - max-age=15552000; includeSubDomains
41
+ Vary:
42
+ - Origin, Accept-Encoding
43
+ Access-Control-Allow-Credentials:
44
+ - 'true'
45
+ Content-Security-Policy:
46
+ - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self''
47
+ https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src
48
+ ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
49
+ Expect-Ct:
50
+ - max-age=0
51
+ Referrer-Policy:
52
+ - no-referrer
53
+ X-Content-Type-Options:
54
+ - nosniff
55
+ X-Dns-Prefetch-Control:
56
+ - 'off'
57
+ X-Download-Options:
58
+ - noopen
59
+ X-Frame-Options:
60
+ - SAMEORIGIN
61
+ X-Permitted-Cross-Domain-Policies:
62
+ - none
63
+ X-Request-Id:
64
+ - 9cd52998-5106-40cf-9080-82c07528c672
65
+ X-Xss-Protection:
66
+ - '0'
67
+ Set-Cookie:
68
+ - _cfuvid=_9dbE_0fDVZ45WXvgEp8frEFOIlVDyARPbMk3AffOcs-1754332624329-0.0.1.1-604800000;
69
+ path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None
70
+ Server:
71
+ - cloudflare
72
+ body:
73
+ encoding: ASCII-8BIT
74
+ string: '{"object":"list","data":[{"object":"feature_flag","id":"flag_01K1V04FV94RNDSN5GKSZVQMYN","slug":"new-sidebar-layout","name":"New
75
+ Sidebar Layout","description":"","created_at":"2025-08-04T16:55:15.557Z","updated_at":"2025-08-04T16:55:15.557Z"},{"object":"feature_flag","id":"flag_01K1V02KNS6WHYXKG0DWB87THK","slug":"dark-mode-toggle","name":"Dark
76
+ Mode Toggle","description":"","created_at":"2025-08-04T16:54:13.942Z","updated_at":"2025-08-04T16:54:13.942Z"}],"list_metadata":{"before":null,"after":null}}'
77
+ recorded_at: Mon, 04 Aug 2025 18:37:04 GMT
78
+ recorded_with: VCR 6.3.1
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: 5.24.0
4
+ version: 5.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-30 00:00:00.000000000 Z
11
+ date: 2025-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: encryptor
@@ -153,6 +153,7 @@ files:
153
153
  - lib/workos/event.rb
154
154
  - lib/workos/events.rb
155
155
  - lib/workos/factor.rb
156
+ - lib/workos/feature_flag.rb
156
157
  - lib/workos/hash_provider.rb
157
158
  - lib/workos/impersonator.rb
158
159
  - lib/workos/invitation.rb
@@ -274,6 +275,7 @@ files:
274
275
  - spec/support/fixtures/vcr_cassettes/organization/get.yml
275
276
  - spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml
276
277
  - spec/support/fixtures/vcr_cassettes/organization/list.yml
278
+ - spec/support/fixtures/vcr_cassettes/organization/list_organization_feature_flags.yml
277
279
  - spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.yml
278
280
  - spec/support/fixtures/vcr_cassettes/organization/update.yml
279
281
  - spec/support/fixtures/vcr_cassettes/organization/update_with_external_id.yml
@@ -504,6 +506,7 @@ test_files:
504
506
  - spec/support/fixtures/vcr_cassettes/organization/get.yml
505
507
  - spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml
506
508
  - spec/support/fixtures/vcr_cassettes/organization/list.yml
509
+ - spec/support/fixtures/vcr_cassettes/organization/list_organization_feature_flags.yml
507
510
  - spec/support/fixtures/vcr_cassettes/organization/list_organization_roles.yml
508
511
  - spec/support/fixtures/vcr_cassettes/organization/update.yml
509
512
  - spec/support/fixtures/vcr_cassettes/organization/update_with_external_id.yml