3.1.0 • Published 4 years ago

ggtu-timetable-api-client v3.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

GGTU Timetable API Client

This library is meat to be used as an API client for GGTU Timetable API. You don't need any authorization to use read-only methods, because the data they provide is publicly accessible.

Installation

$ npm i  

Usage

import ApiClient from 'ggtu-timetable-api-client';
const config = {
    baseURL: '<api_url_here>',
}
const api = new ApiClient(config);
// use the api

Endpoints

All entrypoints extend from the Endpoint template class except the AuthEndpoint.

  • getAll;
  • create;
  • get;
  • update;
  • delete.
declare class Endpoint<T> {
    protected axios: AxiosInstance;
    protected route: string;
    constructor(axios: AxiosInstance, route: string);
    getAll(): Promise<WithId<T>[]>;
    get(id: number): Promise<WithId<T>>;
    delete(id: number): Promise<number>;
    update(id: number, data: Partial<T>): Promise<WithId<T>>;
    create(data: T): Promise<WithId<T>>;
}

Auth

declare class AuthEndpoint {
    private _api;
    protected route: string;
    protected accessToken: string;
    protected refreshToken: string;
    user: User | null; 
    constructor(_api: AxiosInstance);
    login(username: string, password: string): Promise<string>;
    logout(): void;
    getProfile(): Promise<User>; 
    refresh(): Promise<void>;
    private setCredentials;
}

Also, there is a TimetableEndpoint class which is extended by RegularTimetableEndpoint and PatchesEndpoint.

declare class TimetableEndpoint<T> extends Endpoint<T> {
    getForCabinet(cabinetId: number): Promise<T[]>;
    getForCabinetByWeek(cabinetId: number, week: Week): Promise<T[]>;
    getForGroup(groupId: number): Promise<T[]>;
    getForGroupByWeek(groupId: number, week: Week): Promise<T[]>;
    getForSubject(subjectId: number): Promise<T[]>;
    getForSubjectByWeek(subjectId: number, week: Week): Promise<T[]>;
    getForTeacher(teacherId: number): Promise<T[]>;
    getForTeacherByWeek(teacherId: number, week: Week): Promise<T[]>;
}
3.1.0

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.0

4 years ago