in operations/codeup/changeRequests.ts [73:150]
export async function listChangeRequestsFunc(
organizationId: string,
page?: number,
perPage?: number,
projectIds?: string,
authorIds?: string,
reviewerIds?: string,
state?: string, // Possible values: opened, merged, closed
search?: string,
orderBy?: string, // Possible values: created_at, updated_at
sort?: string, // Possible values: asc, desc
createdBefore?: string,
createdAfter?: string
): Promise<z.infer<typeof ChangeRequestSchema>[]> {
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/changeRequests`;
// 构建查询参数
const queryParams: Record<string, string | number | undefined> = {};
if (page !== undefined) {
queryParams.page = page;
}
if (perPage !== undefined) {
queryParams.perPage = perPage;
}
if (projectIds !== undefined) {
queryParams.projectIds = projectIds;
}
if (authorIds !== undefined) {
queryParams.authorIds = authorIds;
}
if (reviewerIds !== undefined) {
queryParams.reviewerIds = reviewerIds;
}
if (state !== undefined) {
queryParams.state = state;
}
if (search !== undefined) {
queryParams.search = search;
}
if (orderBy !== undefined) {
queryParams.orderBy = orderBy;
}
if (sort !== undefined) {
queryParams.sort = sort;
}
if (createdBefore !== undefined) {
queryParams.createdBefore = createdBefore;
}
if (createdAfter !== undefined) {
queryParams.createdAfter = createdAfter;
}
// 使用buildUrl函数构建包含查询参数的URL
const url = buildUrl(baseUrl, queryParams);
const response = await yunxiaoRequest(url, {
method: "GET",
});
// 确保响应是数组
if (!Array.isArray(response)) {
return [];
}
// 解析每个变更请求对象
return response.map(changeRequest => ChangeRequestSchema.parse(changeRequest));
}