Openbadges.bakeAssertion()

The baker will retrieve this image and bake your assertion data into it, returning it to you if your API call was successful.

The assertion should include a link to the badge class, which should include an image field which is the URL of the badge image.

Usage

Hover over inputs/exits for more info.

var Openbadges = require('machinepack-openbadges');


// The baker will retrieve this image and bake your assertion data into it, returning it to you if your API call was successful.

Openbadges.bakeAssertion({

url: 'http://factory.openbadges.it/public/assertions/4c5490b9b83985f02381b4a49cd25c48a7d43185',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Invalid assertion structure

badAssertion: function (result) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

url required

The assertion is a fundamental building block in the badging ecosystem. An assertion represents a badge awarded to an earner.

'http://factory.openbadges.it/public/assertions/4c5490b9b83985f02381b4a49cd25c48a7d43185'

Exits

error

An unexpected error occurred.

badAssertion

Invalid assertion structure

{ status: 400,
  headers: '{headers structure}',
  body: '{"message":"could not get assertion: invalid JSON","stack":"Error: could not get assertion: invalid JSON\\n    at makeError (/var/www/openbadges/lib/analyze-assertion.js:6:26)\\n    at Request._callback (/var/www/openbadges/lib/analyze-assertion.js:31:23)\\n    at Request.self.callback (/var/www/openbadges/node_modules/request/request.js:129:22)\\n    at Request.emit (events.js:98:17)\\n    at Request.<anonymous> (/var/www/openbadges/node_modules/request/request.js:873:14)\\n    at Request.emit (events.js:117:20)\\n    at IncomingMessage.<anonymous> (/var/www/openbadges/node_modules/request/request.js:824:12)\\n    at IncomingMessage.emit (events.js:117:20)\\n    at _stream_readable.js:938:16\\n    at process._tickCallback (node.js:419:13)","code":"parse"}' }
success

OK.

{ status: 200,
  headers: '{headers structure}',
  body: 'BLOB with content type image/png or image/svg+xml' }