2 * Core Service - egEvent
4 * Models / tests event objects returned by many server APIs.
10 * "desc":"The requested container_biblio_record_entry_bucket was not found",
12 * "textcode":"CONTAINER_BIBLIO_RECORD_ENTRY_BUCKET_NOT_FOUND",
13 * "servertime":"Wed Nov 6 16:05:50 2013"
16 * var evt = egEvent.parse(thing);
17 * if (evt) console.error(evt);
21 angular.module('egCoreMod')
23 .factory('egEvent', function() {
26 parse : function(thing) {
28 function EGEvent(args) {
29 this.code = args.ilsevent;
30 this.textcode = args.textcode;
31 this.desc = args.desc;
32 this.payload = args.payload;
33 this.debug = args.stacktrace;
34 this.servertime = args.servertime;
35 this.ilsperm = args.ilsperm;
36 this.ilspermloc = args.ilspermloc;
37 this.note = args.note;
38 this.success = this.textcode == 'SUCCESS';
39 this.toString = function() {
40 var s = 'Event: ' + (this.code || '') + ':' +
41 this.textcode + ' -> ' + new String(this.desc);
43 s += ' ' + this.ilsperm + '@' + this.ilspermloc;
45 s += '\n' + this.note;
50 if(thing && typeof thing == 'object' && 'textcode' in thing)
51 return new EGEvent(thing);