'use strict';

var stanza = require('jxt');
var util = require('./util');


var Iq = module.exports = stanza.define({
    name: 'iq',
    namespace: 'jabber:client',
    element: 'iq',
    topLevel: true,
    fields: {
        lang: stanza.langAttribute(),
        id: stanza.attribute('id'),
        to: util.jidAttribute('to'),
        from: util.jidAttribute('from'),
        type: stanza.attribute('type')
    }
});

Iq.prototype.resultReply = function (data) {
    data = data || {};
    data.to = this.from;
    data.id = this.id;
    data.type = 'result';
    return new Iq(data);
};

Iq.prototype.errorReply = function (data) {
    data = data || {};
    data.to = this.from;
    data.id = this.id;
    data.type = 'error';
    return new Iq(data);
};

@@ -414,16 +414,230 @@
  %7D%0A%7D);%0A%0A
+var toJSON = Iq.prototype.toJSON;%0A%0AIq.prototype.toJSON = function () %7B%0A    var result = toJSON.call(this);%0A    result.resultReply = this.resultReply;%0A    result.errorReply = this.errorReply;%0A    return result;%0A%7D;%0A%0A
 Iq.proto

Fix Iq response functions