This package is a wrapper for the MyGES api written in Swift, it can be used in Swift and SwiftUI.
Using MyGes
Api is as easy as:
import MyGes
MyGes.credentials = Credentials(username: "myges_username", password: "myges_password")
MyGes.getAbsences { result in
print(result)
}
So you basically import the module where you want ot use it and and all the calls to the API are async so there is a completion handler.
The following aspects of MyGes
Api can be used:
func MyGes.login()
Can be used to chain calls to a login call creating an short-life token used to make requests.
(not necessary for any requests in the wrapper)
_ credentials
(Optional) : Option to change the saved credentials for any requests at wrapper-level - Credentials
.saveCredentials
(Optional) : Option to save the credentials in UserDefaults for later use. Bool
- defaults to falseMyGes.APIError?
) - In case of success, nil
is returned, if any error is raised during the login process, an APIError
will be returned.func MyGes.getYears()
Can be used to get all years spent in the school for a student.
[Int]?
) - In case of success an array of years [Int]
is returned, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getLastYear()
Can be used to get the last year the student spent in school.
Int?
) - In case of success, the last year as an Int
is returned, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getProfile()
Can be used to get the profile of a student.
ProfileItem?
) - In case of success, the profile of the student is returned as a ProfileItem
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getAgenda()
Can be used to get the courses times, rooms, etc... of a student in a specific time period.
startDate
: The start of the period to search for courses, as a Date
object.endDate
: The end of the period to search for courses, as a Date
object.[AgendaItem]?
) - In case of success, an array of courses is returned as a [AgendaItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getAbsences()
Can be used to get the absences of a student over an entire year.
year
(optional) : A specific year can be used to override default behavior using the last year spent in school by the student - Int
, defaults to nil
[AbsenceItem]?
) - In case of success, an array of absences is returned as a [AbsenceItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getGrades()
Can be used to get the grades of a student over an entire year.
year
(optional) : A specific year can be used to override default behavior using the last year spent in school by the student - Int
, defaults to nil
[GradeItem]?
) - In case of success, an array of grades is returned as a [GradeItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getCourses()
Can be used to get the courses dispensed to a student over an entire year.
year
(optional) : A specific year can be used to override default behavior using the last year spent in school by the student - Int
, defaults to nil
[CourseItem]?
) - In case of success, an array of courses is returned as a [CourseItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getProjects()
Can be used to get all of a student projects over an entire year.
year
(optional) : A specific year can be used to override default behavior using the last year spent in school by the student - Int
, defaults to nil
[ProjectItem]?
) - In case of success, an array of projects is returned as a [ProjectItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getProject()
Can be used to get a specific project for a student.
id
: The id of the searched project as an Int
ProjectItem?
) - In case of success, a project is returned as a ProjectItem
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.getNextProjectSteps()
Can be used to get the upcoming project steps of a student.
[ProjectStepItem]?
) - In case of success, student's upcoming steps are returned as a [ProjectStepItem]
, in any case of error due to network, login, or api issue, nil
is returned.func MyGes.joinProjectGroup()
Can be used to join a group in a specific project.
_ projectRcId
: The project_rc_id
of the project as an Int
_ projectId
: The project_id
of the project as an Int
_ projectGroupId
: The project_group_id
of the searched group as an Int
Bool
) - Returns true
if successful, false
if errored or failed.func MyGes.leaveProjectGroup()
Can be used to leave a group in a specific project.
_ projectRcId
: The project_rc_id
of the project as an Int
_ projectId
: The project_id
of the project as an Int
_ projectGroupId
: The project_group_id
of the searched group as an Int
Bool
) - Returns true
if successful, false
if errored or failed.func MyGes.getProfilePicLink()
Can be used to get the profile picture link of a student.
String?
) - In case of success, link is returned as a String
, if errored or failed, nil
is returnedMyGes
API wrapper is available using the Swift Package Manager:
Using Xcode 11, go to File -> Swift Packages -> Add Package Dependency
and enter https://github.com/AdrienRoux/MyGes-Swift-Api
If you are using Package.swift
, you can also add MyGes
as a dependency easily.
let package = Package(
name: "TestProject",
dependencies: [
.package(url: "https://github.com/AdrienRoux/MyGes-Swift-Api", from: "1.0.0")
],
targets: [
.target(name: "TestProject", dependencies: ["MyGes"])
]
)
If you find a bug, or would like to suggest a new feature or enhancement, it'd be nice if you could search the issue tracker first; while we don't mind duplicates, keeping issues unique helps us save time and considates effort. If you can't find your issue, feel free to file a new one.
This project is licensed under the MIT License - see the LICENSE file for details
link |
Stars: 0 |
Last commit: 1 year ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics