目录

This software is no longer supported.

Badgekit API Client

A Node client library for badgekit-api.

Build Status

Installation

> npm install mozilla/badgekit-api-client

Usage

const Client = require('badgekit-api-client');

var apiEndpoint = 'https://api.example.org';
var auth = {
  key: '<auth key>',
  secret: '<auth secret>'
};

var client = new Client(apiEndpoint, auth);

Documentation

Full documentation is available in the project: /docs.

Most client methods accept a context object and (optionally) a callback function. The context object is expected to contain namespaced sub-objects, describing the systems, badges, etc relevant to the function call. Passing in a simple string will auto-expand. That is, {system: 'system-slug'} is equivalent to {system: {slug: 'system-slug'}}.

Callback functions should accept two arguments: an error (where thrown) and any response data.

client.getBadges({system: 'system-slug'}, function (err, badges) {
  if (err) return handleError(err);

  badges.forEach(function (badge) {
    // handle badge
  });
});

Method calls provide management for badges, assessment, issuing and system/ issuer/ program admin.

Response data items all have basic functionality to allow for manipulation without having to maintain the context. For example:

client.getBadge({system: 'system-slug', badge: 'badge-slug'}, function (err, badge) {
  if (err) return handleError(err);

  badge.strapline = 'A new badge strapline';
  client.updateBadge({system: 'system-slug', badge: badge});

  //...
});

…is equivalent to:

client.getBadge({system: 'system-slug', badge: 'badge-slug'}, function (err, badge) {
  if (err) return handleError(err);

  badge.strapline = 'A new badge strapline';
  badge.save();

  //...
});
关于
231.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号