Skip to content

Commit d0756d9

Browse files
authored
Mark allow_profiles_outside_organization as deprecated (#307)
* Mark `allow_profiles_outside_organization` as deprecated * Remove redundant condition
1 parent 7d5335f commit d0756d9

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

lib/workos/organizations.rb

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,37 @@ def get_organization(id:)
7474
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization 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"
77-
# @param [Array<String>] domains List of domains that belong to the organization.
78-
# Deprecated: Use domain_data instead.
7977
# @param [String] name A unique, descriptive name for the organization
80-
# @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
81-
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
8278
# @param [String] idempotency_key An idempotency key
79+
# @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
80+
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
81+
# Deprecated: If you need to allow sign-ins from any email domain, contact [email protected].
82+
# @param [Array<String>] domains List of domains that belong to the organization.
83+
# Deprecated: Use domain_data instead.
8384
def create_organization(
8485
domain_data: nil,
8586
domains: nil,
8687
name:,
8788
allow_profiles_outside_organization: nil,
8889
idempotency_key: nil
8990
)
90-
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.' if domains
91+
body = { name: name }
92+
body[:domain_data] = domain_data if domain_data
93+
94+
if domains
95+
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.'
96+
body[:domains] = domains
97+
end
98+
99+
unless allow_profiles_outside_organization.nil?
100+
warn_deprecation '`allow_profiles_outside_organization` is deprecated. ' \
101+
'If you need to allow sign-ins from any email domain, contact [email protected].'
102+
body[:allow_profiles_outside_organization] = allow_profiles_outside_organization
103+
end
91104

92105
request = post_request(
93106
auth: true,
94-
body: {
95-
domain_data: domain_data,
96-
domains: domains,
97-
name: name,
98-
allow_profiles_outside_organization: allow_profiles_outside_organization,
99-
},
107+
body: body,
100108
path: '/organizations',
101109
idempotency_key: idempotency_key,
102110
)
@@ -113,21 +121,36 @@ def create_organization(
113121
# @param [Array<Hash>] domain_data List of domain hashes describing an orgnaization domain.
114122
# @option domain_data [String] domain The domain that belongs to the organization.
115123
# @option domain_data [String] state The state of the domain. "verified" or "pending"
116-
# @param [Array<String>] domains List of domains that belong to the organization.
117-
# Deprecated: Use domain_data instead.
118124
# @param [String] name A unique, descriptive name for the organization
119125
# @param [Boolean, nil] allow_profiles_outside_organization Whether Connections
120-
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
121-
def update_organization(organization:, domains:, name:, allow_profiles_outside_organization: nil)
122-
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.' if domains
126+
# within the Organization allow profiles that are outside of the Organization's configured User Email Domains.
127+
# Deprecated: If you need to allow sign-ins from any email domain, contact [email protected].
128+
# @param [Array<String>] domains List of domains that belong to the organization.
129+
# Deprecated: Use domain_data instead.
130+
def update_organization(
131+
organization:,
132+
domain_data: nil,
133+
domains: nil,
134+
name:,
135+
allow_profiles_outside_organization: nil
136+
)
137+
body = { name: name }
138+
body[:domain_data] = domain_data if domain_data
139+
140+
if domains
141+
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.'
142+
body[:domains] = domains
143+
end
144+
145+
unless allow_profiles_outside_organization.nil?
146+
warn_deprecation '`allow_profiles_outside_organization` is deprecated. ' \
147+
'If you need to allow sign-ins from any email domain, contact [email protected].'
148+
body[:allow_profiles_outside_organization] = allow_profiles_outside_organization
149+
end
123150

124151
request = put_request(
125152
auth: true,
126-
body: {
127-
domains: domains,
128-
name: name,
129-
allow_profiles_outside_organization: allow_profiles_outside_organization,
130-
},
153+
body: body,
131154
path: "/organizations/#{organization}",
132155
)
133156

0 commit comments

Comments
 (0)