1 /** 2 * @fileOverview JavaScript representation of the Finesse Team REST object. 3 * 4 * @name finesse.restservices.Team 5 * @requires finesse.clientservices.ClientServices 6 * @requires Class 7 * @requires finesse.FinesseBase 8 * @requires finesse.restservices.RestBase 9 * @requires finesse.restservices.RestCollectionBase 10 * @requires finesse.restservices.User 11 * @requires finesse.restservices.Users 12 */ 13 14 var finesse = finesse || {}; 15 finesse.restservices = finesse.restservices || {}; 16 17 /** @private */ 18 finesse.restservices.Team = finesse.restservices.RestBase.extend(/** @lends finesse.restservices.Team.prototype */{ 19 20 /** 21 * @class 22 * JavaScript representation of a Team object. Also exposes methods to operate 23 * on the object against the server. 24 * 25 * @param {Object} options 26 * An object with the following properties:<ul> 27 * <li><b>id:</b> The id of the object being constructed</li> 28 * <li><b>onLoad(this): (optional)</b> when the object is successfully loaded from the server</li> 29 * <li><b>onChange(this): (optional)</b> when an update notification of the object is received</li> 30 * <li><b>onAdd(this): (optional)</b> when a notification that the object is created is received</li> 31 * <li><b>onDelete(this): (optional)</b> when a notification that the object is deleted is received</li> 32 * <li><b>onError(rsp): (optional)</b> if loading of the object fails, invoked with the error response object:<ul> 33 * <li><b>status:</b> {Number} The HTTP status code returned</li> 34 * <li><b>content:</b> {String} Raw string of response</li> 35 * <li><b>object:</b> {Object} Parsed object of response</li> 36 * <li><b>error:</b> {Object} Wrapped exception that was caught:<ul> 37 * <li><b>errorType:</b> {String} Type of error that was caught</li> 38 * <li><b>errorMessage:</b> {String} Message associated with error</li> 39 * </ul></li> 40 * </ul></li> 41 * <li><b>parentObj: (optional)</b> The parent object</li></ul> 42 * @constructs finesse.restservices.Team 43 **/ 44 init: function (options) { 45 this._super(options); 46 }, 47 48 /** 49 * @private 50 * Gets the REST class for the current object - this is the Team class. 51 * @returns {Object} The Team constructor. 52 */ 53 getRestClass: function () { 54 return finesse.restservices.Team; 55 }, 56 57 /** 58 * @private 59 * Gets the REST type for the current object - this is a "Team". 60 * @returns {String} The Team string. 61 */ 62 getRestType: function () { 63 return "Team"; 64 }, 65 66 /** 67 * @private 68 * Override default to indicate that this object doesn't support making 69 * requests. 70 */ 71 supportsSubscriptions: false, 72 73 /** 74 * Getter for the team id. 75 * @returns {String} The team id. 76 */ 77 getId: function () { 78 this.isLoaded(); 79 return this.getData().id; 80 }, 81 82 /** 83 * Getter for the team name. 84 * @returns {String} The team name 85 */ 86 getName: function () { 87 this.isLoaded(); 88 return this.getData().name; 89 }, 90 91 /** 92 * Constructs and returns a collection of users 93 * @param {options} constructor options 94 * @returns {finesse.restservices.Users} Users collection of User objects 95 */ 96 getUsers: function (options) { 97 this.isLoaded(); 98 options = options || {}; 99 100 options.parentObj = this; 101 // We are using getData() instead of getData.Users because the superclass (RestCollectionBase) 102 // for Users needs the "Users" key to validate the provided payload matches the class type. 103 options.data = this.getData(); 104 105 return new finesse.restservices.Users(options); 106 } 107 }); 108