1 /** 2 * @author Brian Carlsen 3 * @version 1.0.0 4 * 5 * Serves as a wrapper to the MINDBODY Class Service, providing 6 * some additional functionality. 7 * 8 * All Class Service methods are available returning 9 * 1) An extracted result using the instance method with the same name 10 * 2) The raw array response using the instance method with the same name post-fixed with 'Response'. 11 * The array consists of: 12 * i) The object represtentation of the SOAP response 13 * ii) The raw XML SOAP response 14 * iii) The raw header info of the SOAP response 15 */ 16 17 var Promise = require( 'bluebird' ); 18 19 var mboService = require( './mbo_Service' ); 20 21 //--------------- ClassService Class --------------------- 22 23 /** 24 * Represents the MINDOBDY Class Service. 25 * 26 * @constructor 27 * @param {string} username Username of the MINDBODY client interacting with the service. 28 * @param {string} password Password of the MINDBODY client interacting with the service. 29 * @return {mbo_ClassService} Returns the Class Service. 30 */ 31 function mbo_ClassService( username, password ) { 32 mboService.call( this, 'ClassService', username, password ); 33 } 34 mbo_ClassService.prototype = Object.create( mboService.prototype ); 35 mbo_ClassService.prototype.constructor = mbo_ClassService; 36 37 /** 38 * Gets the IDs of all clients in a given class. 39 * 40 * @param {number} classId The ID of the class to inspect. 41 * @return {Promise} An A+ promise passed an array of client IDs who attended the class. 42 */ 43 mbo_ClassService.prototype.getClassAttendees = function( classId ) { 44 return this.GetClassVisits( { ClassID: classId } ) 45 .then( function( response ) { 46 if( response.Visits === null ) { 47 // no sign ins 48 response.Visits = { Visit: [] }; 49 } 50 51 var clients = []; 52 for ( var i in response.Visits.Visit ) { 53 clients.push( response.Visits.Visit[ i ].Client.ID ); 54 } 55 56 return clients; 57 } ) 58 .catch( function( err ) { 59 throw err; 60 } ); 61 }; 62 63 module.exports = mbo_ClassService;