Edits history of script submission #18902 for ' Create a vendor payment provider (sage_intacct)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type SageIntacct = {
    	token: string
    }
    /**
     * Create a vendor payment provider
     * Creates a new vendor payment provider.
    
    
    Permissions and other requirements
    
    SubscriptionAdministration, Accounts Payable, Sage Cloud Services, Outbound Payment Services
    User typeBusiness user with admin permissions
    PermissionsList, View, Subscribe, Configure Application Subscriptions List, View, Edit Vendors
    
    
    
    
     */
    export async function main(
    	auth: SageIntacct,
    	body: {
    		key?: string
    		id?: string
    		href?: string
    		paymentProvider?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		vendor?: { key?: string; id?: string; name?: string; href?: string }
    		state?:
    			| 'requestInitiated'
    			| 'inProgress'
    			| 'requestReceived'
    			| 'requestFailed'
    			| 'awaitingAuthorization'
    			| 'subscribed'
    			| 'canceled'
    			| 'suspended'
    		preferredPaymentMethod?: {
    			key?: string
    			id?: string
    			name?: string
    			href?: string
    		}
    		status?: 'active' | 'inactive'
    		audit?: {
    			createdDateTime?: string
    			modifiedDateTime?: string
    			createdBy?: string
    			modifiedBy?: string
    		}
    	} & {}
    ) {
    	const url = new URL(
    		`https://api.intacct.com/ia/api/v1/objects/accounts-payable/vendor-payment-provider`
    	)
    
    	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