diff --git a/.ruby-version b/.ruby-version index b5021469..0aec50e6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.2 +3.1.4 diff --git a/lib/workos/organization.rb b/lib/workos/organization.rb index 75145ece..9bad7fc3 100644 --- a/lib/workos/organization.rb +++ b/lib/workos/organization.rb @@ -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) @@ -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 @@ -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, } diff --git a/lib/workos/organizations.rb b/lib/workos/organizations.rb index d8ecb5c5..b463dd15 100644 --- a/lib/workos/organizations.rb +++ b/lib/workos/organizations.rb @@ -71,7 +71,7 @@ def get_organization(id:) # Create an organization # - # @param [Array] domain_data List of domain hashes describing an orgnaization domain. + # @param [Array] 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 @@ -118,9 +118,10 @@ def create_organization( # Update an organization # # @param [String] organization Organization unique identifier - # @param [Array] domain_data List of domain hashes describing an orgnaization domain. + # @param [Array] 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. @@ -129,6 +130,7 @@ def create_organization( # Deprecated: Use domain_data instead. def update_organization( organization:, + stripe_customer_id: nil, domain_data: nil, domains: nil, name: nil, @@ -136,6 +138,7 @@ def update_organization( ) 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.' diff --git a/spec/lib/workos/organizations_spec.rb b/spec/lib/workos/organizations_spec.rb index 30be9337..8552084f 100644 --- a/spec/lib/workos/organizations_spec.rb +++ b/spec/lib/workos/organizations_spec.rb @@ -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 diff --git a/spec/support/fixtures/vcr_cassettes/organization/update_with_stripe_customer_id.yml b/spec/support/fixtures/vcr_cassettes/organization/update_with_stripe_customer_id.yml new file mode 100644 index 00000000..29d6deeb --- /dev/null +++ b/spec/support/fixtures/vcr_cassettes/organization/update_with_stripe_customer_id.yml @@ -0,0 +1,78 @@ +--- +http_interactions: +- request: + method: put + uri: https://api.workos.com/organizations/org_01JJ5H14CAA2SQ5G9HNN6TBZ05 + body: + encoding: UTF-8 + string: '{"name":"Test Organization","stripe_customer_id":"cus_123"}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - WorkOS; ruby/3.1.4; arm64-darwin24; v5.11.1 + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 22 Jan 2025 16:50:26 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cf-Ray: + - 90610b03f84db9f1-SEA + Cf-Cache-Status: + - DYNAMIC + Etag: + - W/"1cc-uqKwJf4L85rLspCK9lJ1ceRlbSA" + Strict-Transport-Security: + - max-age=15552000; includeSubDomains + Vary: + - Origin, Accept-Encoding + Access-Control-Allow-Credentials: + - 'true' + Content-Security-Policy: + - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' + https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src + ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' + Expect-Ct: + - max-age=0 + Referrer-Policy: + - no-referrer + X-Content-Type-Options: + - nosniff + X-Dns-Prefetch-Control: + - 'off' + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 7b62039f-40f4-4c2c-9ef9-7b1f63615481 + X-Xss-Protection: + - '0' + Set-Cookie: + - _cfuvid=TPT.bwe9giSuDXv9bDFC8leHolKCFKy2kdsa0G89jGI-1737564626875-0.0.1.1-604800000; + path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None + Server: + - cloudflare + body: + encoding: ASCII-8BIT + string: '{"object":"organization","id":"org_01JJ5H14CAA2SQ5G9HNN6TBZ05","name":"Test + Organization","allow_profiles_outside_organization":false,"created_at":"2025-01-21T22:51:46.441Z","updated_at":"2025-01-22T16:50:26.789Z","domains":[{"verification_strategy":"manual","state":"verified","object":"organization_domain","id":"org_domain_01JJ5H14CKRGAE9HVA1Y9YABSX","organization_id":"org_01JJ5H14CAA2SQ5G9HNN6TBZ05","domain":"example.me"}],"stripe_customer_id":"cus_123"}' + http_version: + recorded_at: Wed, 22 Jan 2025 16:50:26 GMT +recorded_with: VCR 5.0.0