//native
type Zoho = {
token: string;
};
/**
* Create an addon
* Create a new addon.
*/
export async function main(
auth: Zoho,
X_com_zoho_subscriptions_organizationid: string,
body:
| {
addon_code: string;
name: string;
unit_name: string;
pricing_scheme?: {};
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 }[];
product_id: string;
description?: string;
store_markup_description?: string;
tax_id?: 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_exemption_id?: string;
tax_exemption_code?: string;
}
| {
addon_code: string;
name: string;
unit_name: string;
pricing_scheme?: {};
price_brackets: { 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 }[];
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;
}
| {
addon_code: string;
name: string;
unit_name: string;
pricing_scheme?: {};
price_brackets: { 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 }[];
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;
}
| {
addon_code: string;
name: string;
unit_name: string;
pricing_scheme?: {};
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 }[];
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`);
const response = await fetch(url, {
method: "POST",
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