Add asFunction method of declaring a new api