Edits history of script submission #14120 for ' Add Webhook (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Add Webhook
     * Add a new Webhook. For more details or instructions you can refer to the [webhooks documentation](https://documentation.bamboohr.com/docs/webhooks-2).
     */
    export async function main(auth: RT.BambooHr, body: AddWebhook) {
    	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/webhooks`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
    		},
    		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 AddWebhook {
    	/**
    	 * The name of the webhook.
    	 */
    	name: string
    	/**
    	 * A list of fields to monitor.
    	 */
    	monitorFields: string[]
    	/**
    	 * A list of fields to post to the webhook url. Field ID or alias: external name
    	 */
    	postFields: {
    		[k: string]: unknown
    	}
    	/**
    	 * The url the webhook should send data to (must begin with https://).
    	 */
    	url: string
    	/**
    	 * The format the webhook should use (json - default, form-encoded).
    	 */
    	format?: 'json' | 'form-encoded'
    	/**
    	 * How often the webhook could fire.
    	 */
    	frequency?: {
    		/**
    		 * The hour to potentially fire (0-23, null to potentially fire every hour)
    		 */
    		hour?: number
    		/**
    		 * The minute to potentially fire (0-59, null to potentially fire every minute)
    		 */
    		minute?: number
    		/**
    		 * The day to potentially fire (1-31, null to potentially fire every day)
    		 */
    		day?: number
    		/**
    		 * The month to potentially fire (1-12, null to potentially fire every month)
    		 */
    		month?: number
    		[k: string]: unknown
    	}
    	/**
    	 * To limit how often to potentially fire a webhook, and maximum amount of records to send
    	 */
    	limit?: {
    		/**
    		 * The amount of records to send
    		 */
    		times?: number
    		/**
    		 * The minimum amount of seconds between requests
    		 */
    		seconds?: number
    		[k: string]: unknown
    	}
    	/**
    	 * If set to true, the company domain will be added to the header.
    	 */
    	includeCompanyDomain?: boolean
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago