Hi Ankit,
If you go to:
https://github.com/bantonia/MoodleRest
You can download the current code for V0.1.6 which is in the process of being written, this should cure your issue, I hope! Extra checking has been added to the MoodleUser class to catch these null values. If not, get back to me.
Please note not all the calls have been tested to destruction.