Create a new organization. # Arguments `client` — Authenticated storage client. `name` — Human-readable display name for the organization. `email` — Optional contact email. # Errors Returns [`TeamsError::AlreadyExists`](crate::error::TeamsError::AlreadyExists) if an organization with the derived slug already exists.
(
client: &StorageClient,
name: &str,
email: Option<&str>,
)
| 23 | /// Returns [`TeamsError::AlreadyExists`](crate::error::TeamsError::AlreadyExists) |
| 24 | /// if an organization with the derived slug already exists. |
| 25 | pub async fn create_org( |
| 26 | client: &StorageClient, |
| 27 | name: &str, |
| 28 | email: Option<&str>, |
| 29 | ) -> TeamsResult<OrgInfo> { |
| 30 | debug!("Creating organization: name={name}"); |
| 31 | let slug = slugify(name); |
| 32 | let body = CreateOrgRequest { |
| 33 | slug: &slug, |
| 34 | name, |
| 35 | email, |
| 36 | }; |
| 37 | let info: OrgInfo = client |
| 38 | .post("/orgs", &body) |
| 39 | .await |
| 40 | .map_err(|e| map_remote_error(e, format!("org {name}")))?; |
| 41 | debug!("Created organization: slug={}, id={}", info.slug, info.id); |
| 42 | Ok(info) |
| 43 | } |
| 44 | |
| 45 | /// Fetch an organization by slug. |
| 46 | /// |
no test coverage detected