Polyv Help Center

Help Center

lessonService

Updated: 2024-10-21 09:33:43

1. Create Lesson

Description

创建课节
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/add

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testAddLesson() throws Exception {
        VClassAddLessonRequest vClassAddLessonRequest;
        VClassAddLessonResponse vClassAddLessonResponse;
        try {
            vClassAddLessonRequest = VClassAddLessonRequest.builder()
                    .name("SDK测试创建课节")
                    .duration(30)
                    .startTime(super.getDate(System.currentTimeMillis() + 10 * 86400000))
                    .watchCondition(VClassConstant.AuthType.NULL.getCode())
                    .linkNumber(2)
                    .build();
            vClassAddLessonResponse = new VClassLessonServiceImpl().addLesson(vClassAddLessonRequest);
            Assert.assertNotNull(vClassAddLessonResponse);
            if (vClassAddLessonResponse != null) {
                log.debug("测试创建课节成功,{}", JSON.toJSONString(vClassAddLessonResponse));
                //TODO 此处创建完成后删除了课节,正式使用需删除该语句
                super.deleteLesson(vClassAddLessonResponse.getLessonId());
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a VClassAddLessonResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
name true String Lesson name, length 1~128
startTime true Date Start time
duration true Integer Lesson duration, unit: minutes, 5~180
linkNumber true Integer Number of participants for co-streaming, 0~16
autoConnectMicroEnabled false String Auto-connect microphone, default: N. Y: Auto-connect, N: Manual
autoRecordCourseEnabled false String Auto-record course, default: N. Y: Auto-record, N: Manual
watchCondition true String Viewing condition. NULL: No condition, CODE: Verification code, WHITE_LIST: Whitelist, DIRECT: Independent authorization
code false String Required when watchCondition is CODE. The viewing verification code (max 16 characters)
secretKey false String Required when watchCondition is DIRECT. If not provided, it is auto-generated by the backend (max 32 characters)
resolution false Integer Recording resolution, 720, 1080
playResolution false Integer Class resolution, 360 (Contact support for higher resolutions)
cover false String Cover image URL, length 1~255
teacherId false String Teacher ID. If not provided, the system searches by teacherMobile. If not found, a new teacher is created.
teacherCode false String Teacher's phone country code, default +86
teacherMobile false String Teacher's phone number, length 5~15
teacherName false String Teacher's name. If an existing teacher is found, the name is updated.
teacherPasswd false String Teacher's password, length 6~8

Return Object Description

Parameter Name Type Description
lessonId Long Lesson ID
name String Lesson name
teacherId String Teacher ID
teacherCode String Teacher's phone country code
teacherName String Teacher's name
teacherMobile String Teacher's account
teacherPasswd String Teacher's account password
startTime Date Start time
endTime Date End time
duration Integer Lesson duration, unit: minutes
linkNumber Integer Number of participants for co-streaming, 0 - 16
autoConnectMicroEnabled String Auto-connect microphone. Y: Auto-connect, N: Manual
autoRecordCourseEnabled String Auto-record course. Y: Auto-record, N: Manual
watchCondition String Viewing condition. NULL: No condition, CODE: Verification code, WHITE_LIST: Whitelist, DIRECT: Independent authorization
code String Viewing verification code (max 16 characters) when watchCondition is CODE
secretKey String Authorized viewing KEY
cover String Cover URL
resolution Integer Recording resolution, 720, 1080
playResolution Integer Class resolution, 360






2. Get Lesson Information

Description

获取课节信息
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/get

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetLessonInfo() throws IOException, NoSuchAlgorithmException {
        VClassGetLessonInfoRequest vClassGetLessonInfoRequest;
        VClassGetLessonInfoResponse vClassGetLessonInfoResponse;
        try {
            vClassGetLessonInfoRequest = VClassGetLessonInfoRequest.builder().lessonId(super.createLesson()).build();
            vClassGetLessonInfoResponse = new VClassLessonServiceImpl().getLessonInfo(vClassGetLessonInfoRequest);
            Assert.assertNotNull(vClassGetLessonInfoResponse);
            if (vClassGetLessonInfoResponse != null) {
                //to do something ......
                log.debug("测试获取课节信息成功{}", JSON.toJSONString(vClassGetLessonInfoResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a VClassGetLessonInfoResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID

Return Object Description

Parameter Name Type Description
lessonId Long Lesson ID
name String Lesson name
teacherId String Teacher ID
teacherCode String Teacher's phone country code
teacherName String Teacher's name
teacherMobile String Teacher's account
teacherPasswd String Teacher's account password
startTime Date Start time
endTime Date End time
duration Integer Lesson duration, unit: minutes
linkNumber Integer Number of participants for co-streaming, 0 - 16
autoConnectMicroEnabled String Auto-connect microphone. Y: Auto-connect, N: Manual
autoRecordCourseEnabled String Auto-record course. Y: Auto-record, N: Manual
watchCondition String Viewing condition. NULL: No condition, CODE: Verification code, WHITE_LIST: Whitelist, DIRECT: Independent authorization
code String Viewing password, required when watchCondition is CODE
secretKey String Authorized viewing KEY
cover String Cover URL
resolution Integer Recording resolution, 720, 1080
playResolution Integer Class resolution, 360






3. Update Lesson Information

Description

更新课节信息
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/update

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateLessonInfo() throws IOException, NoSuchAlgorithmException {
        VClassUpdateLessonInfoRequest vClassUpdateLessonInfoRequest;
        Boolean vClassUpdateLessonInfoResponse;
        try {
            Long lessonId = super.createLesson();
            vClassUpdateLessonInfoRequest = VClassUpdateLessonInfoRequest.builder()
                    .lessonId(lessonId)
                    .duration(60)
                    .linkNumber(0)
                    .autoConnectMicroEnabled(VClassConstant.Flag.YES.getFlag())
                    .autoRecordCourseEnabled(VClassConstant.Flag.YES.getFlag())
                    .watchCondition(VClassConstant.AuthType.WHITE_LIST.getCode())
                    .resolution(720)
                    .playResolution(720)
                    .build();
            vClassUpdateLessonInfoResponse = new VClassLessonServiceImpl().updateLessonInfo(
                    vClassUpdateLessonInfoRequest);
            Assert.assertTrue(vClassUpdateLessonInfoResponse);
            if (vClassUpdateLessonInfoResponse) {
                //to do something ......
                log.debug("测试更新课节信息成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID
name false String Lesson name, length 1~128
startTime false Date Start time
duration false Integer Lesson duration, unit: minutes, 5~180
linkNumber false Integer Number of participants for co-streaming, 0~16
autoConnectMicroEnabled false String Auto-connect microphone. Y: Auto-connect, N: Manual
autoRecordCourseEnabled false String Auto-record course. Y: Auto-record, N: Manual
watchCondition false String Viewing condition. NULL: No condition, CODE: Verification code, WHITE_LIST: Whitelist, DIRECT: Independent authorization
code false String Required when watchCondition is CODE. The viewing verification code (max 16 characters)
secretKey false String Required when watchCondition is DIRECT. If not provided, it is auto-generated by the backend (max 32 characters)
resolution false Integer Recording resolution, 720, 1080
playResolution false Integer Class resolution, 360 (Contact support for higher resolutions)
cover false String Cover image URL, length 1~255
teacherId false String Teacher ID. If not provided, no update occurs. If a new ID is provided, a new teacher is created based on the following teacher information.
teacherName false String Teacher's name. If an existing teacher is found, the name is updated.
teacherCode false String Teacher's phone country code, default +86
teacherMobile false String Teacher's phone number, length 5~15
teacherPasswd false String Teacher's password, length 6~8

Return Object Description

Entity returned for updating lesson information.




4. Delete Lesson

Description

删除课节
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/delete

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testDeleteLesson() throws IOException, NoSuchAlgorithmException {
        VClassDeleteLessonRequest vClassDeleteLessonRequest;
        Boolean vClassDeleteLessonResponse;
        try {
            vClassDeleteLessonRequest = VClassDeleteLessonRequest.builder().lessonId(super.createLesson()).build();
            vClassDeleteLessonResponse = new VClassLessonServiceImpl().deleteLesson(vClassDeleteLessonRequest);
            Assert.assertTrue(vClassDeleteLessonResponse);
            if (vClassDeleteLessonResponse) {
                //to do something ......
                log.debug("测试删除课节成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID

Return Object Description

Entity returned for deleting a lesson.




5. Set Lesson Status to Prohibit Class

Description

禁止课节上课,禁止有效期为24小时,24小时后会恢复课节允许上课(如果课节已到达下课时间,则不允许再上课)
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/%s/cutoff

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testCutoffLesson() throws IOException, NoSuchAlgorithmException {
        VClassCutoffLessonRequest vClassCutoffLessonRequest;
        Boolean vClassCutoffLessonResponse;
        try {
            vClassCutoffLessonRequest = VClassCutoffLessonRequest.builder().lessonId(super.createLesson()).build();
            vClassCutoffLessonResponse = new VClassLessonServiceImpl().cutoffLesson(vClassCutoffLessonRequest);
            Assert.assertTrue(vClassCutoffLessonResponse);
            if (vClassCutoffLessonResponse) {
                //to do something ......
                log.debug("测试修改课节状态为禁止上课成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID

Return Object Description

Entity returned for setting lesson status to prohibit class.




6. Restore Lesson Status to Allow Class

Description

恢复课节状态为可以上课(如果课节已到达下课时间,则不允许再上课)
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/%s/resume

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testResumeLesson() throws IOException, NoSuchAlgorithmException {
        VClassResumeLessonRequest vClassResumeLessonRequest;
        Boolean vClassResumeLessonResponse;
        try {
            vClassResumeLessonRequest = VClassResumeLessonRequest.builder().lessonId(super.createLesson()).build();
            vClassResumeLessonResponse = new VClassLessonServiceImpl().resumeLesson(vClassResumeLessonRequest);
            Assert.assertTrue(vClassResumeLessonResponse);
            if (vClassResumeLessonResponse) {
                //to do something ......
                log.debug("测试恢复课节状态为可以上课成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID

Return Object Description

Entity returned for restoring lesson status to allow class.




7. Query Lesson Real-time Status and Online Count

Description

查询课节实时状态和在线人数
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/getLessonLiveInfo

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetLessonLiveInfo() throws IOException, NoSuchAlgorithmException {
        VClassGetLessonLiveInfoRequest vClassGetLessonLiveInfoRequest;
        List<VClassGetLessonLiveInfoResponse> vClassGetLessonLiveInfoResponse;
        try {
            vClassGetLessonLiveInfoRequest = VClassGetLessonLiveInfoRequest.builder()
                    .lessonIds(String.format("%s", super.createLesson()))
                    .build();
            vClassGetLessonLiveInfoResponse = new VClassLessonServiceImpl().getLessonLiveInfo(
                    vClassGetLessonLiveInfoRequest);
            Assert.assertNotNull(vClassGetLessonLiveInfoResponse);
            if (vClassGetLessonLiveInfoResponse != null) {
                //to do something ......
                log.debug("测试查询课节实时状态和在线人数成功 {}", JSON.toJSONString(vClassGetLessonLiveInfoResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a successful request, a VClassGetLessonLiveInfoResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonIds true String Lesson IDs, separated by commas (max 100 lessons). Example: 1015,1016

Return Object Description

The return object is a List<VClassGetLessonLiveInfoResponse>. The specific elements of VClassGetLessonLiveInfoResponse are as follows:

Parameter Name Type Description
lessonId Long Lesson ID
currentTime Date Current time [corresponds to the timestamp field in the API documentation]
teacherOnlineCount Long Number of teachers in the lesson
studentOnlineCount Long Number of students in the lesson
status Integer Lesson status. 0: Not started, 1: In progress, 2: Ended, 11: Class prohibited






8. Query Lesson Playback Video

Description

查询课节回放视频
接口地址(仅做说明使用):https://api.polyv.net/hi-class-api/open/lesson/v1/getPlaybackVideo

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetPlaybackVideo() throws IOException, NoSuchAlgorithmException {
        VClassGetPlaybackVideoRequest vClassGetPlaybackVideoRequest;
        List<VClassGetPlaybackVideoResponse> vClassGetPlaybackVideoResponse;
        try {
            vClassGetPlaybackVideoRequest = VClassGetPlaybackVideoRequest.builder()
                    .lessonId(super.createLesson())
                    .build();
            vClassGetPlaybackVideoResponse = new VClassLessonServiceImpl().getPlaybackVideo(
                    vClassGetPlaybackVideoRequest);
            Assert.assertNotNull(vClassGetPlaybackVideoResponse);
            if (vClassGetPlaybackVideoResponse != null) {
                //to do something ......
                log.debug("测试查询课节回放视频成功 {}", JSON.toJSONString(vClassGetPlaybackVideoResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
}

Unit Test Description

  1. On a successful request, a VClassGetPlaybackVideoResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Validation failed for input parameter [xxx.chat.LivexxxRequest] object, failed fields: [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [Error returned from Polyv request, request ID: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
lessonId true Long Lesson ID

Return Object Description

The return object is a List<VClassGetPlaybackVideoResponse>. The specific elements of VClassGetPlaybackVideoResponse are as follows:

Parameter Name Type Description
lessonId Long Lesson ID
lessonName String Lesson name
firstImage String First frame screenshot
duration String Video duration, format HH:mm:ss
vid String Video ID
status Long Video status code. 60/61: Published, 10: Waiting for encoding, 20
联系客服,在线咨询