/// <summary>
        /// Retrieve the list of users associated with this account.
        /// </summary>
        /// <param name="accountId">The ID of the account to query.</param>
        /// <param name="searchTerm">Optional. The partial name or full ID of the users to match and return in the results list. Must be at least 3 characters.</param>
        /// <param name="page">The results page to fetch</param>
        /// <param name="itemsPerPage">The number of results per page to fetch</param>
        /// <returns></returns>
        public async Task <IEnumerable <User> > GetUsers(long accountId, int page = 1, int itemsPerPage = 10, string searchTerm = null)
        {
            accountId.ThrowIfUnassigned("accountId");
            searchTerm.ThrowIfShorterThanLength(3, "searchTerm");

            ApiRequest request = new PagedApiRequest(_config.AccountsEndpointUri, accountId + "/users", page, itemsPerPage)
                                 .Param("search_term", searchTerm);

            return(await GetReponseAsync <IEnumerable <User> >(request).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fetches the list of users in this course, and optionally the user's enrollments in the course.
        /// </summary>
        /// <param name="courseId">The ID of the course to fetch</param>
        /// <param name="page">Optional. The results page to fetch</param>
        /// <param name="itemsPerPage">Optional. The number of results per page to fetch</param>
        /// <param name="enrollmentType">Optional. When set, only return users where the user is enrolled as this type. This argument is ignored if enrollmentRole is given.</param>
        /// <param name="enrollmentRole">Optional. When set, only return users enrolled with the specified course-level role.</param>
        /// <param name="searchTerm">Optional. The partial name or full ID of the users to match and return in the results list.</param>
        /// <param name="include">Optional. Additional information to be returned for each user.</param>
        /// <returns></returns>
        public async Task <IEnumerable <User> > GetUsers(long courseId, int page = 1, int itemsPerPage = 10, string searchTerm = null, UserEnrollmentType?enrollmentType = null, UserEnrollmentType?enrollmentRole = null, UserInclude?include = null)
        {
            courseId.ThrowIfUnassigned("courseId");
            searchTerm.ThrowIfShorterThanLength(3, "searchTerm");

            ApiRequest request = new PagedApiRequest(_config.CoursesEndpointUri, courseId + "/users", page, itemsPerPage)
                                 .Param("search_term", searchTerm)
                                 .Param("enrollment_type", enrollmentType)
                                 .Param("enrollment_role", enrollmentRole)
                                 .Param("include", include);

            return(await GetReponseAsync <IEnumerable <User> >(request).ConfigureAwait(false));
        }
        /// <summary>
        /// Retrieve the list of courses associated with this account
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="state">Optional. If set, only return courses that are in the given state(s). By default, all states but "deleted" are returned.</param>
        /// <param name="withEnrollments">Optional. If true, include only courses with at least one enrollment. If false, include only courses with no enrollments. If not present, do not filter on course enrollment status.</param>
        /// <param name="hideEnrollmentlessCourses">Optional. If present, only return courses that have at least one enrollment. Equivalent to 'with_enrollments=true'; retained for compatibility.</param>
        /// <param name="byTeachers">Optional. List of User IDs of teachers; if supplied, include only courses taught by one of the referenced users.</param>
        /// <param name="bySubaccounts">Optional. List of Account IDs; if supplied, include only courses associated with one of the referenced subaccounts.</param>
        /// <param name="enrollmentTermId">Optional. If set, only includes courses from the specified term.</param>
        /// <param name="searchTerm">Optional. The partial course name, code, or full ID to match and return in the results list. Must be at least 3 characters.</param>
        /// <param name="page">The results page to fetch</param>
        /// <param name="itemsPerPage">The number of results per page to fetch</param>
        /// <param name="include">Optional Course properties to include. Use bitwise 'OR' operator to specify multiple items, e.g. CourseInclude.Term | CourseInclude.Sections</param>
        /// <returns></returns>
        /// <remarks>The API parameters 'completed' and 'published' are not included here. Use the 'state' enum flags instead.</remarks>
        public async Task <IEnumerable <Course> > GetCourses(long accountId, int page = 1, int itemsPerPage = 10, CourseWorkflowState?state = null, bool?withEnrollments = null, bool?hideEnrollmentlessCourses = null, IEnumerable <long> byTeachers = null, IEnumerable <long> bySubaccounts = null, string enrollmentTermId = null, string searchTerm = null, CourseInclude?include = null)
        {
            accountId.ThrowIfUnassigned("accountId");
            searchTerm.ThrowIfShorterThanLength(3, "searchTerm");

            var request = new PagedApiRequest(_config.AccountsEndpointUri, accountId + "/courses", page, itemsPerPage)
                          .Param("with_enrollments", withEnrollments)
                          .Param("hide_enrollmentless_courses", hideEnrollmentlessCourses)
                          .Param("state", state)
                          .Param("by_teachers", byTeachers)
                          .Param("by_subaccounts", bySubaccounts)
                          .Param("enrollment_term_id", enrollmentTermId)
                          .Param("search_term", searchTerm)
                          .Param("include", include);

            return(await GetReponseAsync <IEnumerable <Course> >(request).ConfigureAwait(false));
        }