//native
/**
* Create child organization
* Creates a new organization along with:
- An API token scoped to the new organization.
*/
export async function main(auth: RT.Deel, body: Body) {
const url = new URL(`https://api.letsdeel.com/rest/v2/organizations/children`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* The request payload.
*/
data: {
/**
* The object that contains all the information related to the child organization that will be created.
*/
child_organization: {
/**
* The organization's name.
*/
name: string
/**
* The department's name where the manager will be added
*/
department?: string
/**
* The flag that enables the public API for the child organization.
*/
is_api_enabled?: boolean
/**
* The workforce size of the child organization.
*/
workforce_size?: number
/**
* The 2-letter country code of the organization's headquarters.
*/
headquarters_country?: string
[k: string]: unknown
}
/**
* The object that contains the information related to the parent_organization.
*/
parent_organization: {
/**
* The email of one of the managers of the parent organization that will be used to create an user for the child organization, it should exists on the parent organization.
*/
admin_email?: string
[k: string]: unknown
}
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago