Edits history of script submission #22029 for ' Update an addon (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Update an addon
     * Update details of an existing addon.
     */
    export async function main(
      auth: Zoho,
      addon_code: string,
      X_com_zoho_subscriptions_organizationid: string,
      body: {
        addon_code: string;
        name: string;
        unit_name: string;
        pricing_scheme?: string;
        price_brackets: {
          start_quantity: number;
          end_quantity: number;
          price: number;
        }[];
        type?: string;
        interval_unit?: string;
        tags?: { tag_id?: number; tag_option_id?: number }[];
        custom_fields?: { label?: string; value?: string }[];
        applicable_to_all_plans?: false | true;
        plans: { plan_code: string; name?: {} }[];
        product_id: string;
        description?: string;
        store_markup_description?: string;
        product_type?: string;
        hsn_or_sac?: string;
        sat_item_key_code?: string;
        unitkey_code?: string;
        item_tax_preferences?: {
          tax_specification?: string;
          tax_name?: string;
          tax_percentage?: number;
          tax_id?: string;
        }[];
        tax_id?: string;
        tax_exemption_id?: string;
        tax_exemption_code?: string;
      },
    ) {
      const url = new URL(
        `https://www.zohoapis.com/billing/v1/addons/${addon_code}`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "X-com-zoho-subscriptions-organizationid":
            X_com_zoho_subscriptions_organizationid,
          "Content-Type": "application/json",
          Authorization: "Zoho-oauthtoken " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago