in operations/codeup/repositories.ts [52:104]
export async function listRepositoriesFunc(
organizationId: string,
page?: number,
perPage?: number,
orderBy?: string,
sort?: string,
search?: string,
archived?: boolean
): Promise<z.infer<typeof RepositorySchema>[]> {
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories`;
// Build query parameters
const queryParams: Record<string, string | number | undefined> = {};
if (page !== undefined) {
queryParams.page = page;
}
if (perPage !== undefined) {
queryParams.perPage = perPage;
}
if (orderBy !== undefined) {
queryParams.orderBy = orderBy;
}
if (sort !== undefined) {
queryParams.sort = sort;
}
if (search !== undefined) {
queryParams.search = search;
}
if (archived !== undefined) {
queryParams.archived = String(archived); // Convert boolean to string
}
// Use buildUrl function to construct URL with query parameters
const url = buildUrl(baseUrl, queryParams);
const response = await yunxiaoRequest(url, {
method: "GET",
});
// Ensure the response is an array
if (!Array.isArray(response)) {
return [];
}
// Parse each repository object
return response.map(repo => RepositorySchema.parse(repo));
}