smappee-api.js
function(handler) {
        if (typeof accessToken == 'undefined') {
            var body = {
                client_id: clientId,
                client_secret: clientSecret,
                username: username,
                password: password,
                grant_type: 'password'
            };

            if (thisObject.debug) {
                console.log("Making oAuth call...");
            }

            var options =  {
                url: 'https://app1pub.smappee.net/dev/v1/oauth2/token',
                headers: {
                    'Host': 'app1pub.smappee.net'
                },
                form: body
            };

            request.post(options, function (err, httpResponse, body) {
                if (err) {
                    return console.error('Request failed:', err);
                }
                if (thisObject.debug) {
                    console.log('Server responded with:', body);
                }

                accessToken = JSON.parse(body);
                handler(accessToken);
            });
        } else {
            handler(accessToken)
        }
    }
function(handler) {
        if (typeof accessToken == 'undefined') {
            var body = {
                client_id: clientId,
                client_secret: clientSecret,
                username: username,
                password: password,
                grant_type: 'password'
            };

            if (thisObject.debug) {
                console.log("Making oAuth call...");
            }

            var options =  {
                url: 'https://app1pub.smappee.net/dev/v1/oauth2/token',
                headers: {
                    'Host': 'app1pub.smappee.net'
                },
                form: body
            };

            request.post(options, function (err, httpResponse, body) {
                if (err) {
                    return console.error('Request failed:', err);
                }
                if (thisObject.debug) {
                    console.log('Server responded with:', body);
                }

                accessToken = JSON.parse(body);
                handler(accessToken);
            });
        } else {
            handler(accessToken)
        }
    }
function ( handler ) { if ( typeof accessToken == 'undefined' ) { var body = { client_id : clientId , client_secret : clientSecret , username : username , password : password , grant_type : 'password' } ; if ( thisObject . debug ) { console . log ( "Making oAuth call..." ) ; } var options = { url : 'https://app1pub.smappee.net/dev/v1/oauth2/token' , headers : { 'Host' : 'app1pub.smappee.net' } , form : body } ; request . post ( options , function ( err , httpResponse , body ) { if ( err ) { return console . error ( 'Request failed:' , err ) ; } if ( thisObject . debug ) { console . log ( 'Server responded with:' , body ) ; } accessToken = JSON . parse ( body ) ; handler ( accessToken ) ; } ) ; } else { handler ( accessToken ) } }
HELPER METHODS ++++++++++++++++++++++++++++++++++++++++
HELPER METHODS ++++++++++++++++++++++++++++++++++++++++