//native
type SageIntacct = {
token: string
}
/**
* Create a user
* Creates a new user.
*/
export async function main(
auth: SageIntacct,
body: {
key?: string
id?: string
userName?: string
accountEmail?: string
userType?:
| 'business'
| 'employee'
| 'viewOnly'
| 'dashboard'
| 'projectManager'
| 'paymentApprover'
| 'platform'
| 'crm'
| 'warehouse'
| 'constructionManager'
adminPrivileges?: 'off' | 'limited' | 'full'
status?: 'active' | 'inactive' | 'lockedOut'
webServices?: { isEnabled?: false | true; isRestricted?: false | true }
password?: {
neverExpires?: false | true
requiresReset?: false | true
disablePassword?: false | true
}
sso?: { isSSOEnabled?: false | true; federatedSSOId?: string }
entityAccess?: {
allowUnrestrictedAccess?: false | true
allowToplevelAccess?: false | true
}
contact?: {
key?: string
id?: string
href?: string
lastName?: string
firstName?: string
middleName?: string
prefix?: string
printAs?: string
email1?: string
email2?: string
phone1?: string
phone2?: string
mobile?: string
pager?: string
fax?: string
URL1?: string
URL2?: string
companyName?: string
mailingAddress?: {
addressLine1?: string
addressLine2?: string
addressLine3?: string
city?: string
state?: string
postCode?: string
country?: string
}
} & {}
trustedDevices?: 'companyDefault' | 'always' | 'never'
isChatterDisabled?: false | true
hideOtherDepartmentTransactions?: false | true
locations?: { key?: string; id?: string; href?: string }[]
departments?: { key?: string; id?: string; href?: string }[]
territories?: { key?: string; id?: string; href?: string }[]
roles?: { key?: string; id?: string; href?: string }[]
permissionAssignments?: {
permission?: { key?: string; id?: string; href?: string }
accessRights?:
| 'ach'
| 'achSetup'
| 'add'
| 'addExpense'
| 'apiProxy'
| 'approvalLevel1'
| 'approvalLevel2'
| 'approvalLevel3'
| 'approvalLevel4'
| 'approvalLevel5'
| 'approvalLevel6'
| 'authorize'
| 'cancel'
| 'calendar'
| 'clone'
| 'close'
| 'config'
| 'confirm'
| 'delete'
| 'deleteExpense'
| 'edit'
| 'editExpense'
| 'enable'
| 'export'
| 'final'
| 'financial'
| 'group'
| 'ignore'
| 'import'
| 'impersonate'
| 'level1'
| 'level2'
| 'level3'
| 'level4'
| 'level5'
| 'level6'
| 'list'
| 'listExpenses'
| 'manualMatch'
| 'mapAccount'
| 'menu'
| 'modify'
| 'offsetAccount'
| 'open'
| 'overrideException'
| 'permission'
| 'post'
| 'print'
| 'readonly'
| 'readonlyExpense'
| 'receipts'
| 'reclass'
| 'reclassExpense'
| 'reconcile'
| 'refresh'
| 'release'
| 'reopen'
| 'report'
| 'resend'
| 'reversalEdit'
| 'reverse'
| 'reverseExpense'
| 'run'
| 'statutoryReportingPeriod'
| 'submit'
| 'subscribe'
| 'template'
| 'uncancel'
| 'unmask'
| 'upload'
| 'view'
| 'viewAll'
| 'void'[]
}[]
audit?: {
createdDateTime?: string
modifiedDateTime?: string
createdBy?: string
modifiedBy?: string
}
entity?: { key?: string; id?: string; name?: string; href?: string }
href?: string
} & {}
) {
const url = new URL(`https://api.intacct.com/ia/api/v1/objects/company-config/user`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago