can add pages

This commit is contained in:
2024-01-12 16:16:13 -07:00
parent bca8497255
commit 550a42f874
7 changed files with 98 additions and 38 deletions

View File

@@ -30,7 +30,7 @@ public class CanvasCoursePageService(
}
public async Task<string> Create(
public async Task<ulong> Create(
ulong canvasCourseId,
LocalCoursePage localCourse
)

View File

@@ -123,4 +123,30 @@ public class CanvasService(
if (newItem == null)
throw new Exception("something went wrong updating module item");
}
public async Task CreateModuleItem(
ulong canvasCourseId,
ulong canvasModuleId,
string title,
string type,
string contentId
)
{
logger.Log($"creating new module item {title}");
var url = $"courses/{canvasCourseId}/modules/{canvasModuleId}/items";
var body = new
{
module_item = new
{
title,
type = type.ToString(),
content_id = contentId,
}
};
var request = new RestRequest(url);
request.AddBody(body);
var (newItem, _response) = await webRequestor.PostAsync<CanvasModuleItem>(request);
if (newItem == null)
throw new Exception("something went wrong updating module item with string content id");
}
}