1.1.3 • Published 10 years ago
dnt-api v1.1.3
DNT API
Node.JS library for communicating with Turistforeningen's API.
Table of Contents
Requirements
Require Node.JS version >= 0.10.
Installing
npm install dnt-api --saveUsage
var DNT = require('dnt-api');Class: DNT
var dnt = new DNT('My Application/1.0', 'myApiKey');dnt.getMemberFor(object query, function cb)
The getMemberFor() method is used to get details for a given member from the
membership register.
query parameter
The query parameter can at the moment have either one, or both, of the following
properties:
sherpa_id- which is the local user id for Sherpa 3.medlemsnummerwhich is the membership number for a given membership.
cb parameter
The callback function to this requests takes tree parameters:
Errorerr - this is an error if the HTTP request itself failed.numberstatusCode - HTTP status code returned from the API.objectmemberData - data returned from the API.
Example
dnt.getMemberFor({ sherpa_id: 1234 }, function(err, statusCode, memberData) {
  if (err) { throw err }
  if (statusCode === 200) {
    console.log('Member is ' + memberData.fornavn);
  } else {
    console.error('Request failed! HTTP status code returned is ' + statusCode);
    console.error(memberData.errors);
  }
});dnt.getAssociationsFor(object query, function cb)
The getAssociationsFor() method is used to get associations (NO foreninger)
for a given member from the membership register.
query parameter
The query parameter can at the moment have either one, or both, of the following
properties:
bruker_sherpa_id- which is the local user id for Sherpa 3.bruker_medlemsnummerwhich is the membership number for a given membership.
cb parameter
The callback function to this requests takes tree parameters:
Errorerr - this is an error if the HTTP request itself failed.numberstatusCode - HTTP status code returned from the API.Arrayassociations - data returned from the API.
Example
dnt.getAssociationsFor({ bruker_sherpa_id: 1234 }, function(err, statusCode, associations) {
  if (err) { throw err }
  if (statusCode === 200) {
    for (var i = 0; i < associations.length; i++) {
      console.log('Member is associated with ' + associations[i].navn);
    }
  } else {
    console.error('Request failed! HTTP status code returned is ' + statusCode);
    console.error(associations.errors);
  }
});