Skip to content

Commit 1b72250

Browse files
authored
update_organization stripe_customer_id param + .rbenv update (#346)
* Update .ruby-version Problem: Upon opening this repo, I tried to run `rbenv install` to install the ruby version required for this project. I was met with the following error as Ruby 3.0.2 is EOL. `BUILD FAILED (macOS 15.2 on arm64 using ruby-build 20250115)` Solution: I noticed in one of the vcr tests that the user agent was using Ruby 3.1.4. After updating the .ruby-version to 3.1.4 (Which is what I am assuming the last engineer used), `rbenv install` worked properly and I was able to bundle and begin contribution. * Add stripe_customer_id to update_organization Adds stripe_customer_id as an optional param to update_organization. This was added in a similar fashion to the node js implementation (https://workos.com/docs/reference/organization/update) and to match the initial entitlements documentation (https://workos.com/docs/user-management/entitlements/use-the-entitlements-in-your-application). Consumers should now be able to simply call WorkOS::Organization.update_organization() with a stripe_customer_id to setup stipe entitlements with their WorkOS orgs.
1 parent 3ba8ec0 commit 1b72250

File tree

5 files changed

+110
-4
lines changed

5 files changed

+110
-4
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.1.4

lib/workos/organization.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ module WorkOS
77
class Organization
88
include HashProvider
99

10-
attr_accessor :id, :domains, :name, :allow_profiles_outside_organization, :created_at, :updated_at
10+
attr_accessor(
11+
:id,
12+
:domains,
13+
:stripe_customer_id,
14+
:name,
15+
:allow_profiles_outside_organization,
16+
:created_at,
17+
:updated_at,
18+
)
1119

1220
def initialize(json)
1321
hash = JSON.parse(json, symbolize_names: true)
@@ -16,6 +24,7 @@ def initialize(json)
1624
@name = hash[:name]
1725
@allow_profiles_outside_organization = hash[:allow_profiles_outside_organization]
1826
@domains = hash[:domains]
27+
@stripe_customer_id = hash[:stripe_customer_id]
1928
@created_at = hash[:created_at]
2029
@updated_at = hash[:updated_at]
2130
end
@@ -26,6 +35,7 @@ def to_json(*)
2635
name: name,
2736
allow_profiles_outside_organization: allow_profiles_outside_organization,
2837
domains: domains,
38+
stripe_customer_id: stripe_customer_id,
2939
created_at: created_at,
3040
updated_at: updated_at,
3141
}

lib/workos/organizations.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_organization(id:)
7171

7272
# Create an organization
7373
#
74-
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization domain.
74+
# @param [Array<Hash>] domain_data List of domain hashes describing an organization domain.
7575
# @option domain_data [String] domain The domain that belongs to the organization.
7676
# @option domain_data [String] state The state of the domain. "verified" or "pending"
7777
# @param [String] name A unique, descriptive name for the organization
@@ -118,9 +118,10 @@ def create_organization(
118118
# Update an organization
119119
#
120120
# @param [String] organization Organization unique identifier
121-
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization domain.
121+
# @param [Array<Hash>] domain_data List of domain hashes describing an organization domain.
122122
# @option domain_data [String] domain The domain that belongs to the organization.
123123
# @option domain_data [String] state The state of the domain. "verified" or "pending"
124+
# @param [String] stripe_customer_id The Stripe customer ID associated with this organization.
124125
# @param [String] name A unique, descriptive name for the organization
125126
# @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
126127
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
@@ -129,13 +130,15 @@ def create_organization(
129130
# Deprecated: Use domain_data instead.
130131
def update_organization(
131132
organization:,
133+
stripe_customer_id: nil,
132134
domain_data: nil,
133135
domains: nil,
134136
name: nil,
135137
allow_profiles_outside_organization: nil
136138
)
137139
body = { name: name }
138140
body[:domain_data] = domain_data if domain_data
141+
body[:stripe_customer_id] = stripe_customer_id if stripe_customer_id
139142

140143
if domains
141144
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.'

spec/lib/workos/organizations_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@
295295
end
296296
end
297297
end
298+
context 'with a stripe_customer_id' do
299+
it 'updates the organization' do
300+
VCR.use_cassette 'organization/update_with_stripe_customer_id' do
301+
organization = described_class.update_organization(
302+
organization: 'org_01JJ5H14CAA2SQ5G9HNN6TBZ05',
303+
name: 'Test Organization',
304+
stripe_customer_id: 'cus_123',
305+
)
306+
307+
expect(organization.id).to eq('org_01JJ5H14CAA2SQ5G9HNN6TBZ05')
308+
expect(organization.name).to eq('Test Organization')
309+
expect(organization.stripe_customer_id).to eq('cus_123')
310+
end
311+
end
312+
end
298313
end
299314

300315
describe '.delete_organization' do

spec/support/fixtures/vcr_cassettes/organization/update_with_stripe_customer_id.yml

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)