Edits history of script submission #21715 for ' List all Recurring Invoice (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * List all  Recurring Invoice
     * List the details of all recurring invoice.
     */
    export async function main(
      auth: Zoho,
      organization_id: string | undefined,
      recurrence_name: string | undefined,
      item_name: string | undefined,
      item_description: string | undefined,
      customer_name: string | undefined,
      line_item_id: string | undefined,
      item_id: string | undefined,
      tax_id: string | undefined,
      notes: string | undefined,
      start_date: string | undefined,
      end_date: string | undefined,
      customer_id: string | undefined,
      status: string | undefined,
      filter_by: string | undefined,
      search_text: string | undefined,
      sort_column: string | undefined,
    ) {
      const url = new URL(`https://www.zohoapis.com/books/v3/recurringinvoices`);
      for (const [k, v] of [
        ["organization_id", organization_id],
        ["recurrence_name", recurrence_name],
        ["item_name", item_name],
        ["item_description", item_description],
        ["customer_name", customer_name],
        ["line_item_id", line_item_id],
        ["item_id", item_id],
        ["tax_id", tax_id],
        ["notes", notes],
        ["start_date", start_date],
        ["end_date", end_date],
        ["customer_id", customer_id],
        ["status", status],
        ["filter_by", filter_by],
        ["search_text", search_text],
        ["sort_column", sort_column],
      ]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          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