ic-portal
This module aims to provide a unified interface for interacting with administration panels designed by I&C Digital for college events, deployed for use at third-level institutions in Ireland.
Current functoinality is event retrieval.
Installation
npm install ic-portal --save
Supported Sources/Functionality
- UCC Societies
- Events calendar
Basic Usage
This example grabs all events running in the next week, hosted by any society at University College, Cork.
First, we create a new Portal
object.
const Portal = const portal = "ucc-societies"
This object represents the administration panel used by organisations/hosts within the named institution, and allows us to retrieve and send data.
Let's get a list of events run by any society, from the current date and up to seven days in the future:
let start = Datelet end = let events try events = await portaleventsallstart end catch e console
If all goes well, we should have a list of all the events that societies are hosting in the next week!
Let's see what the first event might look like:
console
If we want to grab a list of events hosted by a specific group, we can specify that too:
try events = await portalevents catch e console
Or multiple:
try events = await portalevents catch e console
API
Terminology used:
- "host" means the society, club, or other organisation that is hosting a particular event.
Portal(endpoint)
Represents an endpoint/portal of a particular institution where data can be obtained.
endpoint
is one ofucc-societies
.
const Portal = const portal = "ucc-societies"
.events
Reference to an Events
object.
Events(portal)
An interface to interact with the events calendar. Not intended for instantiation outside of this module's source code; one of these objects will be created for you when you create a Portal
object.
.all(start, end, extended=true)
Obtains events from all hosts within the institution. Returns an array of Event
objects.
start
is aDate
object of when to start searching for events.end
is aDate
object of when to stop searching for events.extended
attempts to obtain as much information about each event.
Warning: Please set extended
to false
if the date range is high (e.g. >7 days). In order to grab extended information, this function makes an additional HTTP request for every event.
.byHost(host, start, end, extended=true)
Obtains events from a specified host within the institution. Returns an array of Event
objects.
host
is either aString
,Integer
, orArray
representing host(s) to search.start
is aDate
object of when to start searching for events.end
is aDate
object of when to stop searching for events.extended
attempts to obtain as much information about each event.
If host
is a string, this function will return the events for the first host name that contains host
as a substring.
If host
is an integer, this function will use host
as the exact ID and return events matching it.
If host
is an array, this function will treat each element as representing a host (either a string or integer), and will include them all in the search.
Warning: Please set extended
to false
if the date range is high (e.g. >7 days). In order to grab extended information, this function makes an additional HTTP request for every event.
.byHosts(...args)
Same as .byHost()
.
.hosts(refresh=false)
Grabs a list of possible event hosts, and their associated identifiers used for querying.
This method sets the internal _hosts
property as well as returning the list of hosts.
If the _hosts
property is already set, this method will return the cached version. If it's set and refresh
is set to true
, this function will re-obtain the hosts list and update the cache.
Event(obj)
This object represents a single event. obj
is an object returned by the server.
Properties:
title
(String
): title of the eventhost
(String
): host of the event (what society/club is organising it)plainDescription
(String
): Description of the event without any additional formattingmarkdownDescription
(String
): Description of the event formatted as MarkdownhtmlDescription
(String
): Original description of the event as HTMLstart
(Date
): the date/time the event is startingend
(Date
): the date/time the event is endingallDay
(Boolean
): whether or not the event is occuring all daylocation
(String
): the location of the eventonCampus
(Boolean
): whether or not the event is happening on campus or off campustype
(String
): what kind of event it is, from the following list:general-meeting
: Any kind of general meeting, i.e. AGM or EGMworkshop-or-training
: An event representing an educational workshop or training sessionguest-speaker
: An event centered around hosting a local/international guest speakersocial
: A social event, including social ballscompetition-or-excursion
: An event which is run as a competition in which members of the host are competingmusic
: An event centered around music, e.g. a concertperformance-or-screening
: A performance or screening, e.g. movie screenings, theatrical performancesother
: None of the above
Hosts(hosts)
This object represents a list of hosts, and is mainly just a wrapper class to allow searching through the list.
findFirst(name)
Finds the first host whose name contains name
as a substring.
If not found, returns null
. If found, returns an object containing:
id
: The identifier representing the host, used as a reference in querying.text
: The full name of the host.
findAll(name)
Finds all hosts whose name contains name
as a substring.
If not found, returns []
. If found, returns an array of objects containing:
id
: The identifier representing the host, used as a reference in querying.text
: The full name of the host.
getName(name)
Returns a host with the exact name matching `name.
If not found, this method throws an error. If found, returns an object containing:
id
: The identifier representing the host, used as a reference in querying.text
: The full name of the host.
getId(id)
Returns a host with the exact id matching id
.
If not found, this method throws an error. If found, returns an object containing:
id
: The identifier representing the host, used as a reference in querying.text
: The full name of the host.