The way that I think that deploy could be done is to:
- compile the files into base64
- put the encoded base64 string into a package.xml file
- zip the file
- POST /services/data/vXX.X/metadata/deployRequest
Once the deploy feature is complete it should be pretty trivial to retrieve.
References:
Deploying and Retrieving Metadata with the Zip File
Deploy to Org using SOAP API
Metadata for Apex Classes