diff --git a/config/apisix/apisix.yaml b/config/apisix/apisix.yaml index e9d86cc6b7..3981567dba 100644 --- a/config/apisix/apisix.yaml +++ b/config/apisix/apisix.yaml @@ -3,6 +3,10 @@ upstreams: nodes: "nginx:${{NGINX_PORT}}": 1 type: roundrobin + - id: 2 + nodes: + "${{MITX_ONLINE_UPSTREAM}}": 1 + type: roundrobin routes: - id: 1 @@ -22,7 +26,9 @@ routes: ssl_verify: false session: secret: ${{APISIX_SESSION_SECRET_KEY}} - cookie: { lifetime = 1209600 } + cookie: + lifetime: 1209600 + domain: ${{CSRF_COOKIE_DOMAIN}} logout_path: "/logout/oidc" post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}} unauth_action: "pass" @@ -53,7 +59,9 @@ routes: ssl_verify: false session: secret: ${{APISIX_SESSION_SECRET_KEY}} - cookie: { lifetime = 1209600 } + cookie: + lifetime: 1209600 + domain: ${{CSRF_COOKIE_DOMAIN}} logout_path: "/logout/oidc" post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}} unauth_action: "auth" @@ -69,4 +77,30 @@ routes: uris: - "/admin/login/*" - "/login" + - id: 3 + name: "mitxonline-wildcard" + desc: "General route for the mitxonline application, includes user data if any." + priority: 10 + upstream_id: 2 + plugins: + openid-connect: + client_id: ${{KEYCLOAK_CLIENT_ID}} + client_secret: ${{KEYCLOAK_CLIENT_SECRET}} + discovery: ${{KEYCLOAK_DISCOVERY_URL}} + realm: ${{KEYCLOAK_REALM_NAME}} + scope: "openid profile ol-profile" + bearer_only: false + introspection_endpoint_auth_method: "client_secret_post" + ssl_verify: false + session: + secret: ${{APISIX_SESSION_SECRET_KEY}} + cookie: + lifetime: 1209600 + domain: ${{CSRF_COOKIE_DOMAIN}} + logout_path: "/logout" + post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}} + unauth_action: "pass" + uri: "*" + hosts: + - ${{MITX_ONLINE_DOMAIN}} #END diff --git a/docker-compose.services.yml b/docker-compose.services.yml index 2962725de8..7e82b0601e 100644 --- a/docker-compose.services.yml +++ b/docker-compose.services.yml @@ -119,6 +119,7 @@ services: - apisix image: apache/apisix:latest environment: + - CSRF_COOKIE_DOMAIN=${CSRF_COOKIE_DOMAIN:-.odl.local} - KEYCLOAK_REALM_NAME=${KEYCLOAK_REALM_NAME:-ol-local} - KEYCLOAK_CLIENT_ID=${KEYCLOAK_CLIENT_ID:-apisix} - KEYCLOAK_CLIENT_SECRET=${KEYCLOAK_CLIENT_SECRET} @@ -127,6 +128,8 @@ services: - APISIX_PORT=${APISIX_PORT:-8065} - APISIX_SESSION_SECRET_KEY=${APISIX_SESSION_SECRET_KEY:-something_at_least_16_characters} - APISIX_LOGOUT_URL=${APISIX_LOGOUT_URL:-http://open.odl.local:8065/} + - MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-mitxonline.odl.local:8013} + - MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-mitxonline.odl.local} - NGINX_PORT=${NGINX_PORT:-8062} ports: - ${APISIX_PORT}:${APISIX_PORT} diff --git a/env/frontend.env b/env/frontend.env index 4efd9adbf8..87d942af20 100644 --- a/env/frontend.env +++ b/env/frontend.env @@ -21,3 +21,5 @@ NEXT_PUBLIC_DEFAULT_SEARCH_MAX_INCOMPLETENESS_PENALTY=90 NEXT_PUBLIC_LEARN_AI_RECOMMENDATION_ENDPOINT=https://api-learn-ai-qa.ol.mit.edu/http/recommendation_agent/ NEXT_PUBLIC_LEARN_AI_SYLLABUS_ENDPOINT=https://api-learn-ai-qa.ol.mit.edu/http/syllabus_agent/ + +NEXT_PUBLIC_MITX_ONLINE_BASE_URL=${MITX_ONLINE_BASE_URL} diff --git a/frontends/api/package.json b/frontends/api/package.json index 76439c013d..38f3a1f95b 100644 --- a/frontends/api/package.json +++ b/frontends/api/package.json @@ -30,6 +30,7 @@ "ol-test-utilities": "0.0.0" }, "dependencies": { + "@mitodl/mitxonline-api-axios": "^2025.6.3", "@tanstack/react-query": "^5.66.0", "axios": "^1.6.3" } diff --git a/frontends/api/src/mitxonline/clients.ts b/frontends/api/src/mitxonline/clients.ts index ca2da0b78a..62d5535d06 100644 --- a/frontends/api/src/mitxonline/clients.ts +++ b/frontends/api/src/mitxonline/clients.ts @@ -1,13 +1,35 @@ -import { EnrollmentsApi, ProgramsApi, CoursesApi } from "./generated/v0/api" +import { + B2bApi, + CoursesApi, + EnrollmentsApi, + ProgramsApi, + UsersApi, +} from "@mitodl/mitxonline-api-axios/v1" import axios from "axios" -const axiosInstance = axios.create({}) +const axiosInstance = axios.create({ + baseURL: process.env.NEXT_PUBLIC_MITX_ONLINE_BASE_URL, + xsrfCookieName: process.env.NEXT_PUBLIC_CSRF_COOKIE_NAME, + xsrfHeaderName: "X-CSRFToken", + withXSRFToken: true, + withCredentials: + process.env.NEXT_PUBLIC_MITOL_AXIOS_WITH_CREDENTIALS === "true", +}) const BASE_PATH = - process.env.NEXT_PUBLIC_MITXONLINE_API_BASE_URL?.replace(/\/+$/, "") ?? "" + process.env.NEXT_PUBLIC_MITX_ONLINE_BASE_URL?.replace(/\/+$/, "") ?? "" +const usersApi = new UsersApi(undefined, BASE_PATH, axiosInstance) +const b2bApi = new B2bApi(undefined, BASE_PATH, axiosInstance) const enrollmentsApi = new EnrollmentsApi(undefined, BASE_PATH, axiosInstance) const programsApi = new ProgramsApi(undefined, BASE_PATH, axiosInstance) const coursesApi = new CoursesApi(undefined, BASE_PATH, axiosInstance) -export { enrollmentsApi, programsApi, coursesApi, axiosInstance } +export { + usersApi, + b2bApi, + enrollmentsApi, + programsApi, + coursesApi, + axiosInstance, +} diff --git a/frontends/api/src/mitxonline/generated/v0/.openapi-generator/FILES b/frontends/api/src/mitxonline/generated/v0/.openapi-generator/FILES deleted file mode 100644 index 53250c0269..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/.openapi-generator/FILES +++ /dev/null @@ -1,5 +0,0 @@ -api.ts -base.ts -common.ts -configuration.ts -index.ts diff --git a/frontends/api/src/mitxonline/generated/v0/.openapi-generator/VERSION b/frontends/api/src/mitxonline/generated/v0/.openapi-generator/VERSION deleted file mode 100644 index 0ee843cc60..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.2.0 diff --git a/frontends/api/src/mitxonline/generated/v0/api.ts b/frontends/api/src/mitxonline/generated/v0/api.ts deleted file mode 100644 index 63dbf73577..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/api.ts +++ /dev/null @@ -1,5921 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * MITx Online API - * MIT public API - * - * The version of the OpenAPI document: 0.0.1 (v0) - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Configuration } from "./configuration" -import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios" -import globalAxios from "axios" -// Some imports not used depending on template conditions -// @ts-ignore -import { - DUMMY_BASE_URL, - assertParamExists, - setApiKeyToObject, - setBasicAuthToObject, - setBearerAuthToObject, - setOAuthToObject, - setSearchParams, - serializeDataIfNeeded, - toPathString, - createRequestFunction, -} from "./common" -import type { RequestArgs } from "./base" -// @ts-ignore -import { - BASE_PATH, - COLLECTION_FORMATS, - BaseAPI, - RequiredError, - operationServerMap, -} from "./base" - -/** - * * `anytime` - anytime * `dated` - dated - * @export - * @enum {string} - */ - -export const AvailabilityEnumDescriptions = { - anytime: "anytime", - dated: "dated", -} as const - -export const AvailabilityEnum = { - /** - * anytime - */ - Anytime: "anytime", - /** - * dated - */ - Dated: "dated", -} as const - -export type AvailabilityEnum = - (typeof AvailabilityEnum)[keyof typeof AvailabilityEnum] - -/** - * Course model serializer - * @export - * @interface Course - */ -export interface Course { - /** - * - * @type {number} - * @memberof Course - */ - id: number - /** - * - * @type {string} - * @memberof Course - */ - title: string - /** - * - * @type {string} - * @memberof Course - */ - readable_id: string - /** - * Get next run id - * @type {number} - * @memberof Course - */ - next_run_id: number | null - /** - * - * @type {Array} - * @memberof Course - */ - departments: Array - /** - * - * @type {CoursePage} - * @memberof Course - */ - page: CoursePage - /** - * - * @type {Program} - * @memberof Course - */ - programs: Program | null -} -/** - * Course page model serializer - * @export - * @interface CoursePage - */ -export interface CoursePage { - /** - * Serializes the source of the feature_image - * @type {string} - * @memberof CoursePage - */ - feature_image_src: string - /** - * - * @type {string} - * @memberof CoursePage - */ - page_url: string - /** - * - * @type {string} - * @memberof CoursePage - */ - description: string - /** - * - * @type {boolean} - * @memberof CoursePage - */ - live: boolean - /** - * - * @type {string} - * @memberof CoursePage - */ - length: string - /** - * - * @type {string} - * @memberof CoursePage - */ - effort: string | null - /** - * - * @type {string} - * @memberof CoursePage - */ - financial_assistance_form_url: string - /** - * - * @type {number} - * @memberof CoursePage - */ - current_price: number | null - /** - * - * @type {Array} - * @memberof CoursePage - */ - instructors: Array -} -/** - * Course model serializer - * @export - * @interface CourseRequest - */ -export interface CourseRequest { - /** - * - * @type {string} - * @memberof CourseRequest - */ - title: string - /** - * - * @type {string} - * @memberof CourseRequest - */ - readable_id: string -} -/** - * CourseRunCertificate model serializer - * @export - * @interface CourseRunCertificate - */ -export interface CourseRunCertificate { - /** - * - * @type {string} - * @memberof CourseRunCertificate - */ - uuid: string - /** - * Get the link at which this certificate will be served Format: /certificate// Example: /certificate/93ebd74e-5f88-4b47-bb09-30a6d575328f/ - * @type {string} - * @memberof CourseRunCertificate - */ - link: string -} -/** - * CourseRunEnrollment model serializer - * @export - * @interface CourseRunEnrollment - */ -export interface CourseRunEnrollment { - /** - * - * @type {V1CourseRunWithCourse} - * @memberof CourseRunEnrollment - */ - run: V1CourseRunWithCourse - /** - * - * @type {number} - * @memberof CourseRunEnrollment - */ - id: number - /** - * - * @type {boolean} - * @memberof CourseRunEnrollment - */ - edx_emails_subscription?: boolean - /** - * - * @type {CourseRunCertificate} - * @memberof CourseRunEnrollment - */ - certificate: CourseRunCertificate | null - /** - * - * @type {EnrollmentModeEnum} - * @memberof CourseRunEnrollment - */ - enrollment_mode: EnrollmentModeEnum - /** - * - * @type {boolean} - * @memberof CourseRunEnrollment - */ - approved_flexible_price_exists: boolean - /** - * - * @type {Array} - * @memberof CourseRunEnrollment - */ - grades: Array -} - -/** - * CourseRunEnrollment model serializer - * @export - * @interface CourseRunEnrollmentRequest - */ -export interface CourseRunEnrollmentRequest { - /** - * - * @type {boolean} - * @memberof CourseRunEnrollmentRequest - */ - edx_emails_subscription?: boolean - /** - * - * @type {number} - * @memberof CourseRunEnrollmentRequest - */ - run_id: number -} -/** - * CourseRunGrade serializer - * @export - * @interface CourseRunGrade - */ -export interface CourseRunGrade { - /** - * - * @type {number} - * @memberof CourseRunGrade - */ - grade: number - /** - * - * @type {string} - * @memberof CourseRunGrade - */ - letter_grade?: string | null - /** - * - * @type {boolean} - * @memberof CourseRunGrade - */ - passed?: boolean - /** - * - * @type {boolean} - * @memberof CourseRunGrade - */ - set_by_admin?: boolean - /** - * Returns the grade field value as a number out of 100 (or None if the value is None) - * @type {number} - * @memberof CourseRunGrade - */ - grade_percent: number -} -/** - * Course model serializer - also serializes child course runs - * @export - * @interface CourseWithCourseRuns - */ -export interface CourseWithCourseRuns { - /** - * - * @type {number} - * @memberof CourseWithCourseRuns - */ - id: number - /** - * - * @type {string} - * @memberof CourseWithCourseRuns - */ - title: string - /** - * - * @type {string} - * @memberof CourseWithCourseRuns - */ - readable_id: string - /** - * Get next run id - * @type {number} - * @memberof CourseWithCourseRuns - */ - next_run_id: number | null - /** - * - * @type {Array} - * @memberof CourseWithCourseRuns - */ - departments: Array - /** - * - * @type {CoursePage} - * @memberof CourseWithCourseRuns - */ - page: CoursePage - /** - * - * @type {Array<{ [key: string]: any; }>} - * @memberof CourseWithCourseRuns - */ - programs: Array<{ [key: string]: any }> | null - /** - * List topics of a course - * @type {Array<{ [key: string]: any; }>} - * @memberof CourseWithCourseRuns - */ - topics: Array<{ [key: string]: any }> - /** - * - * @type {string} - * @memberof CourseWithCourseRuns - */ - certificate_type: string - /** - * Check if the prerequisites field is populated in the course page CMS. Returns: bool: True when the prerequisites field is populated in the course page CMS. False otherwise. - * @type {boolean} - * @memberof CourseWithCourseRuns - */ - required_prerequisites: boolean - /** - * Get the duration of the course from the course page CMS. - * @type {string} - * @memberof CourseWithCourseRuns - */ - duration: string - /** - * Get the min weeks of the course from the CMS page. - * @type {number} - * @memberof CourseWithCourseRuns - */ - min_weeks: number | null - /** - * Get the max weeks of the course from the CMS page. - * @type {number} - * @memberof CourseWithCourseRuns - */ - max_weeks: number | null - /** - * Get the time commitment of the course from the course page CMS. - * @type {string} - * @memberof CourseWithCourseRuns - */ - time_commitment: string | null - /** - * Get course availability - * @type {string} - * @memberof CourseWithCourseRuns - */ - availability: string - /** - * Get the min weekly hours of the course from the course page CMS. - * @type {string} - * @memberof CourseWithCourseRuns - */ - min_weekly_hours: string | null - /** - * Get the max weekly hours of the course from the course page CMS. - * @type {string} - * @memberof CourseWithCourseRuns - */ - max_weekly_hours: string | null - /** - * - * @type {Array} - * @memberof CourseWithCourseRuns - */ - courseruns: Array -} -/** - * Department model serializer - * @export - * @interface Department - */ -export interface Department { - /** - * - * @type {string} - * @memberof Department - */ - name: string -} -/** - * Department model serializer - * @export - * @interface DepartmentRequest - */ -export interface DepartmentRequest { - /** - * - * @type {string} - * @memberof DepartmentRequest - */ - name: string -} -/** - * CourseRun model serializer that includes the number of courses and programs associated with each departments - * @export - * @interface DepartmentWithCount - */ -export interface DepartmentWithCount { - /** - * - * @type {string} - * @memberof DepartmentWithCount - */ - name: string - /** - * - * @type {number} - * @memberof DepartmentWithCount - */ - courses: number - /** - * - * @type {number} - * @memberof DepartmentWithCount - */ - programs: number -} -/** - * Department model serializer that includes the number of courses and programs associated with each - * @export - * @interface DepartmentWithCoursesAndPrograms - */ -export interface DepartmentWithCoursesAndPrograms { - /** - * - * @type {number} - * @memberof DepartmentWithCoursesAndPrograms - */ - id: number - /** - * - * @type {string} - * @memberof DepartmentWithCoursesAndPrograms - */ - name: string - /** - * - * @type {string} - * @memberof DepartmentWithCoursesAndPrograms - */ - slug: string - /** - * - * @type {Array} - * @memberof DepartmentWithCoursesAndPrograms - */ - course_ids: Array - /** - * - * @type {Array} - * @memberof DepartmentWithCoursesAndPrograms - */ - program_ids: Array -} -/** - * - * @export - * @interface Discount - */ -export interface Discount { - /** - * - * @type {number} - * @memberof Discount - */ - id: number - /** - * - * @type {string} - * @memberof Discount - */ - amount: string - /** - * - * @type {boolean} - * @memberof Discount - */ - automatic?: boolean - /** - * - * @type {DiscountTypeEnum} - * @memberof Discount - */ - discount_type: DiscountTypeEnum - /** - * - * @type {RedemptionTypeEnum} - * @memberof Discount - */ - redemption_type: RedemptionTypeEnum - /** - * - * @type {number} - * @memberof Discount - */ - max_redemptions?: number | null - /** - * - * @type {string} - * @memberof Discount - */ - discount_code: string - /** - * - * @type {PaymentTypeEnum} - * @memberof Discount - */ - payment_type?: PaymentTypeEnum | null - /** - * Returns True if the discount has been redeemed - * @type {boolean} - * @memberof Discount - */ - is_redeemed: boolean - /** - * If set, this discount code will not be redeemable before this date. - * @type {string} - * @memberof Discount - */ - activation_date?: string | null - /** - * If set, this discount code will not be redeemable after this date. - * @type {string} - * @memberof Discount - */ - expiration_date?: string | null -} - -/** - * * `percent-off` - percent-off * `dollars-off` - dollars-off * `fixed-price` - fixed-price - * @export - * @enum {string} - */ - -export const DiscountTypeEnumDescriptions = { - "percent-off": "percent-off", - "dollars-off": "dollars-off", - "fixed-price": "fixed-price", -} as const - -export const DiscountTypeEnum = { - /** - * percent-off - */ - PercentOff: "percent-off", - /** - * dollars-off - */ - DollarsOff: "dollars-off", - /** - * fixed-price - */ - FixedPrice: "fixed-price", -} as const - -export type DiscountTypeEnum = - (typeof DiscountTypeEnum)[keyof typeof DiscountTypeEnum] - -/** - * * `audit` - audit * `verified` - verified - * @export - * @enum {string} - */ - -export const EnrollmentModeEnumDescriptions = { - audit: "audit", - verified: "verified", -} as const - -export const EnrollmentModeEnum = { - /** - * audit - */ - Audit: "audit", - /** - * verified - */ - Verified: "verified", -} as const - -export type EnrollmentModeEnum = - (typeof EnrollmentModeEnum)[keyof typeof EnrollmentModeEnum] - -/** - * - * @export - * @interface LearnerProgramRecordShare - */ -export interface LearnerProgramRecordShare { - /** - * - * @type {string} - * @memberof LearnerProgramRecordShare - */ - share_uuid: string - /** - * - * @type {string} - * @memberof LearnerProgramRecordShare - */ - created_on: string - /** - * - * @type {string} - * @memberof LearnerProgramRecordShare - */ - updated_on: string - /** - * - * @type {boolean} - * @memberof LearnerProgramRecordShare - */ - is_active?: boolean - /** - * - * @type {number} - * @memberof LearnerProgramRecordShare - */ - user: number - /** - * - * @type {number} - * @memberof LearnerProgramRecordShare - */ - program: number - /** - * - * @type {number} - * @memberof LearnerProgramRecordShare - */ - partner_school: number | null -} -/** - * Gathers the various data needed to display the learner\'s program record. Pass the program you want the record for and attach the learner via context object. - * @export - * @interface LearnerRecord - */ -export interface LearnerRecord { - /** - * User information including name, email, and username - * @type {{ [key: string]: string; }} - * @memberof LearnerRecord - */ - user: { [key: string]: string } - /** - * Program details including title, readable_id, courses, and requirements - * @type {{ [key: string]: { [key: string]: any; }; }} - * @memberof LearnerRecord - */ - program: { [key: string]: { [key: string]: any } } - /** - * Active program record shares for this user - * @type {Array} - * @memberof LearnerRecord - */ - sharing: Array - /** - * List of partner schools - * @type {Array} - * @memberof LearnerRecord - */ - partner_schools: Array -} -/** - * * `operator` - operator * `course` - course - * @export - * @enum {string} - */ - -export const NodeTypeEnumDescriptions = { - operator: "operator", - course: "course", -} as const - -export const NodeTypeEnum = { - /** - * operator - */ - Operator: "operator", - /** - * course - */ - Course: "course", -} as const - -export type NodeTypeEnum = (typeof NodeTypeEnum)[keyof typeof NodeTypeEnum] - -/** - * - * @export - * @enum {string} - */ - -export const NullEnumDescriptions = { - null: "", -} as const - -export const NullEnum = { - Null: "null", -} as const - -export type NullEnum = (typeof NullEnum)[keyof typeof NullEnum] - -/** - * - * @export - * @interface PaginatedCourseWithCourseRunsList - */ -export interface PaginatedCourseWithCourseRunsList { - /** - * - * @type {number} - * @memberof PaginatedCourseWithCourseRunsList - */ - count: number - /** - * - * @type {string} - * @memberof PaginatedCourseWithCourseRunsList - */ - next?: string | null - /** - * - * @type {string} - * @memberof PaginatedCourseWithCourseRunsList - */ - previous?: string | null - /** - * - * @type {Array} - * @memberof PaginatedCourseWithCourseRunsList - */ - results: Array -} -/** - * - * @export - * @interface PaginatedV1CourseWithCourseRunsList - */ -export interface PaginatedV1CourseWithCourseRunsList { - /** - * - * @type {number} - * @memberof PaginatedV1CourseWithCourseRunsList - */ - count: number - /** - * - * @type {string} - * @memberof PaginatedV1CourseWithCourseRunsList - */ - next?: string | null - /** - * - * @type {string} - * @memberof PaginatedV1CourseWithCourseRunsList - */ - previous?: string | null - /** - * - * @type {Array} - * @memberof PaginatedV1CourseWithCourseRunsList - */ - results: Array -} -/** - * - * @export - * @interface PaginatedV1ProgramList - */ -export interface PaginatedV1ProgramList { - /** - * - * @type {number} - * @memberof PaginatedV1ProgramList - */ - count: number - /** - * - * @type {string} - * @memberof PaginatedV1ProgramList - */ - next?: string | null - /** - * - * @type {string} - * @memberof PaginatedV1ProgramList - */ - previous?: string | null - /** - * - * @type {Array} - * @memberof PaginatedV1ProgramList - */ - results: Array -} -/** - * - * @export - * @interface PaginatedV2ProgramList - */ -export interface PaginatedV2ProgramList { - /** - * - * @type {number} - * @memberof PaginatedV2ProgramList - */ - count: number - /** - * - * @type {string} - * @memberof PaginatedV2ProgramList - */ - next?: string | null - /** - * - * @type {string} - * @memberof PaginatedV2ProgramList - */ - previous?: string | null - /** - * - * @type {Array} - * @memberof PaginatedV2ProgramList - */ - results: Array -} -/** - * - * @export - * @interface PartnerSchool - */ -export interface PartnerSchool { - /** - * - * @type {number} - * @memberof PartnerSchool - */ - id: number - /** - * - * @type {string} - * @memberof PartnerSchool - */ - created_on: string - /** - * - * @type {string} - * @memberof PartnerSchool - */ - updated_on: string - /** - * - * @type {string} - * @memberof PartnerSchool - */ - name: string - /** - * - * @type {string} - * @memberof PartnerSchool - */ - email: string -} -/** - * - * @export - * @interface PartnerSchoolRequest - */ -export interface PartnerSchoolRequest { - /** - * - * @type {string} - * @memberof PartnerSchoolRequest - */ - name: string - /** - * - * @type {string} - * @memberof PartnerSchoolRequest - */ - email: string -} -/** - * CourseRunEnrollment model serializer - * @export - * @interface PatchedCourseRunEnrollmentRequest - */ -export interface PatchedCourseRunEnrollmentRequest { - /** - * - * @type {boolean} - * @memberof PatchedCourseRunEnrollmentRequest - */ - edx_emails_subscription?: boolean - /** - * - * @type {number} - * @memberof PatchedCourseRunEnrollmentRequest - */ - run_id?: number -} -/** - * * `marketing` - marketing * `sales` - sales * `financial-assistance` - financial-assistance * `customer-support` - customer-support * `staff` - staff * `legacy` - legacy - * @export - * @enum {string} - */ - -export const PaymentTypeEnumDescriptions = { - marketing: "marketing", - sales: "sales", - "financial-assistance": "financial-assistance", - "customer-support": "customer-support", - staff: "staff", - legacy: "legacy", -} as const - -export const PaymentTypeEnum = { - /** - * marketing - */ - Marketing: "marketing", - /** - * sales - */ - Sales: "sales", - /** - * financial-assistance - */ - FinancialAssistance: "financial-assistance", - /** - * customer-support - */ - CustomerSupport: "customer-support", - /** - * staff - */ - Staff: "staff", - /** - * legacy - */ - Legacy: "legacy", -} as const - -export type PaymentTypeEnum = - (typeof PaymentTypeEnum)[keyof typeof PaymentTypeEnum] - -/** - * Simple serializer for Product without related purchasable objects - * @export - * @interface ProductFlexibilePrice - */ -export interface ProductFlexibilePrice { - /** - * - * @type {number} - * @memberof ProductFlexibilePrice - */ - id: number - /** - * - * @type {string} - * @memberof ProductFlexibilePrice - */ - price: string - /** - * - * @type {string} - * @memberof ProductFlexibilePrice - */ - description: string - /** - * Controls visibility of the product in the app. - * @type {boolean} - * @memberof ProductFlexibilePrice - */ - is_active?: boolean - /** - * - * @type {Discount} - * @memberof ProductFlexibilePrice - */ - product_flexible_price: Discount | null -} -/** - * Simple serializer for Product without related purchasable objects - * @export - * @interface ProductFlexibilePriceRequest - */ -export interface ProductFlexibilePriceRequest { - /** - * - * @type {string} - * @memberof ProductFlexibilePriceRequest - */ - price: string - /** - * - * @type {string} - * @memberof ProductFlexibilePriceRequest - */ - description: string - /** - * Controls visibility of the product in the app. - * @type {boolean} - * @memberof ProductFlexibilePriceRequest - */ - is_active?: boolean -} -/** - * - * @export - * @interface Program - */ -export interface Program { - /** - * - * @type {number} - * @memberof Program - */ - id: number - /** - * - * @type {string} - * @memberof Program - */ - title: string - /** - * - * @type {string} - * @memberof Program - */ - readable_id: string -} -/** - * ProgramCertificate model serializer - * @export - * @interface ProgramCertificate - */ -export interface ProgramCertificate { - /** - * - * @type {string} - * @memberof ProgramCertificate - */ - uuid: string - /** - * Get the link at which this certificate will be served Format: /certificate/program// Example: /certificate/program/93ebd74e-5f88-4b47-bb09-30a6d575328f/ - * @type {string} - * @memberof ProgramCertificate - */ - link: string -} -/** - * Program page model serializer - * @export - * @interface ProgramPage - */ -export interface ProgramPage { - /** - * Serializes the source of the feature_image - * @type {string} - * @memberof ProgramPage - */ - feature_image_src: string - /** - * - * @type {string} - * @memberof ProgramPage - */ - page_url: string - /** - * - * @type {string} - * @memberof ProgramPage - */ - financial_assistance_form_url: string - /** - * The description shown on the home page and product page. - * @type {string} - * @memberof ProgramPage - */ - description: string - /** - * - * @type {boolean} - * @memberof ProgramPage - */ - live: boolean - /** - * A short description indicating how long it takes to complete (e.g. \'4 weeks\'). - * @type {string} - * @memberof ProgramPage - */ - length?: string - /** - * A short description indicating how much effort is required (e.g. 1-3 hours per week). - * @type {string} - * @memberof ProgramPage - */ - effort?: string | null - /** - * - * @type {string} - * @memberof ProgramPage - */ - price: string -} -/** - * * `one-time` - one-time * `one-time-per-user` - one-time-per-user * `unlimited` - unlimited - * @export - * @enum {string} - */ - -export const RedemptionTypeEnumDescriptions = { - "one-time": "one-time", - "one-time-per-user": "one-time-per-user", - unlimited: "unlimited", -} as const - -export const RedemptionTypeEnum = { - /** - * one-time - */ - OneTime: "one-time", - /** - * one-time-per-user - */ - OneTimePerUser: "one-time-per-user", - /** - * unlimited - */ - Unlimited: "unlimited", -} as const - -export type RedemptionTypeEnum = - (typeof RedemptionTypeEnum)[keyof typeof RedemptionTypeEnum] - -/** - * - * @export - * @interface UserProgramEnrollmentDetail - */ -export interface UserProgramEnrollmentDetail { - /** - * - * @type {V1Program} - * @memberof UserProgramEnrollmentDetail - */ - program: V1Program - /** - * - * @type {Array} - * @memberof UserProgramEnrollmentDetail - */ - enrollments: Array - /** - * - * @type {ProgramCertificate} - * @memberof UserProgramEnrollmentDetail - */ - certificate: ProgramCertificate | null -} -/** - * CourseRun model serializer - * @export - * @interface V1BaseCourseRun - */ -export interface V1BaseCourseRun { - /** - * The title of the course. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - title: string - /** - * The day the course begins. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - start_date?: string | null - /** - * The last day the course is active. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - end_date?: string | null - /** - * The first day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - enrollment_start?: string | null - /** - * The last day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - enrollment_end?: string | null - /** - * The date beyond which the learner should not see link to this course run on their dashboard. - * @type {string} - * @memberof V1BaseCourseRun - */ - expiration_date?: string | null - /** - * Get the courseware URL - * @type {string} - * @memberof V1BaseCourseRun - */ - courseware_url: string | null - /** - * - * @type {string} - * @memberof V1BaseCourseRun - */ - courseware_id: string - /** - * The day certificates should be available to users. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1BaseCourseRun - */ - certificate_available_date?: string | null - /** - * The date beyond which the learner can not enroll in paid course mode. - * @type {string} - * @memberof V1BaseCourseRun - */ - upgrade_deadline?: string | null - /** - * Check if the course run is upgradable - * @type {boolean} - * @memberof V1BaseCourseRun - */ - is_upgradable: boolean - /** - * Check if the course run is enrollable - * @type {boolean} - * @memberof V1BaseCourseRun - */ - is_enrollable: boolean - /** - * Check if the course run is archived - * @type {boolean} - * @memberof V1BaseCourseRun - */ - is_archived: boolean - /** - * - * @type {boolean} - * @memberof V1BaseCourseRun - */ - is_self_paced?: boolean - /** - * A string that identifies the set of runs that this run belongs to (example: \'R2\') - * @type {string} - * @memberof V1BaseCourseRun - */ - run_tag: string - /** - * - * @type {number} - * @memberof V1BaseCourseRun - */ - id: number - /** - * - * @type {boolean} - * @memberof V1BaseCourseRun - */ - live?: boolean - /** - * Get the course number - * @type {string} - * @memberof V1BaseCourseRun - */ - course_number: string - /** - * - * @type {Array} - * @memberof V1BaseCourseRun - */ - products: Array - /** - * - * @type {boolean} - * @memberof V1BaseCourseRun - */ - approved_flexible_price_exists: boolean -} -/** - * CourseRun model serializer - also serializes the parent Course. - * @export - * @interface V1CourseRunWithCourse - */ -export interface V1CourseRunWithCourse { - /** - * The title of the course. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - title: string - /** - * The day the course begins. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - start_date?: string | null - /** - * The last day the course is active. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - end_date?: string | null - /** - * The first day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - enrollment_start?: string | null - /** - * The last day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - enrollment_end?: string | null - /** - * The date beyond which the learner should not see link to this course run on their dashboard. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - expiration_date?: string | null - /** - * Get the courseware URL - * @type {string} - * @memberof V1CourseRunWithCourse - */ - courseware_url: string | null - /** - * - * @type {string} - * @memberof V1CourseRunWithCourse - */ - courseware_id: string - /** - * The day certificates should be available to users. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - certificate_available_date?: string | null - /** - * The date beyond which the learner can not enroll in paid course mode. - * @type {string} - * @memberof V1CourseRunWithCourse - */ - upgrade_deadline?: string | null - /** - * Check if the course run is upgradable - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - is_upgradable: boolean - /** - * Check if the course run is enrollable - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - is_enrollable: boolean - /** - * Check if the course run is archived - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - is_archived: boolean - /** - * - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - is_self_paced?: boolean - /** - * A string that identifies the set of runs that this run belongs to (example: \'R2\') - * @type {string} - * @memberof V1CourseRunWithCourse - */ - run_tag: string - /** - * - * @type {number} - * @memberof V1CourseRunWithCourse - */ - id: number - /** - * - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - live?: boolean - /** - * Get the course number - * @type {string} - * @memberof V1CourseRunWithCourse - */ - course_number: string - /** - * List of products associated with this course run - * @type {Array} - * @memberof V1CourseRunWithCourse - */ - products: Array - /** - * - * @type {boolean} - * @memberof V1CourseRunWithCourse - */ - approved_flexible_price_exists: boolean - /** - * - * @type {Course} - * @memberof V1CourseRunWithCourse - */ - course: Course -} -/** - * CourseRun model serializer - also serializes the parent Course. - * @export - * @interface V1CourseRunWithCourseRequest - */ -export interface V1CourseRunWithCourseRequest { - /** - * The title of the course. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - title: string - /** - * The day the course begins. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - start_date?: string | null - /** - * The last day the course is active. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - end_date?: string | null - /** - * The first day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - enrollment_start?: string | null - /** - * The last day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - enrollment_end?: string | null - /** - * The date beyond which the learner should not see link to this course run on their dashboard. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - expiration_date?: string | null - /** - * - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - courseware_id: string - /** - * The day certificates should be available to users. This value is synced automatically with edX studio. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - certificate_available_date?: string | null - /** - * The date beyond which the learner can not enroll in paid course mode. - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - upgrade_deadline?: string | null - /** - * - * @type {boolean} - * @memberof V1CourseRunWithCourseRequest - */ - is_self_paced?: boolean - /** - * A string that identifies the set of runs that this run belongs to (example: \'R2\') - * @type {string} - * @memberof V1CourseRunWithCourseRequest - */ - run_tag: string - /** - * - * @type {boolean} - * @memberof V1CourseRunWithCourseRequest - */ - live?: boolean -} -/** - * Course model serializer - also serializes child course runs - * @export - * @interface V1CourseWithCourseRuns - */ -export interface V1CourseWithCourseRuns { - /** - * - * @type {number} - * @memberof V1CourseWithCourseRuns - */ - id: number - /** - * - * @type {string} - * @memberof V1CourseWithCourseRuns - */ - title: string - /** - * - * @type {string} - * @memberof V1CourseWithCourseRuns - */ - readable_id: string - /** - * Get next run id - * @type {number} - * @memberof V1CourseWithCourseRuns - */ - next_run_id: number | null - /** - * - * @type {Array} - * @memberof V1CourseWithCourseRuns - */ - departments: Array - /** - * - * @type {CoursePage} - * @memberof V1CourseWithCourseRuns - */ - page: CoursePage - /** - * - * @type {Program} - * @memberof V1CourseWithCourseRuns - */ - programs: Program | null - /** - * - * @type {Array} - * @memberof V1CourseWithCourseRuns - */ - courseruns: Array -} -/** - * Program model serializer - * @export - * @interface V1Program - */ -export interface V1Program { - /** - * - * @type {string} - * @memberof V1Program - */ - title: string - /** - * - * @type {string} - * @memberof V1Program - */ - readable_id: string - /** - * - * @type {number} - * @memberof V1Program - */ - id: number - /** - * - * @type {V1CourseWithCourseRuns} - * @memberof V1Program - */ - courses: V1CourseWithCourseRuns - /** - * - * @type {V1ProgramRequirements} - * @memberof V1Program - */ - requirements: V1ProgramRequirements - /** - * - * @type {Array} - * @memberof V1Program - */ - req_tree: Array - /** - * - * @type {ProgramPage} - * @memberof V1Program - */ - page: ProgramPage - /** - * - * @type {string} - * @memberof V1Program - */ - program_type?: string | null - /** - * - * @type {Array} - * @memberof V1Program - */ - departments: Array - /** - * - * @type {boolean} - * @memberof V1Program - */ - live?: boolean -} -/** - * Serializer for a ProgramRequirement - * @export - * @interface V1ProgramRequirement - */ -export interface V1ProgramRequirement { - /** - * - * @type {number} - * @memberof V1ProgramRequirement - */ - id?: number | null - /** - * - * @type {V1ProgramRequirementData} - * @memberof V1ProgramRequirement - */ - data: V1ProgramRequirementData - /** - * - * @type {Array} - * @memberof V1ProgramRequirement - */ - children?: Array -} -/** - * Serializer for ProgramRequirement data - * @export - * @interface V1ProgramRequirementData - */ -export interface V1ProgramRequirementData { - /** - * - * @type {NodeTypeEnum} - * @memberof V1ProgramRequirementData - */ - node_type: NodeTypeEnum - /** - * - * @type {string} - * @memberof V1ProgramRequirementData - */ - course?: string | null - /** - * - * @type {string} - * @memberof V1ProgramRequirementData - */ - program?: string - /** - * - * @type {string} - * @memberof V1ProgramRequirementData - */ - title?: string | null - /** - * - * @type {string} - * @memberof V1ProgramRequirementData - */ - operator?: string | null - /** - * - * @type {string} - * @memberof V1ProgramRequirementData - */ - operator_value?: string | null - /** - * - * @type {boolean} - * @memberof V1ProgramRequirementData - */ - elective_flag?: boolean | null -} - -/** - * - * @export - * @interface V1ProgramRequirements - */ -export interface V1ProgramRequirements { - /** - * List of required course IDs - * @type {Array} - * @memberof V1ProgramRequirements - */ - required?: Array - /** - * List of elective course IDs - * @type {Array} - * @memberof V1ProgramRequirements - */ - electives?: Array -} -/** - * @type V1ProgramRequirementsRequiredInner - * @export - */ -export type V1ProgramRequirementsRequiredInner = number - -/** - * CourseRun model serializer - * @export - * @interface V2CourseRun - */ -export interface V2CourseRun { - /** - * The title of the course. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - title: string - /** - * The day the course begins. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - start_date?: string | null - /** - * The last day the course is active. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - end_date?: string | null - /** - * The first day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - enrollment_start?: string | null - /** - * The last day students can enroll. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - enrollment_end?: string | null - /** - * The date beyond which the learner should not see link to this course run on their dashboard. - * @type {string} - * @memberof V2CourseRun - */ - expiration_date?: string | null - /** - * Get the courseware URL - * @type {string} - * @memberof V2CourseRun - */ - courseware_url: string | null - /** - * - * @type {string} - * @memberof V2CourseRun - */ - courseware_id: string - /** - * The day certificates should be available to users. This value is synced automatically with edX studio. - * @type {string} - * @memberof V2CourseRun - */ - certificate_available_date?: string | null - /** - * The date beyond which the learner can not enroll in paid course mode. - * @type {string} - * @memberof V2CourseRun - */ - upgrade_deadline?: string | null - /** - * Check if the course run is upgradable - * @type {boolean} - * @memberof V2CourseRun - */ - is_upgradable: boolean - /** - * Check if the course run is enrollable - * @type {boolean} - * @memberof V2CourseRun - */ - is_enrollable: boolean - /** - * Check if the course run is archived - * @type {boolean} - * @memberof V2CourseRun - */ - is_archived: boolean - /** - * - * @type {boolean} - * @memberof V2CourseRun - */ - is_self_paced?: boolean - /** - * A string that identifies the set of runs that this run belongs to (example: \'R2\') - * @type {string} - * @memberof V2CourseRun - */ - run_tag: string - /** - * - * @type {number} - * @memberof V2CourseRun - */ - id: number - /** - * - * @type {boolean} - * @memberof V2CourseRun - */ - live?: boolean - /** - * Get the course number - * @type {string} - * @memberof V2CourseRun - */ - course_number: string - /** - * - * @type {Array} - * @memberof V2CourseRun - */ - products: Array - /** - * - * @type {boolean} - * @memberof V2CourseRun - */ - approved_flexible_price_exists: boolean -} -/** - * Program Model Serializer v2 - * @export - * @interface V2Program - */ -export interface V2Program { - /** - * - * @type {string} - * @memberof V2Program - */ - title: string - /** - * - * @type {string} - * @memberof V2Program - */ - readable_id: string - /** - * - * @type {number} - * @memberof V2Program - */ - id: number - /** - * - * @type {Array} - * @memberof V2Program - */ - courses: Array - /** - * - * @type {V1ProgramRequirements} - * @memberof V2Program - */ - requirements: V1ProgramRequirements - /** - * - * @type {Array} - * @memberof V2Program - */ - req_tree: Array - /** - * - * @type {ProgramPage} - * @memberof V2Program - */ - page: ProgramPage - /** - * - * @type {string} - * @memberof V2Program - */ - program_type?: string | null - /** - * - * @type {string} - * @memberof V2Program - */ - certificate_type: string - /** - * - * @type {Array} - * @memberof V2Program - */ - departments: Array - /** - * - * @type {boolean} - * @memberof V2Program - */ - live?: boolean - /** - * - * @type {Array} - * @memberof V2Program - */ - topics: Array - /** - * - * @type {AvailabilityEnum} - * @memberof V2Program - */ - availability?: AvailabilityEnum - /** - * - * @type {string} - * @memberof V2Program - */ - start_date?: string | null - /** - * - * @type {string} - * @memberof V2Program - */ - end_date?: string | null - /** - * - * @type {string} - * @memberof V2Program - */ - enrollment_start?: string | null - /** - * - * @type {string} - * @memberof V2Program - */ - enrollment_end?: string | null - /** - * Check if the prerequisites field is populated in the program page CMS. - * @type {boolean} - * @memberof V2Program - */ - required_prerequisites: boolean - /** - * Get the length/duration field from the program page CMS. - * @type {string} - * @memberof V2Program - */ - duration: string | null - /** - * Get the min weeks of the program from the CMS page. - * @type {number} - * @memberof V2Program - */ - min_weeks: number | null - /** - * Get the max weeks of the program from the CMS page. - * @type {number} - * @memberof V2Program - */ - max_weeks: number | null - /** - * Get the effort/time_commitment field from the program page CMS. - * @type {string} - * @memberof V2Program - */ - time_commitment: string | null - /** - * Get the min weekly hours of the course from the course page CMS. - * @type {string} - * @memberof V2Program - */ - min_weekly_hours: string | null - /** - * Get the max weekly hours of the course from the course page CMS. - * @type {string} - * @memberof V2Program - */ - max_weekly_hours: string | null -} - -/** - * Serializer for a ProgramRequirement - * @export - * @interface V2ProgramRequirement - */ -export interface V2ProgramRequirement { - /** - * - * @type {number} - * @memberof V2ProgramRequirement - */ - id?: number | null - /** - * - * @type {V2ProgramRequirementData} - * @memberof V2ProgramRequirement - */ - data: V2ProgramRequirementData - /** - * - * @type {Array} - * @memberof V2ProgramRequirement - */ - children?: Array -} -/** - * Serializer for ProgramRequirement data - * @export - * @interface V2ProgramRequirementData - */ -export interface V2ProgramRequirementData { - /** - * - * @type {NodeTypeEnum} - * @memberof V2ProgramRequirementData - */ - node_type: NodeTypeEnum - /** - * - * @type {string} - * @memberof V2ProgramRequirementData - */ - course?: string | null - /** - * - * @type {string} - * @memberof V2ProgramRequirementData - */ - program?: string - /** - * - * @type {string} - * @memberof V2ProgramRequirementData - */ - title?: string | null - /** - * - * @type {string} - * @memberof V2ProgramRequirementData - */ - operator?: string | null - /** - * - * @type {string} - * @memberof V2ProgramRequirementData - */ - operator_value?: string | null - /** - * - * @type {boolean} - * @memberof V2ProgramRequirementData - */ - elective_flag?: boolean | null -} - -/** - * - * @export - * @interface V2ProgramTopicsInner - */ -export interface V2ProgramTopicsInner { - /** - * - * @type {string} - * @memberof V2ProgramTopicsInner - */ - name?: string -} - -/** - * ApiApi - axios parameter creator - * @export - */ -export const ApiApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * Disables sharing links for the learner\'s record. This only applies to the anonymous ones; shares sent to partner schools are always allowed once they are sent. - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiRecordsProgramRevokeCreate: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("apiRecordsProgramRevokeCreate", "id", id) - const localVarPath = `/api/records/program/{id}/revoke/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "POST", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Sets up a sharing link for the learner\'s record. Returns back the entire learner record. - * @param {number} id - * @param {PartnerSchoolRequest} PartnerSchoolRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiRecordsProgramShareCreate: async ( - id: number, - PartnerSchoolRequest: PartnerSchoolRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("apiRecordsProgramShareCreate", "id", id) - // verify required parameter 'PartnerSchoolRequest' is not null or undefined - assertParamExists( - "apiRecordsProgramShareCreate", - "PartnerSchoolRequest", - PartnerSchoolRequest, - ) - const localVarPath = `/api/records/program/{id}/share/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "POST", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - PartnerSchoolRequest, - localVarRequestOptions, - configuration, - ) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Get learner record using program ID - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learnerRecordRetrieveById: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("learnerRecordRetrieveById", "id", id) - const localVarPath = `/api/records/program/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Get learner record using share UUID - * @param {string} uuid - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learnerRecordRetrieveByUuid: async ( - uuid: string, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'uuid' is not null or undefined - assertParamExists("learnerRecordRetrieveByUuid", "uuid", uuid) - const localVarPath = `/api/records/shared/{uuid}/`.replace( - `{${"uuid"}}`, - encodeURIComponent(String(uuid)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * ApiApi - functional programming interface - * @export - */ -export const ApiApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = ApiApiAxiosParamCreator(configuration) - return { - /** - * Disables sharing links for the learner\'s record. This only applies to the anonymous ones; shares sent to partner schools are always allowed once they are sent. - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiRecordsProgramRevokeCreate( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiRecordsProgramRevokeCreate( - id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ApiApi.apiRecordsProgramRevokeCreate"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Sets up a sharing link for the learner\'s record. Returns back the entire learner record. - * @param {number} id - * @param {PartnerSchoolRequest} PartnerSchoolRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiRecordsProgramShareCreate( - id: number, - PartnerSchoolRequest: PartnerSchoolRequest, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiRecordsProgramShareCreate( - id, - PartnerSchoolRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ApiApi.apiRecordsProgramShareCreate"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Get learner record using program ID - * @param {number} id - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async learnerRecordRetrieveById( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.learnerRecordRetrieveById(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ApiApi.learnerRecordRetrieveById"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Get learner record using share UUID - * @param {string} uuid - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async learnerRecordRetrieveByUuid( - uuid: string, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.learnerRecordRetrieveByUuid( - uuid, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ApiApi.learnerRecordRetrieveByUuid"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * ApiApi - factory interface - * @export - */ -export const ApiApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = ApiApiFp(configuration) - return { - /** - * Disables sharing links for the learner\'s record. This only applies to the anonymous ones; shares sent to partner schools are always allowed once they are sent. - * @param {ApiApiApiRecordsProgramRevokeCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiRecordsProgramRevokeCreate( - requestParameters: ApiApiApiRecordsProgramRevokeCreateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiRecordsProgramRevokeCreate(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * Sets up a sharing link for the learner\'s record. Returns back the entire learner record. - * @param {ApiApiApiRecordsProgramShareCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiRecordsProgramShareCreate( - requestParameters: ApiApiApiRecordsProgramShareCreateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiRecordsProgramShareCreate( - requestParameters.id, - requestParameters.PartnerSchoolRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * Get learner record using program ID - * @param {ApiApiLearnerRecordRetrieveByIdRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learnerRecordRetrieveById( - requestParameters: ApiApiLearnerRecordRetrieveByIdRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .learnerRecordRetrieveById(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * Get learner record using share UUID - * @param {ApiApiLearnerRecordRetrieveByUuidRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - learnerRecordRetrieveByUuid( - requestParameters: ApiApiLearnerRecordRetrieveByUuidRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .learnerRecordRetrieveByUuid(requestParameters.uuid, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for apiRecordsProgramRevokeCreate operation in ApiApi. - * @export - * @interface ApiApiApiRecordsProgramRevokeCreateRequest - */ -export interface ApiApiApiRecordsProgramRevokeCreateRequest { - /** - * - * @type {number} - * @memberof ApiApiApiRecordsProgramRevokeCreate - */ - readonly id: number -} - -/** - * Request parameters for apiRecordsProgramShareCreate operation in ApiApi. - * @export - * @interface ApiApiApiRecordsProgramShareCreateRequest - */ -export interface ApiApiApiRecordsProgramShareCreateRequest { - /** - * - * @type {number} - * @memberof ApiApiApiRecordsProgramShareCreate - */ - readonly id: number - - /** - * - * @type {PartnerSchoolRequest} - * @memberof ApiApiApiRecordsProgramShareCreate - */ - readonly PartnerSchoolRequest: PartnerSchoolRequest -} - -/** - * Request parameters for learnerRecordRetrieveById operation in ApiApi. - * @export - * @interface ApiApiLearnerRecordRetrieveByIdRequest - */ -export interface ApiApiLearnerRecordRetrieveByIdRequest { - /** - * - * @type {number} - * @memberof ApiApiLearnerRecordRetrieveById - */ - readonly id: number -} - -/** - * Request parameters for learnerRecordRetrieveByUuid operation in ApiApi. - * @export - * @interface ApiApiLearnerRecordRetrieveByUuidRequest - */ -export interface ApiApiLearnerRecordRetrieveByUuidRequest { - /** - * - * @type {string} - * @memberof ApiApiLearnerRecordRetrieveByUuid - */ - readonly uuid: string -} - -/** - * ApiApi - object-oriented interface - * @export - * @class ApiApi - * @extends {BaseAPI} - */ -export class ApiApi extends BaseAPI { - /** - * Disables sharing links for the learner\'s record. This only applies to the anonymous ones; shares sent to partner schools are always allowed once they are sent. - * @param {ApiApiApiRecordsProgramRevokeCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ApiApi - */ - public apiRecordsProgramRevokeCreate( - requestParameters: ApiApiApiRecordsProgramRevokeCreateRequest, - options?: RawAxiosRequestConfig, - ) { - return ApiApiFp(this.configuration) - .apiRecordsProgramRevokeCreate(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Sets up a sharing link for the learner\'s record. Returns back the entire learner record. - * @param {ApiApiApiRecordsProgramShareCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ApiApi - */ - public apiRecordsProgramShareCreate( - requestParameters: ApiApiApiRecordsProgramShareCreateRequest, - options?: RawAxiosRequestConfig, - ) { - return ApiApiFp(this.configuration) - .apiRecordsProgramShareCreate( - requestParameters.id, - requestParameters.PartnerSchoolRequest, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Get learner record using program ID - * @param {ApiApiLearnerRecordRetrieveByIdRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ApiApi - */ - public learnerRecordRetrieveById( - requestParameters: ApiApiLearnerRecordRetrieveByIdRequest, - options?: RawAxiosRequestConfig, - ) { - return ApiApiFp(this.configuration) - .learnerRecordRetrieveById(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Get learner record using share UUID - * @param {ApiApiLearnerRecordRetrieveByUuidRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ApiApi - */ - public learnerRecordRetrieveByUuid( - requestParameters: ApiApiLearnerRecordRetrieveByUuidRequest, - options?: RawAxiosRequestConfig, - ) { - return ApiApiFp(this.configuration) - .learnerRecordRetrieveByUuid(requestParameters.uuid, options) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * CourseRunsApi - axios parameter creator - * @export - */ -export const CourseRunsApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * API view set for CourseRuns - * @param {number} [id] - * @param {boolean} [live] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - courseRunsList: async ( - id?: number, - live?: boolean, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v1/course_runs/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - if (id !== undefined) { - localVarQueryParameter["id"] = id - } - - if (live !== undefined) { - localVarQueryParameter["live"] = live - } - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for CourseRuns - * @param {number} id A unique integer value identifying this course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - courseRunsRetrieve: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("courseRunsRetrieve", "id", id) - const localVarPath = `/api/v1/course_runs/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * CourseRunsApi - functional programming interface - * @export - */ -export const CourseRunsApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = - CourseRunsApiAxiosParamCreator(configuration) - return { - /** - * API view set for CourseRuns - * @param {number} [id] - * @param {boolean} [live] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async courseRunsList( - id?: number, - live?: boolean, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise> - > { - const localVarAxiosArgs = await localVarAxiosParamCreator.courseRunsList( - id, - live, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CourseRunsApi.courseRunsList"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for CourseRuns - * @param {number} id A unique integer value identifying this course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async courseRunsRetrieve( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.courseRunsRetrieve(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CourseRunsApi.courseRunsRetrieve"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * CourseRunsApi - factory interface - * @export - */ -export const CourseRunsApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = CourseRunsApiFp(configuration) - return { - /** - * API view set for CourseRuns - * @param {CourseRunsApiCourseRunsListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - courseRunsList( - requestParameters: CourseRunsApiCourseRunsListRequest = {}, - options?: RawAxiosRequestConfig, - ): AxiosPromise> { - return localVarFp - .courseRunsList(requestParameters.id, requestParameters.live, options) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for CourseRuns - * @param {CourseRunsApiCourseRunsRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - courseRunsRetrieve( - requestParameters: CourseRunsApiCourseRunsRetrieveRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .courseRunsRetrieve(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for courseRunsList operation in CourseRunsApi. - * @export - * @interface CourseRunsApiCourseRunsListRequest - */ -export interface CourseRunsApiCourseRunsListRequest { - /** - * - * @type {number} - * @memberof CourseRunsApiCourseRunsList - */ - readonly id?: number - - /** - * - * @type {boolean} - * @memberof CourseRunsApiCourseRunsList - */ - readonly live?: boolean -} - -/** - * Request parameters for courseRunsRetrieve operation in CourseRunsApi. - * @export - * @interface CourseRunsApiCourseRunsRetrieveRequest - */ -export interface CourseRunsApiCourseRunsRetrieveRequest { - /** - * A unique integer value identifying this course run. - * @type {number} - * @memberof CourseRunsApiCourseRunsRetrieve - */ - readonly id: number -} - -/** - * CourseRunsApi - object-oriented interface - * @export - * @class CourseRunsApi - * @extends {BaseAPI} - */ -export class CourseRunsApi extends BaseAPI { - /** - * API view set for CourseRuns - * @param {CourseRunsApiCourseRunsListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CourseRunsApi - */ - public courseRunsList( - requestParameters: CourseRunsApiCourseRunsListRequest = {}, - options?: RawAxiosRequestConfig, - ) { - return CourseRunsApiFp(this.configuration) - .courseRunsList(requestParameters.id, requestParameters.live, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for CourseRuns - * @param {CourseRunsApiCourseRunsRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CourseRunsApi - */ - public courseRunsRetrieve( - requestParameters: CourseRunsApiCourseRunsRetrieveRequest, - options?: RawAxiosRequestConfig, - ) { - return CourseRunsApiFp(this.configuration) - .courseRunsRetrieve(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * CoursesApi - axios parameter creator - * @export - */ -export const CoursesApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * List all courses - API v1 - * @param {boolean} [courserun_is_enrollable] - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV1CoursesList: async ( - courserun_is_enrollable?: boolean, - id?: number, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v1/courses/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - if (courserun_is_enrollable !== undefined) { - localVarQueryParameter["courserun_is_enrollable"] = - courserun_is_enrollable - } - - if (id !== undefined) { - localVarQueryParameter["id"] = id - } - - if (live !== undefined) { - localVarQueryParameter["live"] = live - } - - if (page !== undefined) { - localVarQueryParameter["page"] = page - } - - if (page__live !== undefined) { - localVarQueryParameter["page__live"] = page__live - } - - if (page_size !== undefined) { - localVarQueryParameter["page_size"] = page_size - } - - if (readable_id !== undefined) { - localVarQueryParameter["readable_id"] = readable_id - } - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Retrieve a specific course - API v1 - * @param {number} id A unique integer value identifying this course. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV1CoursesRetrieve: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("apiV1CoursesRetrieve", "id", id) - const localVarPath = `/api/v1/courses/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * List all courses - API v2 - * @param {boolean} [courserun_is_enrollable] Course Run Is Enrollable - * @param {Array} [id] Multiple values may be separated by commas. - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV2CoursesList: async ( - courserun_is_enrollable?: boolean, - id?: Array, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v2/courses/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - if (courserun_is_enrollable !== undefined) { - localVarQueryParameter["courserun_is_enrollable"] = - courserun_is_enrollable - } - - if (id) { - localVarQueryParameter["id"] = id.join(COLLECTION_FORMATS.csv) - } - - if (live !== undefined) { - localVarQueryParameter["live"] = live - } - - if (page !== undefined) { - localVarQueryParameter["page"] = page - } - - if (page__live !== undefined) { - localVarQueryParameter["page__live"] = page__live - } - - if (page_size !== undefined) { - localVarQueryParameter["page_size"] = page_size - } - - if (readable_id !== undefined) { - localVarQueryParameter["readable_id"] = readable_id - } - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Retrieve a specific course - API v2 - * @param {number} id A unique integer value identifying this course. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV2CoursesRetrieve: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("apiV2CoursesRetrieve", "id", id) - const localVarPath = `/api/v2/courses/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * CoursesApi - functional programming interface - * @export - */ -export const CoursesApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = CoursesApiAxiosParamCreator(configuration) - return { - /** - * List all courses - API v1 - * @param {boolean} [courserun_is_enrollable] - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiV1CoursesList( - courserun_is_enrollable?: boolean, - id?: number, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiV1CoursesList( - courserun_is_enrollable, - id, - live, - page, - page__live, - page_size, - readable_id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CoursesApi.apiV1CoursesList"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Retrieve a specific course - API v1 - * @param {number} id A unique integer value identifying this course. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiV1CoursesRetrieve( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiV1CoursesRetrieve(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CoursesApi.apiV1CoursesRetrieve"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * List all courses - API v2 - * @param {boolean} [courserun_is_enrollable] Course Run Is Enrollable - * @param {Array} [id] Multiple values may be separated by commas. - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiV2CoursesList( - courserun_is_enrollable?: boolean, - id?: Array, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiV2CoursesList( - courserun_is_enrollable, - id, - live, - page, - page__live, - page_size, - readable_id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CoursesApi.apiV2CoursesList"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Retrieve a specific course - API v2 - * @param {number} id A unique integer value identifying this course. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiV2CoursesRetrieve( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiV2CoursesRetrieve(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["CoursesApi.apiV2CoursesRetrieve"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * CoursesApi - factory interface - * @export - */ -export const CoursesApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = CoursesApiFp(configuration) - return { - /** - * List all courses - API v1 - * @param {CoursesApiApiV1CoursesListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV1CoursesList( - requestParameters: CoursesApiApiV1CoursesListRequest = {}, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiV1CoursesList( - requestParameters.courserun_is_enrollable, - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * Retrieve a specific course - API v1 - * @param {CoursesApiApiV1CoursesRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV1CoursesRetrieve( - requestParameters: CoursesApiApiV1CoursesRetrieveRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiV1CoursesRetrieve(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * List all courses - API v2 - * @param {CoursesApiApiV2CoursesListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV2CoursesList( - requestParameters: CoursesApiApiV2CoursesListRequest = {}, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiV2CoursesList( - requestParameters.courserun_is_enrollable, - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * Retrieve a specific course - API v2 - * @param {CoursesApiApiV2CoursesRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiV2CoursesRetrieve( - requestParameters: CoursesApiApiV2CoursesRetrieveRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .apiV2CoursesRetrieve(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for apiV1CoursesList operation in CoursesApi. - * @export - * @interface CoursesApiApiV1CoursesListRequest - */ -export interface CoursesApiApiV1CoursesListRequest { - /** - * - * @type {boolean} - * @memberof CoursesApiApiV1CoursesList - */ - readonly courserun_is_enrollable?: boolean - - /** - * - * @type {number} - * @memberof CoursesApiApiV1CoursesList - */ - readonly id?: number - - /** - * - * @type {boolean} - * @memberof CoursesApiApiV1CoursesList - */ - readonly live?: boolean - - /** - * A page number within the paginated result set. - * @type {number} - * @memberof CoursesApiApiV1CoursesList - */ - readonly page?: number - - /** - * - * @type {boolean} - * @memberof CoursesApiApiV1CoursesList - */ - readonly page__live?: boolean - - /** - * Number of results to return per page. - * @type {number} - * @memberof CoursesApiApiV1CoursesList - */ - readonly page_size?: number - - /** - * - * @type {string} - * @memberof CoursesApiApiV1CoursesList - */ - readonly readable_id?: string -} - -/** - * Request parameters for apiV1CoursesRetrieve operation in CoursesApi. - * @export - * @interface CoursesApiApiV1CoursesRetrieveRequest - */ -export interface CoursesApiApiV1CoursesRetrieveRequest { - /** - * A unique integer value identifying this course. - * @type {number} - * @memberof CoursesApiApiV1CoursesRetrieve - */ - readonly id: number -} - -/** - * Request parameters for apiV2CoursesList operation in CoursesApi. - * @export - * @interface CoursesApiApiV2CoursesListRequest - */ -export interface CoursesApiApiV2CoursesListRequest { - /** - * Course Run Is Enrollable - * @type {boolean} - * @memberof CoursesApiApiV2CoursesList - */ - readonly courserun_is_enrollable?: boolean - - /** - * Multiple values may be separated by commas. - * @type {Array} - * @memberof CoursesApiApiV2CoursesList - */ - readonly id?: Array - - /** - * - * @type {boolean} - * @memberof CoursesApiApiV2CoursesList - */ - readonly live?: boolean - - /** - * A page number within the paginated result set. - * @type {number} - * @memberof CoursesApiApiV2CoursesList - */ - readonly page?: number - - /** - * - * @type {boolean} - * @memberof CoursesApiApiV2CoursesList - */ - readonly page__live?: boolean - - /** - * Number of results to return per page. - * @type {number} - * @memberof CoursesApiApiV2CoursesList - */ - readonly page_size?: number - - /** - * - * @type {string} - * @memberof CoursesApiApiV2CoursesList - */ - readonly readable_id?: string -} - -/** - * Request parameters for apiV2CoursesRetrieve operation in CoursesApi. - * @export - * @interface CoursesApiApiV2CoursesRetrieveRequest - */ -export interface CoursesApiApiV2CoursesRetrieveRequest { - /** - * A unique integer value identifying this course. - * @type {number} - * @memberof CoursesApiApiV2CoursesRetrieve - */ - readonly id: number -} - -/** - * CoursesApi - object-oriented interface - * @export - * @class CoursesApi - * @extends {BaseAPI} - */ -export class CoursesApi extends BaseAPI { - /** - * List all courses - API v1 - * @param {CoursesApiApiV1CoursesListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CoursesApi - */ - public apiV1CoursesList( - requestParameters: CoursesApiApiV1CoursesListRequest = {}, - options?: RawAxiosRequestConfig, - ) { - return CoursesApiFp(this.configuration) - .apiV1CoursesList( - requestParameters.courserun_is_enrollable, - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Retrieve a specific course - API v1 - * @param {CoursesApiApiV1CoursesRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CoursesApi - */ - public apiV1CoursesRetrieve( - requestParameters: CoursesApiApiV1CoursesRetrieveRequest, - options?: RawAxiosRequestConfig, - ) { - return CoursesApiFp(this.configuration) - .apiV1CoursesRetrieve(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * List all courses - API v2 - * @param {CoursesApiApiV2CoursesListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CoursesApi - */ - public apiV2CoursesList( - requestParameters: CoursesApiApiV2CoursesListRequest = {}, - options?: RawAxiosRequestConfig, - ) { - return CoursesApiFp(this.configuration) - .apiV2CoursesList( - requestParameters.courserun_is_enrollable, - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Retrieve a specific course - API v2 - * @param {CoursesApiApiV2CoursesRetrieveRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof CoursesApi - */ - public apiV2CoursesRetrieve( - requestParameters: CoursesApiApiV2CoursesRetrieveRequest, - options?: RawAxiosRequestConfig, - ) { - return CoursesApiFp(this.configuration) - .apiV2CoursesRetrieve(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * DepartmentsApi - axios parameter creator - * @export - */ -export const DepartmentsApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * List departments - v1 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsListV1: async ( - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v1/departments/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * List departments - v2 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsListV2: async ( - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v2/departments/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Get department details - v1 - * @param {number} id A unique integer value identifying this department. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsRetrieveV1: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("departmentsRetrieveV1", "id", id) - const localVarPath = `/api/v1/departments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Get department details - v2 - * @param {number} id A unique integer value identifying this department. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsRetrieveV2: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("departmentsRetrieveV2", "id", id) - const localVarPath = `/api/v2/departments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * DepartmentsApi - functional programming interface - * @export - */ -export const DepartmentsApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = - DepartmentsApiAxiosParamCreator(configuration) - return { - /** - * List departments - v1 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async departmentsListV1( - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise> - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.departmentsListV1(options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["DepartmentsApi.departmentsListV1"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * List departments - v2 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async departmentsListV2( - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise> - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.departmentsListV2(options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["DepartmentsApi.departmentsListV2"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Get department details - v1 - * @param {number} id A unique integer value identifying this department. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async departmentsRetrieveV1( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.departmentsRetrieveV1(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["DepartmentsApi.departmentsRetrieveV1"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Get department details - v2 - * @param {number} id A unique integer value identifying this department. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async departmentsRetrieveV2( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.departmentsRetrieveV2(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["DepartmentsApi.departmentsRetrieveV2"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * DepartmentsApi - factory interface - * @export - */ -export const DepartmentsApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = DepartmentsApiFp(configuration) - return { - /** - * List departments - v1 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsListV1( - options?: RawAxiosRequestConfig, - ): AxiosPromise> { - return localVarFp - .departmentsListV1(options) - .then((request) => request(axios, basePath)) - }, - /** - * List departments - v2 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsListV2( - options?: RawAxiosRequestConfig, - ): AxiosPromise> { - return localVarFp - .departmentsListV2(options) - .then((request) => request(axios, basePath)) - }, - /** - * Get department details - v1 - * @param {DepartmentsApiDepartmentsRetrieveV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsRetrieveV1( - requestParameters: DepartmentsApiDepartmentsRetrieveV1Request, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .departmentsRetrieveV1(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * Get department details - v2 - * @param {DepartmentsApiDepartmentsRetrieveV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - departmentsRetrieveV2( - requestParameters: DepartmentsApiDepartmentsRetrieveV2Request, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .departmentsRetrieveV2(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for departmentsRetrieveV1 operation in DepartmentsApi. - * @export - * @interface DepartmentsApiDepartmentsRetrieveV1Request - */ -export interface DepartmentsApiDepartmentsRetrieveV1Request { - /** - * A unique integer value identifying this department. - * @type {number} - * @memberof DepartmentsApiDepartmentsRetrieveV1 - */ - readonly id: number -} - -/** - * Request parameters for departmentsRetrieveV2 operation in DepartmentsApi. - * @export - * @interface DepartmentsApiDepartmentsRetrieveV2Request - */ -export interface DepartmentsApiDepartmentsRetrieveV2Request { - /** - * A unique integer value identifying this department. - * @type {number} - * @memberof DepartmentsApiDepartmentsRetrieveV2 - */ - readonly id: number -} - -/** - * DepartmentsApi - object-oriented interface - * @export - * @class DepartmentsApi - * @extends {BaseAPI} - */ -export class DepartmentsApi extends BaseAPI { - /** - * List departments - v1 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DepartmentsApi - */ - public departmentsListV1(options?: RawAxiosRequestConfig) { - return DepartmentsApiFp(this.configuration) - .departmentsListV1(options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * List departments - v2 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DepartmentsApi - */ - public departmentsListV2(options?: RawAxiosRequestConfig) { - return DepartmentsApiFp(this.configuration) - .departmentsListV2(options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Get department details - v1 - * @param {DepartmentsApiDepartmentsRetrieveV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DepartmentsApi - */ - public departmentsRetrieveV1( - requestParameters: DepartmentsApiDepartmentsRetrieveV1Request, - options?: RawAxiosRequestConfig, - ) { - return DepartmentsApiFp(this.configuration) - .departmentsRetrieveV1(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Get department details - v2 - * @param {DepartmentsApiDepartmentsRetrieveV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DepartmentsApi - */ - public departmentsRetrieveV2( - requestParameters: DepartmentsApiDepartmentsRetrieveV2Request, - options?: RawAxiosRequestConfig, - ) { - return DepartmentsApiFp(this.configuration) - .departmentsRetrieveV2(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * EnrollmentsApi - axios parameter creator - * @export - */ -export const EnrollmentsApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * View to handle direct POST requests to enroll in a course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiEnrollmentsCreate: async ( - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/enrollments/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "POST", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for user enrollments - * @param {CourseRunEnrollmentRequest} CourseRunEnrollmentRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsCreate: async ( - CourseRunEnrollmentRequest: CourseRunEnrollmentRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'CourseRunEnrollmentRequest' is not null or undefined - assertParamExists( - "enrollmentsCreate", - "CourseRunEnrollmentRequest", - CourseRunEnrollmentRequest, - ) - const localVarPath = `/api/v1/enrollments/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "POST", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - CourseRunEnrollmentRequest, - localVarRequestOptions, - configuration, - ) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsDestroy: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("enrollmentsDestroy", "id", id) - const localVarPath = `/api/v1/enrollments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "DELETE", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for user enrollments - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsList: async ( - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v1/enrollments/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {PatchedCourseRunEnrollmentRequest} [PatchedCourseRunEnrollmentRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsPartialUpdate: async ( - id: number, - PatchedCourseRunEnrollmentRequest?: PatchedCourseRunEnrollmentRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("enrollmentsPartialUpdate", "id", id) - const localVarPath = `/api/v1/enrollments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "PATCH", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - PatchedCourseRunEnrollmentRequest, - localVarRequestOptions, - configuration, - ) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {CourseRunEnrollmentRequest} CourseRunEnrollmentRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsUpdate: async ( - id: number, - CourseRunEnrollmentRequest: CourseRunEnrollmentRequest, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("enrollmentsUpdate", "id", id) - // verify required parameter 'CourseRunEnrollmentRequest' is not null or undefined - assertParamExists( - "enrollmentsUpdate", - "CourseRunEnrollmentRequest", - CourseRunEnrollmentRequest, - ) - const localVarPath = `/api/v1/enrollments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "PUT", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - localVarHeaderParameter["Content-Type"] = "application/json" - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - localVarRequestOptions.data = serializeDataIfNeeded( - CourseRunEnrollmentRequest, - localVarRequestOptions, - configuration, - ) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * EnrollmentsApi - functional programming interface - * @export - */ -export const EnrollmentsApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = - EnrollmentsApiAxiosParamCreator(configuration) - return { - /** - * View to handle direct POST requests to enroll in a course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async apiEnrollmentsCreate( - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.apiEnrollmentsCreate(options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.apiEnrollmentsCreate"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for user enrollments - * @param {CourseRunEnrollmentRequest} CourseRunEnrollmentRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async enrollmentsCreate( - CourseRunEnrollmentRequest: CourseRunEnrollmentRequest, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.enrollmentsCreate( - CourseRunEnrollmentRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.enrollmentsCreate"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async enrollmentsDestroy( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.enrollmentsDestroy(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.enrollmentsDestroy"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for user enrollments - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async enrollmentsList( - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise> - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.enrollmentsList(options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.enrollmentsList"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {PatchedCourseRunEnrollmentRequest} [PatchedCourseRunEnrollmentRequest] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async enrollmentsPartialUpdate( - id: number, - PatchedCourseRunEnrollmentRequest?: PatchedCourseRunEnrollmentRequest, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.enrollmentsPartialUpdate( - id, - PatchedCourseRunEnrollmentRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.enrollmentsPartialUpdate"]?.[index] - ?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for user enrollments - * @param {number} id A unique integer value identifying this course run enrollment. - * @param {CourseRunEnrollmentRequest} CourseRunEnrollmentRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async enrollmentsUpdate( - id: number, - CourseRunEnrollmentRequest: CourseRunEnrollmentRequest, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.enrollmentsUpdate( - id, - CourseRunEnrollmentRequest, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["EnrollmentsApi.enrollmentsUpdate"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * EnrollmentsApi - factory interface - * @export - */ -export const EnrollmentsApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = EnrollmentsApiFp(configuration) - return { - /** - * View to handle direct POST requests to enroll in a course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - apiEnrollmentsCreate(options?: RawAxiosRequestConfig): AxiosPromise { - return localVarFp - .apiEnrollmentsCreate(options) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsCreate( - requestParameters: EnrollmentsApiEnrollmentsCreateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .enrollmentsCreate( - requestParameters.CourseRunEnrollmentRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsDestroyRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsDestroy( - requestParameters: EnrollmentsApiEnrollmentsDestroyRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .enrollmentsDestroy(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for user enrollments - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsList( - options?: RawAxiosRequestConfig, - ): AxiosPromise> { - return localVarFp - .enrollmentsList(options) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsPartialUpdate( - requestParameters: EnrollmentsApiEnrollmentsPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .enrollmentsPartialUpdate( - requestParameters.id, - requestParameters.PatchedCourseRunEnrollmentRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - enrollmentsUpdate( - requestParameters: EnrollmentsApiEnrollmentsUpdateRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .enrollmentsUpdate( - requestParameters.id, - requestParameters.CourseRunEnrollmentRequest, - options, - ) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for enrollmentsCreate operation in EnrollmentsApi. - * @export - * @interface EnrollmentsApiEnrollmentsCreateRequest - */ -export interface EnrollmentsApiEnrollmentsCreateRequest { - /** - * - * @type {CourseRunEnrollmentRequest} - * @memberof EnrollmentsApiEnrollmentsCreate - */ - readonly CourseRunEnrollmentRequest: CourseRunEnrollmentRequest -} - -/** - * Request parameters for enrollmentsDestroy operation in EnrollmentsApi. - * @export - * @interface EnrollmentsApiEnrollmentsDestroyRequest - */ -export interface EnrollmentsApiEnrollmentsDestroyRequest { - /** - * A unique integer value identifying this course run enrollment. - * @type {number} - * @memberof EnrollmentsApiEnrollmentsDestroy - */ - readonly id: number -} - -/** - * Request parameters for enrollmentsPartialUpdate operation in EnrollmentsApi. - * @export - * @interface EnrollmentsApiEnrollmentsPartialUpdateRequest - */ -export interface EnrollmentsApiEnrollmentsPartialUpdateRequest { - /** - * A unique integer value identifying this course run enrollment. - * @type {number} - * @memberof EnrollmentsApiEnrollmentsPartialUpdate - */ - readonly id: number - - /** - * - * @type {PatchedCourseRunEnrollmentRequest} - * @memberof EnrollmentsApiEnrollmentsPartialUpdate - */ - readonly PatchedCourseRunEnrollmentRequest?: PatchedCourseRunEnrollmentRequest -} - -/** - * Request parameters for enrollmentsUpdate operation in EnrollmentsApi. - * @export - * @interface EnrollmentsApiEnrollmentsUpdateRequest - */ -export interface EnrollmentsApiEnrollmentsUpdateRequest { - /** - * A unique integer value identifying this course run enrollment. - * @type {number} - * @memberof EnrollmentsApiEnrollmentsUpdate - */ - readonly id: number - - /** - * - * @type {CourseRunEnrollmentRequest} - * @memberof EnrollmentsApiEnrollmentsUpdate - */ - readonly CourseRunEnrollmentRequest: CourseRunEnrollmentRequest -} - -/** - * EnrollmentsApi - object-oriented interface - * @export - * @class EnrollmentsApi - * @extends {BaseAPI} - */ -export class EnrollmentsApi extends BaseAPI { - /** - * View to handle direct POST requests to enroll in a course run. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public apiEnrollmentsCreate(options?: RawAxiosRequestConfig) { - return EnrollmentsApiFp(this.configuration) - .apiEnrollmentsCreate(options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsCreateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public enrollmentsCreate( - requestParameters: EnrollmentsApiEnrollmentsCreateRequest, - options?: RawAxiosRequestConfig, - ) { - return EnrollmentsApiFp(this.configuration) - .enrollmentsCreate(requestParameters.CourseRunEnrollmentRequest, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsDestroyRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public enrollmentsDestroy( - requestParameters: EnrollmentsApiEnrollmentsDestroyRequest, - options?: RawAxiosRequestConfig, - ) { - return EnrollmentsApiFp(this.configuration) - .enrollmentsDestroy(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for user enrollments - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public enrollmentsList(options?: RawAxiosRequestConfig) { - return EnrollmentsApiFp(this.configuration) - .enrollmentsList(options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsPartialUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public enrollmentsPartialUpdate( - requestParameters: EnrollmentsApiEnrollmentsPartialUpdateRequest, - options?: RawAxiosRequestConfig, - ) { - return EnrollmentsApiFp(this.configuration) - .enrollmentsPartialUpdate( - requestParameters.id, - requestParameters.PatchedCourseRunEnrollmentRequest, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for user enrollments - * @param {EnrollmentsApiEnrollmentsUpdateRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof EnrollmentsApi - */ - public enrollmentsUpdate( - requestParameters: EnrollmentsApiEnrollmentsUpdateRequest, - options?: RawAxiosRequestConfig, - ) { - return EnrollmentsApiFp(this.configuration) - .enrollmentsUpdate( - requestParameters.id, - requestParameters.CourseRunEnrollmentRequest, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * ProgramEnrollmentsApi - axios parameter creator - * @export - */ -export const ProgramEnrollmentsApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * Unenroll the user from this program. This is simpler than the corresponding function for CourseRunEnrollments; edX doesn\'t really know what programs are so there\'s nothing to process there. - * @param {number} id Program enrollment ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programEnrollmentsDestroy: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("programEnrollmentsDestroy", "id", id) - const localVarPath = `/api/v1/program_enrollments/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "DELETE", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * Returns a unified set of program and course enrollments for the current user. - * @param {number} id Program enrollment ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programEnrollmentsList: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("programEnrollmentsList", "id", id) - const localVarPath = `/api/v1/program_enrollments/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * ProgramEnrollmentsApi - functional programming interface - * @export - */ -export const ProgramEnrollmentsApiFp = function ( - configuration?: Configuration, -) { - const localVarAxiosParamCreator = - ProgramEnrollmentsApiAxiosParamCreator(configuration) - return { - /** - * Unenroll the user from this program. This is simpler than the corresponding function for CourseRunEnrollments; edX doesn\'t really know what programs are so there\'s nothing to process there. - * @param {number} id Program enrollment ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programEnrollmentsDestroy( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.programEnrollmentsDestroy(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramEnrollmentsApi.programEnrollmentsDestroy"]?.[ - index - ]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * Returns a unified set of program and course enrollments for the current user. - * @param {number} id Program enrollment ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programEnrollmentsList( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise> - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.programEnrollmentsList(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramEnrollmentsApi.programEnrollmentsList"]?.[ - index - ]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * ProgramEnrollmentsApi - factory interface - * @export - */ -export const ProgramEnrollmentsApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = ProgramEnrollmentsApiFp(configuration) - return { - /** - * Unenroll the user from this program. This is simpler than the corresponding function for CourseRunEnrollments; edX doesn\'t really know what programs are so there\'s nothing to process there. - * @param {ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programEnrollmentsDestroy( - requestParameters: ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .programEnrollmentsDestroy(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * Returns a unified set of program and course enrollments for the current user. - * @param {ProgramEnrollmentsApiProgramEnrollmentsListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programEnrollmentsList( - requestParameters: ProgramEnrollmentsApiProgramEnrollmentsListRequest, - options?: RawAxiosRequestConfig, - ): AxiosPromise> { - return localVarFp - .programEnrollmentsList(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for programEnrollmentsDestroy operation in ProgramEnrollmentsApi. - * @export - * @interface ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest - */ -export interface ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest { - /** - * Program enrollment ID - * @type {number} - * @memberof ProgramEnrollmentsApiProgramEnrollmentsDestroy - */ - readonly id: number -} - -/** - * Request parameters for programEnrollmentsList operation in ProgramEnrollmentsApi. - * @export - * @interface ProgramEnrollmentsApiProgramEnrollmentsListRequest - */ -export interface ProgramEnrollmentsApiProgramEnrollmentsListRequest { - /** - * Program enrollment ID - * @type {number} - * @memberof ProgramEnrollmentsApiProgramEnrollmentsList - */ - readonly id: number -} - -/** - * ProgramEnrollmentsApi - object-oriented interface - * @export - * @class ProgramEnrollmentsApi - * @extends {BaseAPI} - */ -export class ProgramEnrollmentsApi extends BaseAPI { - /** - * Unenroll the user from this program. This is simpler than the corresponding function for CourseRunEnrollments; edX doesn\'t really know what programs are so there\'s nothing to process there. - * @param {ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramEnrollmentsApi - */ - public programEnrollmentsDestroy( - requestParameters: ProgramEnrollmentsApiProgramEnrollmentsDestroyRequest, - options?: RawAxiosRequestConfig, - ) { - return ProgramEnrollmentsApiFp(this.configuration) - .programEnrollmentsDestroy(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * Returns a unified set of program and course enrollments for the current user. - * @param {ProgramEnrollmentsApiProgramEnrollmentsListRequest} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramEnrollmentsApi - */ - public programEnrollmentsList( - requestParameters: ProgramEnrollmentsApiProgramEnrollmentsListRequest, - options?: RawAxiosRequestConfig, - ) { - return ProgramEnrollmentsApiFp(this.configuration) - .programEnrollmentsList(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } -} - -/** - * ProgramsApi - axios parameter creator - * @export - */ -export const ProgramsApiAxiosParamCreator = function ( - configuration?: Configuration, -) { - return { - /** - * List Programs - v1 - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsListV1: async ( - id?: number, - live?: boolean, - page?: number, - page_size?: number, - readable_id?: string, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v1/programs/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - if (id !== undefined) { - localVarQueryParameter["id"] = id - } - - if (live !== undefined) { - localVarQueryParameter["live"] = live - } - - if (page !== undefined) { - localVarQueryParameter["page"] = page - } - - if (page_size !== undefined) { - localVarQueryParameter["page_size"] = page_size - } - - if (readable_id !== undefined) { - localVarQueryParameter["readable_id"] = readable_id - } - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * List Programs - v2 - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsListV2: async ( - id?: number, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options: RawAxiosRequestConfig = {}, - ): Promise => { - const localVarPath = `/api/v2/programs/` - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - if (id !== undefined) { - localVarQueryParameter["id"] = id - } - - if (live !== undefined) { - localVarQueryParameter["live"] = live - } - - if (page !== undefined) { - localVarQueryParameter["page"] = page - } - - if (page__live !== undefined) { - localVarQueryParameter["page__live"] = page__live - } - - if (page_size !== undefined) { - localVarQueryParameter["page_size"] = page_size - } - - if (readable_id !== undefined) { - localVarQueryParameter["readable_id"] = readable_id - } - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for Programs - v1 - * @param {number} id A unique integer value identifying this program. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsRetrieveV1: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("programsRetrieveV1", "id", id) - const localVarPath = `/api/v1/programs/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - /** - * API view set for Programs - v2 - * @param {number} id A unique integer value identifying this program. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsRetrieveV2: async ( - id: number, - options: RawAxiosRequestConfig = {}, - ): Promise => { - // verify required parameter 'id' is not null or undefined - assertParamExists("programsRetrieveV2", "id", id) - const localVarPath = `/api/v2/programs/{id}/`.replace( - `{${"id"}}`, - encodeURIComponent(String(id)), - ) - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL) - let baseOptions - if (configuration) { - baseOptions = configuration.baseOptions - } - - const localVarRequestOptions = { - method: "GET", - ...baseOptions, - ...options, - } - const localVarHeaderParameter = {} as any - const localVarQueryParameter = {} as any - - setSearchParams(localVarUrlObj, localVarQueryParameter) - let headersFromBaseOptions = - baseOptions && baseOptions.headers ? baseOptions.headers : {} - localVarRequestOptions.headers = { - ...localVarHeaderParameter, - ...headersFromBaseOptions, - ...options.headers, - } - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - } - }, - } -} - -/** - * ProgramsApi - functional programming interface - * @export - */ -export const ProgramsApiFp = function (configuration?: Configuration) { - const localVarAxiosParamCreator = ProgramsApiAxiosParamCreator(configuration) - return { - /** - * List Programs - v1 - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programsListV1( - id?: number, - live?: boolean, - page?: number, - page_size?: number, - readable_id?: string, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = await localVarAxiosParamCreator.programsListV1( - id, - live, - page, - page_size, - readable_id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramsApi.programsListV1"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * List Programs - v2 - * @param {number} [id] - * @param {boolean} [live] - * @param {number} [page] A page number within the paginated result set. - * @param {boolean} [page__live] - * @param {number} [page_size] Number of results to return per page. - * @param {string} [readable_id] - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programsListV2( - id?: number, - live?: boolean, - page?: number, - page__live?: boolean, - page_size?: number, - readable_id?: string, - options?: RawAxiosRequestConfig, - ): Promise< - ( - axios?: AxiosInstance, - basePath?: string, - ) => AxiosPromise - > { - const localVarAxiosArgs = await localVarAxiosParamCreator.programsListV2( - id, - live, - page, - page__live, - page_size, - readable_id, - options, - ) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramsApi.programsListV2"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for Programs - v1 - * @param {number} id A unique integer value identifying this program. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programsRetrieveV1( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.programsRetrieveV1(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramsApi.programsRetrieveV1"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - /** - * API view set for Programs - v2 - * @param {number} id A unique integer value identifying this program. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async programsRetrieveV2( - id: number, - options?: RawAxiosRequestConfig, - ): Promise< - (axios?: AxiosInstance, basePath?: string) => AxiosPromise - > { - const localVarAxiosArgs = - await localVarAxiosParamCreator.programsRetrieveV2(id, options) - const index = configuration?.serverIndex ?? 0 - const operationBasePath = - operationServerMap["ProgramsApi.programsRetrieveV2"]?.[index]?.url - return (axios, basePath) => - createRequestFunction( - localVarAxiosArgs, - globalAxios, - BASE_PATH, - configuration, - )(axios, operationBasePath || basePath) - }, - } -} - -/** - * ProgramsApi - factory interface - * @export - */ -export const ProgramsApiFactory = function ( - configuration?: Configuration, - basePath?: string, - axios?: AxiosInstance, -) { - const localVarFp = ProgramsApiFp(configuration) - return { - /** - * List Programs - v1 - * @param {ProgramsApiProgramsListV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsListV1( - requestParameters: ProgramsApiProgramsListV1Request = {}, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .programsListV1( - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * List Programs - v2 - * @param {ProgramsApiProgramsListV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsListV2( - requestParameters: ProgramsApiProgramsListV2Request = {}, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .programsListV2( - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for Programs - v1 - * @param {ProgramsApiProgramsRetrieveV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsRetrieveV1( - requestParameters: ProgramsApiProgramsRetrieveV1Request, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .programsRetrieveV1(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - /** - * API view set for Programs - v2 - * @param {ProgramsApiProgramsRetrieveV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - programsRetrieveV2( - requestParameters: ProgramsApiProgramsRetrieveV2Request, - options?: RawAxiosRequestConfig, - ): AxiosPromise { - return localVarFp - .programsRetrieveV2(requestParameters.id, options) - .then((request) => request(axios, basePath)) - }, - } -} - -/** - * Request parameters for programsListV1 operation in ProgramsApi. - * @export - * @interface ProgramsApiProgramsListV1Request - */ -export interface ProgramsApiProgramsListV1Request { - /** - * - * @type {number} - * @memberof ProgramsApiProgramsListV1 - */ - readonly id?: number - - /** - * - * @type {boolean} - * @memberof ProgramsApiProgramsListV1 - */ - readonly live?: boolean - - /** - * A page number within the paginated result set. - * @type {number} - * @memberof ProgramsApiProgramsListV1 - */ - readonly page?: number - - /** - * Number of results to return per page. - * @type {number} - * @memberof ProgramsApiProgramsListV1 - */ - readonly page_size?: number - - /** - * - * @type {string} - * @memberof ProgramsApiProgramsListV1 - */ - readonly readable_id?: string -} - -/** - * Request parameters for programsListV2 operation in ProgramsApi. - * @export - * @interface ProgramsApiProgramsListV2Request - */ -export interface ProgramsApiProgramsListV2Request { - /** - * - * @type {number} - * @memberof ProgramsApiProgramsListV2 - */ - readonly id?: number - - /** - * - * @type {boolean} - * @memberof ProgramsApiProgramsListV2 - */ - readonly live?: boolean - - /** - * A page number within the paginated result set. - * @type {number} - * @memberof ProgramsApiProgramsListV2 - */ - readonly page?: number - - /** - * - * @type {boolean} - * @memberof ProgramsApiProgramsListV2 - */ - readonly page__live?: boolean - - /** - * Number of results to return per page. - * @type {number} - * @memberof ProgramsApiProgramsListV2 - */ - readonly page_size?: number - - /** - * - * @type {string} - * @memberof ProgramsApiProgramsListV2 - */ - readonly readable_id?: string -} - -/** - * Request parameters for programsRetrieveV1 operation in ProgramsApi. - * @export - * @interface ProgramsApiProgramsRetrieveV1Request - */ -export interface ProgramsApiProgramsRetrieveV1Request { - /** - * A unique integer value identifying this program. - * @type {number} - * @memberof ProgramsApiProgramsRetrieveV1 - */ - readonly id: number -} - -/** - * Request parameters for programsRetrieveV2 operation in ProgramsApi. - * @export - * @interface ProgramsApiProgramsRetrieveV2Request - */ -export interface ProgramsApiProgramsRetrieveV2Request { - /** - * A unique integer value identifying this program. - * @type {number} - * @memberof ProgramsApiProgramsRetrieveV2 - */ - readonly id: number -} - -/** - * ProgramsApi - object-oriented interface - * @export - * @class ProgramsApi - * @extends {BaseAPI} - */ -export class ProgramsApi extends BaseAPI { - /** - * List Programs - v1 - * @param {ProgramsApiProgramsListV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramsApi - */ - public programsListV1( - requestParameters: ProgramsApiProgramsListV1Request = {}, - options?: RawAxiosRequestConfig, - ) { - return ProgramsApiFp(this.configuration) - .programsListV1( - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * List Programs - v2 - * @param {ProgramsApiProgramsListV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramsApi - */ - public programsListV2( - requestParameters: ProgramsApiProgramsListV2Request = {}, - options?: RawAxiosRequestConfig, - ) { - return ProgramsApiFp(this.configuration) - .programsListV2( - requestParameters.id, - requestParameters.live, - requestParameters.page, - requestParameters.page__live, - requestParameters.page_size, - requestParameters.readable_id, - options, - ) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for Programs - v1 - * @param {ProgramsApiProgramsRetrieveV1Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramsApi - */ - public programsRetrieveV1( - requestParameters: ProgramsApiProgramsRetrieveV1Request, - options?: RawAxiosRequestConfig, - ) { - return ProgramsApiFp(this.configuration) - .programsRetrieveV1(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } - - /** - * API view set for Programs - v2 - * @param {ProgramsApiProgramsRetrieveV2Request} requestParameters Request parameters. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ProgramsApi - */ - public programsRetrieveV2( - requestParameters: ProgramsApiProgramsRetrieveV2Request, - options?: RawAxiosRequestConfig, - ) { - return ProgramsApiFp(this.configuration) - .programsRetrieveV2(requestParameters.id, options) - .then((request) => request(this.axios, this.basePath)) - } -} diff --git a/frontends/api/src/mitxonline/generated/v0/base.ts b/frontends/api/src/mitxonline/generated/v0/base.ts deleted file mode 100644 index f02cb4d3e7..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/base.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * MITx Online API - * MIT public API - * - * The version of the OpenAPI document: 0.0.1 (v0) - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Configuration } from "./configuration" -// Some imports not used depending on template conditions -// @ts-ignore -import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios" -import globalAxios from "axios" - -export const BASE_PATH = "http://localhost".replace(/\/+$/, "") - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -} - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string - options: RawAxiosRequestConfig -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined - - constructor( - configuration?: Configuration, - protected basePath: string = BASE_PATH, - protected axios: AxiosInstance = globalAxios, - ) { - if (configuration) { - this.configuration = configuration - this.basePath = configuration.basePath ?? basePath - } - } -} - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - constructor( - public field: string, - msg?: string, - ) { - super(msg) - this.name = "RequiredError" - } -} - -interface ServerMap { - [key: string]: { - url: string - description: string - }[] -} - -/** - * - * @export - */ -export const operationServerMap: ServerMap = {} diff --git a/frontends/api/src/mitxonline/generated/v0/common.ts b/frontends/api/src/mitxonline/generated/v0/common.ts deleted file mode 100644 index c4f40f3dea..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/common.ts +++ /dev/null @@ -1,202 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * MITx Online API - * MIT public API - * - * The version of the OpenAPI document: 0.0.1 (v0) - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Configuration } from "./configuration" -import type { RequestArgs } from "./base" -import type { AxiosInstance, AxiosResponse } from "axios" -import { RequiredError } from "./base" - -/** - * - * @export - */ -export const DUMMY_BASE_URL = "https://example.com" - -/** - * - * @throws {RequiredError} - * @export - */ -export const assertParamExists = function ( - functionName: string, - paramName: string, - paramValue: unknown, -) { - if (paramValue === null || paramValue === undefined) { - throw new RequiredError( - paramName, - `Required parameter ${paramName} was null or undefined when calling ${functionName}.`, - ) - } -} - -/** - * - * @export - */ -export const setApiKeyToObject = async function ( - object: any, - keyParamName: string, - configuration?: Configuration, -) { - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = - typeof configuration.apiKey === "function" - ? await configuration.apiKey(keyParamName) - : await configuration.apiKey - object[keyParamName] = localVarApiKeyValue - } -} - -/** - * - * @export - */ -export const setBasicAuthToObject = function ( - object: any, - configuration?: Configuration, -) { - if (configuration && (configuration.username || configuration.password)) { - object["auth"] = { - username: configuration.username, - password: configuration.password, - } - } -} - -/** - * - * @export - */ -export const setBearerAuthToObject = async function ( - object: any, - configuration?: Configuration, -) { - if (configuration && configuration.accessToken) { - const accessToken = - typeof configuration.accessToken === "function" - ? await configuration.accessToken() - : await configuration.accessToken - object["Authorization"] = "Bearer " + accessToken - } -} - -/** - * - * @export - */ -export const setOAuthToObject = async function ( - object: any, - name: string, - scopes: string[], - configuration?: Configuration, -) { - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = - typeof configuration.accessToken === "function" - ? await configuration.accessToken(name, scopes) - : await configuration.accessToken - object["Authorization"] = "Bearer " + localVarAccessTokenValue - } -} - -function setFlattenedQueryParams( - urlSearchParams: URLSearchParams, - parameter: any, - key: string = "", -): void { - if (parameter == null) return - if (typeof parameter === "object") { - if (Array.isArray(parameter)) { - ;(parameter as any[]).forEach((item) => - setFlattenedQueryParams(urlSearchParams, item, key), - ) - } else { - Object.keys(parameter).forEach((currentKey) => - setFlattenedQueryParams( - urlSearchParams, - parameter[currentKey], - `${key}${key !== "" ? "." : ""}${currentKey}`, - ), - ) - } - } else { - if (urlSearchParams.has(key)) { - urlSearchParams.append(key, parameter) - } else { - urlSearchParams.set(key, parameter) - } - } -} - -/** - * - * @export - */ -export const setSearchParams = function (url: URL, ...objects: any[]) { - const searchParams = new URLSearchParams(url.search) - setFlattenedQueryParams(searchParams, objects) - url.search = searchParams.toString() -} - -/** - * - * @export - */ -export const serializeDataIfNeeded = function ( - value: any, - requestOptions: any, - configuration?: Configuration, -) { - const nonString = typeof value !== "string" - const needsSerialization = - nonString && configuration && configuration.isJsonMime - ? configuration.isJsonMime(requestOptions.headers["Content-Type"]) - : nonString - return needsSerialization - ? JSON.stringify(value !== undefined ? value : {}) - : value || "" -} - -/** - * - * @export - */ -export const toPathString = function (url: URL) { - return url.pathname + url.search + url.hash -} - -/** - * - * @export - */ -export const createRequestFunction = function ( - axiosArgs: RequestArgs, - globalAxios: AxiosInstance, - BASE_PATH: string, - configuration?: Configuration, -) { - return >( - axios: AxiosInstance = globalAxios, - basePath: string = BASE_PATH, - ) => { - const axiosRequestArgs = { - ...axiosArgs.options, - url: - (axios.defaults.baseURL ? "" : (configuration?.basePath ?? basePath)) + - axiosArgs.url, - } - return axios.request(axiosRequestArgs) - } -} diff --git a/frontends/api/src/mitxonline/generated/v0/configuration.ts b/frontends/api/src/mitxonline/generated/v0/configuration.ts deleted file mode 100644 index dec6222e97..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/configuration.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * MITx Online API - * MIT public API - * - * The version of the OpenAPI document: 0.0.1 (v0) - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -export interface ConfigurationParameters { - apiKey?: - | string - | Promise - | ((name: string) => string) - | ((name: string) => Promise) - username?: string - password?: string - accessToken?: - | string - | Promise - | ((name?: string, scopes?: string[]) => string) - | ((name?: string, scopes?: string[]) => Promise) - basePath?: string - serverIndex?: number - baseOptions?: any - formDataCtor?: new () => any -} - -export class Configuration { - /** - * parameter for apiKey security - * @param name security name - * @memberof Configuration - */ - apiKey?: - | string - | Promise - | ((name: string) => string) - | ((name: string) => Promise) - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - username?: string - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - password?: string - /** - * parameter for oauth2 security - * @param name security name - * @param scopes oauth2 scope - * @memberof Configuration - */ - accessToken?: - | string - | Promise - | ((name?: string, scopes?: string[]) => string) - | ((name?: string, scopes?: string[]) => Promise) - /** - * override base path - * - * @type {string} - * @memberof Configuration - */ - basePath?: string - /** - * override server index - * - * @type {number} - * @memberof Configuration - */ - serverIndex?: number - /** - * base options for axios calls - * - * @type {any} - * @memberof Configuration - */ - baseOptions?: any - /** - * The FormData constructor that will be used to create multipart form data - * requests. You can inject this here so that execution environments that - * do not support the FormData class can still run the generated client. - * - * @type {new () => FormData} - */ - formDataCtor?: new () => any - - constructor(param: ConfigurationParameters = {}) { - this.apiKey = param.apiKey - this.username = param.username - this.password = param.password - this.accessToken = param.accessToken - this.basePath = param.basePath - this.serverIndex = param.serverIndex - this.baseOptions = param.baseOptions - this.formDataCtor = param.formDataCtor - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public isJsonMime(mime: string): boolean { - const jsonMime: RegExp = new RegExp( - "^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$", - "i", - ) - return ( - mime !== null && - (jsonMime.test(mime) || - mime.toLowerCase() === "application/json-patch+json") - ) - } -} diff --git a/frontends/api/src/mitxonline/generated/v0/index.ts b/frontends/api/src/mitxonline/generated/v0/index.ts deleted file mode 100644 index a52c6933af..0000000000 --- a/frontends/api/src/mitxonline/generated/v0/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * MITx Online API - * MIT public API - * - * The version of the OpenAPI document: 0.0.1 (v0) - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -export * from "./api" -export * from "./configuration" diff --git a/frontends/api/src/mitxonline/hooks/courses/data.ts b/frontends/api/src/mitxonline/hooks/courses/data.ts deleted file mode 100644 index 2ff9d8b754..0000000000 --- a/frontends/api/src/mitxonline/hooks/courses/data.ts +++ /dev/null @@ -1,87 +0,0 @@ -// FAKE DATA while API / auth work is in development -import { CourseWithCourseRuns } from "../../generated/v0" -import { mockProgramCourseData } from "../programs/data" - -const fakeCourse = ({ - id, - title, -}: { - id: number - title: string -}): CourseWithCourseRuns => { - const runId = id * 10 - return { - id, - title, - readable_id: "course-v1:MITxT+18.03.2x", - next_run_id: runId, - departments: [{ name: "Mathematics" }], - page: { - feature_image_src: - "/media/original_images/18.032x_courseimage_MITxO.png?v=bb0e1eaeb2bc4ff5f079d479ece6954bd8f22ca6", - page_url: "/courses/course-v1:MITxT+18.03.2x/", - description: - "In order to understand most phenomena in the world, we need to understand not just single equations, but systems of differential equations. In this course, we start with 2x2 systems.", - live: true, - length: "9 weeks", - effort: "5-8 hrs/wk", - financial_assistance_form_url: "", - current_price: 75.0, - instructors: [{ name: "Jennifer French", description: "" }], - }, - programs: null, - topics: [{ name: "Mathematics" }, { name: "Science & Math" }], - certificate_type: "Certificate of Completion", - required_prerequisites: true, - duration: "9 weeks", - min_weeks: 9, - max_weeks: 9, - time_commitment: "5-8 hrs/wk", - availability: "anytime", - min_weekly_hours: "5", - max_weekly_hours: "8", - courseruns: [ - { - title: "Differential Equations: 2x2 Systems", - start_date: "2025-01-08T16:00:00Z", - end_date: "2025-03-19T16:00:00Z", - enrollment_start: "2024-12-13T16:00:00Z", - enrollment_end: null, - expiration_date: null, - courseware_url: - "https://courses.mitxonline.mit.edu/courses/course-v1:MITxT+18.03.2x+1T2025/course", - courseware_id: "course-v1:MITxT+18.03.2x+1T2025", - certificate_available_date: "2025-03-19T16:00:00Z", - upgrade_deadline: "2025-03-09T16:00:00Z", - is_upgradable: false, - is_enrollable: true, - is_archived: false, - is_self_paced: false, - run_tag: "1T2025", - id: runId, - live: true, - course_number: "18.03.2x", - products: [], - approved_flexible_price_exists: false, - }, - ], - } -} - -const universalAiCourses: CourseWithCourseRuns[] = [ - fakeCourse(mockProgramCourseData.foundational.one), - fakeCourse(mockProgramCourseData.foundational.two), - fakeCourse(mockProgramCourseData.foundational.three), - fakeCourse(mockProgramCourseData.foundational.four), - fakeCourse(mockProgramCourseData.foundational.five), - fakeCourse(mockProgramCourseData.foundational.six), - fakeCourse(mockProgramCourseData.foundational.seven), - fakeCourse(mockProgramCourseData.foundational.eight), - fakeCourse(mockProgramCourseData.foundational.nine), - fakeCourse(mockProgramCourseData.industry.one), - fakeCourse(mockProgramCourseData.industry.two), - fakeCourse(mockProgramCourseData.industry.three), - fakeCourse(mockProgramCourseData.industry.four), -] - -export { universalAiCourses } diff --git a/frontends/api/src/mitxonline/hooks/courses/queries.ts b/frontends/api/src/mitxonline/hooks/courses/queries.ts index b26880d351..4013379f36 100644 --- a/frontends/api/src/mitxonline/hooks/courses/queries.ts +++ b/frontends/api/src/mitxonline/hooks/courses/queries.ts @@ -2,9 +2,7 @@ import { queryOptions } from "@tanstack/react-query" import type { CoursesApiApiV2CoursesListRequest, PaginatedCourseWithCourseRunsList, -} from "../../generated/v0" - -import * as data from "./data" +} from "@mitodl/mitxonline-api-axios/v1" import { coursesApi } from "../../clients" const coursesKeys = { @@ -21,29 +19,7 @@ const coursesQueries = { queryOptions({ queryKey: coursesKeys.coursesList(opts), queryFn: async (): Promise => { - if (process.env.NODE_ENV === "test") { - /** - * For now, only use the API client during tests so we - * can mock it the way we normally do. - */ - return coursesApi.apiV2CoursesList(opts).then((res) => res.data) - } - const ids = opts?.id ?? [] - const courses = - ids.length === 0 - ? data.universalAiCourses - : data.universalAiCourses.filter((c) => ids.includes(c.id)) - if (courses.length === 0) { - console.error("No mock courses matching the given ids found.", { - ids, - }) - } - return { - count: courses.length, - next: null, - previous: null, - results: courses, - } + return coursesApi.apiV2CoursesList(opts).then((res) => res.data) }, }), } diff --git a/frontends/api/src/mitxonline/hooks/enrollment/data.ts b/frontends/api/src/mitxonline/hooks/enrollment/data.ts deleted file mode 100644 index 6706db9546..0000000000 --- a/frontends/api/src/mitxonline/hooks/enrollment/data.ts +++ /dev/null @@ -1,1030 +0,0 @@ -// FAKE DATA while API / auth work is in development -import { CourseRunEnrollment } from "../../generated/v0" - -const future = (days: number) => { - return new Date(new Date().setDate(new Date().getDate() + days)).toISOString() -} - -const courses = { - started_not_upgradeable: { - run: { - title: "Enrolled, Started, Not Upgradeable", - start_date: "2003-01-01T00:00:00Z", - end_date: null, - enrollment_start: "2003-01-01T00:00:00Z", - enrollment_end: "2030-01-01T00:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:xOnline+test+3T2022/course/", - courseware_id: "course-v1:xOnline+test+3T2022", - certificate_available_date: null, - upgrade_deadline: "2022-12-01T16:35:06Z", - is_upgradable: false, - is_enrollable: true, - is_archived: false, - is_self_paced: false, - run_tag: "3T2022", - id: 20, - live: true, - course_number: "test", - products: [ - { - id: 12, - price: "999.00", - description: "course-v1:xOnline+test", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 21, - title: "Enrolled, Started, Not Upgradeable", - readable_id: "course-v1:xOnline+test", - next_run_id: 20, - departments: [ - { - name: "Department 1", - }, - { - name: "Department 2", - }, - { - name: "Department 3", - }, - { - name: "Department 4", - }, - ], - page: { - feature_image_src: - "/media/original_images/kitten_550x500_1.jpeg?v=5971b4abbe19609fd96201988b7ab2c04d800d74", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:xOnline+test/", - description: - "This is a test that is made for just testing purposes. You can use it for all of your testing-related stuff and enjoy it after wards. Hope you enjoy it though. 1000 characters is an underestimate of the size limit. Importantly, we don't want line breaks in this description.", - live: true, - length: "1 year", - effort: "Minimal", - financial_assistance_form_url: - "/courses/course-v1:xOnline+test/test-program-flex-price-form/", - current_price: 999, - instructors: [ - { - name: "Instructor 1", - description: "", - }, - { - name: "Instructor 2", - description: "", - }, - { - name: "Instructor 3", - description: "", - }, - { - name: "Instructor 4", - description: "", - }, - { - name: "Instructor 5", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/kitten_550x500_1.jpeg?v=5971b4abbe19609fd96201988b7ab2c04d800d74", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:xOnline+test/", - description: - "This is a test that is made for just testing purposes. You can use it for all of your testing-related stuff and enjoy it after wards. Hope you enjoy it though. 1000 characters is an underestimate of the size limit. Importantly, we don't want line breaks in this description.", - live: true, - length: "1 year", - effort: "Minimal", - financial_assistance_form_url: - "/courses/course-v1:xOnline+test/test-program-flex-price-form/", - current_price: 999, - instructors: [ - { - name: "Instructor 1", - description: "", - }, - { - name: "Instructor 2", - description: "", - }, - { - name: "Instructor 3", - description: "", - }, - { - name: "Instructor 4", - description: "", - }, - { - name: "Instructor 5", - description: "", - }, - ], - }, - }, - id: 1118, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - ended: { - run: { - title: "Course That Has Ended", - start_date: "2003-01-01T00:00:00Z", - end_date: "2025-01-01T00:00:00Z", - enrollment_start: "2003-01-01T00:00:00Z", - enrollment_end: "2025-01-01T00:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:xOnline+test+3T2022/course/", - courseware_id: "course-v1:xOnline+test+3T2022", - certificate_available_date: null, - upgrade_deadline: "2022-12-01T16:35:06Z", - is_upgradable: false, - is_enrollable: true, - is_archived: false, - is_self_paced: false, - run_tag: "3T2022", - id: 20, - live: true, - course_number: "test", - products: [ - { - id: 12, - price: "999.00", - description: "course-v1:xOnline+test", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 22, - title: "Course That Has Ended", - readable_id: "course-v1:xOnline+test", - next_run_id: 20, - departments: [ - { - name: "Department 1", - }, - { - name: "Department 2", - }, - { - name: "Department 3", - }, - { - name: "Department 4", - }, - ], - page: { - feature_image_src: - "/media/original_images/kitten_550x500_1.jpeg?v=5971b4abbe19609fd96201988b7ab2c04d800d74", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:xOnline+test/", - description: - "This is a test that is made for just testing purposes. You can use it for all of your testing-related stuff and enjoy it after wards. Hope you enjoy it though. 1000 characters is an underestimate of the size limit. Importantly, we don't want line breaks in this description.", - live: true, - length: "1 year", - effort: "Minimal", - financial_assistance_form_url: - "/courses/course-v1:xOnline+test/test-program-flex-price-form/", - current_price: 999, - instructors: [ - { - name: "Instructor 1", - description: "", - }, - { - name: "Instructor 2", - description: "", - }, - { - name: "Instructor 3", - description: "", - }, - { - name: "Instructor 4", - description: "", - }, - { - name: "Instructor 5", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/kitten_550x500_1.jpeg?v=5971b4abbe19609fd96201988b7ab2c04d800d74", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:xOnline+test/", - description: - "This is a test that is made for just testing purposes. You can use it for all of your testing-related stuff and enjoy it after wards. Hope you enjoy it though. 1000 characters is an underestimate of the size limit. Importantly, we don't want line breaks in this description.", - live: true, - length: "1 year", - effort: "Minimal", - financial_assistance_form_url: - "/courses/course-v1:xOnline+test/test-program-flex-price-form/", - current_price: 999, - instructors: [ - { - name: "Instructor 1", - description: "", - }, - { - name: "Instructor 2", - description: "", - }, - { - name: "Instructor 3", - description: "", - }, - { - name: "Instructor 4", - description: "", - }, - { - name: "Instructor 5", - description: "", - }, - ], - }, - }, - id: 4211118, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - started_already_upgraded: { - run: { - title: - "Started and Already Upgraded And This Course Has a Really Long Name That Goes Across Multiple Lines", - start_date: "2022-09-06T15:00:00Z", - end_date: "2028-12-14T15:00:00Z", - enrollment_start: "2022-07-06T23:59:00Z", - enrollment_end: "2022-10-11T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.310x+3T2022/course/", - courseware_id: "course-v1:MITxT+14.310x+3T2022", - certificate_available_date: "2022-12-16T15:00:00Z", - upgrade_deadline: "2025-12-04T15:00:00Z", - is_upgradable: true, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2022", - id: 22, - live: true, - course_number: "14.310x", - products: [ - { - id: 16, - price: "999.00", - description: "course-v1:MITxT+14.310x+3T2022", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 31, - title: - "Started and Already Upgraded And This Course Has a Really Long Name That Goes Across Multiple Lines", - - readable_id: "course-v1:MITx+14.310x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.310x.jpg?v=6f09dcf8fe955707a565e18b9864c83a1bbe2563", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITx+14.310x/", - description: - "Learn methods for harnessing and analyzing data to answer questions of cultural, social, economic, and policy interest.", - live: false, - length: "Estimated 11 Weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/courses/course-v1:MITx+14.310x/data-analysis-for-social-scientists-request-flexible-pricing/", - current_price: null, - instructors: [ - { - name: "Esther Duflo", - description: "", - }, - { - name: "Sara Fisher Ellison", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.310x.jpg?v=6f09dcf8fe955707a565e18b9864c83a1bbe2563", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITx+14.310x/", - description: - "Learn methods for harnessing and analyzing data to answer questions of cultural, social, economic, and policy interest.", - live: false, - length: "Estimated 11 Weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/courses/course-v1:MITx+14.310x/data-analysis-for-social-scientists-request-flexible-pricing/", - current_price: null, - instructors: [ - { - name: "Esther Duflo", - description: "", - }, - { - name: "Sara Fisher Ellison", - description: "", - }, - ], - }, - }, - id: 551, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "verified", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgradeable_course_not_started: { - run: { - title: "Upgradeable Course, Not Yet Started", - start_date: future(1), - upgrade_deadline: future(5), - end_date: future(10000), - enrollment_start: "2024-03-07T23:59:00Z", - enrollment_end: "2035-10-25T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - is_upgradable: true, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 691, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 34, - title: "Upgradeable Course, Not Yet Started", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 8342, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgradeable_course_not_started_long_name: { - run: { - title: - "Upgradeable Course, Not Yet Started, And This Course Also Has A Really Long Name That Goes Across Multiple Lines", - start_date: future(5), - upgrade_deadline: future(15), - end_date: future(10000), - enrollment_start: "2024-03-07T23:59:00Z", - enrollment_end: "2035-10-25T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - is_upgradable: true, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 35, - title: - "Upgradeable Course, Not Yet Started, And This Course Also Has A Really Long Name That Goes Across Multiple Lines", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 834, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - not_upgradeable_not_started: { - run: { - title: "Not Upgradeable, Not Started", - start_date: future(10), - end_date: "2040-12-20T15:00:00Z", - enrollment_start: "2024-03-07T23:59:00Z", - enrollment_end: "2035-10-25T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: false, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [], - approved_flexible_price_exists: false, - course: { - id: 36, - title: "Not Upgradeable, Not Started", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 8341, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgradable_course_has_started: { - run: { - title: "Upgradeable Course, Already Started", - start_date: "2025-02-12T15:00:00Z", - end_date: "2040-12-20T15:00:00Z", - enrollment_start: "2024-03-07T23:59:00Z", - enrollment_end: "2035-10-25T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: future(8), - is_upgradable: true, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 37, - title: "Upgradeable Course, Already Started", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 6436834, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgraded_and_passed: { - run: { - title: "Upgradeable Course, Ended and Passed", - start_date: "2025-02-12T15:00:00Z", - end_date: "2025-03-10T15:00:00Z", - enrollment_start: "2025-03-20T15:00:00Z", - enrollment_end: "2025-03-20T15:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: false, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 38, - title: "Upgradeable Course, Ended and Passed", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 64368345, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0.7, - letter_grade: null, - passed: true, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgraded_and_not_passed: { - run: { - title: "Upgradeable Course, Ended and Not Passed", - start_date: "2025-02-12T15:00:00Z", - end_date: "2025-03-10T15:00:00Z", - enrollment_start: "2025-03-20T15:00:00Z", - enrollment_end: "2025-03-20T15:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: false, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: 39, - title: "Upgradeable Course, Ended and Not Passed", - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 643683452, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0.3, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, -} satisfies Record - -const enrollments: CourseRunEnrollment[] = Object.values(courses) - -export { enrollments } diff --git a/frontends/api/src/mitxonline/hooks/enrollment/dataForOrgs.ts b/frontends/api/src/mitxonline/hooks/enrollment/dataForOrgs.ts deleted file mode 100644 index 3483b37c71..0000000000 --- a/frontends/api/src/mitxonline/hooks/enrollment/dataForOrgs.ts +++ /dev/null @@ -1,337 +0,0 @@ -import { CourseRunEnrollment } from "../../generated/v0" -import { mockProgramCourseData } from "../programs/data" - -const orgCourseEnollments = { - upgraded_and_passed: { - run: { - title: mockProgramCourseData.foundational.one.title, - start_date: "2025-02-12T15:00:00Z", - end_date: "2025-03-10T15:00:00Z", - enrollment_start: "2025-03-20T15:00:00Z", - enrollment_end: "2025-03-20T15:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: false, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: mockProgramCourseData.foundational.one.id, - title: mockProgramCourseData.foundational.one.title, - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 64368345, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0.7, - letter_grade: null, - passed: true, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgraded_and_not_finished: { - run: { - title: mockProgramCourseData.foundational.two.title, - start_date: "2025-02-12T15:00:00Z", - end_date: "2040-12-20T15:00:00Z", - enrollment_start: "2024-03-07T23:59:00Z", - enrollment_end: "2035-10-25T23:59:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: true, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: mockProgramCourseData.foundational.two.id, - title: mockProgramCourseData.foundational.two.title, - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 6436834, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, - upgraded_and_not_passed: { - run: { - title: mockProgramCourseData.foundational.three.title, - start_date: "2025-02-12T15:00:00Z", - end_date: "2025-03-10T15:00:00Z", - enrollment_start: "2025-03-20T15:00:00Z", - enrollment_end: "2025-03-20T15:00:00Z", - expiration_date: null, - courseware_url: - "https://courses-qa.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x+3T2023/course", - courseware_id: "course-v1:MITxT+14.73x+3T2023", - certificate_available_date: "2024-01-03T00:00:00Z", - upgrade_deadline: "2025-04-10T15:00:00Z", - is_upgradable: false, - is_enrollable: false, - is_archived: false, - is_self_paced: false, - run_tag: "3T2023", - id: 69, - live: true, - course_number: "14.73x", - products: [ - { - id: 56, - price: "999.00", - description: "course-v1:MITxT+14.73x+3T2023", - is_active: true, - product_flexible_price: null, - }, - ], - approved_flexible_price_exists: false, - course: { - id: mockProgramCourseData.foundational.two.id, - title: mockProgramCourseData.foundational.two.title, - readable_id: "course-v1:MITxT+14.73x", - next_run_id: null, - departments: [ - { - name: "Economics", - }, - ], - page: { - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - programs: null, - // @ts-expect-error Schema says this doesn't exist; we won't use it. - feature_image_src: - "/media/original_images/14.73x.jpg?v=74c8454643cd441f918b9bdefce98468902ae6d7", - page_url: - "https://rc.mitxonline.mit.edu/courses/course-v1:MITxT+14.73x/", - description: - "A course for those who are interested in the challenge posed by massive and persistent world poverty.", - live: true, - length: "Estimated 11 weeks", - effort: "12–14 hours per week", - financial_assistance_form_url: - "/programs/program-v1:MITx+DEDP/dedp-micromasters-program-financial-assistance-form/", - current_price: null, - instructors: [ - { - name: "Abhijit Vinayak Banerjee", - description: "", - }, - { - name: "Esther Duflo", - description: "", - }, - ], - }, - }, - id: 643683452, - edx_emails_subscription: true, - certificate: null, - enrollment_mode: "audit", - approved_flexible_price_exists: false, - grades: [ - { - grade: 0.2, - letter_grade: null, - passed: false, - set_by_admin: false, - grade_percent: 0, - }, - ], - }, -} satisfies Record - -const orgData = { - orgX: { id: 488, name: "Organization X" }, - orgY: { - id: 522, - name: "Organization Y", - logo: "https://brand.mit.edu/sites/default/files/styles/tile_narrow/public/2023-08/logo-colors-mit-red.png?itok=k08Ir4pB", - }, -} - -const orgXEnrollments = Object.values(orgCourseEnollments) -const orgYEnrollments = Object.values(orgCourseEnollments).slice(0, 2) - -export { orgXEnrollments, orgYEnrollments, orgData } diff --git a/frontends/api/src/mitxonline/hooks/enrollment/index.ts b/frontends/api/src/mitxonline/hooks/enrollment/index.ts index 8ad6d6c054..cf7a732161 100644 --- a/frontends/api/src/mitxonline/hooks/enrollment/index.ts +++ b/frontends/api/src/mitxonline/hooks/enrollment/index.ts @@ -1,5 +1,3 @@ import { enrollmentQueries } from "./queries" export { enrollmentQueries } - -export { orgData as mockOrgData } from "./dataForOrgs" diff --git a/frontends/api/src/mitxonline/hooks/enrollment/queries.ts b/frontends/api/src/mitxonline/hooks/enrollment/queries.ts index 0fbc0681cd..5888f06adc 100644 --- a/frontends/api/src/mitxonline/hooks/enrollment/queries.ts +++ b/frontends/api/src/mitxonline/hooks/enrollment/queries.ts @@ -1,68 +1,27 @@ import { queryOptions } from "@tanstack/react-query" -import type { CourseRunEnrollment } from "../../generated/v0" +import type { CourseRunEnrollment } from "@mitodl/mitxonline-api-axios/v1" -import * as data from "./data" -import * as dataForOrgs from "./dataForOrgs" -import { axiosInstance } from "../../clients" - -type EnrollmentsListOptions = { - /** - * WARNING: This is not yet implemented in the API. - */ - orgId?: number -} +import { enrollmentsApi } from "../../clients" +import { RawAxiosRequestConfig } from "axios" const enrollmentKeys = { root: ["mitxonline", "enrollments"], - coursesList: (opts?: EnrollmentsListOptions) => [ + enrollmentsList: (opts: RawAxiosRequestConfig) => [ ...enrollmentKeys.root, - "courses", + "programEnrollments", "list", opts, ], } const enrollmentQueries = { - coursesList: (opts: EnrollmentsListOptions = {}) => + enrollmentsList: (opts: RawAxiosRequestConfig) => queryOptions({ - queryKey: enrollmentKeys.coursesList(opts), + queryKey: enrollmentKeys.enrollmentsList(opts), queryFn: async (): Promise => { - if (process.env.NODE_ENV === "test") { - /** - * ALERT! This is a temporary solution while API is under development. - * - * Ideally we would use the real API client here: - * `enrollmentsApi.enrollmentsList(opts)` - * - * However, we are relying on yet-to-be-implemented query parameters - * (namely, orgId). - * - * The generated client ignores unsupported query parameters, which - * inhibits testing. - */ - const urls = await import("../../test-utils/urls") - return axiosInstance - .request({ - url: urls.enrollment.courseEnrollment(opts), - method: "GET", - }) - .then((res) => res.data) - } - await new Promise((resolve) => setTimeout(resolve, 300)) - if (opts.orgId === dataForOrgs.orgData.orgX.id) { - return dataForOrgs.orgXEnrollments - } - if (opts.orgId === dataForOrgs.orgData.orgY.id) { - return dataForOrgs.orgYEnrollments - } - if (opts.orgId) { - console.error(`No data for orgId ${opts.orgId}`) - return [] - } - return data.enrollments + return enrollmentsApi.enrollmentsList(opts).then((res) => res.data) }, }), } export { enrollmentQueries, enrollmentKeys } -export type { EnrollmentsListOptions } diff --git a/frontends/api/src/mitxonline/hooks/organizations/index.ts b/frontends/api/src/mitxonline/hooks/organizations/index.ts new file mode 100644 index 0000000000..61db519596 --- /dev/null +++ b/frontends/api/src/mitxonline/hooks/organizations/index.ts @@ -0,0 +1,3 @@ +import { organizationQueries } from "./queries" + +export { organizationQueries } diff --git a/frontends/api/src/mitxonline/hooks/organizations/queries.ts b/frontends/api/src/mitxonline/hooks/organizations/queries.ts new file mode 100644 index 0000000000..4dd8fa230e --- /dev/null +++ b/frontends/api/src/mitxonline/hooks/organizations/queries.ts @@ -0,0 +1,25 @@ +import { B2bApiB2bOrganizationsRetrieveRequest } from "@mitodl/mitxonline-api-axios/v0" +import { OrganizationPage } from "@mitodl/mitxonline-api-axios/v1" +import { queryOptions } from "@tanstack/react-query" +import { b2bApi } from "../../clients" + +const organizationKeys = { + root: ["mitxonline", "organizations"], + organizationsRetrieve: (opts?: B2bApiB2bOrganizationsRetrieveRequest) => [ + ...organizationKeys.root, + "retrieve", + opts, + ], +} + +const organizationQueries = { + organizationsRetrieve: (opts: B2bApiB2bOrganizationsRetrieveRequest) => + queryOptions({ + queryKey: organizationKeys.organizationsRetrieve(opts), + queryFn: async (): Promise => { + return b2bApi.b2bOrganizationsRetrieve(opts).then((res) => res.data) + }, + }), +} + +export { organizationQueries, organizationKeys } diff --git a/frontends/api/src/mitxonline/hooks/programs/data.ts b/frontends/api/src/mitxonline/hooks/programs/data.ts deleted file mode 100644 index 96cbe7128c..0000000000 --- a/frontends/api/src/mitxonline/hooks/programs/data.ts +++ /dev/null @@ -1,155 +0,0 @@ -// FAKE DATA while API / auth work is in development -import { PaginatedV2ProgramList } from "../../generated/v0" - -const mockProgramCourseData = { - foundational: { - one: { - id: 1001, - title: - "Introduction to Data Analytics, Machine Learning, & Python Coding", - }, - two: { id: 1002, title: "Prescriptive Analytics" }, - three: { id: 1003, title: "Supervised Learning Fundamentals" }, - four: { id: 1004, title: "Clustering and Unsupervised Learning" }, - five: { - id: 1005, - title: "Deep Learning and Convolutional Neural Networks", - }, - six: { id: 1006, title: "Natural Language Processing" }, - seven: { id: 1007, title: "Large Language Models" }, - eight: { - id: 1008, - title: "Generative AI, the Future of Work, and Human Creativity", - }, - nine: { id: 1009, title: "Multimodal AI" }, - }, - industry: { - one: { id: 2001, title: "AI and Machine Learning for Transportation" }, - two: { id: 2002, title: "AI and Precision Medicine" }, - three: { id: 2003, title: "AI for Human Experience" }, - four: { id: 2004, title: "AI and Commerce" }, - }, -} - -const universalAiProgramData: PaginatedV2ProgramList = { - count: 1, - next: null, - previous: null, - results: [ - { - title: "Foundational AI Modules", - readable_id: "program-v1:MITxT+UAI.01x", - id: 101, - courses: [ - mockProgramCourseData.foundational.one.id, - mockProgramCourseData.foundational.two.id, - mockProgramCourseData.foundational.three.id, - mockProgramCourseData.foundational.four.id, - mockProgramCourseData.foundational.five.id, - mockProgramCourseData.foundational.six.id, - mockProgramCourseData.foundational.seven.id, - mockProgramCourseData.foundational.eight.id, - mockProgramCourseData.foundational.nine.id, - ], - requirements: { - required: [], - electives: [], - }, - req_tree: [], - page: { - feature_image_src: "/static/images/mit-dome.png", - page_url: "/programs/program-v1:MITxT+18.03x/", - financial_assistance_form_url: "", - description: "MITxOnline returns raw HTML here.", - live: false, - length: "14 weeks", - effort: "7 hrs/wk", - price: "$175", - }, - program_type: "Series", - certificate_type: "Certificate of Completion", - departments: [ - { - name: "Mathematics", - }, - ], - live: false, - topics: [ - { - name: "Mathematics", - }, - { - name: "Science & Math", - }, - ], - availability: "anytime", - start_date: null, - end_date: null, - enrollment_start: null, - enrollment_end: null, - required_prerequisites: true, - duration: "14 weeks", - min_weeks: 14, - max_weeks: 14, - time_commitment: "7 hrs/wk", - min_weekly_hours: "7", - max_weekly_hours: "7", - }, - { - title: "Industry-specific Vertical Modules", - readable_id: "program-v1:MITxT+UAI.02x", - id: 201, - courses: [ - mockProgramCourseData.industry.one.id, - mockProgramCourseData.industry.two.id, - mockProgramCourseData.industry.three.id, - mockProgramCourseData.industry.four.id, - ], - requirements: { - required: [], - electives: [], - }, - req_tree: [], - page: { - feature_image_src: "/static/images/mit-dome.png", - page_url: "/programs/program-v1:MITxT+18.03x/", - financial_assistance_form_url: "", - description: "MITxOnline returns raw HTML here.", - live: false, - length: "14 weeks", - effort: "7 hrs/wk", - price: "$175", - }, - program_type: "Series", - certificate_type: "Certificate of Completion", - departments: [ - { - name: "Mathematics", - }, - ], - live: false, - topics: [ - { - name: "Mathematics", - }, - { - name: "Science & Math", - }, - ], - availability: "anytime", - start_date: null, - end_date: null, - enrollment_start: null, - enrollment_end: null, - required_prerequisites: true, - duration: "14 weeks", - min_weeks: 14, - max_weeks: 14, - time_commitment: "7 hrs/wk", - min_weekly_hours: "7", - max_weekly_hours: "7", - }, - ], -} - -export { universalAiProgramData, mockProgramCourseData } diff --git a/frontends/api/src/mitxonline/hooks/programs/queries.ts b/frontends/api/src/mitxonline/hooks/programs/queries.ts index c186126613..8327aff306 100644 --- a/frontends/api/src/mitxonline/hooks/programs/queries.ts +++ b/frontends/api/src/mitxonline/hooks/programs/queries.ts @@ -2,21 +2,12 @@ import { queryOptions } from "@tanstack/react-query" import type { PaginatedV2ProgramList, ProgramsApiProgramsListV2Request, -} from "../../generated/v0" - -import * as data from "./data" -import { axiosInstance } from "../../clients" - -type ProgramsListRequest = ProgramsApiProgramsListV2Request & { - /** - * NOT YET IMPLEMENTED - */ - orgId?: number -} +} from "@mitodl/mitxonline-api-axios/v1" +import { programsApi } from "../../clients" const programsKeys = { root: ["mitxonline", "programs"], - programsList: (opts?: ProgramsListRequest) => [ + programsList: (opts?: ProgramsApiProgramsListV2Request) => [ ...programsKeys.root, "list", opts, @@ -24,35 +15,13 @@ const programsKeys = { } const programsQueries = { - programsList: (opts: ProgramsListRequest) => + programsList: (opts: ProgramsApiProgramsListV2Request) => queryOptions({ queryKey: programsKeys.programsList(opts), queryFn: async (): Promise => { - if (process.env.NODE_ENV === "test") { - /** - * ALERT! This is a temporary solution while API is under development. - * - * Ideally we would use the real API client here: - * `enrollmentsApi.enrollmentsList(opts)` - * - * However, we are relying on yet-to-be-implemented query parameters - * (namely, orgId). - * - * The generated client ignores unsupported query parameters, which - * inhibits testing. - */ - const urls = await import("../../test-utils/urls") - return axiosInstance - .request({ - url: urls.programs.programsList(opts), - method: "GET", - }) - .then((res) => res.data) - } - return data.universalAiProgramData + return programsApi.programsListV2(opts).then((res) => res.data) }, }), } export { programsQueries, programsKeys } -export type { ProgramsListRequest } diff --git a/frontends/api/src/mitxonline/hooks/user/index.ts b/frontends/api/src/mitxonline/hooks/user/index.ts new file mode 100644 index 0000000000..35e06b255f --- /dev/null +++ b/frontends/api/src/mitxonline/hooks/user/index.ts @@ -0,0 +1,17 @@ +import { useQuery } from "@tanstack/react-query" +import { usersApi } from "../../clients" +import type { User } from "@mitodl/mitxonline-api-axios/v1" + +const useMitxOnlineCurrentUser = () => + useQuery({ + queryKey: ["mitxonline", "currentUser"], + queryFn: async (): Promise => { + const response = await usersApi.usersCurrentUserRetrieve() + return { + ...response.data, + } + }, + }) + +export { useMitxOnlineCurrentUser } +export type { User as MitxOnlineUser } diff --git a/frontends/api/src/mitxonline/index.ts b/frontends/api/src/mitxonline/index.ts index 81a9cf6946..e69de29bb2 100644 --- a/frontends/api/src/mitxonline/index.ts +++ b/frontends/api/src/mitxonline/index.ts @@ -1 +0,0 @@ -export * from "./generated/v0" diff --git a/frontends/api/src/mitxonline/test-utils/factories/courses.ts b/frontends/api/src/mitxonline/test-utils/factories/courses.ts index f14a56cf4c..b034489a3d 100644 --- a/frontends/api/src/mitxonline/test-utils/factories/courses.ts +++ b/frontends/api/src/mitxonline/test-utils/factories/courses.ts @@ -1,6 +1,6 @@ import { mergeOverrides, makePaginatedFactory } from "ol-test-utilities" import type { PartialFactory } from "ol-test-utilities" -import type { CourseWithCourseRuns } from "../../generated/v0" +import type { CourseWithCourseRuns } from "@mitodl/mitxonline-api-axios/v1" import { faker } from "@faker-js/faker/locale/en" import { UniqueEnforcer } from "enforce-unique" diff --git a/frontends/api/src/mitxonline/test-utils/factories/enrollment.ts b/frontends/api/src/mitxonline/test-utils/factories/enrollment.ts index 1ed33bc1f7..7b97617029 100644 --- a/frontends/api/src/mitxonline/test-utils/factories/enrollment.ts +++ b/frontends/api/src/mitxonline/test-utils/factories/enrollment.ts @@ -1,7 +1,10 @@ import { faker } from "@faker-js/faker/locale/en" import { mergeOverrides } from "ol-test-utilities" import type { PartialFactory } from "ol-test-utilities" -import type { CourseRunEnrollment, CourseRunGrade } from "../../generated/v0" +import type { + CourseRunEnrollment, + CourseRunGrade, +} from "@mitodl/mitxonline-api-axios/v1" import { UniqueEnforcer } from "enforce-unique" const uniqueEnrollmentId = new UniqueEnforcer() diff --git a/frontends/api/src/mitxonline/test-utils/factories/index.ts b/frontends/api/src/mitxonline/test-utils/factories/index.ts index 6d2fbdbf15..5500994cf6 100644 --- a/frontends/api/src/mitxonline/test-utils/factories/index.ts +++ b/frontends/api/src/mitxonline/test-utils/factories/index.ts @@ -1,5 +1,7 @@ import * as mitx from "./enrollment" import * as programs from "./programs" import * as courses from "./courses" +import * as organizations from "./organization" +import * as user from "./user" -export { mitx as enrollment, programs, courses } +export { mitx as enrollment, programs, courses, organizations, user } diff --git a/frontends/api/src/mitxonline/test-utils/factories/organization.ts b/frontends/api/src/mitxonline/test-utils/factories/organization.ts new file mode 100644 index 0000000000..d6e5e0f7f6 --- /dev/null +++ b/frontends/api/src/mitxonline/test-utils/factories/organization.ts @@ -0,0 +1,31 @@ +import { faker } from "@faker-js/faker/locale/en" +import { OrganizationPage } from "@mitodl/mitxonline-api-axios/v1" +import { mergeOverrides } from "ol-test-utilities" + +const organization = ( + overrides: Partial, +): OrganizationPage => { + const merged = mergeOverrides( + { + id: faker.number.int(), + name: faker.company.name(), + description: faker.lorem.paragraph(), + logo: faker.image.url(), + slug: faker.lorem.slug(), + contracts: [], + }, + overrides, + ) + + // Ensure all required fields are present and not undefined + return { + id: merged.id!, + name: merged.name!, + description: merged.description!, + logo: merged.logo!, + slug: merged.slug!, + contracts: merged.contracts!, + } +} + +export { organization } diff --git a/frontends/api/src/mitxonline/test-utils/factories/programs.ts b/frontends/api/src/mitxonline/test-utils/factories/programs.ts index 1ca5c8e952..3600dfb6c5 100644 --- a/frontends/api/src/mitxonline/test-utils/factories/programs.ts +++ b/frontends/api/src/mitxonline/test-utils/factories/programs.ts @@ -1,6 +1,6 @@ import { mergeOverrides, makePaginatedFactory } from "ol-test-utilities" import type { PartialFactory } from "ol-test-utilities" -import type { V2Program } from "../../generated/v0" +import type { V2Program } from "@mitodl/mitxonline-api-axios/v1" import { faker } from "@faker-js/faker/locale/en" import { UniqueEnforcer } from "enforce-unique" diff --git a/frontends/api/src/mitxonline/test-utils/factories/user.ts b/frontends/api/src/mitxonline/test-utils/factories/user.ts new file mode 100644 index 0000000000..82d246c982 --- /dev/null +++ b/frontends/api/src/mitxonline/test-utils/factories/user.ts @@ -0,0 +1,82 @@ +import { faker } from "@faker-js/faker/locale/en" +import { mergeOverrides, type PartialFactory } from "ol-test-utilities" +import type { + User, + LegalAddress, + UserProfile, + UserOrganization, +} from "@mitodl/mitxonline-api-axios/v1" +import { UniqueEnforcer } from "enforce-unique" + +const enforcerId = new UniqueEnforcer() + +const legalAddress = (): LegalAddress => ({ + first_name: faker.person.firstName(), + last_name: faker.person.lastName(), + country: faker.location.countryCode(), + state: faker.datatype.boolean() ? faker.location.state() : null, +}) + +const userProfile = (): UserProfile => ({ + gender: faker.helpers.arrayElement(["m", "f", "t", "nb", "o", ""]), + year_of_birth: faker.number.int({ min: 1940, max: 2010 }), + addl_field_flag: faker.datatype.boolean(), + company: faker.company.name(), + job_title: faker.person.jobTitle(), + industry: faker.commerce.department(), + job_function: faker.person.jobType(), + company_size: faker.helpers.arrayElement([1, 9, 99, 999, 9999, 10000, 0]), + years_experience: faker.helpers.arrayElement([2, 5, 10, 15, 20, 21, 0]), + leadership_level: faker.person.jobDescriptor(), + highest_education: faker.helpers.arrayElement([ + "Doctorate", + "Master's or professional degree", + "Bachelor's degree", + "Associate degree", + "Secondary/high school", + "Junior secondary/junior high/middle school", + "Elementary/primary school", + "No formal education", + "Other education", + "", + ]), + type_is_student: faker.datatype.boolean(), + type_is_professional: faker.datatype.boolean(), + type_is_educator: faker.datatype.boolean(), + type_is_other: faker.datatype.boolean(), +}) + +const userOrganization = (): UserOrganization => ({ + id: faker.number.int(), + name: faker.company.name(), + description: faker.company.catchPhrase(), + logo: faker.image.url(), + slug: faker.helpers.slugify(faker.company.name()), + contracts: [], +}) + +const user: PartialFactory = (overrides = {}): User => { + return mergeOverrides( + { + id: enforcerId.enforce(faker.number.int), + username: faker.internet.userName(), + name: faker.person.fullName(), + email: faker.internet.email(), + legal_address: legalAddress(), + user_profile: userProfile(), + is_anonymous: false, + is_authenticated: true, + is_editor: faker.datatype.boolean(), + is_staff: faker.datatype.boolean(), + is_superuser: faker.datatype.boolean(), + created_on: faker.date.past().toISOString(), + updated_on: faker.date.recent().toISOString(), + grants: [], + is_active: true, + b2b_organizations: [userOrganization()], + }, + overrides, + ) as User +} + +export { user } diff --git a/frontends/api/src/mitxonline/test-utils/urls.ts b/frontends/api/src/mitxonline/test-utils/urls.ts index 8a6ad09fa0..a5dd83047d 100644 --- a/frontends/api/src/mitxonline/test-utils/urls.ts +++ b/frontends/api/src/mitxonline/test-utils/urls.ts @@ -1,16 +1,24 @@ -import type { CoursesApiApiV2CoursesListRequest } from "../generated/v0" +import type { + CoursesApiApiV2CoursesListRequest, + ProgramsApiProgramsListV2Request, +} from "@mitodl/mitxonline-api-axios/v1" +import { RawAxiosRequestConfig } from "axios" import { queryify } from "ol-test-utilities" -import type { EnrollmentsListOptions } from "../hooks/enrollment/queries" -import type { ProgramsListRequest } from "../hooks/programs/queries" -const API_BASE_URL = process.env.NEXT_PUBLIC_MITXONLINE_API_BASE_URL + +const API_BASE_URL = process.env.NEXT_PUBLIC_MITX_ONLINE_BASE_URL + +const currentUser = { + get: (opts?: RawAxiosRequestConfig) => + `${API_BASE_URL}/api/v0/users/current_user/${queryify(opts)}`, +} const enrollment = { - courseEnrollment: (opts?: EnrollmentsListOptions) => + courseEnrollment: (opts?: RawAxiosRequestConfig) => `${API_BASE_URL}/api/v1/enrollments/${queryify(opts)}`, } const programs = { - programsList: (opts?: ProgramsListRequest) => + programsList: (opts?: ProgramsApiProgramsListV2Request) => `${API_BASE_URL}/api/v2/programs/${queryify(opts)}`, } @@ -19,4 +27,9 @@ const courses = { `${API_BASE_URL}/api/v2/courses/${queryify(opts, { explode: false })}`, } -export { enrollment, programs, courses } +const organization = { + organizationList: (organizationSlug: string) => + `${API_BASE_URL}/api/v0/b2b/organizations/${organizationSlug}/`, +} + +export { currentUser, enrollment, programs, courses, organization } diff --git a/frontends/jest-shared-setup.ts b/frontends/jest-shared-setup.ts index f1585d8e3b..9e229abad6 100644 --- a/frontends/jest-shared-setup.ts +++ b/frontends/jest-shared-setup.ts @@ -10,7 +10,7 @@ expect.extend(matchers) // env vars process.env.NEXT_PUBLIC_MITOL_API_BASE_URL = "http://api.test.learn.odl.local:8063" -process.env.NEXT_PUBLIC_MITXONLINE_API_BASE_URL = +process.env.NEXT_PUBLIC_MITX_ONLINE_BASE_URL = "http://api.test.mitxonline.odl.local:8053" process.env.NEXT_PUBLIC_ORIGIN = "http://test.learn.odl.local:8062" process.env.NEXT_PUBLIC_EMBEDLY_KEY = "fake-embedly-key" diff --git a/frontends/main/package.json b/frontends/main/package.json index 0782eab63f..721290c7b5 100644 --- a/frontends/main/package.json +++ b/frontends/main/package.json @@ -14,6 +14,7 @@ "@emotion/cache": "^11.13.1", "@emotion/styled": "^11.11.0", "@mitodl/course-search-utils": "3.3.2", + "@mitodl/mitxonline-api-axios": "^2025.6.3", "@mitodl/smoot-design": "^6.6.1", "@next/bundle-analyzer": "^14.2.15", "@remixicon/react": "^4.2.0", diff --git a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx index 8eeb5525c9..a280e96a5b 100644 --- a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx +++ b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx @@ -9,31 +9,39 @@ import { EnrollmentDisplay } from "./EnrollmentDisplay" import * as mitxonline from "api/mitxonline-test-utils" import moment from "moment" import { faker } from "@faker-js/faker/locale/en" +import { useFeatureFlagEnabled } from "posthog-js/react" + +jest.mock("posthog-js/react") +const mockedUseFeatureFlagEnabled = jest + .mocked(useFeatureFlagEnabled) + .mockImplementation(() => false) const courseEnrollment = mitxonline.factories.enrollment.courseEnrollment const grade = mitxonline.factories.enrollment.grade describe("EnrollmentDisplay", () => { - const setupApis = () => { + const setupApis = (includeExpired: boolean = true) => { const completed = [ courseEnrollment({ run: { title: "C Course Ended" }, grades: [grade({ passed: true })], }), ] - const expired = [ - courseEnrollment({ - run: { - title: "A Course Ended", - end_date: faker.date.past().toISOString(), - }, - }), - courseEnrollment({ - run: { - title: "B Course Ended", - end_date: faker.date.past().toISOString(), - }, - }), - ] + const expired = includeExpired + ? [ + courseEnrollment({ + run: { + title: "A Course Ended", + end_date: faker.date.past().toISOString(), + }, + }), + courseEnrollment({ + run: { + title: "B Course Ended", + end_date: faker.date.past().toISOString(), + }, + }), + ] + : [] const started = [ courseEnrollment({ run: { @@ -67,6 +75,7 @@ describe("EnrollmentDisplay", () => { ...notStarted, ]) + mockedUseFeatureFlagEnabled.mockReturnValue(true) setMockResponse.get( mitxonline.urls.enrollment.courseEnrollment(), mitxonlineCourseEnrollments, @@ -82,7 +91,7 @@ describe("EnrollmentDisplay", () => { const { mitxonlineCourses } = setupApis() renderWithProviders() - screen.getByRole("heading", { name: "My Learning" }) + await screen.findByRole("heading", { name: "My Learning" }) const cards = await screen.findAllByTestId("enrollment-card-desktop") const expectedTitles = [ @@ -100,9 +109,10 @@ describe("EnrollmentDisplay", () => { const { mitxonlineCourses } = setupApis() renderWithProviders() - await user.click(screen.getByText("Show all")) + const showAllButton = await screen.findByText("Show all") + await user.click(showAllButton) - screen.getByRole("heading", { name: "My Learning" }) + await screen.findByRole("heading", { name: "My Learning" }) const cards = await screen.findAllByTestId("enrollment-card-desktop") const expectedTitles = [ @@ -116,4 +126,13 @@ describe("EnrollmentDisplay", () => { expect(cards[i]).toHaveTextContent(title) }) }) + + test("If there are no extra enrollments to display, there should be no show all", async () => { + setupApis(false) + renderWithProviders() + + await screen.findByRole("heading", { name: "My Learning" }) + + expect(screen.queryByText("Show all")).not.toBeInTheDocument() + }) }) diff --git a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.tsx b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.tsx index ec1bc1ceda..8c448350c9 100644 --- a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.tsx +++ b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.tsx @@ -146,49 +146,44 @@ const EnrollmentExpandCollapse: React.FC = ({ /> ))} - - - {hiddenEnrollments.map((course) => ( - - ))} - - - - - {shown ? "Show less" : "Show all"} - - + {hiddenEnrollments.length === 0 ? null : ( + <> + + + {hiddenEnrollments.map((course) => ( + + ))} + + + + + {shown ? "Show less" : "Show all"} + + + + )} ) } const EnrollmentDisplay = () => { const { data: enrolledCourses, isLoading } = useQuery({ - ...enrollmentQueries.coursesList(), + ...enrollmentQueries.enrollmentsList({}), select: mitxonlineEnrollments, }) - /** - * TODO: - * Consider handling UI logic in a component that expects standardized - * EnrollmentData objects. This will simplify testing and isolate API calls - * to the parent - * - * The constants below are separate for impending "Show All" functionality. - * The above TODO could be handled then. - */ const { completed, expired, started, notStarted } = sortEnrollments( enrolledCourses || [], ) const shownEnrollments = [...started, ...notStarted, ...completed] - return ( + return shownEnrollments.length > 0 ? ( My Learning @@ -199,7 +194,7 @@ const EnrollmentDisplay = () => { isLoading={isLoading} /> </Wrapper> - ) + ) : null } export { EnrollmentDisplay } diff --git a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts index d53a5369de..626bae4620 100644 --- a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts +++ b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts @@ -9,7 +9,6 @@ import type { DashboardCourse } from "./types" import * as u from "api/test-utils" import { urls, factories } from "api/mitxonline-test-utils" import { setMockResponse } from "../../../test-utils" -import { mockOrgData } from "api/mitxonline-hooks/enrollment" const makeCourses = factories.courses.courses const makeProgram = factories.programs.program @@ -40,9 +39,13 @@ const dashboardCourse: PartialFactory<DashboardCourse> = (...overrides) => { const setupProgramsAndCourses = () => { const user = u.factories.user.user() + const orgX = factories.organizations.organization({ name: "Org X" }) + const mitxOnlineUser = factories.user.user({ b2b_organizations: [orgX] }) setMockResponse.get(u.urls.userMe.get(), user) + setMockResponse.get(urls.currentUser.get(), mitxOnlineUser) + setMockResponse.get(urls.organization.organizationList(""), orgX) + setMockResponse.get(urls.organization.organizationList(orgX.slug), orgX) - const orgId = mockOrgData.orgX.id const coursesA = makeCourses({ count: 4 }) const coursesB = makeCourses({ count: 3 }) const programA = makeProgram({ @@ -52,20 +55,26 @@ const setupProgramsAndCourses = () => { courses: coursesB.results.map((c) => c.id), }) + setMockResponse.get(urls.programs.programsList({ org_id: orgX.id }), { + results: [programA, programB], + }) setMockResponse.get( - urls.programs.programsList({ orgId: mockOrgData.orgX.id }), - { results: [programA, programB] }, + urls.courses.coursesList({ id: programA.courses, org_id: orgX.id }), + { + results: coursesA.results, + }, + ) + setMockResponse.get( + urls.courses.coursesList({ id: programB.courses, org_id: orgX.id }), + { + results: coursesB.results, + }, ) - setMockResponse.get(urls.courses.coursesList({ id: programA.courses }), { - results: coursesA.results, - }) - setMockResponse.get(urls.courses.coursesList({ id: programB.courses }), { - results: coursesB.results, - }) return { - orgId, + orgX, user, + mitxOnlineUser, programA, programB, coursesA: coursesA.results, diff --git a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/transform.ts b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/transform.ts index 9175a59eaf..d8adea32a5 100644 --- a/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/transform.ts +++ b/frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/transform.ts @@ -8,7 +8,7 @@ import { CourseRunEnrollment, CourseWithCourseRuns, V2Program, -} from "api/mitxonline" +} from "@mitodl/mitxonline-api-axios/v1" import { DashboardResourceType, EnrollmentStatus } from "./types" import type { DashboardCourse, DashboardProgram } from "./types" diff --git a/frontends/main/src/app-pages/DashboardPage/DashboardLayout.test.tsx b/frontends/main/src/app-pages/DashboardPage/DashboardLayout.test.tsx index 087f03de8e..c8d45c9244 100644 --- a/frontends/main/src/app-pages/DashboardPage/DashboardLayout.test.tsx +++ b/frontends/main/src/app-pages/DashboardPage/DashboardLayout.test.tsx @@ -5,6 +5,10 @@ import { renderWithProviders, } from "@/test-utils" import { factories, urls } from "api/test-utils" +import { + factories as mitxOnlineFactories, + urls as mitxOnlineUrls, +} from "api/mitxonline-test-utils" import DashboardLayout from "./DashboardLayout" import React from "react" @@ -18,7 +22,7 @@ import { import { faker } from "@faker-js/faker/locale/en" import invariant from "tiny-invariant" import { useFeatureFlagEnabled } from "posthog-js/react" -import { mockOrgData } from "api/mitxonline-hooks/enrollment" +import { OrganizationPage } from "@mitodl/mitxonline-api-axios/v1" jest.mock("posthog-js/react") const mockedUseFeatureFlagEnabled = jest.mocked(useFeatureFlagEnabled) @@ -30,11 +34,19 @@ describe("DashboardLayout", () => { type SetupOptions = { initialUrl?: string + organizations?: OrganizationPage[] } - const setup = ({ initialUrl = DASHBOARD_HOME }: SetupOptions = {}) => { + const setup = ({ + initialUrl = DASHBOARD_HOME, + organizations = [], + }: SetupOptions = {}) => { const user = factories.user.user() + const mitxOnlineUser = mitxOnlineFactories.user.user({ + b2b_organizations: organizations, + }) setMockResponse.get(urls.userMe.get(), user) + setMockResponse.get(mitxOnlineUrls.currentUser.get(), user) renderWithProviders( <DashboardLayout> @@ -43,7 +55,7 @@ describe("DashboardLayout", () => { { url: initialUrl }, ) - return { user } + return { user, mitxOnlineUser } } test("Renders user info", async () => { @@ -52,71 +64,48 @@ describe("DashboardLayout", () => { await screen.findByText(user.profile.name) }) - test.each([ - { - flagEnabled: true, - organizations: [ - // For now, this is mock data matching the hardcoded data in the component - // This should be replaced by faker data when the API is ready - mockOrgData.orgX, - mockOrgData.orgY, - ], - }, - { - flagEnabled: false, - organizations: [], - }, - ])( - "Renders the expected tab links and labels", - async ({ organizations, flagEnabled }) => { - if (flagEnabled) { - expect(organizations).toHaveLength(2) - } else { - expect(organizations).toHaveLength(0) - } - const expectedUrls = [ - DASHBOARD_HOME, - ...organizations.map((org) => organizationView(org.id)), - MY_LISTS, - PROFILE, - SETTINGS, - ] - const expectedLabels = [ - "Home", - ...organizations.map((org) => org.name), - "My Lists", - "Profile", - "Settings", - ] - - mockedUseFeatureFlagEnabled.mockReturnValue(flagEnabled) - const initialUrl = faker.helpers.arrayElement(expectedUrls) - setup({ initialUrl }) - - const desktopNav = await screen.findByTestId("desktop-nav") - const mobileNav = await screen.findByTestId("mobile-nav") - - expect(desktopNav).toHaveRole("navigation") - expect(mobileNav).toHaveRole("navigation") - const desktopTabList = within(desktopNav).getByRole("tablist") - const mobileTabList = within(mobileNav).getByRole("tablist") - - const desktopTabs = within(desktopTabList).getAllByRole("tab") - const mobileTabs = within(mobileTabList).getAllByRole("tab") - - // Check URLs - expect(desktopTabs.map((el) => el.getAttribute("href"))).toEqual( - expectedUrls, - ) - expect(mobileTabs.map((el) => el.getAttribute("href"))).toEqual( - expectedUrls, - ) - - // Check labels - expect(desktopTabs.map((el) => el.textContent)).toEqual(expectedLabels) - expect(mobileTabs.map((el) => el.textContent)).toEqual(expectedLabels) - }, - ) + test("Renders the expected tab links and labels", async () => { + const { mitxOnlineUser } = setup() + const expectedUrls = [ + DASHBOARD_HOME, + ...mitxOnlineUser.b2b_organizations.map((org) => + organizationView(org.id), + ), + MY_LISTS, + PROFILE, + SETTINGS, + ] + const expectedLabels = [ + "Home", + ...mitxOnlineUser.b2b_organizations.map((org) => org.name), + "My Lists", + "Profile", + "Settings", + ] + + const desktopNav = await screen.findByTestId("desktop-nav") + const mobileNav = await screen.findByTestId("mobile-nav") + + expect(desktopNav).toHaveRole("navigation") + expect(mobileNav).toHaveRole("navigation") + const desktopTabList = within(desktopNav).getByRole("tablist") + const mobileTabList = within(mobileNav).getByRole("tablist") + + const desktopTabs = within(desktopTabList).getAllByRole("tab") + const mobileTabs = within(mobileTabList).getAllByRole("tab") + + // Check URLs + expect(desktopTabs.map((el) => el.getAttribute("href"))).toEqual( + expectedUrls, + ) + expect(mobileTabs.map((el) => el.getAttribute("href"))).toEqual( + expectedUrls, + ) + + // Check labels + expect(desktopTabs.map((el) => el.textContent)).toEqual(expectedLabels) + expect(mobileTabs.map((el) => el.textContent)).toEqual(expectedLabels) + }) test("Active tab is set via url", async () => { const urls = [DASHBOARD_HOME, MY_LISTS, PROFILE, SETTINGS] diff --git a/frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx b/frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx index 55cd697cfd..89b7615e9c 100644 --- a/frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx +++ b/frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx @@ -35,9 +35,12 @@ import { } from "@/common/urls" import dynamic from "next/dynamic" import { - UserWithOrgsField, - useUserMeWithMockedOrgs, -} from "./OrganizationContent" + useMitxOnlineCurrentUser, + MitxOnlineUser, +} from "api/mitxonline-hooks/user" +import { useUserMe } from "api/hooks/user" +import { useFeatureFlagEnabled } from "posthog-js/react" +import { FeatureFlags } from "@/common/feature_flags" const LearningResourceDrawer = dynamic( () => @@ -249,8 +252,11 @@ type TabData = { desktop: React.ReactNode } } -const getTabData = (user?: UserWithOrgsField): TabData[] => { - const orgs = user?.organizations ?? [] +const getTabData = ( + orgsEnabled: boolean = false, + user?: MitxOnlineUser, +): TabData[] => { + const orgs = orgsEnabled ? (user?.b2b_organizations ?? []) : [] return [ { value: DASHBOARD_HOME, @@ -301,9 +307,16 @@ const DashboardPage: React.FC<{ children: React.ReactNode }> = ({ children }) => { const pathname = usePathname() - const { isLoading: isLoadingUser, data: user } = useUserMeWithMockedOrgs() - - const tabData = useMemo(() => getTabData(user), [user]) + const { isLoading: isLoadingUser, data: user } = useUserMe() + const { isLoading: isLoadingMitxOnlineUser, data: mitxOnlineUser } = + useMitxOnlineCurrentUser() + const orgsEnabled = useFeatureFlagEnabled(FeatureFlags.OrganizationDashboard) + + const tabData = useMemo( + () => + isLoadingMitxOnlineUser ? [] : getTabData(orgsEnabled, mitxOnlineUser), + [isLoadingMitxOnlineUser, mitxOnlineUser], + ) const tabValue = useMemo(() => { /** diff --git a/frontends/main/src/app-pages/DashboardPage/HomeContent.test.tsx b/frontends/main/src/app-pages/DashboardPage/HomeContent.test.tsx index c700402754..99c5fd7bc7 100644 --- a/frontends/main/src/app-pages/DashboardPage/HomeContent.test.tsx +++ b/frontends/main/src/app-pages/DashboardPage/HomeContent.test.tsx @@ -18,6 +18,7 @@ import * as mitxonline from "api/mitxonline-test-utils" import { useFeatureFlagEnabled } from "posthog-js/react" import HomeContent from "./HomeContent" import invariant from "tiny-invariant" +import { courseEnrollments } from "../../../../api/src/mitxonline/test-utils/factories/enrollment" jest.mock("posthog-js/react") const mockedUseFeatureFlagEnabled = jest @@ -207,14 +208,24 @@ describe("HomeContent", () => { async ({ enrollmentsEnabled }) => { setupAPIs() mockedUseFeatureFlagEnabled.mockReturnValue(enrollmentsEnabled) + if (enrollmentsEnabled) { - setMockResponse.get(mitxonline.urls.enrollment.courseEnrollment(), []) + const enrollments = courseEnrollments(3) + setMockResponse.get( + mitxonline.urls.enrollment.courseEnrollment(), + enrollments, + ) } + renderWithProviders(<HomeContent />) - const enrollmentsHeading = screen.queryByRole("heading", { - name: "My Learning", - }) - expect(!!enrollmentsHeading).toBe(enrollmentsEnabled) + + if (enrollmentsEnabled) { + await screen.findByRole("heading", { name: "My Learning" }) + } else { + expect( + screen.queryByRole("heading", { name: "My Learning" }), + ).not.toBeInTheDocument() + } }, ) }) diff --git a/frontends/main/src/app-pages/DashboardPage/OrganizationContent.test.tsx b/frontends/main/src/app-pages/DashboardPage/OrganizationContent.test.tsx index 530a47c4f1..105203d0ed 100644 --- a/frontends/main/src/app-pages/DashboardPage/OrganizationContent.test.tsx +++ b/frontends/main/src/app-pages/DashboardPage/OrganizationContent.test.tsx @@ -3,7 +3,6 @@ import { renderWithProviders, screen, within } from "@/test-utils" import OrganizationContent from "./OrganizationContent" import { setMockResponse } from "api/test-utils" import { urls, factories } from "api/mitxonline-test-utils" -import { mockOrgData } from "api/mitxonline-hooks/enrollment" import { useFeatureFlagEnabled } from "posthog-js/react" import { mitxonlineCourses, @@ -26,13 +25,13 @@ describe("OrganizationContent", () => { }) it("displays a header for each program returned and cards for courses in program", async () => { - const { orgId, programA, programB, coursesA, coursesB } = + const { orgX, programA, programB, coursesA, coursesB } = setupProgramsAndCourses() - setMockResponse.get(urls.enrollment.courseEnrollment({ orgId }), []) - renderWithProviders(<OrganizationContent orgId={orgId} />) + setMockResponse.get(urls.enrollment.courseEnrollment({}), []) + renderWithProviders(<OrganizationContent orgId={orgX.id} />) await screen.findByRole("heading", { - name: `Your ${mockOrgData.orgX.name} Home`, + name: `Your ${orgX.name} Home`, }) const programs = await screen.findAllByTestId("org-program-root") expect(programs.length).toBe(2) @@ -50,7 +49,7 @@ describe("OrganizationContent", () => { }) test("Shows correct enrollment status", async () => { - const { orgId, programA, coursesA } = setupProgramsAndCourses() + const { orgX, programA, coursesA } = setupProgramsAndCourses() const enrollments = [ makeCourseEnrollment({ run: { course: { id: coursesA[0].id, title: coursesA[0].title } }, @@ -61,11 +60,8 @@ describe("OrganizationContent", () => { grades: [], }), ] - setMockResponse.get( - urls.enrollment.courseEnrollment({ orgId }), - enrollments, - ) - renderWithProviders(<OrganizationContent orgId={orgId} />) + setMockResponse.get(urls.enrollment.courseEnrollment({}), enrollments) + renderWithProviders(<OrganizationContent orgId={orgX.id} />) const [programElA] = await screen.findAllByTestId("org-program-root") const cards = await within(programElA).findAllByTestId( diff --git a/frontends/main/src/app-pages/DashboardPage/OrganizationContent.tsx b/frontends/main/src/app-pages/DashboardPage/OrganizationContent.tsx index e38b621e35..5c9b00dc74 100644 --- a/frontends/main/src/app-pages/DashboardPage/OrganizationContent.tsx +++ b/frontends/main/src/app-pages/DashboardPage/OrganizationContent.tsx @@ -2,49 +2,20 @@ import React from "react" import Image from "next/image" -import { User, useUserMe } from "api/hooks/user" import { useFeatureFlagEnabled } from "posthog-js/react" import { FeatureFlags } from "@/common/feature_flags" -import { useQueries, useQuery, UseQueryResult } from "@tanstack/react-query" +import { useQueries, useQuery } from "@tanstack/react-query" import { programsQueries } from "api/mitxonline-hooks/programs" import { coursesQueries } from "api/mitxonline-hooks/courses" -import { V2Program } from "api/mitxonline" import * as transform from "./CoursewareDisplay/transform" import { enrollmentQueries } from "api/mitxonline-hooks/enrollment" import { DashboardCard } from "./CoursewareDisplay/DashboardCard" import { PlainList, Stack, styled, Typography } from "ol-components" import { DashboardCourse, DashboardProgram } from "./CoursewareDisplay/types" import graduateLogo from "@/public/images/dashboard/graduate.png" - -type Organization = { id: number; name: string; logo?: string } -type UserWithOrgsField = User & { organizations: Organization[] } - -/** - * TEMPORARY MOCKED ORGANIZATIONS - * - * This should be replaced with useUserMe() once the backend is ready. - */ -const useUserMeWithMockedOrgs = (): UseQueryResult< - UserWithOrgsField, - Error -> => { - const query = useUserMe() as UseQueryResult<UserWithOrgsField, Error> - const isOrgDashboardEnabled = useFeatureFlagEnabled( - FeatureFlags.OrganizationDashboard, - ) - if (!query.data) return query - const organizations = isOrgDashboardEnabled - ? [ - { id: 488, name: "Organization X" }, - { - id: 522, - name: "Organization Y", - logo: "https://brand.mit.edu/sites/default/files/styles/tile_narrow/public/2023-08/logo-colors-mit-red.png?itok=k08Ir4pB", - }, - ] - : [] - return { ...query, data: { ...query.data, organizations } } -} +import { OrganizationPage, V2Program } from "@mitodl/mitxonline-api-axios/v1" +import { useMitxOnlineCurrentUser } from "api/mitxonline-hooks/user" +import { organizationQueries } from "api/mitxonline-hooks/organizations" const HeaderRoot = styled.div({ display: "flex", @@ -65,7 +36,7 @@ const ImageContainer = styled.div(({ theme }) => ({ height: "auto", }, })) -const OrganizationHeader: React.FC<{ org: Organization }> = ({ org }) => { +const OrganizationHeader: React.FC<{ org?: OrganizationPage }> = ({ org }) => { return ( <HeaderRoot> <ImageContainer> @@ -77,15 +48,15 @@ const OrganizationHeader: React.FC<{ org: Organization }> = ({ org }) => { // reserving space for the image anyway. Using next/image still gets us // the image optimization, though. height={78} - src={org.logo ?? graduateLogo} + src={org?.logo ?? graduateLogo} alt="" /> </ImageContainer> <Stack gap="8px"> <Typography variant="h3" component="h1"> - Your {org.name} Home + Your {org?.name} Home </Typography> - <Typography variant="body1">MIT courses for {org.name}</Typography> + <Typography variant="body1">MIT courses for {org?.name}</Typography> </Stack> </HeaderRoot> ) @@ -95,13 +66,14 @@ const OrganizationHeader: React.FC<{ org: Organization }> = ({ org }) => { * For an array of programs, fetch the associated courses. * [program1, program2] => [[...courses1], [...courses2]] */ -const useMitxonlineProgramsCourses = (programs: V2Program[]) => { + +const useMitxonlineProgramsCourses = (programs: V2Program[], orgId: number) => { const courseGroupIds = programs.map((program) => program.courses.map((id) => id as number)) ?? [] const courseGroups = useQueries({ queries: courseGroupIds.map((courseIds) => - coursesQueries.coursesList({ id: courseIds }), + coursesQueries.coursesList({ org_id: orgId, id: courseIds }), ), }) @@ -171,14 +143,30 @@ type OrganizationContentProps = { orgId: number } const OrganizationContent: React.FC<OrganizationContentProps> = ({ orgId }) => { - const user = useUserMeWithMockedOrgs() - - const enrollments = useQuery(enrollmentQueries.coursesList({ orgId })) - const programs = useQuery(programsQueries.programsList({ orgId })) + const { isLoading: isLoadingMitxOnlineUser, data: mitxOnlineUser } = + useMitxOnlineCurrentUser() + const isOrgDashboardEnabled = useFeatureFlagEnabled( + FeatureFlags.OrganizationDashboard, + ) + const b2bOrganization = mitxOnlineUser?.b2b_organizations.find( + (org) => org.id === orgId, + ) + const organization = useQuery( + organizationQueries.organizationsRetrieve({ + organization_slug: b2bOrganization?.slug || "", + }), + ) + const enrollments = useQuery(enrollmentQueries.enrollmentsList({})) + const programs = useQuery(programsQueries.programsList({ org_id: orgId })) const courseGroups = useMitxonlineProgramsCourses( programs.data?.results ?? [], + orgId, ) + if (!isOrgDashboardEnabled) return null + if (isLoadingMitxOnlineUser) return "Loading" + if (!b2bOrganization) return "Organization not found" + const transformedCourseGroups = courseGroups.map((courseGroup) => { if (!courseGroup.data || !enrollments.data) return [] return transform.mitxonlineCourses({ @@ -190,14 +178,9 @@ const OrganizationContent: React.FC<OrganizationContentProps> = ({ orgId }) => { transform.mitxonlineProgram(program), ) - if (user.isLoading) return "Loading" - const organization = user.data?.organizations.find((org) => org.id === orgId) - - if (!organization) return null - return ( <OrganizationRoot> - <OrganizationHeader org={organization} /> + <OrganizationHeader org={organization.data} /> {programs.isLoading ? "Programs Loading" : transformedPrograms?.map((program, index) => { @@ -220,7 +203,3 @@ const OrganizationContent: React.FC<OrganizationContentProps> = ({ orgId }) => { export default OrganizationContent export type { OrganizationContentProps } - -// To be removed -export { useUserMeWithMockedOrgs } -export type { Organization, UserWithOrgsField } diff --git a/yarn.lock b/yarn.lock index c2fd429e3f..6c92ba7dd5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2712,6 +2712,16 @@ __metadata: languageName: node linkType: hard +"@mitodl/mitxonline-api-axios@npm:^2025.6.3": + version: 2025.6.3 + resolution: "@mitodl/mitxonline-api-axios@npm:2025.6.3" + dependencies: + "@types/node": "npm:^20.11.19" + axios: "npm:^1.6.5" + checksum: 10/8619c9e4775a2d5d4467bfd5d6c64dc4c1c302ef81bca36a489369fe9e970f2d3029880024fb7bc8b66ee8de6cc63ff4b33818d8ced9772d137a0759b0467832 + languageName: node + linkType: hard + "@mitodl/open-api-axios@npm:2024.9.16": version: 2024.9.16 resolution: "@mitodl/open-api-axios@npm:2024.9.16" @@ -6938,6 +6948,7 @@ __metadata: resolution: "api@workspace:frontends/api" dependencies: "@faker-js/faker": "npm:^9.0.0" + "@mitodl/mitxonline-api-axios": "npm:^2025.6.3" "@tanstack/react-query": "npm:^5.66.0" "@testing-library/react": "npm:^16.1.0" axios: "npm:^1.6.3" @@ -13338,6 +13349,7 @@ __metadata: "@emotion/styled": "npm:^11.11.0" "@faker-js/faker": "npm:^9.0.0" "@mitodl/course-search-utils": "npm:3.3.2" + "@mitodl/mitxonline-api-axios": "npm:^2025.6.3" "@mitodl/smoot-design": "npm:^6.6.1" "@next/bundle-analyzer": "npm:^14.2.15" "@remixicon/react": "npm:^4.2.0"