Skip to content

Commit

Permalink
Merge pull request #18 from Danomanic/feat/module_exports
Browse files Browse the repository at this point in the history
Export all modules for NPM Module
  • Loading branch information
Danomanic authored Nov 5, 2019
2 parents f97f18f + 9f6eaf4 commit 0ebcdf5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 64 deletions.
47 changes: 23 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,70 @@ Configuration

Set the API ID and Token
```js
osm.apiid = '<API-ID>';
osm.token = '<API-TOKEN>';

osm.email = '<EMAIL>';
osm.password = '<PASSWORD>';
```

Example:
```js
osm.apiid = '123';
osm.token = '9b7782b7-0f28-4fd8-adb5-6da212e3217b';

osm.email = 'joe@blogs.com';
osm.password = 'securepassword';
osm.core.apiid = '<API-ID>';
osm.core.token = '<API-TOKEN>';

osm.core.email = '<EMAIL>';
osm.core.password = '<PASSWORD>';
```

Usage
---------------
```js
const osm = require('osm-node');

osm.core.apiid = '123';
osm.core.token = '9b7782b7-0f28-4fd8-adb5-6da212e3217b';

osm.core.email = 'joe@blogs.com';
osm.core.password = 'securepassword';
```

### Core
```js
// MUST be called before calling other methods.
osm.authorise();
osm.core.authorise();
```
### Members
```js
// Get Members
osm.getMembers();
osm.members.getMembers();

// Get Member Details (sectionid, memberid)
osm.getMembersDetails(1234, 1234);
osm.members.getMemberDetails(1234, 1234);

// Get Attendance (sectionid, termid)
osm.getAttendance(1234, 1234);
osm.members.getAttendance(1234, 1234);

// Get Patrols (sectionid, termid)
osm.members.getPatrols(1234, 1234);
```

### Terms
```js
// Get Terms
osm.getTerms();
osm.terms.getTerms();
```

### Programme
```js
// Get Programme Summary (secitonid, termid)
osm.getProgrammeSummary(1234, 1234);
osm.programme.getProgrammeSummary(1234, 1234);
```

### Events
```js
// Get Event Summary (sectionid, termid)
osm.getEventsSummary(1234, 1234);
osm.events.getEventsSummary(1234, 1234);

// Get Event Structure (sectionid, eventid)
osm.getEventStructure(1234, 1234);
osm.events.getEventStructure(1234, 1234);

// Get Event Attendance (sectionid, eventid, termid)
osm.getEventAttendance(1234, 1234, 1234);
osm.events.getEventAttendance(1234, 1234, 1234);

// Get Event Attachments (sectionid, eventid)
osm.getEventAttachments(1234, 1234);
osm.events.getEventAttachments(1234, 1234);
```

Changelog
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "osm-node",
"version": "0.0.3",
"version": "0.0.4",
"description": "Node package for interacting with OSM (Online Scout Manager) API",
"main": "./src",
"scripts": {
Expand Down
45 changes: 7 additions & 38 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,10 @@ const members = require('./members');
const programme = require('./programme');
const events = require('./events');

const { log } = console;
/**
* Obtain these from OSM Support
*/
core.apiid = '<API-ID>';
core.token = '<API-TOKEN>';

/**
* Your OSM username and password
*/
core.email = '<EMAIL>';
core.password = '<PASSWORD>';

/**
* Main
*/
async function main() {
await core.authorise();

/* Get Terms */
log(await terms.getTerms());
/* Get Members */
log(await members.getMembers('<SECTIONID>', '<TERMID>'));
/* Get Member Details */
log(await members.getMemberDetails('<SECTIONID>', '<MEMBERID>'));
/* Get Programme Summary */
log(await programme.getProgrammeSummary('<SECTIONID>', '<TERMID(OPTIONAL)'));
/* Get Events Summary */
log(await events.getEventsSummary('<SECTIONID>', '<TERMID(OPTIONAL)'));
/* Get Events Structure & Parameters */
log(await events.getEventStructure('<SECTIONID>', '<EVENTID>'));
/* Get Event Attendance */
log(await events.getEventAttendance('<SECTIONID>', '<EVENTID>', '<TERMID>'));
/* Get Event Attachments */
log(await events.getEventAttachments('<SECTIONID>', '<EVENTID>'));
}

main();
module.exports = {
core,
terms,
members,
programme,
events,
};

0 comments on commit 0ebcdf5

Please sign in to comment.