ApplETS / ETS-API-Clients

The API clients that are used across our apps. It can be used to access SignetsAPI and MonETSAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coverage

A dart package to be able to handle all API calls from a main source. The code in this package was initially written by apomalyn inside our main project Notre-Dame. It was then ported to pub package by MysticFragilist.

This package is also a way of standardizing the models used across all projects that needs an access to SignETS API.

Also, it's now possible to use null safety on models and functions from this package. It's a good start in implementing null safety without refactoring all existing code 😄

Features

With this package you can call specific method from multiple sources:

MonETSAPI:

  • authenticate({String username, String password})

SignetsAPI:

  • authenticate({String username, String password})
  • getCoursesActivities({String username, String password, String session = "", String courseGroup = "", DateTime startDate, DateTime endDate})
  • getScheduleActivities({String username, String password, String session = ""})
  • getCourses({String username, String password})
  • getCourseSummary({String username, String password, Course course})
  • getStudentInfo({String username, String password})
  • getStudentInfo({String username, String password})
  • getPrograms({String username, String password})
  • getCourseReviews({String username, String password, Session session})

Getting started

To start using this package, it's as simple as to import the package in your pubspec.yaml file using the git tg of the desired version:

dependencies:
  ...
  ets_api_clients: 
    git:
      url: https://github.com/ApplETS/ETS-API-Clients.git
      ref: 1.0.0

Usage

To use this library you can create an instance of the SignetsApiClient class. You will first need to import the clients file from the package. Then, call any function that you wish to use.

import 'package:signets_api_client/clients.dart';

  // ...
  
  final programs = await SignetsAPIClient().getPrograms(username: "user", password: "pwd");
  final monEtsUser = await MonETSAPIClient().getPrograms(username: "user", password: "pwd");

Or using getIt:

  locator.registerLazySingleton(() => SignetsAPIClient());
  
  // from anywhere in your code (and easily mockable)
  
  locator<SignetsAPIClient>().getStudentInfo(username: "user", password: "pwd");

To import models or exceptions used in this package you can use these simples imports:

import 'package:signets_api_client/models.dart';
import 'package:signets_api_client/exceptions.dart';

Mock

Mocks are provided by this package for each client if you import:

import 'package:signets_api_client/testing.dart';

SignetsAPIClientMock.stubGetCourseSummary(mock, "username", course,
      summaryToReturn: mySummary);

You can use the static class to stub any function present in the Features section of this doc. Couples of things to know:

  • The password is anyNamed which means it could be any password passed as parameter to stub this entry.
  • You can also stub Exception:
SignetsAPIClientMock.stubGetCourseSummaryException(mock, "username", course,
      exceptionToThrow: MyException("An exception occurs while accessing get course summary"));

Additional information

This package is the property of App|ETS, an ÉTS club. It is licensed under the Apache 2.0.

About

The API clients that are used across our apps. It can be used to access SignetsAPI and MonETSAPI

License:Apache License 2.0


Languages

Language:Dart 100.0%