Edits history of script submission #13768 for ' Get Invoice (vercel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vercel = {
      token: string;
    };
    /**
     * Get Invoice
     * Get Invoice details and status for a given invoice ID.  See Billing Events with Webhooks documentation on how to receive invoice events. This endpoint is used to retrieve the invoice details.
     */
    export async function main(
      auth: Vercel,
      integrationConfigurationId: string,
      invoiceId: string,
    ) {
      const url = new URL(
        `https://api.vercel.com/v1/installations/${integrationConfigurationId}/billing/invoices/${invoiceId}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago