fluminus v1.4.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 information about the current term.
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 Types
Link to this section Functions
api(authorization, path, method \\ :get, body \\ "", headers \\ [])
View SourceMakes 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 Sourcecurrent_term(Fluminus.Authorization.t()) :: {:ok, %{term: String.t(), description: String.t()}} | {:error, any()}
Returns information about the current term.
Examples
iex> Fluminus.API.current_term(auth)
%{term: "1820", description: "2018/2019 Semester 2"}
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)
{:ok,
[
%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)
{:ok,
[
%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 Sourcename(Fluminus.Authorization.t()) :: {:ok, String.t()} | {:error, any()}
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"