lib/api.js
function() {
        var self = this;
        // Read all files from ./services and add them to this object
        // ex: services/User.js becomes mangopay.Users
        var servicesRoot = path.join(__dirname, 'services');
        fs.readdirSync(servicesRoot).forEach(function (file) {
            var serviceName = file.match(/(.*)\.js/)[1];
            var ServiceClass = require(servicesRoot + '/' + file);
            self[serviceName] = new ServiceClass();
            self[serviceName]._api = self;
        });

        // Read all files from ./models and add them to this object
        // ex: models/User.js becomes mangopay.models.User
        var modelsRoot = path.join(__dirname, 'models');
        self.models = {};
        fs.readdirSync(modelsRoot).forEach(function (file) {
            var modelName = file.match(/(.*)\.js/)[1];
            self.models[modelName] = require(modelsRoot + '/' + file);
        });
    }
function() {
        var self = this;
        // Read all files from ./services and add them to this object
        // ex: services/User.js becomes mangopay.Users
        var servicesRoot = path.join(__dirname, 'services');
        fs.readdirSync(servicesRoot).forEach(function (file) {
            var serviceName = file.match(/(.*)\.js/)[1];
            var ServiceClass = require(servicesRoot + '/' + file);
            self[serviceName] = new ServiceClass();
            self[serviceName]._api = self;
        });

        // Read all files from ./models and add them to this object
        // ex: models/User.js becomes mangopay.models.User
        var modelsRoot = path.join(__dirname, 'models');
        self.models = {};
        fs.readdirSync(modelsRoot).forEach(function (file) {
            var modelName = file.match(/(.*)\.js/)[1];
            self.models[modelName] = require(modelsRoot + '/' + file);
        });
    }
function ( ) { var self = this ; // Read all files from ./services and add them to this object // ex: services/User.js becomes mangopay.Users var servicesRoot = path . join ( __dirname , 'services' ) ; fs . readdirSync ( servicesRoot ) . forEach ( function ( file ) { var serviceName = file . match ( / (.*)\.js / ) [ 1 ] ; var ServiceClass = require ( servicesRoot + '/' + file ) ; self [ serviceName ] = new ServiceClass ( ) ; self [ serviceName ] . _api = self ; } ) ; // Read all files from ./models and add them to this object // ex: models/User.js becomes mangopay.models.User var modelsRoot = path . join ( __dirname , 'models' ) ; self . models = { } ; fs . readdirSync ( modelsRoot ) . forEach ( function ( file ) { var modelName = file . match ( / (.*)\.js / ) [ 1 ] ; self . models [ modelName ] = require ( modelsRoot + '/' + file ) ; } ) ; }
Populates the SDK object with the services
Populates the SDK object with the services