rcc-api v2.4.2
rcc-api
Easy to use JavaScript adapter for the RockBlock Calendar Compiler's API.
This package allows developers to access the RCC API from JavaScript with Promises and Superagent. Promise support is required and should be polyfilled by the user if needed.
Written in TypeScript for type support and IDE hinting.
Installation
NPM
First install the package from npm:
npm i rcc-api
Then import it in your JavaScript:
const { api } = require('rcc-api');
api.rotationGetToday()
.then((rotation) => { console.log(rotation); })
.catch((err) => { console.error(err); });
This module should be used with webpack if you are writing code for the browser.
Directly
If you prefer using this module directly it is also available as a UMD JavaScript module in this file.
For example, in a webpage:
<script src="rccapi.bundle.js"></script>
<script>
RCCAPI.api.rotationGetToday()
.then(function (rotation) { console.log(rotation); })
.catch(function (err) { console.error(err); });
</script>
Please note that this method requires an implementation of Promises to be present.
Usage
This is a reference for the exported class and methods.
NOTE: Day/month params should be zero-padded strings. (EX: "/rotation/09/12") Years should always be 4 characters long. (If you are using this past year 9999 then you should write a patch)
class RCCAPI
RockBlock Calendar Compiler API binding.
Example:
const { RCCAPI } = require('rcc-api');
const customBinding = new RCCAPI('https://customserver.com');
static RCCAPI.api
Static instance of this class with default params.
Example:
const { RCCAPI } = require('rcc-api');
RCCAPI.api.rotationGetYear('2019')
.then((rotation) => { console.log(rotation); })
.catch((err) => { console.error(err); });
RCCAPI.rotationGetToday(): Promise<API_Rotation_Day>
Get today's block rotation.
RCCAPI.rotationGetDay(year: YearNumberExpression, month: MonthNumberExpression, day: DayNumberExpression): Promise<API_Rotation_Day>
Get a block rotation for a specific day.
RCCAPI.rotationGetMonth(year: YearNumberExpression, month: MonthNumberExpression): Promise<API_Rotation_Month>
Get block rotations for a specific month.
Example:
const { RCCAPI } = require('rcc-api');
RCCAPI.api.rotationGetMonth('2019', '09')
.then((rotation) => { console.log(rotation); })
.catch((err) => { console.error(err); });
RCCAPI.rotationGetYear(year: YearNumberExpression): Promise<API_Rotation_Year>
Get all months and their block rotations in a year.
RCCAPI.miscGetMonth(year: YearNumberExpression, month: MonthNumberExpression): Promise<API_Misc_Month>
Get all misc events in a month.
RCCAPI.miscGetYear(year: YearNumberExpression): Promise<API_Misc_Year>
Get all misc events in a year.
RCCAPI.announcementsGetMonth(year: YearNumberExpression, month: MonthNumberExpression): Promise<API_Announcements_Month>
Get announcements in a month.
RCCAPI.announcementsGetAll(): Promise<API_Announcements_All>
Get all announcements.
Contributing
Pull requests are welcome! Direct all issues/pull requests to the main repository at rockblock-calendar-compiler.
Authors
Made with ❤ by Jack MacDougall (lua.wtf)
License
This project is licensed under MPL 2.0. More info in the LICENSE file.
"This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0."