Edits history of script submission #19749 for ' Update a bank transaction rule set (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Update a bank transaction rule set
     * Updates an existing bank transaction rule set by setting field values. Any fields not provided remain unchanged. Updating a rule set affects matches for incoming transactions going forward for every associated account that uses the rule set. Updating a rule set does not affect transactions that have already been matched.
    
    
    Permissions and other requirements
    
    SubscriptionCash Management
    User typeBusiness
    PermissionsList, Edit Bank transaction rule sets
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	key: string,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		ruleSetId?: string
    		name?: string
    		description?: string
    		accountType?: 'bank' | 'creditcard'
    		numberOfAccounts?: number
    		numberOfRules?: number
    		location?: { key?: string; id?: string; href?: string }
    		status?: 'active' | 'inactive'
    		rules?: {
    			key?: string
    			id?: string
    			ruleOrder?: number
    			bankTxnRule?: {
    				id?: string
    				key?: string
    				href?: string
    				ruleId?: string
    				name?: string
    				ruleType?: 'match' | 'create'
    			}
    			bankTxnRuleSet?: { id?: string; key?: string; href?: string }
    			audit?: {
    				createdDateTime?: string
    				modifiedDateTime?: string
    				createdBy?: string
    				modifiedBy?: string
    			}
    		}[]
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    		entity?: { key?: string; id?: string; name?: string; href?: string }
    	} & { id?: {} }
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/cash-management/bank-txn-rule-set/${key}`
    	)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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