/// <summary>
        /// Lists all TeamMemberships matching the given criteria.
        /// </summary>
        /// <param name="error">Error from Spark, if any.</param>
        /// <param name="results">List of TeamMemberships.</param>
        /// <param name="team">The Team to show TeamMemberships for.</param>
        /// <param name="person">The Person to show TeamMemberships for.</param>
        /// <param name="max">The maximum number of TeamMemberships to return.</param>
        /// <returns></returns>
        public static IEnumerator ListTeamMemberships(Action<SparkMessage> error, Action<List<TeamMembership>> results, Team team = null, Person person = null, int max = 0)
        {
            var constraints = new Dictionary<string, string>();
            if (team != null)
            {
                constraints.Add("teamId", team.Id);
            }
            else if (person != null)
            {
                constraints.Add("personId", person.Id);
            }

            if (max > 0)
            {
                constraints.Add("max", max.ToString());
            }

            var listObjects = ListObjects<TeamMembership>(constraints, SparkType.TeamMembership, error, results);
            yield return Request.Instance.StartCoroutine(listObjects);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Cisco.Spark.TeamMembership"/> class.
 /// </summary>
 /// <param name="team">The Team of the TeamMembership.</param>
 /// <param name="person">The person belonging to the TeamMembership.</param>
 /// <param name="isModerator">True if this member will be a moderator.</param>
 public TeamMembership(Team team, Person person, bool isModerator = false)
 {
     Team = team;
     Person = person;
     IsModerator = isModerator;
 }
 /// <summary>
 /// Constructor to build a new Room locally.
 /// </summary>
 /// <param name="title">The title of the Room.</param>
 /// <param name="team">The team the room should be assigned to, if any.</param>
 public Room(string title, Team team)
 {
     Title = title;
     Team = team;
 }
 /// <summary>
 /// Populates the TeamMembership with data from Spark.
 /// </summary>
 /// <param name="data">Dictionary of TeamMembership data.</param>
 protected override void LoadDict(Dictionary<string, object> data)
 {
     base.LoadDict(data);
     var teamId = data["teamId"] as string;
     Team = new Team(teamId);
     var personId = data["personId"] as string;
     Person = new Person(personId);
     IsModerator = (bool)data["isModerator"];
 }
        /// <summary>
        /// Lists all Rooms the registered user is a member of, matching the given filters.
        /// </summary>
        /// <param name="error">Error from Spark, if any.</param>
        /// <param name="results">The resultant list of Rooms.</param>
        /// <param name="team">The Team to filter on.</param>
        /// <param name="max">The maximum number of rooms to return.</param>
        /// <param name="type">The RoomType of Room to look for.</param>
        public static IEnumerator ListRooms(Action<SparkMessage> error, Action<List<Room>> results, Team team = null, int max = 0, RoomType type = RoomType.Unsupported)
        {
            var constraints = new Dictionary<string, string>();
            if (team != null)
            {
                constraints.Add("teamId", team.Id);
            }

            if (max > 0)
            {
                constraints.Add("max", max.ToString());
            }

            if (type != RoomType.Unsupported)
            {
                constraints.Add("type", type.ToApi());
            }

            var listObjects = ListObjects<Room>(constraints, SparkType.Room, error, results);
            yield return Request.Instance.StartCoroutine(listObjects);
        }