Skip to content

Commit

Permalink
Merge pull request #14 from OneLiL05/feature
Browse files Browse the repository at this point in the history
release: 0.2.3
  • Loading branch information
OneLiL05 authored Oct 2, 2023
2 parents 88f1d58 + f2947ac commit 6dbdaab
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/nurekit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nurejs/api",
"description": "Node.js client for Nure API",
"version": "0.2.2",
"version": "0.2.3",
"keywords": [
"api",
"nure",
Expand Down
12 changes: 8 additions & 4 deletions packages/nurekit/src/adapters/timestamp.adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { toTimestamp } from "../helpers/date.helper.js";

interface ConvertParams {
startTime: string;
endTime: string;
Expand All @@ -13,8 +11,14 @@ interface IConvertedTime {
export class TimestampAdapter {
public convert({ startTime, endTime }: ConvertParams): IConvertedTime {
return {
startTimestamp: toTimestamp(startTime),
endTimestamp: toTimestamp(endTime),
startTimestamp: this.#toTimestamp(startTime),
endTimestamp: this.#toTimestamp(endTime),
};
}

#toTimestamp(date: string) {
const parsedDate = Date.parse(date);

return parsedDate / 1000;
}
}
5 changes: 0 additions & 5 deletions packages/nurekit/src/helpers/date.helper.ts

This file was deleted.

17 changes: 10 additions & 7 deletions packages/nurekit/src/helpers/schedule.helper.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { IRawSchedule, ISchedule } from "../index.js";
import { IRawSchedule, ISchedule } from "../types/index.js";
import { transformTeachers } from "./teachers.helper.js";

export function transformSchedule(rawSchedule: IRawSchedule[]): ISchedule[] {
return rawSchedule.map((rawSchedule) => {
const { end_time, start_time, teachers, number_pair, auditory, ...rest } =
rawSchedule;
const transformedSchedule: ISchedule[] = [];

return {
for (let subject of rawSchedule) {
const { end_time, start_time, teachers, number_pair, auditory, ...rest } = subject;

transformedSchedule.push({
...rest,
endTime: end_time,
startTime: start_time,
teachers: transformTeachers(teachers),
numberPair: number_pair,
auditorium: auditory,
};
});
});
}

return transformedSchedule;
}
12 changes: 8 additions & 4 deletions packages/nurekit/src/helpers/teachers.helper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { IRawTeacher, ITeacher } from "../types/index.js";

function transformTeachers(rawTeachers: IRawTeacher[]): ITeacher[] {
return rawTeachers.map((teacher) => {
return {
const transformedTeachers: ITeacher[] = []

for (let teacher of rawTeachers) {
transformedTeachers.push({
id: teacher.id,
fullName: teacher.full_name,
shortName: teacher.short_name,
};
});
})
}

return transformedTeachers;
}

export { transformTeachers };
12 changes: 11 additions & 1 deletion packages/nurekit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
import { Nurekit } from "./client.js";

export * from "./client.js";
export * from "./types/index.js";
export { IAuditorium, IGroup, ISchedule, ISubject, ITeacher } from "./types/index.js";

const nurekit = new Nurekit()

console.log(await nurekit.groups.getSchedule({
groupName: "пзпі-23-5",
startTime: "2023-09-22",
endTime: "2023-09-23"
}))
2 changes: 1 addition & 1 deletion packages/nurekit/src/modules/groups.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TimestampAdapter } from "../adapters/timestamp.adapter.js";
import { handleAxiosError } from "../helpers/axios.helper.js";
import { transformSchedule } from "../helpers/schedule.helper.js";
import { IGroup, IRawSchedule, ISchedule } from "../index.js";
import { IGroup, IRawSchedule, ISchedule } from "../types/index.js";
import { axiosClient } from "../libs/axios.js";

interface GetScheduleParams {
Expand Down
1 change: 1 addition & 0 deletions packages/nurekit/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outDir": "dist",
"strict": true,
"strictNullChecks": true,
"skipLibCheck": true
},
"include": ["src"]
}

0 comments on commit 6dbdaab

Please sign in to comment.