node-steamcommunity/classes/CConfirmation.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

var SteamCommunity = require('../index.js');
2015-12-03 10:31:17 +08:00
module.exports = CConfirmation;
function CConfirmation(community, data) {
Object.defineProperty(this, '_community', {value: community});
2015-12-03 10:31:17 +08:00
this.id = data.id.toString();
this.type = data.type;
this.creator = data.creator.toString();
2015-12-03 10:31:17 +08:00
this.key = data.key;
this.title = data.title;
this.receiving = data.receiving;
this.sending = data.sending;
2015-12-03 10:31:17 +08:00
this.time = data.time;
this.timestamp = data.timestamp;
2015-12-03 10:31:17 +08:00
this.icon = data.icon;
this.offerID = this.type == SteamCommunity.ConfirmationType.Trade ? this.creator : null;
2015-12-03 10:31:17 +08:00
}
CConfirmation.prototype.getOfferID = function(time, key, callback) {
if (this.type && this.creator) {
if (this.type != SteamCommunity.ConfirmationType.Trade) {
callback(new Error('Not a trade confirmation'));
return;
}
callback(null, this.creator);
return;
}
2015-12-03 10:31:17 +08:00
this._community.getConfirmationOfferID(this.id, time, key, callback);
};
CConfirmation.prototype.respond = function(time, key, accept, callback) {
this._community.respondToConfirmation(this.id, this.key, time, key, accept, callback);
};