Retrieve details of an existing plan.
1
//native
2
type Zoho = {
3
token: string;
4
};
5
/**
6
* Retrieve a plan
7
* Retrieve details of an existing plan.
8
*/
9
export async function main(
10
auth: Zoho,
11
plan_code: string,
12
X_com_zoho_subscriptions_organizationid: string,
13
) {
14
const url = new URL(`https://www.zohoapis.com/billing/v1/plans/${plan_code}`);
15
16
const response = await fetch(url, {
17
method: "GET",
18
headers: {
19
"X-com-zoho-subscriptions-organizationid":
20
X_com_zoho_subscriptions_organizationid,
21
Authorization: "Zoho-oauthtoken " + auth.token,
22
},
23
body: undefined,
24
});
25
if (!response.ok) {
26
const text = await response.text();
27
throw new Error(`${response.status} ${text}`);
28
}
29
return await response.json();
30
31