(categoriesManagement)
This enables the management of Categories i.e. collections of LineItems.
- getAllCategories - Get all Categories
- createCategory - Create a Category
- getCategory - Get a Category
- updateCategory - Update a Category
- deleteCategory - Delete a Category
Get all of the Line Item Categories on the service provider.
import { OneRoster } from "@superbuilders/oneroster";
const oneRoster = new OneRoster({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await oneRoster.categoriesManagement.getAllCategories({
fields: "sourcedId,name",
filter: "status='active'",
});
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { categoriesManagementGetAllCategories } from "@superbuilders/oneroster/funcs/categoriesManagementGetAllCategories.js";
// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const res = await categoriesManagementGetAllCategories(oneRoster, {
fields: "sourcedId,name",
filter: "status='active'",
});
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("categoriesManagementGetAllCategories failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetAllCategoriesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetAllCategoriesResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedRequestResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.UnprocessableEntityResponseError | 422 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerErrorResponse | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |
To create a new Category. The responding system must return the set of sourcedIds that have been allocated to the newly created category record. A 'title' MUST be provided when creating a category.
import { OneRoster } from "@superbuilders/oneroster";
const oneRoster = new OneRoster({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await oneRoster.categoriesManagement.createCategory({
category: {
status: "tobedeleted",
title: "<value>",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { categoriesManagementCreateCategory } from "@superbuilders/oneroster/funcs/categoriesManagementCreateCategory.js";
// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const res = await categoriesManagementCreateCategory(oneRoster, {
category: {
status: "tobedeleted",
title: "<value>",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesManagementCreateCategory failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateCategoryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.CreateCategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedRequestResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.UnprocessableEntityResponseError | 422 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerErrorResponse | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Get a specific category on the service provider. If the corresponding record cannot be located, the api will return a 404 error code and message 'Category not found.'
import { OneRoster } from "@superbuilders/oneroster";
const oneRoster = new OneRoster({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await oneRoster.categoriesManagement.getCategory({
sourcedId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { categoriesManagementGetCategory } from "@superbuilders/oneroster/funcs/categoriesManagementGetCategory.js";
// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const res = await categoriesManagementGetCategory(oneRoster, {
sourcedId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesManagementGetCategory failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetCategoryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetCategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedRequestResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.UnprocessableEntityResponseError | 422 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerErrorResponse | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |
To update an existing Category. The sourcedId for the record to be updated is supplied by the requesting system.
import { OneRoster } from "@superbuilders/oneroster";
const oneRoster = new OneRoster({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const result = await oneRoster.categoriesManagement.updateCategory({
sourcedId: "<id>",
requestBody: {
category: {
status: "tobedeleted",
title: "<value>",
},
},
});
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { categoriesManagementUpdateCategory } from "@superbuilders/oneroster/funcs/categoriesManagementUpdateCategory.js";
// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const res = await categoriesManagementUpdateCategory(oneRoster, {
sourcedId: "<id>",
requestBody: {
category: {
status: "tobedeleted",
title: "<value>",
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesManagementUpdateCategory failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateCategoryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.UpdateCategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedRequestResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.UnprocessableEntityResponseError | 422 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerErrorResponse | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Perform a soft delete on a specific Category on the service provider. This operation changes the status of the Category to 'tobedeleted'.
import { OneRoster } from "@superbuilders/oneroster";
const oneRoster = new OneRoster({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
await oneRoster.categoriesManagement.deleteCategory({
sourcedId: "<id>",
});
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { categoriesManagementDeleteCategory } from "@superbuilders/oneroster/funcs/categoriesManagementDeleteCategory.js";
// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
security: {
clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
},
});
async function run() {
const res = await categoriesManagementDeleteCategory(oneRoster, {
sourcedId: "<id>",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("categoriesManagementDeleteCategory failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteCategoryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedRequestResponseError | 401 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.UnprocessableEntityResponseError | 422 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerErrorResponse | 500 | application/json |
| errors.APIError | 4XX, 5XX | */* |