@classmethod<EOL><INDENT>def enroll_user(cls, enterprise_customer, user, course_mode, *course_ids):<DEDENT>
enterprise_customer_user, __ = EnterpriseCustomerUser.objects.get_or_create(<EOL>enterprise_customer=enterprise_customer,<EOL>user_id=user.id<EOL>)<EOL>enrollment_client = EnrollmentApiClient()<EOL>succeeded = True<EOL>for course_id in course_ids:<EOL><INDENT>try:<EOL><INDENT>enrollment_client.enroll_user_in_course(user.username, course_id, course_mode)<EOL><DEDENT>except HttpClientError as exc:<EOL><INDENT>if cls.is_user_enrolled(user, course_id, course_mode):<EOL><INDENT>succeeded = True<EOL><DEDENT>else:<EOL><INDENT>succeeded = False<EOL>default_message = '<STR_LIT>'<EOL>try:<EOL><INDENT>error_message = json.loads(exc.content.decode()).get('<STR_LIT:message>', default_message)<EOL><DEDENT>except ValueError:<EOL><INDENT>error_message = default_message<EOL><DEDENT>logging.error(<EOL>'<STR_LIT>',<EOL>dict(user=user.username, message=error_message)<EOL>)<EOL><DEDENT><DEDENT>if succeeded:<EOL><INDENT>__, created = EnterpriseCourseEnrollment.objects.get_or_create(<EOL>enterprise_customer_user=enterprise_customer_user,<EOL>course_id=course_id<EOL>)<EOL>if created:<EOL><INDENT>track_enrollment('<STR_LIT>', user.id, course_id)<EOL><DEDENT><DEDENT><DEDENT>return succeeded<EOL>
Enroll a single user in any number of courses using a particular course mode.

Args:
    enterprise_customer: The EnterpriseCustomer which is sponsoring the enrollment
    user: The user who needs to be enrolled in the course
    course_mode: The mode with which the enrollment should be created
    *course_ids: An iterable containing any number of course IDs to eventually enroll the user in.

Returns:
    Boolean: Whether or not enrollment succeeded for all courses specified