Edits history of script submission #18352 for ' Get organization billing status (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Get organization billing status
     * This endpoint returns a "is_valid" boolean field reflecting the billing status of the organization:
    - If true, the organization billing is valid
    - For Startup organization, it returns false if there is at least 1 invoice unpaid since 1 week
    - For Community organization, it returns false if there is no credit left
    
     */
    export async function main(auth: RT.Qovery, organizationId: string) {
    	const url = new URL(`https://api.qovery.com/organization/${organizationId}/billingStatus`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago