Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2
3.1.4
12 changes: 11 additions & 1 deletion lib/workos/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ module WorkOS
class Organization
include HashProvider

attr_accessor :id, :domains, :name, :allow_profiles_outside_organization, :created_at, :updated_at
attr_accessor(
:id,
:domains,
:stripe_customer_id,
:name,
:allow_profiles_outside_organization,
:created_at,
:updated_at,
)

def initialize(json)
hash = JSON.parse(json, symbolize_names: true)
Expand All @@ -16,6 +24,7 @@ def initialize(json)
@name = hash[:name]
@allow_profiles_outside_organization = hash[:allow_profiles_outside_organization]
@domains = hash[:domains]
@stripe_customer_id = hash[:stripe_customer_id]
@created_at = hash[:created_at]
@updated_at = hash[:updated_at]
end
Expand All @@ -26,6 +35,7 @@ def to_json(*)
name: name,
allow_profiles_outside_organization: allow_profiles_outside_organization,
domains: domains,
stripe_customer_id: stripe_customer_id,
created_at: created_at,
updated_at: updated_at,
}
Expand Down
7 changes: 5 additions & 2 deletions lib/workos/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_organization(id:)

# Create an organization
#
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization domain.
# @param [Array<Hash>] domain_data List of domain hashes describing an organization domain.
# @option domain_data [String] domain The domain that belongs to the organization.
# @option domain_data [String] state The state of the domain. "verified" or "pending"
# @param [String] name A unique, descriptive name for the organization
Expand Down Expand Up @@ -118,9 +118,10 @@ def create_organization(
# Update an organization
#
# @param [String] organization Organization unique identifier
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization domain.
# @param [Array<Hash>] domain_data List of domain hashes describing an organization domain.
# @option domain_data [String] domain The domain that belongs to the organization.
# @option domain_data [String] state The state of the domain. "verified" or "pending"
# @param [String] stripe_customer_id The Stripe customer ID associated with this organization.
# @param [String] name A unique, descriptive name for the organization
# @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
Expand All @@ -129,13 +130,15 @@ def create_organization(
# Deprecated: Use domain_data instead.
def update_organization(
organization:,
stripe_customer_id: nil,
domain_data: nil,
domains: nil,
name: nil,
allow_profiles_outside_organization: nil
)
body = { name: name }
body[:domain_data] = domain_data if domain_data
body[:stripe_customer_id] = stripe_customer_id if stripe_customer_id

if domains
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.'
Expand Down
15 changes: 15 additions & 0 deletions spec/lib/workos/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,21 @@
end
end
end
context 'with a stripe_customer_id' do
it 'updates the organization' do
VCR.use_cassette 'organization/update_with_stripe_customer_id' do
organization = described_class.update_organization(
organization: 'org_01JJ5H14CAA2SQ5G9HNN6TBZ05',
name: 'Test Organization',
stripe_customer_id: 'cus_123',
)

expect(organization.id).to eq('org_01JJ5H14CAA2SQ5G9HNN6TBZ05')
expect(organization.name).to eq('Test Organization')
expect(organization.stripe_customer_id).to eq('cus_123')
end
end
end
end

describe '.delete_organization' do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading