Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
import wpcom from 'calypso/lib/wp';
export interface Plan {
id?: string | null;
current_plan?: boolean;
expiry?: string;
has_domain_credit?: boolean;
product_slug?: string;
subscribed_date?: string;
user_facing_expiry?: string;
}
export async function fetchCurrentSitePlan( siteId: number ): Promise< Plan > {
const plans: Record< string, Plan > = await wpcom.req.get( {
path: `/sites/${ siteId }/plans`,
apiVersion: '1.3',
} );
const plan = Object.values( plans ).find( ( plan ) => plan.current_plan );
if ( ! plan ) {
throw new Error( 'No current plan found' );
}
return plan;
}