trade-opskins-manager
Version:
Trade Opskins Manager for Node.js (ExpressTrade manager)
33 lines (22 loc) • 1.01 kB
JavaScript
const Item = require('./Item');
const Offer = function(offer) {
this.id = offer['id'];
this.state = offer['state'];
this.state_name = offer['state_name'];
this.sender = offer['sender'];
this.recipient = offer['recipient'];
this.message = offer['message'];
this.is_gift = offer['is_gift'];
this.sent_by_you = offer['sent_by_you'];
this.is_case_opening = offer['is_case_opening'];
this.time_created = offer['time_created'];
this.time_updated = offer['time_updated'];
this.time_expires = offer['time_expires'];
this.items_to_give = offer['sent_by_you'] ? offer['sender']['items'] : offer['recipient']['items'];
this.items_to_receive = offer['sent_by_you'] ? offer['recipient']['items'] : offer['sender']['items'];
this.items_to_give = this.items_to_give.map((item) => new Item(item));
this.items_to_receive = this.items_to_receive.map((item) => new Item(item));
delete this.sender['items'];
delete this.recipient['items'];
};
module.exports = Offer;