luminus_api 0.2.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 47

A library for Dart developers who's in need of LumiNUS API.

Created from templates made available by Stagehand under a BSD-style license.

Usage #

A simple usage example:

import 'package:luminus_api/luminus_api.dart';
import 'package:dotenv/dotenv.dart' show load, env;

main(List<String> args) async {
  // Remember to load the env var for the main() of your own application!
  load();
  Future<Authentication> auth = Future.delayed(
      Duration(seconds: 3),
      () => Authentication(
          password: env['LUMINUS_PASSWORD'],
          username: env['LUMINUS_USERNAME']));
  var modules = await API.getModules(auth);
  for (Module mod in modules) {
    print(mod.courseName);
    print(mod.id);
    print(await API.getAnnouncements(auth, mod));
    var dirs = await API.getModuleDirectories(auth, mod);
    for (var dir in dirs) {
      var items = await API.getItemsFromDirectory(auth, dir);
      print(items);
      for (var item in items) {
        if (item is File) {
          print(await API.getDownloadUrl(auth, item));
        }
      }
    }
  }
  print(await API.getProfile(auth));
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.1.1 #

  • Initial version.

0.1.2 #

  • Update sample code.

0.1.3 #

  • Cache JWT (no expiry check though)
  • Update API link

0.1.4 #

  • Fixed a serious problem =)

0.1.5 #

  • Now all the provided APIs work properly =)

0.1.6 #

  • Hide files that are necessary and exported inside luminus_api.dart
  • Fixed the dependency issue.
  • Added documentation for luminus_api.dart, which is the entry of this package.
  • Implemented automatic management of JWT renewal as long as you stick to the same Authentication objected created.

0.1.7 #

  • Downgraded dependecy requirement of meta
  • Removed unnecessary imports.
  • Made the package description longer so that pub.dev doesn't complain.

0.1.8 #

  • Maybe LumiNUS internally has a shorter token expiry time, I manually set the _jwtExpiresIn as 10 minutes and _refreshTokenExpiresIn as an hour. Please send an issue if this doesn't solve your problem.
  • Provide exceptions for API call HTTP exceptions (as specified in LumiNUS API documentation).
  • Add timeouts for HTTP requests.
  • Add methods for enforced re-authentication: forcedRefresh method in Authorization.

0.1.9 #

  • Overriden == for data abstractions to resolve this issue.

0.1.10 - 0.1.15 #

  • Support FutureOr
  • Throw AuthorizationException when something goes wrong in _getJwt
  • Added RestartAuthException to deal with weird LumiNUS behavior
  • Overrode hashCode for File class

0.1.16-0.1.18 #

  • Support for notifictaions
  • Provide WrongCredentialsException
  • 10x timeout threshold

0.2.0-0.2.3 #

  • Support for new ADFS auth channel
  • Fixed a minor bug.
  • Hardcoded a shorter token refresh time

example/luminus_api_example.dart

import 'package:luminus_api/luminus_api.dart';
import 'package:dotenv/dotenv.dart' show load, env;
// import 'dart:io' as io;

main(List<String> args) async {
  // Remember to load the env var for the main() of your own application!
  load();
  var auth = Authentication(
      password: env['LUMINUS_PASSWORD'], username: env['LUMINUS_USERNAME']);
  var modules = await API.getModules(auth);
  for (Module mod in modules) {
    print(mod.courseName);
    print(mod.id);
    print(await API.getAnnouncements(auth, mod));
    var dirs = await API.getModuleDirectories(auth, mod);
    for (var dir in dirs) {
      var items = await API.getItemsFromDirectory(auth, dir);
      print(items);
      for (var item in items) {
        if (item is File) {
          print(await API.getDownloadUrl(auth, item));
        }
      }
    }
  }
  print(await API.getProfile(auth));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  luminus_api: ^0.2.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:luminus_api/luminus_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

We analyzed this package on Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:luminus_api/luminus_api.dart with components: io.

Health suggestions

Fix lib/src/authorization.dart. (-1.99 points)

Analysis of lib/src/authorization.dart reported 4 hints:

line 170 col 25: The declaration '_renewJwt' isn't referenced.

line 183 col 15: The declaration '_isCookieExpired' isn't referenced.

line 190 col 15: The declaration '_isJwtExpired' isn't referenced.

line 211 col 31: The declaration '_getAuthLoginInfo' isn't referenced.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (dio).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
convert ^2.1.1 2.1.1
cookie_jar ^1.0.0 1.0.1
dio ^2.1.3 2.2.2 3.0.4
html ^0.14.0+2 0.14.0+3
http ^0.12.0+2 0.12.0+2
meta ^1.1.6 1.1.8
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
csslib 0.16.1
http_parser 3.1.3
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
dotenv ^1.0.0
pedantic ^1.0.0 1.8.0+1
test ^1.0.0