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
12 changes: 8 additions & 4 deletions lib/workos/organizations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ defmodule WorkOS.Organizations do
Parameter options:

* `:name` - A descriptive name for the Organization. This field does not need to be unique. (required)
* `:domains` - The domains of the Organization.
* `:domain_data` - A list of maps containing domain information composed of the following:
* `:domain` - The domain of the Organization
* `:state` - The verification state of the domain. "pending" | "verified"
* `:allow_profiles_outside_organization` - Whether the Connections within this Organization should allow Profiles that do not have a domain that is present in the set of the Organization’s User Email Domains.
* `:idempotency_key` - A unique string as the value. Each subsequent request matching this unique string will return the same response.

Expand All @@ -96,7 +98,7 @@ defmodule WorkOS.Organizations do
"/organizations",
%{
name: opts[:name],
domains: opts[:domains],
domain_data: opts[:domain_data],
allow_profiles_outside_organization: opts[:allow_profiles_outside_organization]
},
headers: [
Expand All @@ -112,7 +114,9 @@ defmodule WorkOS.Organizations do

* `:organization` - Unique identifier of the Organization. (required)
* `:name` - A descriptive name for the Organization. This field does not need to be unique. (required)
* `:domains` - The domains of the Organization.
* `:domain_data` - A list of maps containing domain information composed of the following:
* `:domain` - The domain of the Organization
* `:state` - The verification state of the domain. "pending" | "verified"
* `:allow_profiles_outside_organization` - Whether the Connections within this Organization should allow Profiles that do not have a domain that is present in the set of the Organization’s User Email Domains.

"""
Expand All @@ -123,7 +127,7 @@ defmodule WorkOS.Organizations do
when is_map_key(opts, :name) do
WorkOS.Client.put(client, Organization, "/organizations/#{organization_id}", %{
name: opts[:name],
domains: opts[:domains],
domain_data: opts[:domain_data],
allow_profiles_outside_organization: !!opts[:allow_profiles_outside_organization]
})
end
Expand Down
9 changes: 6 additions & 3 deletions test/workos/organizations_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule WorkOS.OrganizationsTest do
describe "create_organization" do
test "with an idempotency key, includes an idempotency key with request", context do
opts = [
domains: ["example.com"],
domain_data: [%{"domain" => "example.com", "state" => "pending"}],
name: "Test Organization",
idempotency_key: "the-idempotency-key"
]
Expand All @@ -72,7 +72,10 @@ defmodule WorkOS.OrganizationsTest do
end

test "with a valid payload, creates an organization", context do
opts = [domains: ["example.com"], name: "Test Organization"]
opts = [
domain_data: [%{"domain" => "example.com", "state" => "pending"}],
name: "Test Organization"
]

context |> ClientMock.create_organization(assert_fields: opts)

Expand All @@ -87,7 +90,7 @@ defmodule WorkOS.OrganizationsTest do
test "with a valid payload, updates an organization", context do
opts = [
organization_id: "org_01EHT88Z8J8795GZNQ4ZP1J81T",
domains: ["example.com"],
domain_data: [%{"domain" => "example.com", "state" => "pending"}],
name: "Test Organization 2"
]

Expand Down
Loading