Added credit api and test example.
Refactored credit API in propper clases.