export type PermissionsCapabilities = {enabled?: boolean | undefined, manageEnabled?: boolean | undefined, grantEnabled?: boolean | undefined}; export type PermissionIdResource = {uri?: string | undefined, id?: string | undefined, siteCompatible?: ('Compatible' | 'Incompatible' | 'Independent') | undefined, readOnly?: boolean | undefined, assignable?: boolean | undefined, permissionsCapabilities?: PermissionsCapabilities | undefined}; export type RoleResource = {uri?: string | undefined, id?: string | undefined, displayName?: string | undefined, description?: string | undefined, siteCompatible?: boolean | undefined, custom?: boolean | undefined, scope?: ('Account' | 'AllExtensions' | 'Federation' | 'Group' | 'NonUserExtensions' | 'RoleBased' | 'Self' | 'UserExtensions') | undefined, hidden?: boolean | undefined, lastUpdated?: string | undefined, permissions?: Array | undefined}; export type CreateApiRestapiV10AccountAccountIdUserRoleArgs = {accountId: string, body: RoleResource}; export type CreateApiRestapiV10AccountAccountIdUserRoleOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Custom Role * * POST /restapi/v1.0/account/{accountId}/user-role */ export const createApiRestapiV10AccountAccountIdUserRole = async (args: CreateApiRestapiV10AccountAccountIdUserRoleArgs, options?: CreateApiRestapiV10AccountAccountIdUserRoleOptions) => { const {baseUrl = "https://platform.ringcentral.com", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/restapi/v1.0/account/${encodeURIComponent(String(args.accountId))}/user-role${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };