# Channel Session

## 描述

```
查询频道直播场次信息
接口地址（仅做说明使用）：https://api.polyv.net/live/v3/channel/session/data/list
```

## 调用约束

1、接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/live/java/limit.md)，调用常见异常，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/live/java/exceptionDoc/README.md)

## 单元测试

```java
	@Test
	public void testGetSessionList() throws IOException, NoSuchAlgorithmException {
        LiveSessionListRequest liveSessionListRequest = new LiveSessionListRequest();
        LiveSessionListResponse liveSessionListResponse;
        try {
            String channelId = super.createChannel();
            liveSessionListRequest.setChannelId(channelId);
            liveSessionListRequest.setStartDate(super.getDate(2022, 07, 01));
            liveSessionListRequest.setEndDate(super.getDate(2022, 07, 22));
            liveSessionListResponse = new LiveChannelSessionServiceImpl().getSessionList(liveSessionListRequest);
            Assert.assertNotNull(liveSessionListResponse);
            if (liveSessionListResponse != null) {
                //to do something ......
                log.debug("测试查询频道场次信息成功 {}", JSON.toJSONString(liveSessionListResponse));
            }
        } 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;
        }
    }
```

## 单元测试说明

1、请求正确，返回LiveSessionListResponse对象，B端依据此对象处理业务逻辑；

2、请求参数校验不合格，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 输入参数 \[xxx.chat.LivexxxRequest]对象校验失败，失败字段 \[pic不能为空 / msg不能为空] ]

3、服务器处理异常，抛出PloyvSdkException，错误信息见PloyvSdkException.getMessage()，如 \[ 保利威请求返回数据错误，请求流水号：66e7ad29fd04425a84c2b2b562d2025b，错误原因： invalid signature. ]

## 请求入参描述

| 参数名       | 必选    | 类型     | 说明                                                             |
| --------- | ----- | ------ | -------------------------------------------------------------- |
| channelId | true  | String | 频道号                                                            |
| startDate | false | Date   | 直播场次的开始日期，格式：yyyy-MM-dd HH:mm:ss，如果时间为00:00:00也支持格式：yyyy-MM-dd |
| endDate   | false | Date   | 直播场次的结束日期，格式：yyyy-MM-dd HH:mm:ss，如果时间为00:00:00也支持格式：yyyy-MM-dd |
| page      | false | String | 页数，默认为1                                                        |
| pageSize  | false | String | 每页显示的数据条数，默认20                                                 |

## 返回对象描述

| 参数名         | 类型      | 说明                                                                                                                                                             |
| ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| contents    | Array   | 查询的结果列表【详见[SessionInfo参数描述](https://git.polyv.net/help-center/document-center/-/blob/master/live/java/channelSession.md?id=pa906661f92cf7b4089e7687a05790a02)】 |
| pageSize    | Integer | 每页显示的数据条数，默认每页显示20条数据                                                                                                                                          |
| currentPage | Integer | 当前页【对应api文档的**pageNumber**字段】                                                                                                                                  |
| totalItems  | Integer | 记录总条数                                                                                                                                                          |
| totalPage   | Integer | 总页数【对应api文档的**totalPages**字段】                                                                                                                                  |

[**SessionInfo参数描述**](#/channelSession.md?id=pa906661f92cf7b4089e7687a05790a02)

| 参数名       | 类型     | 说明                                       |
| --------- | ------ | ---------------------------------------- |
| channelId | String | 频道号                                      |
| sessionId | String | 直播场次ID                                   |
| userId    | String | POLYV用户ID，和保利威官网一致，获取路径：官网->登录->直播（开发设置） |
| startTime | Date   | 直播开始时间                                   |
| endTime   | Date   | 直播结束时间                                   |

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/live/java/channelsession.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
