You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
organizer-fetch-client/api.ts

514 lines
16 KiB

/**
* Organizer
* Dies ist eine API, die es ermöglicht Daten zu Stunden-, Vertretungs-, oder Klausurplänen zu erhalten.
*
* OpenAPI spec version: 1.0.0
* Contact: info@jonasfranz.software
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import * as querystring from "querystring";
import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign";
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
const BASE_PATH = "http://api.organizer.martin-luther.schule/v1".replace(/\/+$/, "");
export interface FetchArgs {
url: string;
options: any;
}
export class BaseAPI {
basePath: string;
fetch: FetchAPI;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) {
this.basePath = basePath;
this.fetch = fetch;
}
};
export interface Exam {
"id"?: number;
"date"?: Date;
/**
* The period of the day where the exam starts
*/
"startPeriod"?: number;
/**
* The period of the day where the exam ends
*/
"endPeriod"?: number;
"lesson"?: Lesson;
}
export interface Lesson {
"weekday"?: number;
/**
* The period of the day where the lesson is
*/
"period"?: number;
/**
* Class or Course
*/
"course"?: string;
"subject"?: Subject;
"teacher"?: Teacher;
/**
* An additional information like 'Every 14 days only'
*/
"additionalInformation"?: string;
"room"?: string;
}
export interface ReplacementLesson {
"id"?: number;
"date"?: Date;
"lesson"?: Lesson;
"replacementLesson"?: Lesson;
}
export interface Subject {
/**
* The abbreviation of the subject like LB for sports.
*/
"abbreviation"?: string;
"name"?: string;
}
export interface Teacher {
/**
* An unique string that is mostly the abbreviation of the teacher's name
*/
"identifier"?: string;
/**
* The family name of the teacher
*/
"name"?: string;
}
/**
* ExaminationSchedulingApi - fetch parameter creator
*/
export const ExaminationSchedulingApiFetchParamCreator = {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getExams");
}
const baseUrl = `/course/{course}/exams`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* ExaminationSchedulingApi - functional programming interface
*/
export const ExaminationSchedulingApiFp = {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<Exam>> {
const fetchArgs = ExaminationSchedulingApiFetchParamCreator.getExams(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* ExaminationSchedulingApi - object-oriented interface
*/
export class ExaminationSchedulingApi extends BaseAPI {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any) {
return ExaminationSchedulingApiFp.getExams(params, options)(this.fetch, this.basePath);
}
};
/**
* ExaminationSchedulingApi - factory interface
*/
export const ExaminationSchedulingApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Returns course's exams
* @param course
*/
getExams(params: { "course": string; }, options?: any) {
return ExaminationSchedulingApiFp.getExams(params, options)(fetch, basePath);
},
};
};
/**
* ReplacementLessonsApi - fetch parameter creator
*/
export const ReplacementLessonsApiFetchParamCreator = {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any): FetchArgs {
const baseUrl = `/replacement/findAll`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any): FetchArgs {
// verify required parameter "date" is set
if (params["date"] == null) {
throw new Error("Missing required parameter date when calling findReplacementLessonsByDate");
}
const baseUrl = `/replacement/findByDate`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
"date": params["date"],
});
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any): FetchArgs {
// verify required parameter "id" is set
if (params["id"] == null) {
throw new Error("Missing required parameter id when calling getReplacement");
}
const baseUrl = `/replacement/{id}`
.replace(`{${"id"}}`, `${ params["id"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getReplacementByCourse");
}
const baseUrl = `/course/{course}/replacements`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* ReplacementLessonsApi - functional programming interface
*/
export const ReplacementLessonsApiFp = {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.findReplacementLessons(options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.findReplacementLessonsByDate(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<ReplacementLesson> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.getReplacement(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<ReplacementLesson>> {
const fetchArgs = ReplacementLessonsApiFetchParamCreator.getReplacementByCourse(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* ReplacementLessonsApi - object-oriented interface
*/
export class ReplacementLessonsApi extends BaseAPI {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any) {
return ReplacementLessonsApiFp.findReplacementLessons(options)(this.fetch, this.basePath);
}
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any) {
return ReplacementLessonsApiFp.findReplacementLessonsByDate(params, options)(this.fetch, this.basePath);
}
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any) {
return ReplacementLessonsApiFp.getReplacement(params, options)(this.fetch, this.basePath);
}
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any) {
return ReplacementLessonsApiFp.getReplacementByCourse(params, options)(this.fetch, this.basePath);
}
};
/**
* ReplacementLessonsApi - factory interface
*/
export const ReplacementLessonsApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Finds all available replacement lessons
*/
findReplacementLessons(options?: any) {
return ReplacementLessonsApiFp.findReplacementLessons(options)(fetch, basePath);
},
/**
*
* @summary Finds replacement lessons by date
* @param date Date of the searched replacement lessons
*/
findReplacementLessonsByDate(params: { "date": Date; }, options?: any) {
return ReplacementLessonsApiFp.findReplacementLessonsByDate(params, options)(fetch, basePath);
},
/**
*
* @summary Get replacement lesson by id
* @param id Replacement lesson&#39;s id
*/
getReplacement(params: { "id": number; }, options?: any) {
return ReplacementLessonsApiFp.getReplacement(params, options)(fetch, basePath);
},
/**
*
* @summary Get replacement lesson of a course/class
* @param course
*/
getReplacementByCourse(params: { "course": string; }, options?: any) {
return ReplacementLessonsApiFp.getReplacementByCourse(params, options)(fetch, basePath);
},
};
};
/**
* TimetableApi - fetch parameter creator
*/
export const TimetableApiFetchParamCreator = {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any): FetchArgs {
// verify required parameter "course" is set
if (params["course"] == null) {
throw new Error("Missing required parameter course when calling getTimetable");
}
const baseUrl = `/course/{course}/timetable`
.replace(`{${"course"}}`, `${ params["course"] }`);
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = assign({}, { method: "GET" }, options);
let contentTypeHeader: Dictionary<string> = {};
if (contentTypeHeader) {
fetchOptions.headers = assign({}, contentTypeHeader, fetchOptions.headers);
}
return {
url: url.format(urlObj),
options: fetchOptions,
};
},
};
/**
* TimetableApi - functional programming interface
*/
export const TimetableApiFp = {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Array<Lesson>> {
const fetchArgs = TimetableApiFetchParamCreator.getTimetable(params, options);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json();
} else {
throw response;
}
});
};
},
};
/**
* TimetableApi - object-oriented interface
*/
export class TimetableApi extends BaseAPI {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any) {
return TimetableApiFp.getTimetable(params, options)(this.fetch, this.basePath);
}
};
/**
* TimetableApi - factory interface
*/
export const TimetableApiFactory = function (fetch?: FetchAPI, basePath?: string) {
return {
/**
*
* @summary Returns course's timetable
* @param course
*/
getTimetable(params: { "course": string; }, options?: any) {
return TimetableApiFp.getTimetable(params, options)(fetch, basePath);
},
};
};