UNPKG

eligible-api

Version:

Implementation of Eligible (https://eligible.com/) REST API

25 lines (18 loc) 769 B
var _ = require('lodash'); var BaseEligibleError = require('./baseEligibleError'); function EligibleErrorResponse(eligibleResponse, rawJson) { var errorsSummery = ''; eligibleResponse.errors.forEach(function (error) { errorsSummery += 'Eligible returned the following error:\n' + 'Description: ' + error.code + '\n' + 'Error message: ' + error.message + '\n' + 'Problematic Param: ' + error.param + '\n'; }); BaseEligibleError.call(this, errorsSummery); this.message = errorsSummery; _.extend(this, eligibleResponse); this.raw = rawJson; } EligibleErrorResponse.prototype = Object.create(BaseEligibleError.prototype); EligibleErrorResponse.prototype.constructor = EligibleErrorResponse; module.exports = EligibleErrorResponse;