fluminus v0.1.3 Fluminus.API View Source
Provides an abstraction over the LumiNUS API.
This module is dependent on Fluminus.Authorization
to authorize to the LumiNUS servers.
Link to this section Summary
Functions
Makes a LumiNUS API call with a given authorization, and then parses the JSON response
Returns a tuple of {current_term, human_readable_term_description}
Returns the modules that the user with the given authorization is taking
Returns the name of the user with the given authorization
Link to this section Functions
api(auth, path, method \\ :get, body \\ "", headers \\ %{}) View Source
Makes a LumiNUS API call with a given authorization, and then parses the JSON response.
Examples
iex> Fluminus.API.api(authorization, "/user/Profile")
{:ok,
%{
"displayPhoto" => true,
"email" => "e0123456@u.nus.edu",
"expireDate" => "2018-03-10T01:23:45.67+08:00",
"id" => "01234567-1c23-5abc-def1-2345ad7efcd2",
"nickName" => "",
"officialEmail" => "",
"userID" => "e0123456",
"userNameOriginal" => "JOHN SMITH"
}}
current_term(auth)
View Source
current_term(Fluminus.Authorization.t()) :: {String.t(), String.t()}
current_term(Fluminus.Authorization.t()) :: {String.t(), String.t()}
Returns a tuple of {current_term, human_readable_term_description}.
Examples
iex> Fluminus.API.current_term(auth)
{"1820", "2018/2019 Semester 2"}
modules(auth, current_term_only \\ false) View Source
Returns the modules that the user with the given authorization is taking.
current_term_only
- iftrue
, will only return modules that the user is currently taking this semester. Otherwise, return all modules that are still in the LumiNUS system.
Examples
iex> Fluminus.API.modules(auth)
[
%Fluminus.API.Module{
code: "CS2100",
id: "063773a9-43ac-4dc0-bdc6-4be2f5b50300",
name: "Computer Organisation",
teaching?: true,
term: "1820"
},
%Fluminus.API.Module{
code: "ST2334",
id: "40582141-1a1d-41b6-ba3a-efa44ff7fd05",
name: "Probability and Statistics",
teaching?: false,
term: "1820"
},
%Fluminus.API.Module{
code: "CS1101S",
id: "8722e9a5-abc5-4160-820d-bf69d8a63c6f",
name: "Programming Methodology",
teaching?: true,
term: "1810"
}
]
iex> Fluminus.API.modules(auth, true)
[
%Fluminus.API.Module{
code: "CS2100",
id: "063773a9-43ac-4dc0-bdc6-4be2f5b50300",
name: "Computer Organisation",
teaching?: true,
term: "1820"
},
%Fluminus.API.Module{
code: "ST2334",
id: "40582141-1a1d-41b6-ba3a-efa44ff7fd05",
name: "Probability and Statistics",
teaching?: false,
term: "1820"
}
]
name(auth)
View Source
name(Fluminus.Authorization.t()) :: String.t()
name(Fluminus.Authorization.t()) :: String.t()
Returns the name of the user with the given authorization.
The LumiNUS API returns the name of the user all capitalised, but this function normalises the capitalisation to Title Case.
Examples
iex> Fluminus.API.name(auth)
"John Smith"