Edits history of script submission #21886 for ' Retreive a credit note (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Retreive a credit note
     * Details of an existing creditnote.
     */
    export async function main(
      auth: Zoho,
      creditnote_id: string,
      X_com_zoho_subscriptions_organizationid: string,
    ) {
      const url = new URL(
        `https://www.zohoapis.com/billing/v1/creditnotes/${creditnote_id}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          "X-com-zoho-subscriptions-organizationid":
            X_com_zoho_subscriptions_organizationid,
          Authorization: "Zoho-oauthtoken " + 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 235 days ago