Skip to content

ACM-Planner/planner-js-sdk

Repository files navigation

UC Planner JS SDK

david

Universal npm module to interact with ACM-Planner/main-api.

Install

Install this module with:

npm install --save uc-planner-sdk

This module depends on fetch.

Browsers and React-Native

Modern browsers support this feature and fetch is a global function you can use.

You can use whatwg-fetch to support older platforms (not required in React-Native):

npm install --save whatwg-fetch

And somewhere at the begining of your code:

import 'whatwg-fetch'

Then:

import plannerSDK from 'uc-planner-sdk'

const client = plannerSDK({ fetch })

client.courses({ name: 'MAT', year: 2016, period: 2 }).then(result => {
  const courses = result.data
  const page = result.page
  // ...
}).catch(err => {
  // ...
})

Node.js

On a Node.js enviorement you can import node-fetch:

npm install --save node-fetch
const fetch = require('node-fetch')
const plannerSDK = require('uc-planner-sdk')

const client = plannerSDK({ fetch })

client.courseSections('MAT1610', { year: 2016, period: 1 }).then(result => {
  const sections = result.data
  const page = result.page
  // ...
})

Usage

import plannerSDK from 'uc-planner-sdk'

const client = plannerSDK({ fetch })

client.courseSection('MAT1610', 1, { year: 2016, period: 1 }).then(result => {
  const section = result.data
})

See more examples in test/index.test.js.

Development

Clone this repository:

git clone https://github.com/ACM-Planner/planner-js-sdk.git
cd planner-js-sdk

Install dependencies:

npm install

Testing

Run test located at test directory with:

npm test

About

Universal JS SDK for UC Planner WEB API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published