//native
type Zoho = {
token: string;
};
/**
* List all subscriptions
* List of subscriptions that match the given subscription status. To list the subscriptions of a particular customer append a param customer_id={customer_id}. To list subscriptions based on Reference#, append the param reference_contains={reference_value}.
*/
export async function main(
auth: Zoho,
filter_by: string | undefined,
X_com_zoho_subscriptions_organizationid: string,
) {
const url = new URL(`https://www.zohoapis.com/billing/v1/subscriptions`);
for (const [k, v] of [["filter_by", filter_by]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
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