Skip to content

Commit

Permalink
feat: rewrite GetEvents, improve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ketronix-dev committed Mar 20, 2024
1 parent 5fac9e6 commit ac468ef
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 5 deletions.
10 changes: 8 additions & 2 deletions Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ public static class Cist
}
}

public static List<Event>? GetEvents(long startTime, long endTime, EventType type, long id)
public static List<Event>? GetEvents( EventType type, long id, long startTime = 0, long endTime = 0)
{
var json = JsonFixers.TryFix(Requests.GetEventsJson(type, id));
return NureParser.ParseEvents(json);
if(startTime == 0 && endTime == 0)
return NureParser.ParseEvents(json);
else
{
var events = NureParser.ParseEvents(json);
return events.Where(e => e.StartTime >= startTime && e.EndTime <= endTime).ToList();
}
}
}
4 changes: 2 additions & 2 deletions Nure.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<PackageProjectUrl>https://api.mindenit.tech</PackageProjectUrl>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<RepositoryUrl>https://github.com/mindenit/Nure.NET</RepositoryUrl>
<ApplicationVersion>0.8.3</ApplicationVersion>
<Version>0.8.3</Version>
<ApplicationVersion>0.8.4</ApplicationVersion>
<Version>0.8.4</Version>
</PropertyGroup>

</Project>
115 changes: 114 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,118 @@
# Nure.NET

.NET library for work with cist.nure.ua
.NET library for work with cist.nure.ua. That library allows you to get information about schedule, teachers, groups, and other information from the site cist.nure.ua.

> **Note:** This library is not official and is not supported by the site cist.nure.ua.
> **But**, it is supported by students and Mindenit Team :)
Below you will find a short guide to using this library.

---
### Links:
[NuGet](https://www.nuget.org/packages/Nure.NET/)

---
### Installation:
You can install this library via Nuget Package Manager, or via .NET CLI:
```bash
dotnet add package Nure.NET
```

### Usage:
Get teachers list:
```csharp
using Nure.NET;
using Nure.NET.Types;

class Program
{
static void Main()
{
var teachers = Cist.GetTeachers();

foreach (var teacher in teachers)
{
Console.WriteLine(teacher.FullName);
}
}
}
```
Get groups list:
```csharp
using Nure.NET;
using Nure.NET.Types;

class Program
{
static void Main()
{
var groups = Cist.GetGroups();

foreach (var group in groups)
{
Console.WriteLine(group.Name);
}
}
}
```
Get auditories list:
```csharp
using Nure.NET;
using Nure.NET.Types;

class Program
{
static void Main()
{
var auditories = Cist.GetAuditories();

foreach (var auditory in auditories)
{
Console.WriteLine(auditory.Name);
}
}
}
```
Get schedule for group or other entity:
```csharp
using Nure.NET;
using Nure.NET.Types;

class Program
{
static void Main()
{
/* Get schedule for group "КІУКІ-22-7", for other entities use EntityType enum
* EntityType.Group - for groups
* EntityType.Teacher - for teachers
* EntityType.Auditory - for auditories
Default, if you don't specify startTime and endTime, method will return
all avilable lessons for that group.
*/
var schedule = Cist.GetEvents(10304333, EntityType.Group);

foreach (var lesson in schedule)
{
Console.WriteLine(lesson);
}
}
}
```
Get schedule for group with specified time:
```csharp
using Nure.NET;
using Nure.NET.Types;

class Program
{
static void Main()
{
var events = Cist.GetEvents(EventType.Group, 10304333, 1693170000, 1694811599);

foreach (var item in events)
{
Console.WriteLine(item.Subject.Title);
}
}
}
```

0 comments on commit ac468ef

Please sign in to comment.